You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/05/27 17:58:35 UTC

[GitHub] [mynewt-core] vrahane commented on a change in pull request #2606: Improve bus write read transactions

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



##########
File path: hw/bus/drivers/spi_hal/src/spi_hal.c
##########
@@ -191,6 +191,66 @@ bus_spi_write(struct bus_dev *bdev, struct bus_node *bnode, const uint8_t *buf,
     return rc;
 }
 
+static int
+bus_spi_write_read(struct bus_dev *bdev, struct bus_node *bnode,
+                   const uint8_t *wbuf, uint16_t wlength,
+                   uint8_t *rbuf, uint16_t rlength,
+                   os_time_t timeout, uint16_t flags)
+{
+    struct bus_spi_hal_dev *dev = (struct bus_spi_hal_dev *)bdev;
+    struct bus_spi_node *node = (struct bus_spi_node *)bnode;
+    int rc;
+    uint8_t buf[16];
+
+    BUS_DEBUG_VERIFY_DEV(&dev->spi_dev);
+    BUS_DEBUG_VERIFY_NODE(node);
+
+    hal_gpio_write(node->pin_cs, 0);
+
+    /* XXX update HAL to accept const instead */
+
+#if MYNEWT_VAL(SPI_HAL_USE_NOBLOCK)
+    if (wlength + rlength <= sizeof(buf)) {
+        memcpy(buf, wbuf, wlength);
+        memset(buf + wlength, 0, rlength);
+        rc = hal_spi_txrx_noblock(dev->spi_dev.cfg.spi_num, buf, buf, wlength + rlength);
+        if (rc == 0) {
+            os_sem_pend(&dev->sem, OS_TIMEOUT_NEVER);

Review comment:
       This does need a specific timeout value. same with the one below.




-- 
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:
users@infra.apache.org