Skip to content

Add a restricted peripheral list #11026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ 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;
}
// skipp pin searching if single pin port type
if (PortType::pin_count > 1) {
find_port_pins<PortType, FormFactorType>(port);
Expand Down
9 changes: 9 additions & 0 deletions hal/mbed_pinmap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,12 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin)
return false;
}

bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral)
{
for (uint32_t i = 0; i < list->count; i++) {
if (list->peripheral[i] == peripheral) {
return true;
}
}
return false;
}
9 changes: 9 additions & 0 deletions hal/mbed_pinmap_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ MBED_WEAK const PinList *pinmap_restricted_pins()
return &pin_list;
}

//*** Default restricted peripherals ***
MBED_WEAK const PeripheralList *pinmap_restricted_peripherals()
{
static const PeripheralList peripheral_list = {
0,
0
};
return &peripheral_list;
}
39 changes: 39 additions & 0 deletions hal/pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ typedef struct {
const PinName *pins;
} PinList;

typedef struct {
uint32_t count;
const int *peripheral;
} PeripheralList;

void pin_function(PinName pin, int function);
void pin_mode(PinName pin, PinMode mode);

Expand Down Expand Up @@ -123,6 +128,15 @@ bool pinmap_find_peripheral_pins(const PinList *whitelist, const PinList *blackl
*/
bool pinmap_list_has_pin(const PinList *list, PinName pin);

/**
* Check if the peripheral is in the list
*
* @param list peripheral list to check
* @param peripheral peripheral to check for in the list
* @return true if the peripheral is in the list, false otherwise
*/
bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral);

/**
* Get the pin list of pins to avoid during testing
*
Expand All @@ -139,6 +153,31 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin);
*/
const PinList *pinmap_restricted_pins(void);

/**
* Get the pin list of peripherals 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.
* For example, using the USB serial port during tests will interfere
* with the test runner and should be avoided.
*
* Targets should override the weak implementation of this
* 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.
*
* @return Pointer to a peripheral list of peripheral to avoid
*/
const PeripheralList *pinmap_restricted_peripherals(void);

#ifdef TARGET_FF_ARDUINO

/**
Expand Down