Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cb6e69b
Merged nuttx/nuttx into master
Apr 5, 2019
3c11d9e
Merged nuttx/nuttx into master
Apr 7, 2019
6d13529
Merged nuttx/nuttx into master
Jun 5, 2019
3b5c9d3
Merged nuttx/nuttx into master
Jul 9, 2019
00ddedb
Merged nuttx/nuttx into master
Jul 11, 2019
9ae6140
Merged nuttx/nuttx into master
Jul 17, 2019
8a20155
Save CONFIG_ARCH_BOARD_CUSTOM when running 'make savedefconfig'
Jul 17, 2019
835b5e9
Only use PCLKSEL0 for ADC on LPC176x family.
Jul 29, 2019
f3aba93
Merged in lpc40xx_updates (pull request #1)
Jul 29, 2019
c43e5a8
Made grep search expression more specific.
Aug 16, 2019
38b51f0
Added missing '=' to second grep
Aug 19, 2019
4a89539
Merged in makefile_update (pull request #2)
Aug 19, 2019
c785607
Revert "Only use PCLKSEL0 for ADC on LPC176x family."
Aug 19, 2019
aa2ed7f
Revert "Added missing '=' to second grep"
Aug 19, 2019
6fdf8ed
Merged nuttx/nuttx into master
Aug 19, 2019
3a6f68e
Added a missing '=' in the second grep statement
Aug 19, 2019
9f29211
Merged nuttx/nuttx into master
Aug 29, 2019
c6c603d
Don't compile up_earlyserialinit if USE_EARLYSERIALINIT is not defined
Aug 29, 2019
0a7ecc3
Merged nuttx/nuttx into master
Sep 3, 2019
389ae29
Merged nuttx/nuttx into master
Sep 5, 2019
9b55a26
Merged nuttx/nuttx into master
Sep 6, 2019
509fe86
Revert extra = in CONFIG_ARCH_BOARD_CUSTOM
Sep 6, 2019
c025a56
Merged nuttx/nuttx into master
Sep 18, 2019
3e4eb68
Merged nuttx/nuttx into master
Sep 25, 2019
26d89ce
Merged master into lpc17xx_fixes
Sep 25, 2019
fb1b845
Added support for RS485 direction control on LPC17xx UART1
Sep 25, 2019
7c07648
First pass at fractional baud rate divider on LPC17xx/40xx
Oct 18, 2019
c642d5c
Added support for fractional divider to console UART
Oct 18, 2019
9453799
Small fixes for fractional baud rate on console
Oct 18, 2019
bced7c3
fix typo
Oct 18, 2019
4ac4303
Merge remote-tracking branch 'bitbucket/lpc17xx_fixes' into lpc17_serial
Jan 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions arch/arm/src/lpc17xx_40xx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,36 @@ config LPC17_40_UART1_RINGINDICATOR
---help---
Enable UART1 ring indicator

config LPC17_40_UART1_RS485
bool "RS-485 on UART1"
default n
depends on LPC17_40_UART1
---help---
Enable RS-485 interface on UART1. Your board config will have to
provide GPIO_UART1_RS485_DIR pin definition.

config LPC17_40_RS485_DIR_POLARITY
int "UART1 RS-485 DIR pin polarity"
default 1
range 0 1
depends on LPC17_40_UART1_RS485
---help---
Polarity of DIR pin for RS-485 on UART1. Set to state on DIR pin which
enables TX (0 - low / nTXEN, 1 - high / TXEN).

config LPC17_40_UART1_RS485_DIR_DTR
bool "UART1 RS-485 DIR pin use DTR"
default n
depends on LPC17_40_UART1_RS485
---help---
Selects between RTS and DTR pins for RS485 DIR. This must correspond to
the GPIO_USART1_RS485_DIR pin specified in your board config. The DTR pin
will be used if selected, the RTS pin will be used otherwise.

config LPC17_40_UART_USE_FRACTIONAL_DIVIDER
bool "Use fractional divider for UART baud rate"
default n

endmenu

menu "ADC driver options"
Expand Down
38 changes: 23 additions & 15 deletions arch/arm/src/lpc17xx_40xx/lpc17_40_lowputc.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@
* And for the LPC178x/40xx, the PCLK is determined by the global divisor setting in
* the PLKSEL register.
*
* Ignoring the fractional divider for now. (If you want to extend this driver
* to support the fractional divider, see lpc43xx_uart.c. The LPC43xx uses
* the same peripheral and that logic could easily leveraged here).
*/

#ifdef LPC178x_40xx
Expand All @@ -165,6 +162,10 @@
# define CONSOLE_NUMERATOR BOARD_PCLK_FREQUENCY

#else
# ifdef CONFIG_LPC17_40_UART_USE_FRACTIONAL_DIVIDER
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK
# define CONSOLE_NUMERATOR (LPC17_40_CCLK)
# else
/* Calculate and optimal PCLKSEL0/1 divisor.
* First, check divisor == 1. This works if the upper limit is met:
*
Expand All @@ -181,9 +182,9 @@
* BAUD <= CCLK / 16 / MinDL
*/

# if CONSOLE_BAUD < (LPC17_40_CCLK / 16 / UART_MINDL)
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK
# define CONSOLE_NUMERATOR (LPC17_40_CCLK)
# if CONSOLE_BAUD < (LPC17_40_CCLK / 16 / UART_MINDL)
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK
# define CONSOLE_NUMERATOR (LPC17_40_CCLK)

/* Check divisor == 2. This works if:
*
Expand All @@ -196,9 +197,9 @@
* BAUD <= CCLK / 8 / MinDL
*/

# elif CONSOLE_BAUD < (LPC17_40_CCLK / 8 / UART_MINDL)
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK2
# define CONSOLE_NUMERATOR (LPC17_40_CCLK / 2)
# elif CONSOLE_BAUD < (LPC17_40_CCLK / 8 / UART_MINDL)
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK2
# define CONSOLE_NUMERATOR (LPC17_40_CCLK / 2)

/* Check divisor == 4. This works if:
*
Expand All @@ -211,9 +212,9 @@
* BAUD <= CCLK / 4 / MinDL
*/

# elif CONSOLE_BAUD < (LPC17_40_CCLK / 4 / UART_MINDL)
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK4
# define CONSOLE_NUMERATOR (LPC17_40_CCLK / 4)
# elif CONSOLE_BAUD < (LPC17_40_CCLK / 4 / UART_MINDL)
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK4
# define CONSOLE_NUMERATOR (LPC17_40_CCLK / 4)

/* Check divisor == 8. This works if:
*
Expand All @@ -226,9 +227,10 @@
* BAUD <= CCLK / 2 / MinDL
*/

# else /* if CONSOLE_BAUD < (LPC17_40_CCLK / 2 / UART_MINDL) */
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK8
# define CONSOLE_NUMERATOR (LPC17_40_CCLK / 8)
# else /* if CONSOLE_BAUD < (LPC17_40_CCLK / 2 / UART_MINDL) */
# define CONSOLE_CCLKDIV SYSCON_PCLKSEL_CCLK8
# define CONSOLE_NUMERATOR (LPC17_40_CCLK / 8)
# endif
# endif
#endif /* LPC178x_40xx */

Expand Down Expand Up @@ -396,22 +398,28 @@ void lpc17_40_lowsetup(void)
putreg32(UART_FCR_FIFOEN | UART_FCR_RXTRIGGER_8,
CONSOLE_BASE + LPC17_40_UART_FCR_OFFSET);

#ifndef CONFIG_LPC17_40_UART_USE_FRACTIONAL_DIVIDER
/* Disable FDR (fractional divider),
* ignored by baudrate calculation => has to be disabled
*/

putreg32((1 << UART_FDR_MULVAL_SHIFT) + (0 << UART_FDR_DIVADDVAL_SHIFT),
CONSOLE_BASE + LPC17_40_UART_FDR_OFFSET);

#endif
/* Set up the LCR and set DLAB=1 */

putreg32(CONSOLE_LCR_VALUE | UART_LCR_DLAB,
CONSOLE_BASE + LPC17_40_UART_LCR_OFFSET);

#ifdef CONFIG_LPC17_40_UART_USE_FRACTIONAL_DIVIDER
up_setbaud(CONSOLE_BASE, CONSOLE_NUMERATOR, CONSOLE_BAUD);
#else
/* Set the BAUD divisor */

putreg32(CONSOLE_DL >> 8, CONSOLE_BASE + LPC17_40_UART_DLM_OFFSET);
putreg32(CONSOLE_DL & 0xff, CONSOLE_BASE + LPC17_40_UART_DLL_OFFSET);
#endif

/* Clear DLAB */

Expand Down
Loading