Add pinmap_gpio_restricted_pins() to provide list of restricted GPIO pins

This is a special case since targets do not provide by default GPIO pin-maps.
This extension is required for FPGA GPIO tests - if some pins have limitations (e.g. fixed pull-up) we need to skip these pins while testing.
To do that we were adding a dummy pin-map with commented out pins that can't be tested because of the limitations.
This solution is redundant and the proposition is to provide a list of restricted gpio pins if required (by default weak implementation is provided with an empty list).

This mechanism will be backward compatible, so the old method with dummy gpio pinmap will also work. The switch from dummy pin-maps to pinmap_gpio_restricted_pins() will be performed in separate commits/PRs.
pull/12379/head
Przemyslaw Stekiel 2020-02-07 10:30:59 +01:00
parent a4e1354769
commit 3c0982d939
3 changed files with 41 additions and 2 deletions

View File

@ -28,6 +28,8 @@
#define I2C_NAME "I2C"
#define SPI_NAME "SPI"
#define SPISLAVE_NAME "SPISlave"
#define GPIO_NAME "GPIO"
#define GPIO_IRQ_NAME "GPIO_IRQ"
// test function prototypes
typedef void (*TF1)(PinName p0);
@ -125,6 +127,15 @@ void find_ports(std::list<PortType> &matched_ports, std::list<PortType> &not_mat
continue;
}
if (!strcmp(PortType::PinMap::name, GPIO_IRQ_NAME) || !strcmp(PortType::PinMap::name, GPIO_NAME)) {
// Don't test restricted gpio pins
if (pinmap_list_has_pin(pinmap_gpio_restricted_pins(), port.pins[i])) {
utest_printf("Skipping %s pin %s (%i)\r\n", pin_type,
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,
@ -455,7 +466,7 @@ struct GPIOMaps {
};
const PinMap *GPIOMaps::maps[] = { gpio_pinmap() };
const char *const GPIOMaps::pin_type_names[] = { "IO" };
const char *const GPIOMaps::name = "GPIO";
const char *const GPIOMaps::name = GPIO_NAME;
typedef Port<1, GPIOMaps, DefaultFormFactor, TF1> GPIOPort;
#if DEVICE_INTERRUPTIN
@ -467,7 +478,7 @@ struct GPIOIRQMaps {
};
const PinMap *GPIOIRQMaps::maps[] = { gpio_irq_pinmap() };
const char *const GPIOIRQMaps::pin_type_names[] = { "IRQ_IN" };
const char *const GPIOIRQMaps::name = "GPIO_IRQ";
const char *const GPIOIRQMaps::name = GPIO_IRQ_NAME;
typedef Port<1, GPIOIRQMaps, DefaultFormFactor, TF1> GPIOIRQPort;
#endif

View File

@ -78,6 +78,17 @@ MBED_WEAK const PinList *pinmap_restricted_pins()
return &pin_list;
}
//*** Default restricted gpio pins ***
// GPIO pins are special case because there are no pin-maps for GPIO
MBED_WEAK const PinList *pinmap_gpio_restricted_pins()
{
static const PinList pin_list = {
0,
0
};
return &pin_list;
}
//*** Default restricted peripherals ***
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
{

View File

@ -176,6 +176,23 @@ const PinList *pinmap_restricted_pins(void);
*/
const PeripheralList *pinmap_uart_restricted_peripherals(void);
/**
* Get the pin list of pins to avoid during GPIO/GPIO_IRQ testing
*
* The GPIO restricted pin list is used to indicate to testing
* that a pin should be skipped due to some caveat about it.
*
* Targets should override the weak implementation of this
* function if they have peripherals which should be
* skipped during testing.
*
* @note This is special case only for GPIO/GPIO_IRQ tests because
* targets do not provide pin-maps for GPIO.
*
* @return Pointer to a peripheral list of peripheral to avoid
*/
const PinList *pinmap_gpio_restricted_pins(void);
#ifdef TARGET_FF_ARDUINO
/**