Add STDIO UART as restricted for FPGA testing for all targets

Substantiation for this is that the STDIO UART peripheral is used by Mbed, so it should never be tested.

Also solve the potential problem with accidenty skipped peripherals in FPGA testing. Currently, we have a one `pinmap_restricted_peripherals()` function for all interfaces (UART, I2C, SPI, etc.).
The problem can be encountered if different interfaces have the same peripheral ids (e.g. `UART_0` = 0, `SPI_0` = 0). In this case, if `UART_0` is on the restricted list, then SPI tests will be also skipped for `SPI_0`.
The good news is that usually, the peripheral ids are the base addresses of the peripheral's register set, but we can't rely on this. It is also good that `pinmap_restricted_peripherals()` at this moment is only required for STDIO UART (Nuvoton and STM).

To solve this issue we will change name of `pinmap_restricted_peripherals()` to `pinmap_uart_restricted_peripherals()`, make STDIO UART restricted by default for all targets and update FPGA test utilily functions to use `pinmap_uart_restricted_peripherals()` to skip only uart peripherals.
In the future if needed we can consider to add support to restrict peripherals of other interfaces(SPI, I2C, etc).
pull/12379/head
Przemyslaw Stekiel 2020-02-05 14:31:53 +01:00
parent 8dc15ee6e1
commit 54f4777e64
3 changed files with 43 additions and 27 deletions

View File

