Skip to content

Commit ed029d0

Browse files
committed
Add proposition of requirements for the HAL APIs tested by FPGA test shield.
1 parent 28eb39c commit ed029d0

File tree

8 files changed

+289
-0
lines changed

8 files changed

+289
-0
lines changed

hal/analogin_api.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,29 @@ typedef struct analogin_s analogin_t;
3535

3636
/**
3737
* \defgroup hal_analogin Analogin hal functions
38+
*
39+
* # Defined behaviour
40+
* * The function ::analogin_init initializes the analogin peripheral
41+
* * The function ::analogin_read reads the input voltage, represented as a float in the range [0.0, 1.0]
42+
* * The function ::analogin_read_u16 reads the value from analogin pin, represented as an unsigned 16bit value
43+
*
44+
* # Undefined behaviour
45+
*
46+
* * ::analogin_init is called with invalid pin (which does not support analog input function)
47+
* * Calling ::analogin_read, ::analogin_read_u16 before ::analogin_init
3848
* @{
3949
*/
4050

51+
/**
52+
* \defgroup hal_analogin_tests Analogin hal tests
53+
* The Analogin HAL tests ensure driver conformance to defined behaviour.
54+
*
55+
* To run the Analogin hal tests use the command:
56+
*
57+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-analogin
58+
*
59+
*/
60+
4161
/** Initialize the analogin peripheral
4262
*
4363
* Configures the pin used by analogin.

hal/analogout_api.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,32 @@ typedef struct dac_s dac_t;
3535

3636
/**
3737
* \defgroup hal_analogout Analogout hal functions
38+
*
39+
* # Defined behaviour
40+
* * The function ::analogout_init initializes the analogin peripheral
41+
* * The function ::analogout_write sets the output voltage, specified as a percentage (float) in range [0.0, 1.0]
42+
* * The function ::analogout_write_u16 sets the output voltage, specified as unsigned 16-bit value
43+
* * The function ::analogout_read reads the current voltage value on the pin and returns a floating-point value representing the current voltage in range [0.0, 1.0]
44+
* * The function ::analogout_read_u16 reads the current voltage value on the pin and returns the output voltage, specified as unsigned 16-bit value
45+
* * The function ::analogout_free releases the analogout object
46+
*
47+
* # Undefined behaviour
48+
*
49+
* * ::analogout_init is called with invalid pin (which does not support analog output function)
50+
* * Calling other functions before ::analogout_init
3851
* @{
3952
*/
4053

54+
/**
55+
* \defgroup hal_analogin_tests Analogout hal tests
56+
* The Analogout HAL tests ensure driver conformance to defined behaviour.
57+
*
58+
* To run the Analogout hal tests use the command:
59+
*
60+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-analogout
61+
*
62+
*/
63+
4164
/** Initialize the analogout peripheral
4265
*
4366
* Configures the pin used by analogout.

hal/gpio_api.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ extern "C" {
3333
* # Defined behavior
3434
* * ::gpio_init and other init functions can be called with NC or a valid PinName for the target - Verified by ::gpio_nc_test
3535
* * ::gpio_is_connected can be used to test whether a gpio_t object was initialized with NC - Verified by ::gpio_nc_test
36+
* * ::gpio_init initializes the GPIO pin
37+
* * ::gpio_mode sets the mode of the given pin
38+
* * ::gpio_dir sets the direction of the given pin
39+
* * ::gpio_write sets the gpio output value
40+
* * ::gpio_read reads the input value
41+
* * ::gpio_init_in inits the input pin and sets mode to PullDefault
42+
* * ::gpio_init_in_ex inits the input pin and sets the mode
43+
* * ::gpio_init_out inits the pin as an output, with predefined output value 0
44+
* * ::gpio_init_out_ex inits the pin as an output and sets the output value
45+
* * ::gpio_init_inout inits the pin to be input/output and set pin mode and value
3646
*
3747
* # Undefined behavior
3848
* * Calling any ::gpio_mode, ::gpio_dir, ::gpio_write or ::gpio_read on a gpio_t object that was initialized
@@ -42,6 +52,16 @@ extern "C" {
4252
* @{
4353
*/
4454

