[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on pull request #958: Various Mesh fixes

2021-05-18 Thread GitBox


apache-mynewt-bot removed a comment on pull request #958:
URL: https://github.com/apache/mynewt-nimble/pull/958#issuecomment-834402631


   
   ## Style check fail: Payload was too large


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-nimble] apache-mynewt-bot commented on pull request #958: Various Mesh fixes

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #958:
URL: https://github.com/apache/mynewt-nimble/pull/958#issuecomment-843766783


   
   ## Style check fail: Payload was too large


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-nimble] KKopyscinski commented on pull request #958: Various Mesh fixes

2021-05-18 Thread GitBox


KKopyscinski commented on pull request #958:
URL: https://github.com/apache/mynewt-nimble/pull/958#issuecomment-843766141


   @michal-narajowski Fixed commit messages and missing newlines at the end of 
files


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-nimble] apache-mynewt-bot commented on pull request #978: mesh: Check if ack is pending in trans_seg

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #978:
URL: https://github.com/apache/mynewt-nimble/pull/978#issuecomment-843765091


   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/host/mesh/src/transport.c
   
   
   ```diff
   @@ -54,1699 +54,1743 @@
 * need to have a timeout that's bigger than that.
 */
#define SEG_RETRANSMIT_TIMEOUT_UNICAST(tx) \
   -(MYNEWT_VAL(BLE_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST) + 50 * (tx)->ttl)
   +(MYNEWT_VAL(BLE_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST) + 50 * (tx)->ttl)
/* When sending to a group, the messages are not acknowledged, and there's 
no
 * reason to delay the repetitions significantly. Delaying by more than 0 ms
 * to avoid flooding the network.
 */
#define SEG_RETRANSMIT_TIMEOUT_GROUP \
   -MYNEWT_VAL(BLE_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP)
   +MYNEWT_VAL(BLE_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP)

#define SEG_RETRANSMIT_TIMEOUT(tx)  
   \
   -(BT_MESH_ADDR_IS_UNICAST(tx->dst) ?\
   - SEG_RETRANSMIT_TIMEOUT_UNICAST(tx) :  \
   - SEG_RETRANSMIT_TIMEOUT_GROUP)
   +(BT_MESH_ADDR_IS_UNICAST(tx->dst) ?\
   + SEG_RETRANSMIT_TIMEOUT_UNICAST(tx) :  \
   + SEG_RETRANSMIT_TIMEOUT_GROUP)
/* How long to wait for available buffers before giving up */
#define BUF_TIMEOUT K_NO_WAIT

static struct seg_tx {
   -struct bt_mesh_subnet *sub;
   -void  *seg[CONFIG_BT_MESH_TX_SEG_MAX];
   -uint64_t  seq_auth;
   -uint16_t  src;
   -uint16_t  dst;
   -uint16_t  len;
   -uint8_t   hdr;
   -uint8_t   xmit;
   -uint8_t   seg_n; /* Last segment index */
   -uint8_t   seg_o; /* Segment being sent */
   -uint8_t   nack_count;/* Number of unacked segs */
   -uint8_t   attempts;  /* Remaining tx attempts */
   -uint8_t   ttl;   /* Transmitted TTL value */
   -uint8_t   seg_pending;   /* Number of segments pending */
   -uint8_t   blocked:1, /* Blocked by ongoing tx */
   -  ctl:1, /* Control packet 
*/
   -  aszmic:1,  /* MIC size */
   -  started:1, /* Start cb called */
   -  sending:1, /* Sending is in 
progress */
   -  friend_cred:1; /* Using Friend 
credentials */
   -const struct bt_mesh_send_cb *cb;
   -void  *cb_data;
   -struct k_delayed_work retransmit; /* Retransmit timer */
   +struct bt_mesh_subnet *sub;
   +void *seg[CONFIG_BT_MESH_TX_SEG_MAX];
   +uint64_t seq_auth;
   +uint16_t src;
   +uint16_t dst;
   +uint16_t len;
   +uint8_t hdr;
   +uint8_t xmit;
   +uint8_t seg_n;   /* Last segment index */
   +uint8_t seg_o;   /* Segment being sent */
   +uint8_t nack_count;  /* Number of unacked segs */
   +uint8_t attempts;/* Remaining tx attempts */
   +uint8_t ttl; /* Transmitted TTL value */
   +uint8_t seg_pending; /* Number of segments pending */
   +uint8_t blocked : 1, /* Blocked by ongoing tx */
   +ctl : 1, /* Control packet */
   +aszmic : 1,  /* MIC size */
   +started : 1, /* Start cb called */
   +sending : 1, /* Sending is in progress */
   +friend_cred : 1; /* Using Friend credentials */
   +const struct bt_mesh_send_cb *cb;
   +void *cb_data;
   +struct k_delayed_work retransmit; /* Retransmit timer */
} seg_tx[MYNEWT_VAL(BLE_MESH_TX_SEG_MSG_COUNT)];

static struct seg_rx {
   -struct bt_mesh_subnet   *sub;
   -void*seg[CONFIG_BT_MESH_RX_SEG_MAX];
   -uint64_tseq_auth;
   -uint16_tsrc;
   -uint16_tdst;
   -uint16_tlen;
   -uint8_t hdr;
   -uint8_t seg_n:5,
   - ctl:1,
   - in_use:1,
   - obo:1;
   -uint8_t ttl;
   -uint32_tblock;
   -uint32_t

[GitHub] [mynewt-nimble] KKopyscinski commented on a change in pull request #958: Various Mesh fixes

2021-05-18 Thread GitBox


KKopyscinski commented on a change in pull request #958:
URL: https://github.com/apache/mynewt-nimble/pull/958#discussion_r634928669



##
File path: nimble/host/mesh/src/transport.c
##
@@ -1413,8 +1413,9 @@ static int trans_seg(struct os_mbuf *buf, struct 
bt_mesh_net_rx *net_rx,
/* Reset the Incomplete Timer */
rx->last = k_uptime_get_32();
 
-   if (!k_delayed_work_remaining_get(>ack) &&
-   !bt_mesh_lpn_established()) {
+   if (!k_delayed_work_pending(>ack) ||

Review comment:
   Moved this commit to https://github.com/apache/mynewt-nimble/pull/978




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-nimble] KKopyscinski opened a new pull request #978: mesh: Check if ack is pending in trans_seg

2021-05-18 Thread GitBox


KKopyscinski opened a new pull request #978:
URL: https://github.com/apache/mynewt-nimble/pull/978


   Before scheduling ack it was checked if previous ack reached it's
   timeout. If it did, it was assumed it was sent, where in fact,
   timeout could be not reached and work could be canceled. Now,
   check if work is pending at all, and if not, schedule next one.
   
   This affects MESH/NODE/TNPT/BV-11-C


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-nimble] apache-mynewt-bot commented on pull request #960: Align logo, grammar updates

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #960:
URL: https://github.com/apache/mynewt-nimble/pull/960#issuecomment-843756214


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on pull request #960: Align logo, grammar updates

2021-05-18 Thread GitBox


apache-mynewt-bot removed a comment on pull request #960:
URL: https://github.com/apache/mynewt-nimble/pull/960#issuecomment-818450200


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[mynewt-nimble] branch master updated (83ea568 -> be97b73)

2021-05-18 Thread kopyscinski
This is an automated email from the ASF dual-hosted git repository.

kopyscinski pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 83ea568  ble_att_svr: fix keysize check for SC Only mode
 add be97b73  mesh: BLE_MESH_RELAY_ENABLED should have BLE_MESH_RELAY as 
default value

No new revisions were added by this update.

Summary of changes:
 nimble/host/mesh/syscfg.yml | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)


[GitHub] [mynewt-nimble] KKopyscinski merged pull request #937: mesh: BLE_MESH_RELAY_ENABLED should have BLE_MESH_RELAY as default value

2021-05-18 Thread GitBox


KKopyscinski merged pull request #937:
URL: https://github.com/apache/mynewt-nimble/pull/937


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2597: sensor_creator: Add LIS2DW12 configuration for bus drivers

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2597:
URL: https://github.com/apache/mynewt-core/pull/2597#discussion_r634690744



##
File path: hw/sensor/creator/src/sensor_creator.c
##
@@ -595,16 +595,48 @@ static struct sensor_itf i2c_0_itf_lpst = {
 };
 #endif
 
-#if MYNEWT_VAL(I2C_0) && MYNEWT_VAL(LIS2DW12_OFB)
+#if MYNEWT_VAL(LIS2DW12_OFB)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#if MYNEWT_VAL(LIS2DW12_OFB_I2C_NUM) >= 0
+static const struct bus_i2c_node_cfg lis2dw12_node_cfg = {
+.node_cfg = {
+.bus_name = MYNEWT_VAL(LIS2DW12_OFB_BUS),
+},
+.addr = MYNEWT_VAL(LIS2DW12_OFB_ITF_ADDR),
+.freq = MYNEWT_VAL(LIS2DW12_OFB_BAUDRATE),
+};
+#elif MYNEWT_VAL(LIS2DW12_OFB_SPI_NUM) >= 0
+static const struct bus_spi_node_cfg lis2dw12_node_cfg = {
+.node_cfg = {
+.bus_name = MYNEWT_VAL(LIS2DW12_OFB_BUS),
+},
+.pin_cs = MYNEWT_VAL(LIS2DW12_OFB_CS),
+.mode = BUS_SPI_MODE_3,
+.data_order = BUS_SPI_DATA_ORDER_MSB,
+.freq = MYNEWT_VAL(LIS2DW12_OFB_BAUDRATE),
+};
+#endif
+static struct sensor_itf lis2dw12_itf = {
+.si_ints = {
+{ MYNEWT_VAL(LIS2DW12_OFB_INT1_PIN_HOST), 1,
+  MYNEWT_VAL(LIS2DW12_OFB_INT_CFG_ACTIVE)},
+{ -1, 0, 0 },
+}
+};
+#else
+#if MYNEWT_VAL(I2C_0)
 static struct sensor_itf i2c_0_itf_lis2dw12 = {
 .si_type = SENSOR_ITF_I2C,
-.si_num  = 0,
+.si_num = 0,
 .si_addr = 0x18,

Review comment:
   +1, it should be `LIS2DW12_OFB_ITF_ADDR`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] vikrant-proxy commented on a change in pull request #2597: sensor_creator: Add LIS2DW12 configuration for bus drivers

2021-05-18 Thread GitBox


vikrant-proxy commented on a change in pull request #2597:
URL: https://github.com/apache/mynewt-core/pull/2597#discussion_r634644197



##
File path: hw/sensor/creator/src/sensor_creator.c
##
@@ -595,16 +595,48 @@ static struct sensor_itf i2c_0_itf_lpst = {
 };
 #endif
 
-#if MYNEWT_VAL(I2C_0) && MYNEWT_VAL(LIS2DW12_OFB)
+#if MYNEWT_VAL(LIS2DW12_OFB)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#if MYNEWT_VAL(LIS2DW12_OFB_I2C_NUM) >= 0
+static const struct bus_i2c_node_cfg lis2dw12_node_cfg = {
+.node_cfg = {
+.bus_name = MYNEWT_VAL(LIS2DW12_OFB_BUS),
+},
+.addr = MYNEWT_VAL(LIS2DW12_OFB_ITF_ADDR),
+.freq = MYNEWT_VAL(LIS2DW12_OFB_BAUDRATE),
+};
+#elif MYNEWT_VAL(LIS2DW12_OFB_SPI_NUM) >= 0
+static const struct bus_spi_node_cfg lis2dw12_node_cfg = {
+.node_cfg = {
+.bus_name = MYNEWT_VAL(LIS2DW12_OFB_BUS),
+},
+.pin_cs = MYNEWT_VAL(LIS2DW12_OFB_CS),
+.mode = BUS_SPI_MODE_3,
+.data_order = BUS_SPI_DATA_ORDER_MSB,
+.freq = MYNEWT_VAL(LIS2DW12_OFB_BAUDRATE),
+};
+#endif
+static struct sensor_itf lis2dw12_itf = {
+.si_ints = {
+{ MYNEWT_VAL(LIS2DW12_OFB_INT1_PIN_HOST), 1,
+  MYNEWT_VAL(LIS2DW12_OFB_INT_CFG_ACTIVE)},
+{ -1, 0, 0 },
+}
+};
+#else
+#if MYNEWT_VAL(I2C_0)
 static struct sensor_itf i2c_0_itf_lis2dw12 = {
 .si_type = SENSOR_ITF_I2C,
-.si_num  = 0,
+.si_num = 0,
 .si_addr = 0x18,

Review comment:
   I think this should use the syscfg, as it is variable




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


apache-mynewt-bot removed a comment on pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#issuecomment-842924663


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#issuecomment-843110539


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


kasjer commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634251911



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);
+#endif
+}
+
+void
+spiram_cs_activate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = (struct bus_spi_node *)>dev;
+hal_gpio_write(node->pin_cs, 0);
+#else
+hal_gpio_write(dev->ss_pin, 0);
+#endif
+}
+
+void
+spiram_cs_deactivate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = >dev;
+hal_gpio_write(node->pin_cs, 1);
+#else
+hal_gpio_write(dev->ss_pin, 1);
+#endif
+}
+
+int
+spiram_write_enable(struct spiram_dev *dev)
+{
+int rc = 0;
+spiram_lock(dev);
+
+if (dev->characteristics->write_enable_cmd) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write((struct os_dev *)>dev,
+  >characteristics->write_enable_cmd, 1);
+#else
+spiram_cs_activate(dev);
+
+rc = hal_spi_tx_val(dev->spi_num, 
dev->characteristics->write_enable_cmd);
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_read(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[5] = { SPIRAM_READ };
+int i;
+int rc = 0;
+int cmd_size = 1 + dev->characteristics->address_bytes + 
dev->characteristics->dummy_bytes;
+
+i = dev->characteristics->address_bytes;
+while (i) {
+cmd[i] = (uint8_t)addr;
+addr >>= 8;
+--i;
+}
+spiram_lock(dev);
+
+if (size > 0) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write_read_transact((struct os_dev *)>dev,
+ , cmd_size, buf, size);
+#else
+spiram_cs_activate(dev);
+
+/* Send command + address */
+rc = hal_spi_txrx(dev->spi_num, cmd, NULL, cmd_size);
+if (rc == 0) {
+/* For security mostly, do not output random data, fill it with FF 
*/
+memset(buf, 0xFF, size);
+/* Tx buf does not matter, for simplicity pass read buffer */
+rc = hal_spi_txrx(dev->spi_num, buf, buf, size);
+}
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_write(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[4] = { SPIRAM_WRITE };
+int rc = 0;
+int i;

Review comment:
   see above




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


kasjer commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634251729



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);
+#endif
+}
+
+void
+spiram_cs_activate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = (struct bus_spi_node *)>dev;
+hal_gpio_write(node->pin_cs, 0);
+#else
+hal_gpio_write(dev->ss_pin, 0);
+#endif
+}
+
+void
+spiram_cs_deactivate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = >dev;
+hal_gpio_write(node->pin_cs, 1);
+#else
+hal_gpio_write(dev->ss_pin, 1);
+#endif
+}
+
+int
+spiram_write_enable(struct spiram_dev *dev)
+{
+int rc = 0;
+spiram_lock(dev);
+
+if (dev->characteristics->write_enable_cmd) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write((struct os_dev *)>dev,
+  >characteristics->write_enable_cmd, 1);
+#else
+spiram_cs_activate(dev);
+
+rc = hal_spi_tx_val(dev->spi_num, 
dev->characteristics->write_enable_cmd);
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_read(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[5] = { SPIRAM_READ };
+int i;

Review comment:
   int is a native type and it's usage usually produces more optimal code.
   In this case for ARM build both debug and optimized profiles result in 
shorter binary when int is used instead of uint8_t.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


kasjer commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634249854



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);

Review comment:
   done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2597: sensor_creator: Add LIS2DW12 configuration for bus drivers

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #2597:
URL: https://github.com/apache/mynewt-core/pull/2597#issuecomment-843049032


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2597: sensor_creator: Add LIS2DW12 configuration for bus drivers

2021-05-18 Thread GitBox


apache-mynewt-bot removed a comment on pull request #2597:
URL: https://github.com/apache/mynewt-core/pull/2597#issuecomment-842986547


   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/sensor/creator/src/sensor_creator.c
   
   
   ```diff
   @@ -619,7 +622,7 @@
