diff --git a/arch/arm/src/nrf52/nrf52_config.h b/arch/arm/src/nrf52/nrf52_config.h index 82d4377a00..a01abca183 100644 --- a/arch/arm/src/nrf52/nrf52_config.h +++ b/arch/arm/src/nrf52/nrf52_config.h @@ -50,6 +50,7 @@ ************************************************************************************/ /* Configuration *********************************************************************/ + /* Make sure that no unsupported UART, I2C master, or SPI master peripherals are * enabled. */ diff --git a/arch/arm/src/nrf52/nrf52_lowputc.c b/arch/arm/src/nrf52/nrf52_lowputc.c index 37cba0ded5..2491191bdb 100644 --- a/arch/arm/src/nrf52/nrf52_lowputc.c +++ b/arch/arm/src/nrf52/nrf52_lowputc.c @@ -84,7 +84,7 @@ /* UART console configuration */ -static const struct uart_config_s g_console_config= +static const struct uart_config_s g_console_config = { .baud = CONSOLE_BAUD, .parity = CONSOLE_PARITY, @@ -116,11 +116,11 @@ static const struct uart_config_s g_console_config= #ifdef HAVE_UART_DEVICE static void nrf52_setbaud(uintptr_t base, const struct uart_config_s *config) { - uint32_t br = 0x01D7E000; /* 268.444444 */ + uint32_t br = 0x01d7e000; /* 268.444444 */ if (config->baud == 115200) { - br = 0x01D7E000; + br = 0x01d7e000; } putreg32(br, base + NRF52_UART_BAUDRATE_OFFSET); @@ -204,14 +204,15 @@ void nrf52_usart_configure(uintptr_t base, const struct uart_config_s *config) void nrf52_usart_disable(uintptr_t base) { /* Disable interrupts */ + /* Disable the UART */ putreg32(1, base + NRF52_UART_TASKS_STOPRX_OFFSET); putreg32(1, base + NRF52_UART_TASKS_STOPTX_OFFSET); putreg32(NRF52_UART_ENABLE_DISABLE, base + NRF52_UART_ENABLE_OFFSET); - putreg32(0xFFFFFFFF, base + NRF52_UART_PSELTXD_OFFSET); - putreg32(0xFFFFFFFF, base + NRF52_UART_PSELRXD_OFFSET); + putreg32(0xffffffff, base + NRF52_UART_PSELTXD_OFFSET); + putreg32(0xffffffff, base + NRF52_UART_PSELRXD_OFFSET); } #endif @@ -229,7 +230,7 @@ void up_lowputc(char ch) putreg32(1, CONSOLE_BASE + NRF52_UART_TASKS_STARTTX_OFFSET); putreg32(0, CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET); putreg32(ch, CONSOLE_BASE + NRF52_UART_TXD_OFFSET); - while (getreg32(CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET) == 0 ) + while (getreg32(CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET) == 0) { } diff --git a/arch/arm/src/nrf52/nrf52_serial.c b/arch/arm/src/nrf52/nrf52_serial.c index 7114a1cf6f..544424f4bb 100644 --- a/arch/arm/src/nrf52/nrf52_serial.c +++ b/arch/arm/src/nrf52/nrf52_serial.c @@ -71,6 +71,7 @@ ****************************************************************************/ /* Some sanity checks *******************************************************/ + /* Is there at least one UART enabled and configured as a RS-232 device? */ #ifndef HAVE_UART_DEVICE @@ -193,7 +194,7 @@ static uart_dev_t g_uart0port = { .size = CONFIG_UART0_TXBUFSIZE, .buffer = g_uart0txbuffer, - }, + }, .ops = &g_uart_ops, .priv = &g_uart0priv, }; @@ -301,6 +302,7 @@ static void nrf52_shutdown(struct uart_dev_s *dev) /* TODO: release uart pins */ /* Disable interrupts */ + /* Reset hardware and disable Rx and Tx */ nrf52_usart_disable(priv->uartbase); @@ -513,12 +515,11 @@ static void nrf52_send(struct uart_dev_s *dev, int ch) putreg32(1, priv->uartbase + NRF52_UART_TASKS_STARTTX_OFFSET); putreg32(ch, priv->uartbase + NRF52_UART_TXD_OFFSET); - while (getreg32(priv->uartbase + NRF52_UART_EVENTS_TXDRDY_OFFSET) == 0 ) + while (getreg32(priv->uartbase + NRF52_UART_EVENTS_TXDRDY_OFFSET) == 0) { } putreg32(1, priv->uartbase + NRF52_UART_TASKS_STOPTX_OFFSET); - } /****************************************************************************