Skip to content

Commit 6f86064

Browse files
authored
Merge pull request #2140 from mbedmicro/k64f_flow_control
Added flow control for K64F
2 parents 089b67c + a4475a0 commit 6f86064

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

hal/targets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@
579579
"inherits": ["Target"],
580580
"progen": {"target": "frdm-k64f"},
581581
"detect_code": ["0240"],
582-
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_RED", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "STORAGE"],
582+
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_RED", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "STORAGE"],
583583
"features": ["IPV4"],
584584
"release": true
585585
},
@@ -592,7 +592,7 @@
592592
"is_disk_virtual": true,
593593
"macros": ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED", "TARGET_K64F"],
594594
"progen": {"target": "mts-gambit"},
595-
"device_has": ["I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"]
595+
"device_has": ["I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"]
596596
},
597597
"HEXIWEAR": {
598598
"inherits": ["Target"],
@@ -605,7 +605,7 @@
605605
"default_toolchain": "ARM",
606606
"detect_code": ["0214"],
607607
"progen": {"target": "hexiwear-k64f"},
608-
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_RED", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
608+
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_RED", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
609609
"default_build": "standard"
610610
},
611611
"NUCLEO_F030R8": {

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K64F/TARGET_FRDM/PeripheralPins.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,40 @@ const PinMap PinMap_UART_RX[] = {
112112
{NC , NC , 0}
113113
};
114114

115+
const PinMap PinMap_UART_CTS[] = {
116+
{PTB13, UART_3, 2},
117+
{PTE2 , UART_1, 3},
118+
{PTE6 , UART_3, 3},
119+
{PTE26, UART_4, 3},
120+
{PTA0 , UART_0, 2},
121+
{PTA16, UART_0, 3},
122+
{PTB3 , UART_0, 3},
123+
{PTB9 , UART_3, 3},
124+
{PTC2 , UART_1, 3},
125+
{PTC13, UART_4, 3},
126+
{PTC19, UART_3, 3},
127+
{PTD1 , UART_2, 3},
128+
{PTD5 , UART_0, 3},
129+
{NC , NC , 0}
130+
};
131+
132+
const PinMap PinMap_UART_RTS[] = {
133+
{PTB12, UART_3, 2},
134+
{PTE3 , UART_1, 3},
135+
{PTE7 , UART_3, 3},
136+
{PTE27, UART_4, 3},
137+
{PTA17, UART_0, 3},
138+
{PTB8 , UART_3, 3},
139+
{PTC1 , UART_1, 3},
140+
{PTC12, UART_4, 3},
141+
{PTC18, UART_3, 3},
142+
{PTD0 , UART_2, 3},
143+
{PTD4 , UART_0, 3},
144+
{PTA3 , UART_0, 2},
145+
{PTB2 , UART_0, 3},
146+
{NC , NC , 0}
147+
};
148+
115149
/************SPI***************/
116150
const PinMap PinMap_SPI_SCLK[] = {
117151
{PTD1 , SPI_0, 2},

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K64F/serial_api.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,37 @@ void serial_break_clear(serial_t *obj) {
280280
uart_addrs[obj->index]->C2 &= ~UART_C2_SBK_MASK;
281281
}
282282

283+
/*
284+
* Only hardware flow control is implemented in this API.
285+
*/
286+
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
287+
{
288+
switch(type) {
289+
case FlowControlRTS:
290+
pinmap_pinout(rxflow, PinMap_UART_RTS);
291+
uart_addrs[obj->index]->MODEM &= ~UART_MODEM_TXCTSE_MASK;
292+
uart_addrs[obj->index]->MODEM |= UART_MODEM_RXRTSE_MASK;
293+
break;
294+
295+
case FlowControlCTS:
296+
pinmap_pinout(txflow, PinMap_UART_CTS);
297+
uart_addrs[obj->index]->MODEM &= ~UART_MODEM_RXRTSE_MASK;
298+
uart_addrs[obj->index]->MODEM |= UART_MODEM_TXCTSE_MASK;
299+
break;
300+
301+
case FlowControlRTSCTS:
302+
pinmap_pinout(rxflow, PinMap_UART_RTS);
303+
pinmap_pinout(txflow, PinMap_UART_CTS);
304+
uart_addrs[obj->index]->MODEM |= UART_MODEM_TXCTSE_MASK | UART_MODEM_RXRTSE_MASK;
305+
break;
306+
307+
case FlowControlNone:
308+
uart_addrs[obj->index]->MODEM &= ~(UART_MODEM_TXCTSE_MASK | UART_MODEM_RXRTSE_MASK);
309+
break;
310+
311+
default:
312+
break;
313+
}
314+
}
315+
283316
#endif

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/api/PeripheralPins.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ extern const PinMap PinMap_I2C_SCL[];
3636
/************UART***************/
3737
extern const PinMap PinMap_UART_TX[];
3838
extern const PinMap PinMap_UART_RX[];
39-
39+
extern const PinMap PinMap_UART_CTS[];
40+
extern const PinMap PinMap_UART_RTS[];
4041
/************SPI***************/
4142
extern const PinMap PinMap_SPI_SCLK[];
4243
extern const PinMap PinMap_SPI_MOSI[];

0 commit comments

Comments
 (0)