Skip to content

Commit 166ff13

Browse files
committed
Add missing documentation
Add documentation to the MbedTester class and the test_utils.h file.
1 parent 45301ea commit 166ff13

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,48 @@
2323
#include "platform/Callback.h"
2424
#include "drivers/DigitalInOut.h"
2525

26+
/**
27+
* The base class for controlling the FPGA CI Test Shield
28+
*
29+
* This is the primary interface to the FPGA CI Test Shield. It contains
30+
* all the code to communicate with the FPGA. It also provides high level
31+
* helper functions, such as functions to setup pin multiplexing, to
32+
* select the currently active peripheral and to perform software updates.
33+
*
34+
* Subclasses can inherit from this class and provide further functionality,
35+
* such as the ability to test SPI.
36+
*
37+
* @note Synchronization level: Not protected
38+
*
39+
* Example of how to toggle Arduino pin D6 from the FPGA cI Test Shield:
40+
* @code
41+
* #include "mbed.h"
42+
* #include "MbedTester.h"
43+
*
44+
* const PinList *form_factor = pinmap_ff_default_pins();
45+
* const PinList *restricted = pinmap_restricted_pins();
46+
* MbedTester tester(form_factor, restricted);
47+
*
48+
* int main() {
49+
* // Reset the FPGA CI Test Shield to put it into a known state
50+
* tester.reset();
51+
*
52+
* // Select the GPIO peripheral
53+
* tester.select_peripheral(MbedTester::PeripheralGPIO);
54+
*
55+
* // Map D6 to LogicalPinGPIO0
56+
* tester.pin_map_set(D6, MbedTester::LogicalPinGPIO0);
57+
*
58+
* // Toggle the LED
59+
* int toggle = 0;
60+
* while (1) {
61+
* tester.gpio_write(MbedTester::LogicalPinGPIO0, toggle, true);
62+
* wait(0.5);
63+
* toggle = !toggle;
64+
* }
65+
* }
66+
* @endcode
67+
*/
2668
class MbedTester {
2769
public:
2870

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
*/
229240
template<typename PortType, typename FormFactorType, typename PortType::TestFunctionType f>
230241
void 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+
*/
239261
template<typename PortType, typename FormFactorType, typename PortType::TestFunctionType f>
240262
void 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+
*/
253286
template<typename PortType, typename FormFactorType, typename PortType::TestFunctionType f>
254287
void 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+
*/
361401
class DefaultFormFactor {
362402
public:
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"
381430
struct SPIMaps {

0 commit comments

Comments
 (0)