You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/07/21 18:02:55 UTC

[2/2] incubator-mynewt-core git commit: nrf52 uart; add hal_uart_close(). Allow 76800 baud rate.

nrf52 uart; add hal_uart_close(). Allow 76800 baud rate.


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

Branch: refs/heads/develop
Commit: c0921043f9859e5182759db5eb9502d647135d71
Parents: 0dd7cf8
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jul 21 11:00:46 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jul 21 11:00:46 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c0921043/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 4986100..ad1700c 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_uart.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_uart.c
@@ -6,7 +6,7 @@
  * 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,
@@ -31,6 +31,7 @@
 #define UARTE_CONFIG_PARITY	UARTE_CONFIG_PARITY_Msk
 #define UARTE_CONFIG_HWFC	UARTE_CONFIG_HWFC_Msk
 #define UARTE_ENABLE		UARTE_ENABLE_ENABLE_Enabled
+#define UARTE_DISABLE           UARTE_ENABLE_ENABLE_Disabled
 
 /*
  * Only one UART on NRF 52832.
@@ -91,6 +92,9 @@ hal_uart_start_tx(int port)
     int sr;
     int rc;
 
+    if (port != 0) {
+        return;
+    }
     u = &uart;
     __HAL_DISABLE_INTERRUPTS(sr);
     if (u->u_tx_started == 0) {
@@ -113,6 +117,9 @@ hal_uart_start_rx(int port)
     int sr;
     int rc;
 
+    if (port != 0) {
+        return;
+    }
     u = &uart;
     if (u->u_rx_stall) {
         __HAL_DISABLE_INTERRUPTS(sr);
@@ -131,6 +138,10 @@ hal_uart_blocking_tx(int port, uint8_t data)
 {
     struct hal_uart *u;
 
+    if (port != 0) {
+        return;
+    }
+
     u = &uart;
     if (!u->u_open) {
         return;
@@ -202,6 +213,8 @@ hal_uart_baudrate(int baudrate)
         return UARTE_BAUDRATE_BAUDRATE_Baud38400;
     case 57600:
         return UARTE_BAUDRATE_BAUDRATE_Baud57600;
+    case 76800:
+        return UARTE_BAUDRATE_BAUDRATE_Baud76800;
     case 115200:
         return UARTE_BAUDRATE_BAUDRATE_Baud115200;
     case 230400:
@@ -307,3 +320,19 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
 
     return 0;
 }
+
+int
+hal_uart_close(int port)
+{
+    struct hal_uart *u;
+
+    u = &uart;
+
+    if (port == 0) {
+        u->u_open = 0;
+        NRF_UARTE0->ENABLE = 0;
+        NRF_UARTE0->INTENCLR = 0xffffffff;
+        return 0;
+    }
+    return -1;
+}