Skip to content

Commit 9cdfe37

Browse files
author
Arto Kinnunen
authored
Merge pull request #10994 from fkjagodzinski/fix-serial_fc_guards
Add DEVICE_SERIAL_FC guards to serial HAL API
2 parents 85a9022 + 4842c87 commit 9cdfe37

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

TESTS/mbed_hal_fpga_ci_test_shield/uart/main.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ static void uart_test_common(int baudrate, int data_bits, SerialParity parity, i
118118
serial_init(&serial, tx, rx);
119119
serial_baud(&serial, baudrate);
120120
serial_format(&serial, data_bits, parity, stop_bits);
121+
#if DEVICE_SERIAL_FC
121122
if (use_flow_control) {
122123
serial_set_flow_control(&serial, FlowControlRTSCTS, rts, cts);
123124
} else {
124125
serial_set_flow_control(&serial, FlowControlNone, NC, NC);
125126
}
127+
#endif
126128

127129
// Reset tester stats and select UART
128130
tester.peripherals_reset();
@@ -277,9 +279,11 @@ void test_init_free(PinName tx, PinName rx, PinName cts = NC, PinName rts = NC)
277279
serial_init(&serial, tx, rx);
278280
serial_baud(&serial, 9600);
279281
serial_format(&serial, 8, ParityNone, 1);
282+
#if DEVICE_SERIAL_FC
280283
if (use_flow_control) {
281284
serial_set_flow_control(&serial, FlowControlRTSCTS, rts, cts);
282285
}
286+
#endif
283287
serial_free(&serial);
284288
}
285289

@@ -302,28 +306,38 @@ void test_common_no_fc(PinName tx, PinName rx)
302306

303307
Case cases[] = {
304308
// Every set of pins from every peripheral.
305-
Case("init/free, FC on", all_ports<UARTPort, DefaultFormFactor, test_init_free>),
306309
Case("init/free, FC off", all_ports<UARTNoFCPort, DefaultFormFactor, test_init_free_no_fc>),
307310

308311
// One set of pins from every peripheral.
309-
Case("basic, 9600, 8N1, FC on", all_peripherals<UARTPort, DefaultFormFactor, test_common<9600, 8, ParityNone, 1> >),
310312
Case("basic, 9600, 8N1, FC off", all_peripherals<UARTNoFCPort, DefaultFormFactor, test_common_no_fc<9600, 8, ParityNone, 1> >),
311313

312314
// One set of pins from one peripheral.
313315
// baudrate
314-
Case("19200, 8N1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<19200, 8, ParityNone, 1> >),
315316
Case("19200, 8N1, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, test_common_no_fc<19200, 8, ParityNone, 1> >),
316-
Case("38400, 8N1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<38400, 8, ParityNone, 1> >),
317317
Case("38400, 8N1, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, test_common_no_fc<38400, 8, ParityNone, 1> >),
318-
Case("115200, 8N1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<115200, 8, ParityNone, 1> >),
319318
Case("115200, 8N1, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, test_common_no_fc<115200, 8, ParityNone, 1> >),
319+
// stop bits
320+
Case("9600, 8N2, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, test_common_no_fc<9600, 8, ParityNone, 2> >),
321+
322+
#if DEVICE_SERIAL_FC
323+
// Every set of pins from every peripheral.
324+
Case("init/free, FC on", all_ports<UARTPort, DefaultFormFactor, test_init_free>),
325+
326+
// One set of pins from every peripheral.
327+
Case("basic, 9600, 8N1, FC on", all_peripherals<UARTPort, DefaultFormFactor, test_common<9600, 8, ParityNone, 1> >),
328+
329+
// One set of pins from one peripheral.
330+
// baudrate
331+
Case("19200, 8N1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<19200, 8, ParityNone, 1> >),
332+
Case("38400, 8N1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<38400, 8, ParityNone, 1> >),
333+
Case("115200, 8N1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<115200, 8, ParityNone, 1> >),
320334
// data bits: not tested (some platforms support 8 bits only)
321335
// parity
322336
Case("9600, 8O1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<9600, 8, ParityOdd, 1> >),
323337
Case("9600, 8E1, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<9600, 8, ParityEven, 1> >),
324338
// stop bits
325339
Case("9600, 8N2, FC on", one_peripheral<UARTPort, DefaultFormFactor, test_common<9600, 8, ParityNone, 2> >),
326-
Case("9600, 8N2, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, test_common_no_fc<9600, 8, ParityNone, 2> >),
340+
#endif
327341
};
328342

329343
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ typedef Port<1, AnalogoutMaps, DefaultFormFactor, TF1> AnalogoutPort;
511511
#endif
512512

513513
#if DEVICE_SERIAL
514+
#if DEVICE_SERIAL_FC
514515
struct UARTMaps {
515516
static const PinMap *maps[];
516517
static const char *const pin_type_names[];
@@ -520,6 +521,7 @@ const PinMap *UARTMaps::maps[] = { serial_tx_pinmap(), serial_rx_pinmap(), seria
520521
const char *const UARTMaps::pin_type_names[] = { "TX", "RX", "CLS", "RTS" };
521522
const char *const UARTMaps::name = "UART";
522523
typedef Port<4, UARTMaps, DefaultFormFactor, TF4> UARTPort;
524+
#endif
523525

524526
struct UARTNoFCMaps {
525527
static const PinMap *maps[];

hal/serial_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ void serial_break_clear(serial_t *obj);
211211
*/
212212
void serial_pinout_tx(PinName tx);
213213

214+
#if DEVICE_SERIAL_FC
214215
/** Configure the serial for the flow control. It sets flow control in the hardware
215216
* if a serial peripheral supports it, otherwise software emulation is used.
216217
*
@@ -220,6 +221,7 @@ void serial_pinout_tx(PinName tx);
220221
* @param txflow The RX pin name
221222
*/
222223
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
224+
#endif
223225

224226
/** Get the pins that support Serial TX
225227
*
@@ -239,6 +241,7 @@ const PinMap *serial_tx_pinmap(void);
239241
*/
240242
const PinMap *serial_rx_pinmap(void);
241243

244+
#if DEVICE_SERIAL_FC
242245
/** Get the pins that support Serial CTS
243246
*
244247
* Return a PinMap array of pins that support Serial CTS. The
@@ -256,6 +259,7 @@ const PinMap *serial_cts_pinmap(void);
256259
* @return PinMap array
257260
*/
258261
const PinMap *serial_rts_pinmap(void);
262+
#endif
259263

260264
#if DEVICE_SERIAL_ASYNCH
261265

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/serial_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
153153
}
154154
uart_data[obj->index].sw_rts.pin = NC;
155155
uart_data[obj->index].sw_cts.pin = NC;
156-
serial_set_flow_control(obj, FlowControlNone, NC, NC);
157156

158157
is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
159158

targets/TARGET_ARM_SSG/TARGET_MPS2/serial_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
157157
}
158158
uart_data[obj->index].sw_rts.pin = NC;
159159
uart_data[obj->index].sw_cts.pin = NC;
160-
serial_set_flow_control(obj, FlowControlNone, NC, NC);
161160

162161
is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
163162

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8557,6 +8557,7 @@
85578557
"INTERRUPTIN",
85588558
"EMAC",
85598559
"SERIAL",
8560+
"SERIAL_FC",
85608561
"STDIO_MESSAGES",
85618562
"PWMOUT",
85628563
"SPI",

0 commit comments

Comments
 (0)