Skip to content

Commit fb58931

Browse files
I2CTester: upgrade checksum calculation
1 parent 3ef8d1b commit fb58931

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp

Lines changed: 8 additions & 0 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;

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h

Lines changed: 11 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 of data read from the tester
80+
*
81+
* @return The sum of all bytes read from the tester since reset
82+
*/
83+
uint32_t get_send_checksum();
84+
7885
/**
7986
* Get the I2C slave state number
8087
*
@@ -153,7 +160,7 @@ class I2CTester: public MbedTester {
153160
uint8_t get_next_from_slave();
154161

155162
/**
156-
* Read the number of writes which have occurred, not including the device address byte
163+
* Read the number of writes which have occurred
157164
*
158165
* @return The number of I2C writes that have completed since
159166
* i2c was reset, not including the device address byte
@@ -164,7 +171,7 @@ class I2CTester: public MbedTester {
164171
* Read the number of reads which have occurred
165172
*
166173
* @return The number of I2C reads that have completed since
167-
* i2c was reset
174+
* i2c was reset, not including the device address byte
168175
*/
169176
uint16_t num_reads();
170177

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,5 @@
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

0 commit comments

Comments
 (0)