LPC55S69: Add support for UART hardware flow control

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
pull/10509/head
Mahesh Mahadevan 2019-04-23 10:29:18 -05:00
parent 2cd7aa1148
commit 39975b818d
3 changed files with 50 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include "fsl_usart.h" #include "fsl_usart.h"
#include "PeripheralPins.h" #include "PeripheralPins.h"
#include "clock_config.h" #include "clock_config.h"
#include "gpio_api.h"
static uint32_t serial_irq_ids[FSL_FEATURE_SOC_USART_COUNT] = {0}; static uint32_t serial_irq_ids[FSL_FEATURE_SOC_USART_COUNT] = {0};
static uart_irq_handler irq_handler; static uart_irq_handler irq_handler;
@ -381,6 +382,48 @@ void serial_break_clear(serial_t *obj)
uart_addrs[obj->index]->CTL &= ~USART_CTL_TXBRKEN_MASK; uart_addrs[obj->index]->CTL &= ~USART_CTL_TXBRKEN_MASK;
} }
#if DEVICE_SERIAL_FC
/*
* Only hardware flow control is implemented in this API.
*/
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
{
gpio_t gpio;
switch(type) {
case FlowControlRTS:
pinmap_pinout(rxflow, PinMap_UART_RTS);
uart_addrs[obj->index]->CFG &= ~USART_CFG_CTSEN_MASK;
break;
case FlowControlCTS:
/* Do not use RTS, configure pin to GPIO input */
gpio_init(&gpio, rxflow);
gpio_dir(&gpio, PIN_INPUT);
pinmap_pinout(txflow, PinMap_UART_CTS);
uart_addrs[obj->index]->CFG |= USART_CFG_CTSEN_MASK;
break;
case FlowControlRTSCTS:
pinmap_pinout(rxflow, PinMap_UART_RTS);
pinmap_pinout(txflow, PinMap_UART_CTS);
uart_addrs[obj->index]->CFG |= USART_CFG_CTSEN_MASK;
break;
case FlowControlNone:
/* Do not use RTS, configure pin to GPIO input */
gpio_init(&gpio, rxflow);
gpio_dir(&gpio, PIN_INPUT);
uart_addrs[obj->index]->CFG &= ~USART_CFG_CTSEN_MASK;
break;
default:
break;
}
}
#endif
const PinMap *serial_tx_pinmap() const PinMap *serial_tx_pinmap()
{ {
return PinMap_UART_TX; return PinMap_UART_TX;

View File

@ -65,21 +65,27 @@ const PinMap PinMap_I2C_SCL[] = {
/************UART***************/ /************UART***************/
const PinMap PinMap_UART_TX[] = { const PinMap PinMap_UART_TX[] = {
{P0_30, UART_0, 1}, {P0_30, UART_0, 1},
{P1_6, UART_0, 1},
{P0_27, UART_1, 1}, {P0_27, UART_1, 1},
{NC , NC , 0} {NC , NC , 0}
}; };
const PinMap PinMap_UART_RX[] = { const PinMap PinMap_UART_RX[] = {
{P0_29, UART_0, 1}, {P0_29, UART_0, 1},
{P1_5, UART_0, 1},
{P1_24, UART_1, 1}, {P1_24, UART_1, 1},
{NC , NC , 0} {NC , NC , 0}
}; };
const PinMap PinMap_UART_CTS[] = { const PinMap PinMap_UART_CTS[] = {
{P1_8, UART_0, 1},
{P1_26, UART_1, 1},
{NC , NC , 0} {NC , NC , 0}
}; };
const PinMap PinMap_UART_RTS[] = { const PinMap PinMap_UART_RTS[] = {
{P1_7, UART_0, 1},
{P1_27, UART_1, 1},
{NC , NC , 0} {NC , NC , 0}
}; };

View File

@ -2088,6 +2088,7 @@
"PORTINOUT", "PORTINOUT",
"PORTOUT", "PORTOUT",
"SERIAL", "SERIAL",
"SERIAL_FC",
"SLEEP", "SLEEP",
"SPI", "SPI",
"SPISLAVE", "SPISLAVE",