diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-08-15 01:50:35 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-08-15 01:50:35 +0000 |
commit | 981c97bce640f4f0ef7484c4d3acafad25a79614 (patch) | |
tree | 2a7c671cefcaf13730797072c8487d8a02fde785 /nuttx/arch/arm/src/kinetis/kinetis_lowputc.c | |
parent | f10e8daef8081c68439d129dc02e79e87eeffde5 (diff) | |
download | px4-nuttx-981c97bce640f4f0ef7484c4d3acafad25a79614.tar.gz px4-nuttx-981c97bce640f4f0ef7484c4d3acafad25a79614.tar.bz2 px4-nuttx-981c97bce640f4f0ef7484c4d3acafad25a79614.zip |
More Kinetis logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3881 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/kinetis/kinetis_lowputc.c')
-rw-r--r-- | nuttx/arch/arm/src/kinetis/kinetis_lowputc.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/nuttx/arch/arm/src/kinetis/kinetis_lowputc.c b/nuttx/arch/arm/src/kinetis/kinetis_lowputc.c index 20d76013b..34624a600 100644 --- a/nuttx/arch/arm/src/kinetis/kinetis_lowputc.c +++ b/nuttx/arch/arm/src/kinetis/kinetis_lowputc.c @@ -115,10 +115,12 @@ * Private Variables **************************************************************************/ +static uint8_t g_sizemap[8] = {1, 4, 8, 16, 32, 64, 128, 0}; + /************************************************************************** * Private Functions **************************************************************************/ - + /************************************************************************** * Public Functions **************************************************************************/ @@ -296,10 +298,11 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud, uint32_t clock, unsigned int parity, unsigned int nbits) { - uint32_t sbr; - uint32_t brfa; - uint32_t tmp; - uint8_t regval; + uint32_t sbr; + uint32_t brfa; + uint32_t tmp; + uint8_t regval; + unsigned int depth; /* Disable the transmitter and receiver throughout the reconfiguration */ @@ -384,10 +387,32 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud, regval |= ((uint8_t)brfa << UART_C4_BRFA_SHIFT) & UART_C4_BRFA_MASK; putreg8(regval, uart_base+KINETIS_UART_C4_OFFSET); + /* Set the FIFO watermarks */ + + regval = getreg8(uart_base+KINETIS_UART_PFIFO_OFFSET); + + depth = g_sizemap[(regval & UART_PFIFO_RXFIFOSIZE_MASK) >> UART_PFIFO_RXFIFOSIZE_SHIFT]; + if (depth > 1) + { + depth = (3 * depth) >> 2; + } + putreg8(depth , uart_base+KINETIS_UART5_RWFIFO); + + depth = g_sizemap[(regval & UART_PFIFO_TXFIFOSIZE_MASK) >> UART_PFIFO_TXFIFOSIZE_SHIFT]; + if (depth > 3) + { + depth = (depth >> 2); + } + putreg8(depth, uart_base+KINETIS_UART5_TWFIFO); + + /* Enable RX and TX FIFOs */ + + putreg8(UART_PFIFO_RXFE | UART_PFIFO_TXFE, uart_base+KINETIS_UART_PFIFO_OFFSET); + /* Now we can re-enable the transmitter and receiver */ regval = getreg8(uart_base+KINETIS_UART_C2_OFFSET); - regval |= (UART_C2_RE|UART_C2_TE); + regval |= (UART_C2_RE | UART_C2_TE); putreg8(regval, uart_base+KINETIS_UART_C2_OFFSET); } #endif |