@@ -226,6 +226,17 @@ void test_all_peripherals(std::list<PortType> &matched_ports, std::list<PortType
226226 }
227227}
228228
229+ /* *
230+ * Test function for all pinouts of all peripherals of a given type
231+ *
232+ * This template function takes in three template parameters:
233+ * - PortType - The type of peripheral to test
234+ * - FormFactorType - The form factor to test on
235+ * - f - The test function to run.
236+ *
237+ * This function is calls the test function multiple times with
238+ * the appropriate combinations of pins.
239+ */
229240template <typename PortType, typename FormFactorType, typename PortType::TestFunctionType f>
230241void all_ports ()
231242{
@@ -236,6 +247,17 @@ void all_ports()
236247 test_all_ports<PortType, FormFactorType, typename PortType::TestFunctionType, f>(matched_ports, not_matched_ports);
237248}
238249
250+ /* *
251+ * Test function for one pinout of all peripherals of a given type
252+ *
253+ * This template function takes in three template parameters:
254+ * - PortType - The type of peripheral to test
255+ * - FormFactorType - The form factor to test on
256+ * - f - The test function to run.
257+ *
258+ * This function is calls the test function once for each peripheral
259+ * of the given type.
260+ */
239261template <typename PortType, typename FormFactorType, typename PortType::TestFunctionType f>
240262void all_peripherals ()
241263{
@@ -250,6 +272,17 @@ void all_peripherals()
250272 test_all_peripherals<PortType, typename PortType::TestFunctionType, f>(matched_ports, not_matched_ports);
251273}
252274
275+ /* *
276+ * Test function for one pinout of one peripheral of a given type
277+ *
278+ * This template function takes in three template parameters:
279+ * - PortType - The type of peripheral to test
280+ * - FormFactorType - The form factor to test on
281+ * - f - The test function to run.
282+ *
283+ * This function is calls the test function once for one peripheral
284+ * of the given type.
285+ */
253286template <typename PortType, typename FormFactorType, typename PortType::TestFunctionType f>
254287void one_peripheral ()
255288{
@@ -358,6 +391,13 @@ bool operator== (const Port<N, PinMapType, FormFactorType, FunctionType> &port1,
358391 return true ;
359392}
360393
394+ /* *
395+ * This is a convenience class for use with the above templates
396+ *
397+ * This class can be passed as a template parameter to all_ports,
398+ * all_peripherals or one_peripheral to choose test pins from
399+ * the default form factor.
400+ */
361401class DefaultFormFactor {
362402public:
363403 static const PinList *pins ()
@@ -376,6 +416,15 @@ class DefaultFormFactor {
376416 }
377417};
378418
419+ /*
420+ * Peripheral port declarations are given below
421+ *
422+ * Each Port type represents a set of pins used by a peripheral.
423+ * The Port typedef is used as a template parameter to the functions
424+ * all_ports, all_peripherals and one_peripheral to select the peripheral
425+ * pin set to use for testing.
426+ */
427+
379428#if DEVICE_SPI
380429#include " spi_api.h"
381430struct SPIMaps {
0 commit comments