static struct sensor_itf lis2dw12_itf = {
.si_ints = {
{ MYNEWT_VAL(LIS2DW12_OFB_INT1_PIN_HOST), 1,
   -MYNEWT_VAL(LIS2DW12_OFB_INT_CFG_ACTIVE)},
   +  MYNEWT_VAL(LIS2DW12_OFB_INT_CFG_ACTIVE)},
{ -1, 0, 0 },
}
};
   @@ -627,11 +630,12 @@
#if MYNEWT_VAL(I2C_0)
static struct sensor_itf i2c_0_itf_lis2dw12 = {
.si_type = SENSOR_ITF_I2C,
   -.si_num  = 0,
   +.si_num = 0,
.si_addr = 0x18,
.si_ints = {
{ MYNEWT_VAL(LIS2DW12_INT1_PIN_HOST), 
MYNEWT_VAL(LIS2DW12_INT1_PIN_DEVICE),
   -  MYNEWT_VAL(LIS2DW12_INT1_CFG_ACTIVE)}}
   +  MYNEWT_VAL(LIS2DW12_INT1_CFG_ACTIVE)}
   +}
};
#endif
#endif
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


kasjer commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634245017



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);

Review comment:
   done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634213967



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);
+#endif
+}
+
+void
+spiram_cs_activate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = (struct bus_spi_node *)>dev;
+hal_gpio_write(node->pin_cs, 0);
+#else
+hal_gpio_write(dev->ss_pin, 0);
+#endif
+}
+
+void
+spiram_cs_deactivate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = >dev;
+hal_gpio_write(node->pin_cs, 1);
+#else
+hal_gpio_write(dev->ss_pin, 1);
+#endif
+}
+
+int
+spiram_write_enable(struct spiram_dev *dev)
+{
+int rc = 0;
+spiram_lock(dev);
+
+if (dev->characteristics->write_enable_cmd) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write((struct os_dev *)>dev,
+  >characteristics->write_enable_cmd, 1);
+#else
+spiram_cs_activate(dev);
+
+rc = hal_spi_tx_val(dev->spi_num, 
dev->characteristics->write_enable_cmd);
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_read(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[5] = { SPIRAM_READ };
+int i;
+int rc = 0;
+int cmd_size = 1 + dev->characteristics->address_bytes + 
dev->characteristics->dummy_bytes;
+
+i = dev->characteristics->address_bytes;
+while (i) {
+cmd[i] = (uint8_t)addr;
+addr >>= 8;
+--i;
+}
+spiram_lock(dev);
+
+if (size > 0) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write_read_transact((struct os_dev *)>dev,
+ , cmd_size, buf, size);
+#else
+spiram_cs_activate(dev);
+
+/* Send command + address */
+rc = hal_spi_txrx(dev->spi_num, cmd, NULL, cmd_size);
+if (rc == 0) {
+/* For security mostly, do not output random data, fill it with FF 
*/
+memset(buf, 0xFF, size);
+/* Tx buf does not matter, for simplicity pass read buffer */
+rc = hal_spi_txrx(dev->spi_num, buf, buf, size);
+}
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_write(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[4] = { SPIRAM_WRITE };
+int rc = 0;
+int i;
+
+spiram_lock(dev);
+
+if (size) {
+i = dev->characteristics->address_bytes;
+while (i) {
+cmd[i] = (uint8_t)addr;
+addr >>= 8;
+--i;
+}
+spiram_write_enable(dev);
+
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_lock((struct os_dev *)>dev,
+   BUS_NODE_LOCK_DEFAULT_TIMEOUT);
+if (rc) {
+goto end;
+}
+rc = bus_node_write((struct os_dev *)>dev,
+cmd, dev->characteristics->address_bytes + 1,
+BUS_NODE_LOCK_DEFAULT_TIMEOUT, BUS_F_NOSTOP);
+if (rc == 0) {
+rc = bus_node_simple_write((struct os_dev *)>dev, buf, size);
+}
+(void)bus_node_unlock((struct os_dev *)>dev);
+#else
+spiram_cs_activate(dev);
+rc = hal_spi_txrx(dev->spi_num, cmd, NULL, 
dev->characteristics->address_bytes + 1);
+if (rc == 0) {
+rc = hal_spi_txrx(dev->spi_num, buf, NULL, size);
+}
+spiram_cs_deactivate(dev);
+#endif
+}
+end:
+spiram_unlock(dev);
+
+return rc;
+}
+
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)

[GitHub] [mynewt-core] vrahane commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634219346



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);
+#endif
+}
+
+void
+spiram_cs_activate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = (struct bus_spi_node *)>dev;
+hal_gpio_write(node->pin_cs, 0);
+#else
+hal_gpio_write(dev->ss_pin, 0);
+#endif
+}
+
+void
+spiram_cs_deactivate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = >dev;
+hal_gpio_write(node->pin_cs, 1);
+#else
+hal_gpio_write(dev->ss_pin, 1);
+#endif
+}
+
+int
+spiram_write_enable(struct spiram_dev *dev)
+{
+int rc = 0;
+spiram_lock(dev);
+
+if (dev->characteristics->write_enable_cmd) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write((struct os_dev *)>dev,
+  >characteristics->write_enable_cmd, 1);
+#else
+spiram_cs_activate(dev);
+
+rc = hal_spi_tx_val(dev->spi_num, 
dev->characteristics->write_enable_cmd);
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_read(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[5] = { SPIRAM_READ };
+int i;
+int rc = 0;
+int cmd_size = 1 + dev->characteristics->address_bytes + 
dev->characteristics->dummy_bytes;
+
+i = dev->characteristics->address_bytes;
+while (i) {
+cmd[i] = (uint8_t)addr;
+addr >>= 8;
+--i;
+}
+spiram_lock(dev);
+
+if (size > 0) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write_read_transact((struct os_dev *)>dev,
+ , cmd_size, buf, size);
+#else
+spiram_cs_activate(dev);
+
+/* Send command + address */
+rc = hal_spi_txrx(dev->spi_num, cmd, NULL, cmd_size);
+if (rc == 0) {
+/* For security mostly, do not output random data, fill it with FF 
*/
+memset(buf, 0xFF, size);
+/* Tx buf does not matter, for simplicity pass read buffer */
+rc = hal_spi_txrx(dev->spi_num, buf, buf, size);
+}
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_write(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[4] = { SPIRAM_WRITE };
+int rc = 0;
+int i;

Review comment:
   Why is this an int ? A uint8_t is enough.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634218288



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);
+#endif
+}
+
+void
+spiram_cs_activate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = (struct bus_spi_node *)>dev;
+hal_gpio_write(node->pin_cs, 0);
+#else
+hal_gpio_write(dev->ss_pin, 0);
+#endif
+}
+
+void
+spiram_cs_deactivate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = >dev;
+hal_gpio_write(node->pin_cs, 1);
+#else
+hal_gpio_write(dev->ss_pin, 1);
+#endif
+}
+
+int
+spiram_write_enable(struct spiram_dev *dev)
+{
+int rc = 0;
+spiram_lock(dev);
+
+if (dev->characteristics->write_enable_cmd) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write((struct os_dev *)>dev,
+  >characteristics->write_enable_cmd, 1);
+#else
+spiram_cs_activate(dev);
+
+rc = hal_spi_tx_val(dev->spi_num, 
dev->characteristics->write_enable_cmd);
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_read(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[5] = { SPIRAM_READ };
+int i;

Review comment:
   Why is this an int ? A uint8_t is enough.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634213967



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);
+#endif
+}
+
+void
+spiram_cs_activate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = (struct bus_spi_node *)>dev;
+hal_gpio_write(node->pin_cs, 0);
+#else
+hal_gpio_write(dev->ss_pin, 0);
+#endif
+}
+
+void
+spiram_cs_deactivate(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+struct bus_spi_node *node = >dev;
+hal_gpio_write(node->pin_cs, 1);
+#else
+hal_gpio_write(dev->ss_pin, 1);
+#endif
+}
+
+int
+spiram_write_enable(struct spiram_dev *dev)
+{
+int rc = 0;
+spiram_lock(dev);
+
+if (dev->characteristics->write_enable_cmd) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write((struct os_dev *)>dev,
+  >characteristics->write_enable_cmd, 1);
+#else
+spiram_cs_activate(dev);
+
+rc = hal_spi_tx_val(dev->spi_num, 
dev->characteristics->write_enable_cmd);
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_read(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[5] = { SPIRAM_READ };
+int i;
+int rc = 0;
+int cmd_size = 1 + dev->characteristics->address_bytes + 
dev->characteristics->dummy_bytes;
+
+i = dev->characteristics->address_bytes;
+while (i) {
+cmd[i] = (uint8_t)addr;
+addr >>= 8;
+--i;
+}
+spiram_lock(dev);
+
+if (size > 0) {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_simple_write_read_transact((struct os_dev *)>dev,
+ , cmd_size, buf, size);
+#else
+spiram_cs_activate(dev);
+
+/* Send command + address */
+rc = hal_spi_txrx(dev->spi_num, cmd, NULL, cmd_size);
+if (rc == 0) {
+/* For security mostly, do not output random data, fill it with FF 
*/
+memset(buf, 0xFF, size);
+/* Tx buf does not matter, for simplicity pass read buffer */
+rc = hal_spi_txrx(dev->spi_num, buf, buf, size);
+}
+
+spiram_cs_deactivate(dev);
+#endif
+}
+
+spiram_unlock(dev);
+
+return rc;
+}
+
+int
+spiram_write(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
+{
+uint8_t cmd[4] = { SPIRAM_WRITE };
+int rc = 0;
+int i;
+
+spiram_lock(dev);
+
+if (size) {
+i = dev->characteristics->address_bytes;
+while (i) {
+cmd[i] = (uint8_t)addr;
+addr >>= 8;
+--i;
+}
+spiram_write_enable(dev);
+
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+rc = bus_node_lock((struct os_dev *)>dev,
+   BUS_NODE_LOCK_DEFAULT_TIMEOUT);
+if (rc) {
+goto end;
+}
+rc = bus_node_write((struct os_dev *)>dev,
+cmd, dev->characteristics->address_bytes + 1,
+BUS_NODE_LOCK_DEFAULT_TIMEOUT, BUS_F_NOSTOP);
+if (rc == 0) {
+rc = bus_node_simple_write((struct os_dev *)>dev, buf, size);
+}
+(void)bus_node_unlock((struct os_dev *)>dev);
+#else
+spiram_cs_activate(dev);
+rc = hal_spi_txrx(dev->spi_num, cmd, NULL, 
dev->characteristics->address_bytes + 1);
+if (rc == 0) {
+rc = hal_spi_txrx(dev->spi_num, buf, NULL, size);
+}
+spiram_cs_deactivate(dev);
+#endif
+}
+end:
+spiram_unlock(dev);
+
+return rc;
+}
+
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)

[GitHub] [mynewt-core] vrahane commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634206520



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);
+#endif
+}
+
+static inline void
+spiram_unlock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_release(>lock);

Review comment:
   Error handling needs to be done here as well.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


vrahane commented on a change in pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#discussion_r634205999



##
File path: hw/drivers/ram/spiram/src/spiram.c
##
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include 
+#endif
+
+static inline void
+spiram_lock(struct spiram_dev *dev)
+{
+#if MYNEWT_VAL(OS_SCHEDULING)
+os_mutex_pend(>lock, OS_TIMEOUT_NEVER);

Review comment:
   I think error handling needs to be there for this along with a syscfg 
for the timeout.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2598: da1469x/i2c: Correct CON_REG settings

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #2598:
URL: https://github.com/apache/mynewt-core/pull/2598#issuecomment-842998985


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2597: sensor_creator: Add LIS2DW12 configuration for bus drivers

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #2597:
URL: https://github.com/apache/mynewt-core/pull/2597#issuecomment-842986547


   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/sensor/creator/src/sensor_creator.c
   
   
   ```diff
   @@ -619,7 +622,7 @@
static struct sensor_itf lis2dw12_itf = {
.si_ints = {
{ MYNEWT_VAL(LIS2DW12_OFB_INT1_PIN_HOST), 1,
   -MYNEWT_VAL(LIS2DW12_OFB_INT_CFG_ACTIVE)},
   +  MYNEWT_VAL(LIS2DW12_OFB_INT_CFG_ACTIVE)},
{ -1, 0, 0 },
}
};
   @@ -627,11 +630,12 @@
#if MYNEWT_VAL(I2C_0)
static struct sensor_itf i2c_0_itf_lis2dw12 = {
.si_type = SENSOR_ITF_I2C,
   -.si_num  = 0,
   +.si_num = 0,
.si_addr = 0x18,
.si_ints = {
{ MYNEWT_VAL(LIS2DW12_INT1_PIN_HOST), 
MYNEWT_VAL(LIS2DW12_INT1_PIN_DEVICE),
   -  MYNEWT_VAL(LIS2DW12_INT1_CFG_ACTIVE)}}
   +  MYNEWT_VAL(LIS2DW12_INT1_CFG_ACTIVE)}
   +}
};
#endif
#endif
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer opened a new pull request #2598: da1469x/i2c: Correct CON_REG settings

2021-05-18 Thread GitBox


kasjer opened a new pull request #2598:
URL: https://github.com/apache/mynewt-core/pull/2598


   For register I2C_CON_REG datasheet description of
   bit I2C_MASTER_MODE:
   This bit controls whether the controller master is enabled.
0= master disabled
1= master enabled
   Software should ensure that if this bit is written with
   '1' then bit 6 (SLAVE_DISABLE) should also be written with a '1'.
   
   It's not clear what will happened otherwise, so far it seemed to
   work without this but to be on the safe side.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer opened a new pull request #2597: sensor_creator: Add LIS2DW12 configuration for bus drivers

2021-05-18 Thread GitBox


kasjer opened a new pull request #2597:
URL: https://github.com/apache/mynewt-core/pull/2597


   LIS2DW12 has support for bus driver.
   Now it can be used with sensor_creator.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


apache-mynewt-bot removed a comment on pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#issuecomment-841328364


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2596: hw/drivers/spiram: Add SPI RAM driver

2021-05-18 Thread GitBox


apache-mynewt-bot commented on pull request #2596:
URL: https://github.com/apache/mynewt-core/pull/2596#issuecomment-842924663


   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org