@@ -39,6 +39,18 @@ static const SWM_Map SWM_UART_RX[] = {
39
39
{2 , 24 },
40
40
};
41
41
42
+ static const SWM_Map SWM_UART_RTS [] = {
43
+ {0 , 16 },
44
+ {1 , 24 },
45
+ {3 , 0 },
46
+ };
47
+
48
+ static const SWM_Map SWM_UART_CTS [] = {
49
+ {0 , 24 },
50
+ {2 , 0 },
51
+ {3 , 8 }
52
+ };
53
+
42
54
// bit flags for used UARTs
43
55
static unsigned char uart_used = 0 ;
44
56
static int get_available_uart (void ) {
@@ -60,6 +72,7 @@ static int get_available_uart(void) {
60
72
#define TXRDY (0x01<<2)
61
73
62
74
#define TXBRKEN (0x01<<1)
75
+ #define CTSEN (0x01<<9)
63
76
64
77
static uint32_t UARTSysClk ;
65
78
@@ -278,3 +291,34 @@ void serial_break_clear(serial_t *obj) {
278
291
obj -> uart -> CTRL &= ~TXBRKEN ;
279
292
}
280
293
294
+ void serial_set_flow_control (serial_t * obj , FlowControl type , PinName rxflow , PinName txflow ) {
295
+ const SWM_Map * swm_rts , * swm_cts ;
296
+ uint32_t regVal_rts , regVal_cts ;
297
+
298
+ swm_rts = & SWM_UART_RTS [obj -> index ];
299
+ swm_cts = & SWM_UART_CTS [obj -> index ];
300
+ regVal_rts = LPC_SWM -> PINASSIGN [swm_rts -> n ] & ~(0xFF << swm_rts -> offset );
301
+ regVal_cts = LPC_SWM -> PINASSIGN [swm_cts -> n ] & ~(0xFF << swm_cts -> offset );
302
+
303
+ if (FlowControlNone == type ) {
304
+ LPC_SWM -> PINASSIGN [swm_rts -> n ] = regVal_rts | (0xFF << swm_rts -> offset );
305
+ LPC_SWM -> PINASSIGN [swm_cts -> n ] = regVal_cts | (0xFF << swm_cts -> offset );
306
+ obj -> uart -> CFG &= ~CTSEN ;
307
+ return ;
308
+ }
309
+ if ((FlowControlRTS == type || FlowControlRTSCTS == type ) && (rxflow != NC )) {
310
+ LPC_SWM -> PINASSIGN [swm_rts -> n ] = regVal_rts | (rxflow << swm_rts -> offset );
311
+ if (FlowControlRTS == type ) {
312
+ LPC_SWM -> PINASSIGN [swm_cts -> n ] = regVal_cts | (0xFF << swm_cts -> offset );
313
+ obj -> uart -> CFG &= ~CTSEN ;
314
+ }
315
+ }
316
+ if ((FlowControlCTS == type || FlowControlRTSCTS == type ) && (txflow != NC )) {
317
+ LPC_SWM -> PINASSIGN [swm_cts -> n ] = regVal_cts | (txflow << swm_cts -> offset );
318
+ obj -> uart -> CFG |= CTSEN ;
319
+ if (FlowControlCTS == type ) {
320
+ LPC_SWM -> PINASSIGN [swm_rts -> n ] = regVal_rts | (0xFF << swm_rts -> offset );
321
+ }
322
+ }
323
+ }
324
+
0 commit comments