diff --git a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h index 89e44f8886b..10086aa01c2 100644 --- a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h +++ b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h @@ -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 &matched_ports, std::list ¬_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 diff --git a/hal/mbed_pinmap_default.cpp b/hal/mbed_pinmap_default.cpp index 3ae953557f3..a1ea453a9d0 100644 --- a/hal/mbed_pinmap_default.cpp +++ b/hal/mbed_pinmap_default.cpp @@ -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() { diff --git a/hal/pinmap.h b/hal/pinmap.h index 5ab10873137..abc3654585f 100644 --- a/hal/pinmap.h +++ b/hal/pinmap.h @@ -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 /**