You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2015/11/05 01:01:40 UTC

incubator-mynewt-larva git commit: Add hal_uart_blocking_tx to nrf52 code

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master e19a4f98c -> 579348ed4


Add hal_uart_blocking_tx to nrf52 code


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/579348ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/579348ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/579348ed

Branch: refs/heads/master
Commit: 579348ed47d0ac58b638400ec7078fa6e70a6e97
Parents: e19a4f9
Author: Willam San Filippo <wi...@micosa.io>
Authored: Wed Nov 4 16:01:18 2015 -0800
Committer: Willam San Filippo <wi...@micosa.io>
Committed: Wed Nov 4 16:01:27 2015 -0800

----------------------------------------------------------------------
 hw/mcu/nordic/nrf52xxx/src/hal_uart.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/579348ed/hw/mcu/nordic/nrf52xxx/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_uart.c b/hw/mcu/nordic/nrf52xxx/src/hal_uart.c
index 04c16d6..f2e144b 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_uart.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_uart.c
@@ -126,7 +126,31 @@ hal_uart_start_rx(int port)
 void
 hal_uart_blocking_tx(int port, uint8_t data)
 {
-    /* XXXX fill this in */
+    struct hal_uart *u;
+
+    u = &uart;
+    if (!u->u_open) {
+        return;
+    }
+
+    /* If we have started, wait until the current uart dma buffer is done */
+    if (u->u_tx_started) {
+        while (NRF_UARTE0->EVENTS_ENDTX == 0) {
+            /* Wait here until the dma is finished */
+        }
+    }
+
+    NRF_UARTE0->EVENTS_ENDTX = 0;
+    NRF_UARTE0->TXD.PTR = (uint32_t)&data;
+    NRF_UARTE0->TXD.MAXCNT = 1;
+    NRF_UARTE0->TASKS_STARTTX = 1;
+
+    while (NRF_UARTE0->EVENTS_ENDTX == 0) {
+        /* Wait till done */
+    }
+
+    /* Stop the uart */
+    NRF_UARTE0->TASKS_STOPTX = 1;
 }
 
 static void