55+
/**
56+
* \defgroup hal_gpio_tests GPIO HAL tests
57+
* The GPIO HAL tests ensure driver conformance to defined behaviour.
58+
*
59+
* To run the GPIO hal tests use the command:
60+
*
61+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-gpio,tests-mbed_hal-gpio
62+
*
63+
*/
64+
4565
/** Set the given pin as GPIO
4666
*
4767
* @param pin The pin to be set as GPIO

hal/gpio_irq_api.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,31 @@ typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
4444

4545
/**
4646
* \defgroup hal_gpioirq GPIO IRQ HAL functions
47+
*
48+
* # Defined behavior
49+
* * ::gpio_irq_init initializes the GPIO IRQ pin
50+
* * ::gpio_irq_init attaches the interrupt handler
51+
* * ::gpio_irq_free releases the GPIO IRQ pin
52+
* * ::gpio_irq_set enables/disables pin IRQ event
53+
* * ::gpio_irq_enable enables GPIO IRQ
54+
* * ::gpio_irq_disable disables GPIO IRQ
55+
*
56+
* # Undefined behavior
57+
* * Calling other function before ::gpio_irq_init
58+
*
4759
* @{
4860
*/
4961

62+
/**
63+
* \defgroup hal_gpioirq_tests GPIO IRQ HAL tests
64+
* The GPIO IRQ HAL tests ensure driver conformance to defined behaviour.
65+
*
66+
* To run the GPIO IRQ hal tests use the command:
67+
*
68+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-gpio_irq
69+
*
70+
*/
71+
5072
/** Initialize the GPIO IRQ pin
5173
*
5274
* @param obj The GPIO object to initialize

hal/i2c_api.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,72 @@ extern "C" {
7070

7171
/**
7272
* \defgroup hal_GeneralI2C I2C Configuration Functions
73+
*
74+
* # Defined behavior
75+
* * ::i2c_init initialize the I2C peripheral
76+
* * ::i2c_init sets the default parameters for I2C peripheral
77+
* * ::i2c_init configures the pins used by I2C
78+
* * ::i2c_frequency configure the I2C frequency
79+
* * ::i2c_start sends START command
80+
* * ::i2c_read reads `length` bytes from the I2C slave specified by `address` to the `data` buffer
81+
* * ::i2c_read reads generates a stop condition on the bus at the end of the transfer if `stop` parameter is non-zero
82+
* * ::i2c_read reads returns the number of symbols received from the bus
83+
* * ::i2c_write writes `length` bytes to the I2C slave specified by `address` from the `data` buffer
84+
* * ::i2c_write generates a stop condition on the bus at the end of the transfer if `stop` parameter is non-zero
85+
* * ::i2c_write returns zero on success, error code otherwise
86+
* * ::i2c_reset resets the I2C peripheral
87+
* * ::i2c_byte_read reads and return one byte from the specfied I2C slave
88+
* * ::i2c_byte_read uses `last` parameter to inform the slave that all bytes have been read
89+
* * ::i2c_byte_write writes one byte to the specified I2C slave
90+
* * ::i2c_byte_write returns 0 if NAK was received, 1 if ACK was received, 2 for timeout
91+
* * ::i2c_slave_mode enables/disables I2S slave mode
92+
* * ::i2c_slave_receive returns: 1 - read addresses, 2 - write to all slaves, 3 write addressed, 0 - the slave has not been addressed
93+
* * ::i2c_slave_read reads `length` bytes from the I2C master to the `data` buffer
94+
* * ::i2c_slave_read returns non-zero if a value is available, 0 otherwise
95+
* * ::i2c_slave_write writes `length` bytes to the I2C master from the `data` buffer
96+
* * ::i2c_slave_write returns non-zero if a value is available, 0 otherwise
97+
* * ::i2c_slave_address configures I2C slave address
98+
* * ::i2c_transfer_asynch starts I2C asynchronous transfer
99+
* * ::i2c_transfer_asynch writes `tx_length` bytes to the I2C slave specified by `address` from the `tx` buffer
100+
* * ::i2c_transfer_asynch reads `rx_length` bytes from the I2C slave specified by `address` to the `rx` buffer
101+
* * ::i2c_transfer_asynch generates a stop condition on the bus at the end of the transfer if `stop` parameter is non-zero
102+
* * The callback given to ::i2c_transfer_asynch is invoked when the transfer completes
103+
* * ::i2c_transfer_asynch specifies the logical OR of events to be registered
104+
* * The ::i2c_transfer_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm
105+
* * ::i2c_irq_handler_asynch returns event flags if a transfer termination condition was met, otherwise returns 0.
106+
* * ::i2c_active returns non-zero if the I2C module is active or 0 if it is not
107+
* * ::i2c_abort_asynch aborts an on-going async transfer
108+
*
109+
* # Undefined behavior
110+
* * Calling ::i2c_init multiple times on the same `i2c_t`
111+
* * Calling any function other than ::i2c_init on a non-initialized `i2c_t`
112+
* * Initialising the `I2C` peripheral with invalid `SDA` and `SCL` pins.
113+
* * Passing pins that cannot be on the same peripheral
114+
* * Passing an invalid pointer as `obj` to any function
115+
* * Use of a `null` pointer as an argument to any function.
116+
* * Initialising the peripheral in slave mode if slave mode is not supported
117+
* * Operating the peripheral in slave mode without first specifying and address using ::i2c_slave_address
118+
* * Setting an address using i2c_slave_address after initialising the peripheral in master mode
119+
* * Setting an address to an `I2C` reserved value
120+
* * Specifying an invalid address when calling any `read` or `write` functions
121+
* * Setting the length of the transfer or receive buffers to larger than the buffers are
122+
* * Passing an invalid pointer as `handler`
123+
* * Calling ::i2c_abort_async when no transfer is currently in progress
124+
*
125+
*
73126
* @{
74127
*/
75128