@ -20,6 +20,15 @@
#include <list>
#define UART_NAME "UART"
#define UARTNOFC_NAME "UART-no-FC"
#define ANALOGOUT_NAME "DAC"
#define ANALOGIN_NAME "ADC"
#define PWM_NAME "PWM"
#define I2C_NAME "I2C"
#define SPI_NAME "SPI"
#define SPISLAVE_NAME "SPISlave"
// test function prototypes
typedef void (*TF1)(PinName p0);
typedef void (*TF2)(PinName p0, PinName p1);
@ -115,11 +124,15 @@ void find_ports(std::list<PortType> &matched_ports, std::list<PortType> &not_mat
FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
continue;
}
if (pinmap_list_has_peripheral(pinmap_restricted_peripherals(), port.peripheral)) {
utest_printf("Skipping %s peripheral %i with pin %s (%i)\r\n", pin_type,
port.peripheral, FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
continue;
if (!strcmp(PortType::PinMap::name, UART_NAME) || !strcmp(PortType::PinMap::name, UARTNOFC_NAME)) {
if (pinmap_list_has_peripheral(pinmap_uart_restricted_peripherals(), port.peripheral)) {
utest_printf("Skipping %s peripheral %i with pin %s (%i)\r\n", pin_type,
port.peripheral, FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
continue;
}
}
// skipp pin searching if single pin port type
if (PortType::pin_count > 1) {
find_port_pins<PortType, FormFactorType>(port);
@ -467,7 +480,7 @@ struct SPIMaps {
};
const PinMap *SPIMaps::maps[] = { spi_master_mosi_pinmap(), spi_master_miso_pinmap(), spi_master_clk_pinmap(), spi_master_cs_pinmap() };
const char *const SPIMaps::pin_type_names[] = { "MOSI", "MISO", "SCLK", "SSEL" };
const char *const SPIMaps::name = "SPI";
const char *const SPIMaps::name = SPI_NAME;
typedef Port<4, SPIMaps, DefaultFormFactor, TF4> SPIPort;
struct SPINoCSMaps {
@ -477,7 +490,7 @@ struct SPINoCSMaps {
};
const PinMap *SPINoCSMaps::maps[] = { spi_master_mosi_pinmap(), spi_master_miso_pinmap(), spi_master_clk_pinmap()};
const char *const SPINoCSMaps::pin_type_names[] = { "MOSI", "MISO", "SCLK" };
const char *const SPINoCSMaps::name = "SPI";
const char *const SPINoCSMaps::name = SPI_NAME;
typedef Port<3, SPINoCSMaps, DefaultFormFactor, TF3> SPINoCSPort;
struct SPISlaveMaps {
@ -487,7 +500,7 @@ struct SPISlaveMaps {
};
const PinMap *SPISlaveMaps::maps[] = { spi_slave_mosi_pinmap(), spi_slave_miso_pinmap(), spi_slave_clk_pinmap(), spi_slave_cs_pinmap() };
const char *const SPISlaveMaps::pin_type_names[] = { "MOSI", "MISO", "SCLK", "SSEL" };
const char *const SPISlaveMaps::name = "SPISlave";
const char *const SPISlaveMaps::name = SPISLAVE_NAME;
typedef Port<4, SPISlaveMaps, DefaultFormFactor, TF4> SPISlavePort;
#endif
@ -500,7 +513,7 @@ struct I2CMaps {
};
const PinMap *I2CMaps::maps[] = { i2c_master_sda_pinmap(), i2c_master_scl_pinmap() };
const char *const I2CMaps::pin_type_names[] = { "SDA", "SCL" };
const char *const I2CMaps::name = "I2C";
const char *const I2CMaps::name = I2C_NAME;
typedef Port<2, I2CMaps, DefaultFormFactor, TF2> I2CPort;
#endif
@ -513,7 +526,7 @@ struct PWMMaps {
};
const PinMap *PWMMaps::maps[] = { pwmout_pinmap() };
const char *const PWMMaps::pin_type_names[] = { "PWM_OUT" };
const char *const PWMMaps::name = "PWM";
const char *const PWMMaps::name = PWM_NAME;
typedef Port<1, PWMMaps, DefaultFormFactor, TF1> PWMPort;
#endif
@ -526,7 +539,7 @@ struct AnaloginMaps {
};
const PinMap *AnaloginMaps::maps[] = { analogin_pinmap() };
const char *const AnaloginMaps::pin_type_names[] = { "ADC_IN" };
const char *const AnaloginMaps::name = "ADC";
const char *const AnaloginMaps::name = ANALOGIN_NAME;
typedef Port<1, AnaloginMaps, DefaultFormFactor, TF1> AnaloginPort;
#endif
@ -539,7 +552,7 @@ struct AnalogoutMaps {
};
const PinMap *AnalogoutMaps::maps[] = { analogout_pinmap() };
const char *const AnalogoutMaps::pin_type_names[] = { "DAC_OUT" };
const char *const AnalogoutMaps::name = "DAC";
const char *const AnalogoutMaps::name = ANALOGOUT_NAME;
typedef Port<1, AnalogoutMaps, DefaultFormFactor, TF1> AnalogoutPort;
#endif
@ -553,7 +566,7 @@ struct UARTMaps {
};
const PinMap *UARTMaps::maps[] = { serial_tx_pinmap(), serial_rx_pinmap(), serial_cts_pinmap(), serial_rts_pinmap() };
const char *const UARTMaps::pin_type_names[] = { "TX", "RX", "CLS", "RTS" };
const char *const UARTMaps::name = "UART";
const char *const UARTMaps::name = UART_NAME;
typedef Port<4, UARTMaps, DefaultFormFactor, TF4> UARTPort;
#endif
@ -564,8 +577,7 @@ struct UARTNoFCMaps {
};
const PinMap *UARTNoFCMaps::maps[] = { serial_tx_pinmap(), serial_rx_pinmap() };
const char *const UARTNoFCMaps::pin_type_names[] = { "TX", "RX" };
const char *const UARTNoFCMaps::name = "UART-no-FC";
const char *const UARTNoFCMaps::name = UARTNOFC_NAME;
typedef Port<2, UARTNoFCMaps, DefaultFormFactor, TF2> UARTNoFCPort;
#endif
#endif

View File

@ -20,6 +20,7 @@
#include "platform/mbed_toolchain.h"
#include "platform/mbed_assert.h"
#include "device.h"
#include "hal/serial_api.h"
//*** Common form factors ***
#ifdef TARGET_FF_ARDUINO
@ -78,11 +79,17 @@ MBED_WEAK const PinList *pinmap_restricted_pins()
}
//*** Default restricted peripherals ***
MBED_WEAK const PeripheralList *pinmap_restricted_peripherals()
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
{
static const int stdio_uart = pinmap_peripheral(STDIO_UART_TX, serial_tx_pinmap());
static const int peripherals[] = {
stdio_uart
};
static const PeripheralList peripheral_list = {
0,
0
sizeof peripherals / sizeof peripherals[0],
peripherals
};
return &peripheral_list;
}

View File

@ -155,7 +155,7 @@ bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral);
const PinList *pinmap_restricted_pins(void);
/**
* Get the pin list of peripherals to avoid during testing
* Get the pin list of peripherals per interface to avoid during testing
*
* The restricted peripheral list is used to indicate to testing
* that a peripheral should be skipped due to some caveat about it.
@ -166,18 +166,15 @@ const PinList *pinmap_restricted_pins(void);
* function if they have peripherals which should be
* skipped during testing.
*
* @note Some targets use the same value for multiple
* different types of peripherals. For example SPI 0
* and UART 0 may both be identified by the peripheral
* value 0. If your target does this then do not
* use this function to skip peripherals, as this will
* unintentionally cause all peripherals with that value
* to be skipped. Instead these entries should be removed
* from the peripheral PinMap itself.
* @note Restricting peripheral is at the moment available for UART
* interface only as only STDIO UART must be skipped because it is
* used by Mbed.
* Restricting peripherals for other interfaces should be added
* in the future if required.
*
* @return Pointer to a peripheral list of peripheral to avoid
*/
const PeripheralList *pinmap_restricted_peripherals(void);
const PeripheralList *pinmap_uart_restricted_peripherals(void);
#ifdef TARGET_FF_ARDUINO