Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPC55S69: Add support for UART hardware flow control #10509

Merged
merged 1 commit into from May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/serial_api.c
Expand Up @@ -28,6 +28,7 @@
#include "fsl_usart.h"
#include "PeripheralPins.h"
#include "clock_config.h"
#include "gpio_api.h"

static uint32_t serial_irq_ids[FSL_FEATURE_SOC_USART_COUNT] = {0};
static uart_irq_handler irq_handler;
Expand Down Expand Up @@ -381,6 +382,48 @@ void serial_break_clear(serial_t *obj)
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()
{
return PinMap_UART_TX;
Expand Down
Expand Up @@ -65,21 +65,27 @@ const PinMap PinMap_I2C_SCL[] = {
/************UART***************/
const PinMap PinMap_UART_TX[] = {
{P0_30, UART_0, 1},
{P1_6, UART_0, 1},
{P0_27, UART_1, 1},
{NC , NC , 0}
};

const PinMap PinMap_UART_RX[] = {
{P0_29, UART_0, 1},
{P1_5, UART_0, 1},
{P1_24, UART_1, 1},
{NC , NC , 0}
};

const PinMap PinMap_UART_CTS[] = {
{P1_8, UART_0, 1},
{P1_26, UART_1, 1},
{NC , NC , 0}
};

const PinMap PinMap_UART_RTS[] = {
{P1_7, UART_0, 1},
{P1_27, UART_1, 1},
{NC , NC , 0}
};

Expand Down
1 change: 1 addition & 0 deletions targets/targets.json
Expand Up @@ -2088,6 +2088,7 @@
"PORTINOUT",
"PORTOUT",
"SERIAL",
"SERIAL_FC",
"SLEEP",
"SPI",
"SPISLAVE",
Expand Down