129+
/**
130+
* \defgroup hal_GeneralI2C_tests I2C hal tests
131+
* The I2C HAL tests ensure driver conformance to defined behaviour.
132+
*
133+
* To run the I2C hal tests use the command:
134+
*
135+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-i2c
136+
*
137+
*/
138+
76139
/** Initialize the I2C peripheral. It sets the default parameters for I2C
77140
* peripheral, and configures its specifieds pins.
78141
*

hal/pwmout_api.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,36 @@ typedef struct pwmout_s pwmout_t;
3535

3636
/**
3737
* \defgroup hal_pwmout Pwmout hal functions
38+
*
39+
* # Defined behavior
40+
* * ::pwmout_init initializes the pwm out peripheral and configures the pin
41+
* * ::pwmout_free deinitializes the pwmout object
42+
* * ::pwmout_write sets the output duty-cycle in range <0.0f, 1.0f>
43+
* * ::pwmout_read returns the current float-point output duty-cycle in range <0.0f, 1.0f>
44+
* * ::pwmout_period sets the PWM period specified in seconds, keeping the duty cycle the same
45+
* * ::pwmout_period_ms sets the PWM period specified in miliseconds, keeping the duty cycle the same
46+
* * ::pwmout_period_us sets the PWM period specified in microseconds, keeping the duty cycle the same
47+
* * ::pwmout_pulsewidth sets the PWM pulsewidth specified in seconds, keeping the period the same
48+
* * ::pwmout_pulsewidth_ms sets the PWM pulsewidth specified in miliseconds, keeping the period the same
49+
* * ::pwmout_pulsewidth_us sets the PWM pulsewidth specified in microseconds, keeping the period the same
50+
*
51+
* # Undefined behavior
52+
* * Calling other function before ::pwmout_init
53+
* * Calling ::pwmout_init with NC as pwmout pin
54+
*
3855
* @{
3956
*/
4057

