Mistake on this page?
Report an issue in GitHub or email us
spi_api_tests.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2018 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /** \addtogroup hal_spi_tests */
18 /** @{*/
19 
20 #ifndef MBED_SPI_API_TESTS_H
21 #define MBED_SPI_API_TESTS_H
22 
23 #include "device.h"
24 
25 #if DEVICE_SPI
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /** Test that spi_get_module() returns the SPIName - unique identifier to the peripheral associated
32  * to this SPI channel.
33  *
34  * Given is platform with SPI support.
35  * When spi_get_module() is called with valid SPI pins.
36  * Then function returns the SPIName - unique identifier to the peripheral associated
37  * to this SPI channel.
38  *
39  * @note `mosi` or `miso` pin can be undefined (but not both). `mclk` must be defined.
40  */
41 void spi_test_get_module();
42 
43 /** Test that spi_get_capabilities() fills the given spi_capabilities_t instance with capabilities
44  * of the specified SPI peripheral.
45  *
46  * Given is platform with SPI support.
47  * When spi_get_capabilities() is called with the valid SPI name (and SS pin).
48  * Then function fills the given spi_capabilities_t instance with capabilities
49  * of the specified SPI peripheral.
50  *
51  * @note spi_get_capabilities() considers the `ssel` pin when evaluation the
52  * support_slave_mode capability.
53  *
54  */
56 
57 /** Test that spi_init() successfully initializes the pins and spi_free() can successfully
58  * reset the pins to their default state.
59  *
60  * Given is platform with SPI support.
61  * When spi_init() is called with the valid pins configuration and then spi_free() is called on
62  * the created SPI object.
63  * Then both operations are successfully performed.
64  *
65  */
66 void spi_test_init_free();
67 
68 /** Test that spi_format() sets/updates the transmission format of the SPI peripheral.
69  *
70  * Given is platform with SPI support.
71  * When spi_format() is called and valid format is specified.
72  * Then function is executed successfully.
73  *
74  */
75 void spi_test_set_format();
76 
77 /** Test that spi_test_set_frequency() sets the frequency used during the SPI transfer.
78  *
79  * Given is platform with SPI support.
80  * When spi_test_set_frequency() is called and valid frequency is specified.
81  * Then function is executed successfully and actual frequency which will be used during the transfer is returned.
82  *
83  * @note Frequency can be only set by SPI peripheral operating in master mode.
84  * @note Frequency must be in range specified by the capabilities of the SPI peripheral.
85  *
86  */
88 
89 /** Test that spi_transfer() can successfully perform transfer in master mode
90  * (TX/RX buffers are defined and have the same sizes) and returns the number of
91  * symbols clocked on the bus during this transfer.
92  *
93  * Given is platform with SPI support.
94  * When spi_transfer() is called for SPI peripheral operating in master mode and
95  * both TX/RX buffers are specified and have equal sizes.
96  * Then function is executed successfully and returns number of symbols clocked on the bus during this transfer.
97  *
98  */
100 
101 /** Test that spi_transfer() can successfully perform transfer in master mode
102  * (TX/RX buffers are undefined or have different sizes) and returns the number of
103  * symbols clocked on the bus during this transfer.
104  *
105  * Given is platform with SPI support.
106  * When spi_transfer() is called for SPI peripheral operating in master mode and
107  * TX/RX buffers are undefined or have different sizes.
108  * Then function is executed successfully and returns number of symbols clocked on the bus during this transfer.
109  *
110  */
112 
113 /** Test that spi_transfer_async() can successfully perform asynchronous transfer
114  * in master mode.
115  *
116  * Given is platform with SPI support.
117  * When spi_transfer_async() is called for SPI peripheral operating in master mode.
118  * Then function returns true on success, performs transfer and invokes specified callback
119  * when the transfer completes (passing the operation status).
120  *
121  */
123 
124 /** Test that spi_transfer_async_abort() can successfully abort an on-going async transfer.
125  *
126  * Given is platform with SPI support.
127  * When spi_transfer_async() is called for SPI peripheral operating in master mode and
128  * operation is aborted immediately by means of spi_transfer_async_abort().
129  * Then operation is successfully performed and specified callback is invoked with
130  * the status which indicates that the transfer has been aborted.
131  *
132  */
134 
135 /**@}*/
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif
142 
143 #endif
144 
145 /**@}*/
void spi_test_init_free()
Test that spi_init() successfully initializes the pins and spi_free() can successfully reset the pins...
void spi_test_get_capabilities()
Test that spi_get_capabilities() fills the given spi_capabilities_t instance with capabilities of the...
void spi_test_transfer_master_async()
Test that spi_transfer_async() can successfully perform asynchronous transfer in master mode...
void spi_test_transfer_master()
Test that spi_transfer() can successfully perform transfer in master mode (TX/RX buffers are defined ...
void spi_test_transfer_master_async_abort()
Test that spi_transfer_async_abort() can successfully abort an on-going async transfer.
void spi_test_set_format()
Test that spi_format() sets/updates the transmission format of the SPI peripheral.
void spi_test_set_frequency()
Test that spi_test_set_frequency() sets the frequency used during the SPI transfer.
void spi_test_get_module()
Test that spi_get_module() returns the SPIName - unique identifier to the peripheral associated to th...
void spi_test_transfer_master_fill_sym()
Test that spi_transfer() can successfully perform transfer in master mode (TX/RX buffers are undefine...
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.