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/08/26 21:30:52 UTC
[4/4] incubator-mynewt-core git commit: nrf51xx uart;
add hal_uart_init(), hal_uart_close()
nrf51xx uart; add hal_uart_init(), hal_uart_close()
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/2c79b4d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2c79b4d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2c79b4d2
Branch: refs/heads/sterly_refactor
Commit: 2c79b4d29c966974a394a758f0686a94eb13670e
Parents: 24fed7b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Aug 26 13:15:31 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Aug 26 14:27:59 2016 -0700
----------------------------------------------------------------------
hw/mcu/nordic/nrf51xxx/src/hal_uart.c | 37 +++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2c79b4d2/hw/mcu/nordic/nrf51xxx/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_uart.c b/hw/mcu/nordic/nrf51xxx/src/hal_uart.c
index a927c60..090ac81 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_uart.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_uart.c
@@ -42,6 +42,7 @@ struct hal_uart {
hal_uart_tx_char u_tx_func;
hal_uart_tx_done u_tx_done;
void *u_func_arg;
+ const struct nrf51_uart_cfg *u_cfg;
};
static struct hal_uart uart;
@@ -217,6 +218,24 @@ hal_uart_baudrate(int baudrate)
}
int
+hal_uart_init(int port, void *arg)
+{
+ struct hal_uart *u;
+
+ if (port != 0) {
+ return -1;
+ }
+
+ u = &uart;
+ if (u->u_open) {
+ return -1;
+ }
+ u->u_cfg = arg;
+
+ return 0;
+}
+
+int
hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
enum hal_uart_parity parity, enum hal_uart_flow_ctl flow_ctl)
{
@@ -233,7 +252,7 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
if (u->u_open) {
return -1;
}
- cfg = bsp_uart_config();
+ cfg = u->u_cfg;
assert(cfg);
/*
@@ -303,3 +322,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_UART0->ENABLE = 0;
+ NRF_UART0->INTENCLR = 0xffffffff;
+ return 0;
+ }
+ return -1;
+}