58+
/**
59+
* \defgroup hal_pwmout_tests GPIO IRQ HAL tests
60+
* The Pwmout HAL tests ensure driver conformance to defined behaviour.
61+
*
62+
* To run the Pwmout hal tests use the command:
63+
*
64+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-pwm
65+
*
66+
*/
67+
4168
/** Initialize the pwm out peripheral and configure the pin
4269
*
4370
* @param obj The pwmout object to initialize

hal/serial_api.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,69 @@ extern "C" {
108108

109109
/**
110110
* \defgroup hal_GeneralSerial Serial Configuration Functions
111+
*
112+
* # Defined behaviour
113+
* * ::serial_init initializes the serial peripheral
114+
* * ::serial_init sets the default parameters for serial peripheral
115+
* * ::serial_init configures its specified pins
116+
* * ::serial_free releases the serial peripheral
117+
* * ::serial_baud configures the baud rate
118+
* * ::serial_format configures the transmission format (number of bits, parity and the number of stop bits)
119+
* * ::serial_irq_handler registers the interrupt handler which will be invoked when the interrupt fires
120+
* * ::serial_irq_set enables or disables serial irq (RX or TX)
121+
* * ::serial_getc returns the character from serial buffer
122+
* * ::serial_getc is a blocking call (waits for the character)
123+
* * ::serial_putc sends a character
124+
* * ::serial_putc is a blocking call (waits for a peripheral to be available)
125+
* * ::serial_readable returns non-zero value if a character can be read, 0 if nothing to read
126+
* * ::serial_writable returns non-zero value if a character can be written, 0 otherwise
127+
* * ::serial_clear clears the serial peripheral
128+
* * ::serial_break_set sets the break signal
129+
* * ::serial_pinout_tx configures the TX pin for UART function
130+
* * ::serial_set_flow_control configures serial flow control
131+
* * ::serial_set_flow_control sets flow control in the hardware if a serial peripheral supports it, otherwise software emulation is used
132+
* * ::serial_tx_asynch starts the serial asynchronous transfer
133+
* * ::serial_tx_asynch writes `tx_length` bytes from the `tx` to the bus
134+
* * The callback given to ::serial_tx_asynch is invoked when the transfer completes
135+
* * ::serial_tx_asynch specifies the logical OR of events to be registered
136+
* * The ::serial_tx_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm
137+
* * ::serial_rx_asynch starts the serial asynchronous transfer
138+
* * ::serial_rx_asynch reads `rx_length` bytes to the `rx`buffer
139+
* * The callback given to ::serial_rx_asynch is invoked when the transfer completes
140+
* * ::serial_tx_asynch specifies the logical OR of events to be registered
141+
* * The ::serial_tx_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm
142+
* * ::serial_tx_asynch specifies the character in range 0-254 to be matched
143+
* * ::serial_tx_active returns non-zero if the TX transaction is ongoing, 0 otherwise
144+
* * ::serial_rx_active returns non-zero if the RX transaction is ongoing, 0 otherwise
145+
* * ::serial_irq_handler_asynch returns event flags if an RX transfer termination condition was met, otherwise returns 0
146+
* * ::serial_tx_abort_asynch aborts the ongoing TX transaction
147+
* * ::serial_tx_abort_asynch disables the enabled interupt for TX
148+
* * ::serial_tx_abort_asynch flushes the TX hardware buffer if TX FIFO is used
149+
* * ::serial_rx_abort_asynch aborts the ongoing RX transaction
150+
* * ::serial_rx_abort_asynch disables the enabled interupt for RX
151+
* * ::serial_rx_abort_asynch flushes the TX hardware buffer if RX FIFO is used
152+
*
153+
* # Undefined behaviour
154+
*
155+
* * Calling ::serial_init multiple times on the same `serial_t` without ::serial_free
156+
* * Passing invalid pin to ::serial_init, ::serial_pinout_tx
157+
* * Calling any function other than ::serial_init on a non-initialized or freed `serial_t`
158+
* * Passing an invalid pointer as `obj` to any function
159+
* * Passing an invalid pointer as `handler` to ::serial_irq_handler, ::serial_tx_asynch, ::serial_rx_asynch
160+
* * Calling ::spi_abort while no async transfer is being processed (no transfer or a synchronous transfer)
111161
* @{
112162
*/
113163

