Mistake on this page?
Report an issue in GitHub or email us
i2c_test.h
1 /*
2  * Copyright (c) 2019, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** \addtogroup hal_i2c_tests
19  * @{
20  */
21 
22 #ifndef I2C_API_TESTS_H
23 #define I2C_API_TESTS_H
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /** Test that i2c_get_capabilities() fills given i2c_capabilities_t instance with capabilities.
31  *
32  * Given is platform with I2C support.
33  * When i2c_get_capabilities() is called.
34  * Then function fills the given i2c_capabilities_t instance.
35  */
37 
38 /** Test that i2c_init() successfully initializes and i2c_free() successfully frees i2c interface.
39  *
40  * Given is platform with I2C support.
41  * When i2c_init() is called with the valid pins configuration and then i2c_free() is called on
42  * the created I2C object.
43  * Then both operations are successfully performed.
44  */
45 void fpga_i2c_test_init_free(PinName sda, PinName scl);
46 
47 /** Test that i2c_frequency() sets the frequency used during the I2C transfer.
48  *
49  * Given is platform with I2C support.
50  * When i2c_frequency() is called and valid frequency is specified.
51  * Then function is executed successfully and actual frequency which will be used during the transfer is returned.
52  *
53  * @note Frequency must be in range specified by the capabilities of the I2C peripheral.
54  */
55 void fpga_i2c_test_frequency(PinName sda, PinName scl);
56 
57 /** Test blocking transmission timeout.
58  *
59  * Given board provides I2C-Master support.
60  * When I2C transmission is performed using different settings.
61  * Then data is successfully transfered.
62  */
63 void fpga_i2c_test_blocking_transmission_timeout(PinName sda, PinName scl, uint32_t frequency);
64 
65 /** Test blocking transmission when no slave.
66  *
67  * Given board provides I2C-Master support.
68  * When I2C transmission with address of nonexistent slave is performed using
69  * Then transfer fails returning appropriate error.
70  */
71 void fpga_i2c_test_transmission_no_slave(PinName sda, PinName scl, uint32_t frequency);
72 
73 /** Test blocking transmission.
74  *
75  * Given board provides I2C-Master support.
76  * When I2C transmission is performed using different settings.
77  * Then data is successfully transfered.
78  */
79 void fpga_i2c_test_blocking_write_read(PinName sda, PinName scl, uint16_t addr, uint32_t frequency, TransferType ttype, uint32_t data_size, uint32_t transfer_count, bool stop_each);
80 
81 /** Test asynchronous transmission.
82  *
83  * Given board provides I2C-Master support.
84  * When I2C transmission is performed using different settings.
85  * Then data is successfully transfered.
86  */
87 void fpga_i2c_test_async_write_read(PinName sda, PinName scl, uint16_t addr, uint32_t frequency, TransferType ttype, uint32_t data_size, uint32_t transfer_count, bool stop_each);
88 
89 /** Test that @i2c_abort_async call aborts ongoing asynchronous transfer.
90  *
91  * Given is asynchronous transfer ongoing.
92  * When call @i2c_abort_async.
93  * Then transfer is aborted,
94  * and callback doesn't triggers
95  * and stop condition is generated
96  */
97 void fpga_i2c_test_async_abort(PinName sda, PinName scl, uint32_t frequency);
98 
99 /**@}*/
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif
106 
107 /**@}*/
void fpga_i2c_test_async_abort(PinName sda, PinName scl, uint32_t frequency)
Test that call aborts ongoing asynchronous transfer.
void fpga_i2c_test_get_capabilities()
Test that i2c_get_capabilities() fills given i2c_capabilities_t instance with capabilities.
void fpga_i2c_test_async_write_read(PinName sda, PinName scl, uint16_t addr, uint32_t frequency, TransferType ttype, uint32_t data_size, uint32_t transfer_count, bool stop_each)
Test asynchronous transmission.
void fpga_i2c_test_init_free(PinName sda, PinName scl)
Test that i2c_init() successfully initializes and i2c_free() successfully frees i2c interface...
void fpga_i2c_test_blocking_transmission_timeout(PinName sda, PinName scl, uint32_t frequency)
Test blocking transmission timeout.
void fpga_i2c_test_blocking_write_read(PinName sda, PinName scl, uint16_t addr, uint32_t frequency, TransferType ttype, uint32_t data_size, uint32_t transfer_count, bool stop_each)
Test blocking transmission.
void fpga_i2c_test_transmission_no_slave(PinName sda, PinName scl, uint32_t frequency)
Test blocking transmission when no slave.
void fpga_i2c_test_frequency(PinName sda, PinName scl)
Test that i2c_frequency() sets the frequency used during the I2C transfer.
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.