Skip to content

Commit b21c278

Browse files
authored
Merge pull request #10509 from NXPmicro/LPC55S69_Add_UART_Flowcontrol
LPC55S69: Add support for UART hardware flow control
2 parents 13880dc + 39975b8 commit b21c278

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/serial_api.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "fsl_usart.h"
2929
#include "PeripheralPins.h"
3030
#include "clock_config.h"
31+
#include "gpio_api.h"
3132

3233
static uint32_t serial_irq_ids[FSL_FEATURE_SOC_USART_COUNT] = {0};
3334
static uart_irq_handler irq_handler;
@@ -381,6 +382,48 @@ void serial_break_clear(serial_t *obj)
381382
uart_addrs[obj->index]->CTL &= ~USART_CTL_TXBRKEN_MASK;
382383
}
383384

385+
#if DEVICE_SERIAL_FC
386+
/*
387+
* Only hardware flow control is implemented in this API.
388+
*/
389+
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
390+
{
391+
gpio_t gpio;
392+
393+
switch(type) {
394+
case FlowControlRTS:
395+
pinmap_pinout(rxflow, PinMap_UART_RTS);
396+
uart_addrs[obj->index]->CFG &= ~USART_CFG_CTSEN_MASK;
397+
break;
398+
399+
case FlowControlCTS:
400+
/* Do not use RTS, configure pin to GPIO input */
401+
gpio_init(&gpio, rxflow);
402+
gpio_dir(&gpio, PIN_INPUT);
403+
404+
pinmap_pinout(txflow, PinMap_UART_CTS);
405+
uart_addrs[obj->index]->CFG |= USART_CFG_CTSEN_MASK;
406+
break;
407+
408+
case FlowControlRTSCTS:
409+
pinmap_pinout(rxflow, PinMap_UART_RTS);
410+
pinmap_pinout(txflow, PinMap_UART_CTS);
411+
uart_addrs[obj->index]->CFG |= USART_CFG_CTSEN_MASK;
412+
break;
413+
414+
case FlowControlNone:
415+
/* Do not use RTS, configure pin to GPIO input */
416+
gpio_init(&gpio, rxflow);
417+
gpio_dir(&gpio, PIN_INPUT);
418+
419+
uart_addrs[obj->index]->CFG &= ~USART_CFG_CTSEN_MASK;
420+
break;
421+
422+
default:
423+
break;
424+
}
425+
}
426+
#endif
384427
const PinMap *serial_tx_pinmap()
385428
{
386429
return PinMap_UART_TX;

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC55S69/TARGET_LPCXpresso/PeripheralPins.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,27 @@ const PinMap PinMap_I2C_SCL[] = {
6565
/************UART***************/
6666
const PinMap PinMap_UART_TX[] = {
6767
{P0_30, UART_0, 1},
68+
{P1_6, UART_0, 1},
6869
{P0_27, UART_1, 1},
6970
{NC , NC , 0}
7071
};
7172

7273
const PinMap PinMap_UART_RX[] = {
7374
{P0_29, UART_0, 1},
75+
{P1_5, UART_0, 1},
7476
{P1_24, UART_1, 1},
7577
{NC , NC , 0}
7678
};
7779

7880
const PinMap PinMap_UART_CTS[] = {
81+
{P1_8, UART_0, 1},
82+
{P1_26, UART_1, 1},
7983
{NC , NC , 0}
8084
};
8185

8286
const PinMap PinMap_UART_RTS[] = {
87+
{P1_7, UART_0, 1},
88+
{P1_27, UART_1, 1},
8389
{NC , NC , 0}
8490
};
8591

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,7 @@
20882088
"PORTINOUT",
20892089
"PORTOUT",
20902090
"SERIAL",
2091+
"SERIAL_FC",
20912092
"SLEEP",
20922093
"SPI",
20932094
"SPISLAVE",

0 commit comments

Comments
 (0)