mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Add a restricted peripheral list
Allow peripherals to be excluded from testing.pull/11026/head
							parent
							
								
									237ad40093
								
							
						
					
					
						commit
						57d75538da
					
				| 
						 | 
					@ -115,6 +115,11 @@ void find_ports(std::list<PortType> &matched_ports, std::list<PortType> ¬_mat
 | 
				
			||||||
                             FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
 | 
					                             FormFactorType::pin_to_string(port.pins[i]), port.pins[i]);
 | 
				
			||||||
                continue;
 | 
					                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
 | 
					            // skipp pin searching if single pin port type
 | 
				
			||||||
            if (PortType::pin_count > 1) {
 | 
					            if (PortType::pin_count > 1) {
 | 
				
			||||||
                find_port_pins<PortType, FormFactorType>(port);
 | 
					                find_port_pins<PortType, FormFactorType>(port);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -178,3 +178,12 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin)
 | 
				
			||||||
    return false;
 | 
					    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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,3 +77,12 @@ MBED_WEAK const PinList *pinmap_restricted_pins()
 | 
				
			||||||
    return &pin_list;
 | 
					    return &pin_list;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//*** Default restricted peripherals ***
 | 
				
			||||||
 | 
					MBED_WEAK const PeripheralList *pinmap_restricted_peripherals()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static const PeripheralList peripheral_list = {
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    return &peripheral_list;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								hal/pinmap.h
								
								
								
								
							
							
						
						
									
										39
									
								
								hal/pinmap.h
								
								
								
								
							| 
						 | 
					@ -38,6 +38,11 @@ typedef struct {
 | 
				
			||||||
    const PinName *pins;
 | 
					    const PinName *pins;
 | 
				
			||||||
} PinList;
 | 
					} PinList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					    uint32_t count;
 | 
				
			||||||
 | 
					    const int *peripheral;
 | 
				
			||||||
 | 
					} PeripheralList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pin_function(PinName pin, int function);
 | 
					void pin_function(PinName pin, int function);
 | 
				
			||||||
void pin_mode(PinName pin, PinMode mode);
 | 
					void pin_mode(PinName pin, PinMode mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
					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
 | 
					 * Get the pin list of pins to avoid during testing
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -139,6 +153,31 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin);
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const PinList *pinmap_restricted_pins(void);
 | 
					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
 | 
					#ifdef TARGET_FF_ARDUINO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue