Skip to content

Commit 0425ffd

Browse files
author
Seppo Takalo
authored
Merge pull request #11026 from c1728p9/skip_peripherals
Add a restricted peripheral list
2 parents 02f8fbd + 57d7553 commit 0425ffd

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ void find_ports(std::list<PortType> &matched_ports, std::list<PortType> &not_mat
115115
FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
116116
continue;
117117
}
118+
if (pinmap_list_has_peripheral(pinmap_restricted_peripherals(), port.peripheral)) {
119+
utest_printf("Skipping %s peripheral %i with pin %s (%i)\r\n", pin_type,
120+
port.peripheral, FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
121+
continue;
122+
}
118123
// skipp pin searching if single pin port type
119124
if (PortType::pin_count > 1) {
120125
find_port_pins<PortType, FormFactorType>(port);

hal/mbed_pinmap_common.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,12 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin)
178178
return false;
179179
}
180180

181+
bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral)
182+
{
183+
for (uint32_t i = 0; i < list->count; i++) {
184+
if (list->peripheral[i] == peripheral) {
185+
return true;
186+
}
187+
}
188+
return false;
189+
}

hal/mbed_pinmap_default.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,12 @@ MBED_WEAK const PinList *pinmap_restricted_pins()
7777
return &pin_list;
7878
}
7979

80+
//*** Default restricted peripherals ***
81+
MBED_WEAK const PeripheralList *pinmap_restricted_peripherals()
82+
{
83+
static const PeripheralList peripheral_list = {
84+
0,
85+
0
86+
};
87+
return &peripheral_list;
88+
}

hal/pinmap.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ typedef struct {
3838
const PinName *pins;
3939
} PinList;
4040

41+
typedef struct {
42+
uint32_t count;
43+
const int *peripheral;
44+
} PeripheralList;
45+
4146
void pin_function(PinName pin, int function);
4247
void pin_mode(PinName pin, PinMode mode);
4348

@@ -123,6 +128,15 @@ bool pinmap_find_peripheral_pins(const PinList *whitelist, const PinList *blackl
123128
*/
124129
bool pinmap_list_has_pin(const PinList *list, PinName pin);
125130

131+
/**
132+
* Check if the peripheral is in the list
133+
*
134+
* @param list peripheral list to check
135+
* @param peripheral peripheral to check for in the list
136+
* @return true if the peripheral is in the list, false otherwise
137+
*/
138+
bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral);
139+
126140
/**
127141
* Get the pin list of pins to avoid during testing
128142
*
@@ -139,6 +153,31 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin);
139153
*/
140154
const PinList *pinmap_restricted_pins(void);
141155

156+
/**
157+
* Get the pin list of peripherals to avoid during testing
158+
*
159+
* The restricted peripheral list is used to indicate to testing
160+
* that a peripheral should be skipped due to some caveat about it.
161+
* For example, using the USB serial port during tests will interfere
162+
* with the test runner and should be avoided.
163+
*
164+
* Targets should override the weak implementation of this
165+
* function if they have peripherals which should be
166+
* skipped during testing.
167+
*
168+
* @note Some targets use the same value for multiple
169+
* different types of peripherals. For example SPI 0
170+
* and UART 0 may both be identified by the peripheral
171+
* value 0. If your target does this then do not
172+
* use this function to skip peripherals, as this will
173+
* unintentionally cause all peripherals with that value
174+
* to be skipped. Instead these entries should be removed
175+
* from the peripheral PinMap itself.
176+
*
177+
* @return Pointer to a peripheral list of peripheral to avoid
178+
*/
179+
const PeripheralList *pinmap_restricted_peripherals(void);
180+
142181
#ifdef TARGET_FF_ARDUINO
143182

144183
/**

0 commit comments

Comments
 (0)