drivers: uart_nrf5: Use MDK baudrate divisor constants

The baudrate calculation present in set_baudrate() is
causing the UART to emit inital bytes incorrectly, for a
reason currently unknown, but directly related to the fact
that __aeabi_uldivmod is being invoked.
Since the nRF5x Product Specifications do not provide a
standard formula to calculate baudrates and instead list
a predefined set of divisor values, we opt here to use the
official values and remove the attempt at calculating them
manually.

Change-Id: Ic3ff42ea6d065e9a1d26a5350ce5bf5ad661160a
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2016-10-25 14:06:55 +02:00 committed by Anas Nashif
commit 33d17497d2
2 changed files with 87 additions and 13 deletions

View file

@ -71,4 +71,28 @@
#define NRF52_IRQ_I2S_IRQn 37
#define NRF52_IRQ_FPU_IRQn 38
/**
* @file UART baudrate divisors for NRF51/NRF52 family processors.
*
* Based on Nordic MDK included header file: nrf52_bitfields.h
* Uses the UARTE_BAUDRATE macros since they are more precise.
*/
#define NRF5_UART_BAUDRATE_1200 0x0004f000
#define NRF5_UART_BAUDRATE_2400 0x0009d000
#define NRF5_UART_BAUDRATE_4800 0x0013b000
#define NRF5_UART_BAUDRATE_9600 0x00275000
#define NRF5_UART_BAUDRATE_14400 0x003af000
#define NRF5_UART_BAUDRATE_19200 0x004ea000
#define NRF5_UART_BAUDRATE_28800 0x0075c000
#define NRF5_UART_BAUDRATE_38400 0x009d0000
#define NRF5_UART_BAUDRATE_57600 0x00eb0000
#define NRF5_UART_BAUDRATE_76800 0x013a9000
#define NRF5_UART_BAUDRATE_115200 0x01d60000
#define NRF5_UART_BAUDRATE_230400 0x03b00000
#define NRF5_UART_BAUDRATE_250000 0x04000000
#define NRF5_UART_BAUDRATE_460800 0x07400000
#define NRF5_UART_BAUDRATE_921600 0x0f000000
#define NRF5_UART_BAUDRATE_1000000 0x10000000
#endif /* _NRF5_SOC_COMMON_H_ */