Mistake on this page?
Report an issue in GitHub or email us
I2CTester.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 #ifndef I2C_TESTER_H
19 #define I2C_TESTER_H
20 
21 #include "MbedTester.h"
22 
23 
24 class I2CTester: public MbedTester {
25 public:
26 
27  I2CTester(const PinList *form_factor, const PinList *exclude_pins)
28  : MbedTester(form_factor, exclude_pins)
29  {
30 
31  }
32 
33  /* **I2C peripheral functions** */
34 
35  /**
36  * Get the number of start conditions since last I2C reset
37  *
38  * @return The number of start conditions
39  */
40  uint8_t num_starts();
41 
42  /**
43  * Get the number of stop conditions since last I2C reset
44  *
45  * @return The number of stop conditions
46  */
47  uint8_t num_stops();
48 
49  /**
50  * Get the number of ACKs since last I2C reset
51  *
52  * @return The number of ACKs
53  */
54  uint16_t num_acks();
55 
56  /**
57  * Get the number of NACKs since last I2C reset
58  *
59  * @return The number of NACKs
60  */
61  uint16_t num_nacks();
62 
63  /**
64  * Read the number of transfers which have occurred
65  *
66  * @return The number of I2C transfers that have completed since
67  * i2c was reset, including the device address byte.
68  */
69  uint16_t transfer_count();
70 
71  /**
72  * Read a checksum of data send to the tester
73  *
74  * @return The sum of all bytes sent to the tester since reset
75  */
76  uint32_t get_receive_checksum();
77 
78  /**
79  * Read a checksum the tester calculated for data it has already sent
80  *
81  * @return The sum of all bytes the tester has sent since reset
82  */
83  uint32_t get_send_checksum();
84 
85  /**
86  * Get the I2C slave state number
87  *
88  * @return The state number
89  */
90  uint8_t state_num();
91 
92  /**
93  * Get the number of times the device address has been sent correctly
94  *
95  * @return The number of times the device address has been sent correctly
96  */
97  uint8_t num_dev_addr_matches();
98 
99  /**
100  * Get the number of times the device address has been sent incorrectly
101  *
102  * @return The number of times the device address has been sent incorrectly
103  */
104  uint8_t num_dev_addr_mismatches();
105 
106  /**
107  * Set the I2C slave device address
108  *
109  * @param addr New address for slave device
110  */
111  void set_device_address(uint16_t addr);
112 
113  /**
114  * Get the I2C slave device address
115  *
116  * @return The slave device address
117  */
118  uint16_t get_device_address();
119 
120  /**
121  * Set SDA (test mode)
122  *
123  * @param value Test value for SDA
124  */
125  void set_sda(uint8_t value);
126 
127  /**
128  * Get the value written to slave in the fourth to last transaction
129  *
130  * @return value written to slave in the fourth to last transaction
131  */
132  uint8_t get_prev_to_slave_4();
133 
134  /**
135  * Get the value written to slave in the third to last transaction
136  *
137  * @return value written to slave in the third to last transaction
138  */
139  uint8_t get_prev_to_slave_3();
140 
141  /**
142  * Get the value written to slave in the second to last transaction
143  *
144  * @return value written to slave in the second to last transaction
145  */
146  uint8_t get_prev_to_slave_2();
147 
148  /**
149  * Get the value written to slave in the last transaction
150  *
151  * @return value written to slave in the last transaction
152  */
153  uint8_t get_prev_to_slave_1();
154 
155  /**
156  * Set the value to be read from slave in next read transaction
157  *
158  * @param value Value to be read from slave in next read transaction
159  */
160  void set_next_from_slave(uint8_t value);
161 
162  /**
163  * Get the value to be read from slave in next read transaction
164  *
165  * @return Value to be read from slave in next read transaction
166  */
167  uint8_t get_next_from_slave();
168 
169  /**
170  * Read the number of writes which have occurred
171  *
172  * @return The number of I2C writes that have completed since
173  * i2c was reset, not including the device address byte
174  */
175  uint16_t num_writes();
176 
177  /**
178  * Read the number of reads which have occurred
179  *
180  * @return The number of I2C reads that have completed since
181  * i2c was reset, not including the device address byte
182  */
183  uint16_t num_reads();
184 
185 };
186 
187 #endif
void set_device_address(uint16_t addr)
Set the I2C slave device address.
uint8_t get_prev_to_slave_1()
Get the value written to slave in the last transaction.
uint32_t get_receive_checksum()
Read a checksum of data send to the tester.
Definition: pinmap.h:36
uint8_t num_starts()
Get the number of start conditions since last I2C reset.
uint16_t num_acks()
Get the number of ACKs since last I2C reset.
uint16_t num_nacks()
Get the number of NACKs since last I2C reset.
uint8_t get_prev_to_slave_3()
Get the value written to slave in the third to last transaction.
uint16_t num_reads()
Read the number of reads which have occurred.
uint16_t get_device_address()
Get the I2C slave device address.
uint8_t num_dev_addr_matches()
Get the number of times the device address has been sent correctly.
MbedTester(const PinList *form_factor, const PinList *exclude_pins)
Construct a new MbedTester object.
uint8_t get_prev_to_slave_2()
Get the value written to slave in the second to last transaction.
uint8_t get_prev_to_slave_4()
Get the value written to slave in the fourth to last transaction.
uint8_t state_num()
Get the I2C slave state number.
uint8_t num_stops()
Get the number of stop conditions since last I2C reset.
uint16_t num_writes()
Read the number of writes which have occurred.
uint16_t transfer_count()
Read the number of transfers which have occurred.
void set_sda(uint8_t value)
Set SDA (test mode)
void set_next_from_slave(uint8_t value)
Set the value to be read from slave in next read transaction.
The base class for controlling the FPGA CI Test Shield.
Definition: MbedTester.h:68
uint8_t num_dev_addr_mismatches()
Get the number of times the device address has been sent incorrectly.
uint32_t get_send_checksum()
Read a checksum the tester calculated for data it has already sent.
uint8_t get_next_from_slave()
Get the value to be read from slave in next read transaction.
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.