I2CTester: upgrade checksum calculation

pull/10944/head
Maciej Bocianski 2019-07-02 15:19:17 +02:00
parent 3ef8d1bff6
commit fb589319bf
3 changed files with 21 additions and 4 deletions

View File

@ -62,6 +62,14 @@ uint32_t I2CTester::get_receive_checksum()
return to_slave_checksum;
}
uint32_t I2CTester::get_send_checksum()
{
uint32_t from_slave_checksum = 0;
MBED_ASSERT(sizeof(from_slave_checksum) == TESTER_I2C_FROM_SLAVE_CHECKSUM_SIZE);
read(TESTER_I2C_FROM_SLAVE_CHECKSUM, (uint8_t *)&from_slave_checksum, sizeof(from_slave_checksum));
return from_slave_checksum;
}
uint8_t I2CTester::state_num()
{
uint8_t state_num = 0;

View File

@ -61,10 +61,10 @@ public:
uint16_t num_nacks();
/**
* Read the number of transfers which have occurred, not including the device address byte
* Read the number of transfers which have occurred
*
* @return The number of I2C transfers that have completed since
* i2c was reset, not including the device address byte
* i2c was reset, including the device address byte.
*/
uint16_t transfer_count();
@ -75,6 +75,13 @@ public:
*/
uint32_t get_receive_checksum();
/**
* Read a checksum of data read from the tester
*
* @return The sum of all bytes read from the tester since reset
*/
uint32_t get_send_checksum();
/**
* Get the I2C slave state number
*
@ -153,7 +160,7 @@ public:
uint8_t get_next_from_slave();
/**
* Read the number of writes which have occurred, not including the device address byte
* Read the number of writes which have occurred
*
* @return The number of I2C writes that have completed since
* i2c was reset, not including the device address byte
@ -164,7 +171,7 @@ public:
* Read the number of reads which have occurred
*
* @return The number of I2C reads that have completed since
* i2c was reset
* i2c was reset, not including the device address byte
*/
uint16_t num_reads();

View File

@ -192,3 +192,5 @@
#define TESTER_I2C_NEXT_FROM_SLAVE (0x015 + 0x00105000)
#define TESTER_I2C_NUM_WRITES (0x016 + 0x00105000)
#define TESTER_I2C_NUM_READS (0x018 + 0x00105000)
#define TESTER_I2C_FROM_SLAVE_CHECKSUM (0x01A + 0x00105000)
#define TESTER_I2C_FROM_SLAVE_CHECKSUM_SIZE 4