cpu/nrf5x: implemented UART TX only mode
This commit is contained in:
parent
a2bc7bf8c7
commit
b0def58927
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2014-2016 Freie Universität Berlin
|
||||
* Copyright (C) 2014-2017 Freie Universität Berlin
|
||||
* 2015 Jan Wagner <mail@jwagner.eu>
|
||||
*
|
||||
*
|
||||
|
@ -50,14 +50,20 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||
/* power on the UART device */
|
||||
NRF_UART0->POWER = 1;
|
||||
#endif
|
||||
|
||||
/* reset configuration registers */
|
||||
NRF_UART0->CONFIG = 0;
|
||||
/* configure RX/TX pin modes */
|
||||
|
||||
/* configure RX pin */
|
||||
if (rx_cb) {
|
||||
GPIO_BASE->DIRCLR = (1 << UART_PIN_RX);
|
||||
NRF_UART0->PSELRXD = UART_PIN_RX;
|
||||
}
|
||||
|
||||
/* configure TX pin */
|
||||
GPIO_BASE->DIRSET = (1 << UART_PIN_TX);
|
||||
GPIO_BASE->DIRCLR = (1 << UART_PIN_RX);
|
||||
/* configure UART pins to use */
|
||||
NRF_UART0->PSELTXD = UART_PIN_TX;
|
||||
NRF_UART0->PSELRXD = UART_PIN_RX;
|
||||
|
||||
/* enable HW-flow control if defined */
|
||||
#if UART_HWFLOWCTRL
|
||||
/* set pin mode for RTS and CTS pins */
|
||||
|
@ -127,10 +133,14 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||
NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled;
|
||||
/* enable TX and RX */
|
||||
NRF_UART0->TASKS_STARTTX = 1;
|
||||
NRF_UART0->TASKS_STARTRX = 1;
|
||||
/* enable global and receiving interrupt */
|
||||
NVIC_EnableIRQ(UART_IRQN);
|
||||
NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Msk;
|
||||
|
||||
if (rx_cb) {
|
||||
NRF_UART0->TASKS_STARTRX = 1;
|
||||
/* enable global and receiving interrupt */
|
||||
NVIC_EnableIRQ(UART_IRQN);
|
||||
NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Msk;
|
||||
}
|
||||
|
||||
return UART_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue