Skip to content

Commit b55344c

Browse files
authored
Merge pull request #10944 from maciejbocianski/i2c_fpga_test_update
Update I2CTester for fpga-ci-test-shield
2 parents 608e4c2 + a6353b0 commit b55344c

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ uint32_t I2CTester::get_receive_checksum()
6262
return to_slave_checksum;
6363
}
6464

65+
uint32_t I2CTester::get_send_checksum()
66+
{
67+
uint32_t from_slave_checksum = 0;
68+
MBED_ASSERT(sizeof(from_slave_checksum) == TESTER_I2C_FROM_SLAVE_CHECKSUM_SIZE);
69+
read(TESTER_I2C_FROM_SLAVE_CHECKSUM, (uint8_t *)&from_slave_checksum, sizeof(from_slave_checksum));
70+
return from_slave_checksum;
71+
}
72+
6573
uint8_t I2CTester::state_num()
6674
{
6775
uint8_t state_num = 0;
@@ -71,9 +79,16 @@ uint8_t I2CTester::state_num()
7179

7280
uint8_t I2CTester::num_dev_addr_matches()
7381
{
74-
uint8_t num_correct = 0;
75-
read(TESTER_I2C_NUMBER_DEV_ADDR_MATCHES, &num_correct, sizeof(num_correct));
76-
return num_correct;
82+
uint8_t num_dev_addr_matches = 0;
83+
read(TESTER_I2C_NUMBER_DEV_ADDR_MATCHES, &num_dev_addr_matches, sizeof(num_dev_addr_matches));
84+
return num_dev_addr_matches;
85+
}
86+
87+
uint8_t I2CTester::num_dev_addr_mismatches()
88+
{
89+
uint8_t num_dev_addr_mismatches = 0;
90+
read(TESTER_I2C_NUMBER_DEV_ADDR_MISMATCHES, &num_dev_addr_mismatches, sizeof(num_dev_addr_mismatches));
91+
return num_dev_addr_mismatches;
7792
}
7893

7994
void I2CTester::set_device_address(uint16_t addr)

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ class I2CTester: public MbedTester {
6161
uint16_t num_nacks();
6262

6363
/**
64-
* Read the number of transfers which have occurred, not including the device address byte
64+
* Read the number of transfers which have occurred
6565
*
6666
* @return The number of I2C transfers that have completed since
67-
* i2c was reset, not including the device address byte
67+
* i2c was reset, including the device address byte.
6868
*/
6969
uint16_t transfer_count();
7070

@@ -75,6 +75,13 @@ class I2CTester: public MbedTester {
7575
*/
7676
uint32_t get_receive_checksum();
7777

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+
7885
/**
7986
* Get the I2C slave state number
8087
*
@@ -89,6 +96,13 @@ class I2CTester: public MbedTester {
8996
*/
9097
uint8_t num_dev_addr_matches();
9198

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+
92106
/**
93107
* Set the I2C slave device address
94108
*
@@ -153,7 +167,7 @@ class I2CTester: public MbedTester {
153167
uint8_t get_next_from_slave();
154168

155169
/**
156-
* Read the number of writes which have occurred, not including the device address byte
170+
* Read the number of writes which have occurred
157171
*
158172
* @return The number of I2C writes that have completed since
159173
* i2c was reset, not including the device address byte
@@ -164,7 +178,7 @@ class I2CTester: public MbedTester {
164178
* Read the number of reads which have occurred
165179
*
166180
* @return The number of I2C reads that have completed since
167-
* i2c was reset
181+
* i2c was reset, not including the device address byte
168182
*/
169183
uint16_t num_reads();
170184

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,7 @@
192192
#define TESTER_I2C_NEXT_FROM_SLAVE (0x015 + 0x00105000)
193193
#define TESTER_I2C_NUM_WRITES (0x016 + 0x00105000)
194194
#define TESTER_I2C_NUM_READS (0x018 + 0x00105000)
195+
#define TESTER_I2C_FROM_SLAVE_CHECKSUM (0x01A + 0x00105000)
196+
#define TESTER_I2C_FROM_SLAVE_CHECKSUM_SIZE 4
197+
#define TESTER_I2C_NUMBER_DEV_ADDR_MISMATCHES (0x01E + 0x00105000)
198+
#define TESTER_I2C_NUMBER_DEV_ADDR_MISMATCHES_SIZE 1

0 commit comments

Comments
 (0)