@@ -86,16 +86,37 @@ static void test_irq_handler(uint32_t id, SerialIrq event)
8686static void uart_test_common (int baudrate, int data_bits, SerialParity parity, int stop_bits, bool init_direct, PinName tx, PinName rx, PinName cts, PinName rts)
8787{
8888 // The FPGA CI shield only supports None, Odd & Even.
89- // Forced parity is not supported on Atmel, Freescale, Nordic & STM targets.
89+ // Forced parity is not supported on many targets
9090 MBED_ASSERT (parity != ParityForced1 && parity != ParityForced0);
9191
92- // STM-specific constraints
93- // Only 7, 8 & 9 data bits.
94- MBED_ASSERT (data_bits >= 7 && data_bits <= 9 );
95- // Only Odd or Even parity for 7 data bits.
92+ // See TESTS/configs/fpga.json to check which target supports what
93+ #if defined(UART_9BITS_NOT_SUPPORTED)
94+ if (data_bits == 9 ) {
95+ utest_printf (" UART_9BITS_NOT_SUPPORTED set ... " );
96+ return ;
97+ }
98+ #endif
99+
100+ #if defined(UART_9BITS_PARITY_NOT_SUPPORTED)
101+ if ((data_bits == 9 ) && (parity != ParityNone)) {
102+ utest_printf (" UART_9BITS_PARITY_NOT_SUPPORTED set ... " );
103+ return ;
104+ }
105+ #endif
106+
107+ #if defined(UART_7BITS_NOT_SUPPORTED)
96108 if (data_bits == 7 ) {
97- MBED_ASSERT (parity != ParityNone);
109+ utest_printf (" UART_7BITS_NOT_SUPPORTED set ... " );
110+ return ;
98111 }
112+ #endif
113+
114+ #if defined(UART_7BITS_PARITY_NONE_NOT_SUPPORTED)
115+ if ((data_bits == 7 ) && (parity == ParityNone)) {
116+ utest_printf (" UART_7BITS_PARITY_NONE_NOT_SUPPORTED set ... " );
117+ return ;
118+ }
119+ #endif
99120
100121 // Limit the actual TX & RX chars to 8 bits for this test.
101122 int test_buff_bits = data_bits < 8 ? data_bits : 8 ;
@@ -333,6 +354,10 @@ Case cases[] = {
333354 Case (" basic, 9600, 8N1, FC off" , all_peripherals<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<9600 , 8 , ParityNone, 1 , false > >),
334355 Case (" basic (direct init), 9600, 8N1, FC off" , all_peripherals<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<9600 , 8 , ParityNone, 1 , true > >),
335356
357+ // same test with 7 and 9 bits data length
358+ Case (" basic, 9600, 7N1, FC off" , all_peripherals<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<9600 , 7 , ParityNone, 1 , false > >),
359+ Case (" basic, 9600, 9N1, FC off" , all_peripherals<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<9600 , 9 , ParityNone, 1 , false > >),
360+
336361 // One set of pins from one peripheral.
337362 // baudrate
338363 Case (" 19200, 8N1, FC off" , one_peripheral<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<19200 , 8 , ParityNone, 1 , false > >),
@@ -351,6 +376,10 @@ Case cases[] = {
351376 Case (" basic, 9600, 8N1, FC on" , all_peripherals<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 8 , ParityNone, 1 , false > >),
352377 Case (" basic (direct init), 9600, 8N1, FC on" , all_peripherals<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 8 , ParityNone, 1 , true > >),
353378
379+ // same test with 7 and 9 bits data length
380+ Case (" basic, 9600, 7N1, FC on" , all_peripherals<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 7 , ParityNone, 1 , false > >),
381+ Case (" basic, 9600, 9N1, FC on" , all_peripherals<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 9 , ParityNone, 1 , false > >),
382+
354383 // One set of pins from one peripheral.
355384 // baudrate
356385 Case (" 19200, 8N1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<19200 , 8 , ParityNone, 1 , false > >),
@@ -360,8 +389,17 @@ Case cases[] = {
360389 // parity
361390#if !defined(UART_ODD_PARITY_NOT_SUPPORTED)
362391 Case (" 9600, 8O1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 8 , ParityOdd, 1 , false > >),
392+
393+ // same test with 7 and 9 bits data length
394+ Case (" 9600, 7O1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 7 , ParityOdd, 1 , false > >),
395+ Case (" 9600, 9O1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 9 , ParityOdd, 1 , false > >),
363396#endif
364397 Case (" 9600, 8E1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 8 , ParityEven, 1 , false > >),
398+
399+ // same test with 7 and 9 bits data length
400+ Case (" 9600, 7E1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 7 , ParityEven, 1 , false > >),
401+ Case (" 9600, 9E1, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 9 , ParityEven, 1 , false > >),
402+
365403 // stop bits
366404#if !defined(UART_TWO_STOP_BITS_NOT_SUPPORTED)
367405 Case (" 9600, 8N2, FC on" , one_peripheral<UARTPort, DefaultFormFactor, fpga_uart_test_common<9600 , 8 , ParityNone, 2 , false > >),
0 commit comments