164+
/**
165+
* \defgroup hal_GeneralSerial_tests Serial hal tests
166+
* The Serial HAL tests ensure driver conformance to defined behaviour.
167+
*
168+
* To run the Serial hal tests use the command:
169+
*
170+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-uart
171+
*
172+
*/
173+
114174
/** Initialize the serial peripheral. It sets the default parameters for serial
115175
* peripheral, and configures its specifieds pins.
116176
*

hal/spi_api.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,63 @@ extern "C" {
5959

6060
/**
6161
* \defgroup hal_GeneralSPI SPI Configuration Functions
62+
*
63+
* # Defined behavior
64+
* * ::spi_init initialize the SPI peripheral
65+
* * ::spi_init configures the pins used by SPI
66+
* * ::spi_init sets a default format and frequency
67+
* * ::spi_init enables the peripheral
68+
* * ::spi_free returns the pins owned by the SPI object to their reset state
69+
* * ::spi_format sets the number of bits per frame
70+
* * ::spi_format configures clock polarity and phase
71+
* * ::spi_format configures master/slave mode
72+
* * ::spi_frequency sets the SPI baud rate
73+
* * ::spi_master_write writes a symbol out in master mode and receives a symbol
74+
* * ::spi_master_block_write writes `tx_length` words to the bus
75+
* * ::spi_master_block_write reads `rx_length` words from the bus
76+
* * ::spi_master_block_write returns the maximum of tx_length and rx_length
77+
* * ::spi_master_block_write specifies the write_fill which is default data transmitted while performing a read
78+
* * ::spi_get_module returns non-zero if a value is available to read from SPI channel, 0 otherwise
79+
* * ::spi_slave_read returns a received value out of the SPI receive buffer in slave mode
80+
* * ::spi_slave_read blocks until a value is available
81+
* * ::spi_slave_write writes a value to the SPI peripheral in slave mode
82+
* * ::spi_slave_write blocks until the SPI peripheral can be written to
83+
* * ::spi_busy returns non-zero if the peripheral is currently transmitting, 0 otherwise
84+
* * ::spi_master_transfer starts the SPI asynchronous transfer
85+
* * ::spi_master_transfer writes `tx_len` words to the bus
86+
* * ::spi_master_transfer reads `rx_len` words from the bus
87+
* * ::spi_master_transfer specifies the bit width of buffer words
88+
* * The callback given to ::spi_master_transfer is invoked when the transfer completes (with a success or an error)
89+
* * ::spi_master_transfer specifies the logical OR of events to be registered
90+
* * The ::spi_master_transfer function may use the `DMAUsage` hint to select the appropriate async algorithm
91+
* * ::spi_irq_handler_asynch reads the received values out of the RX FIFO
92+
* * ::spi_irq_handler_asynch writes values into the TX FIFO
93+
* * ::spi_irq_handler_asynch checks for transfer termination conditions, such as buffer overflows or transfer complete
94+
* * ::spi_irq_handler_asynch returns event flags if a transfer termination condition was met, otherwise 0
95+
* * ::spi_abort_asynch aborts an on-going async transfer
96+
* * ::spi_active returns non-zero if the SPI port is active or zero if it is not
97+
*
98+
* # Undefined behavior
99+
* * Calling ::spi_init multiple times on the same `spi_t` without ::spi_free
100+
* * Calling any function other than ::spi_init on a non-initialized or freed `spi_t`
101+
* * Passing pins that cannot be on the same peripheral
102+
* * Passing an invalid pointer as `obj` to any function
103+
* * Passing an invalid pointer as `handler` to ::spi_master_transfer
104+
* * Calling ::spi_abort while no async transfer is being processed (no transfer or a synchronous transfer)
105+
*
62106
* @{
63107
*/
64108

109+
/**
110+
* \defgroup hal_GeneralSPI_tests SPI hal tests
111+
* The SPI HAL tests ensure driver conformance to defined behaviour.
112+
*
113+
* To run the SPI hal tests use the command:
114+
*
115+
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-spi
116+
*
117+
*/
118+
65119
#ifdef DEVICE_SPI_COUNT
66120
/**
67121
* Returns a variant of the SPIName enum uniquely identifying a SPI peripheral of the device.

0 commit comments

Comments
 (0)