From fb589319bfb7efed50258534207941a1de6b28bf Mon Sep 17 00:00:00 2001 From: Maciej Bocianski Date: Tue, 2 Jul 2019 15:19:17 +0200 Subject: [PATCH] I2CTester: upgrade checksum calculation --- .../COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp | 8 ++++++++ .../COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h | 15 +++++++++++---- .../COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp index 0628385c72..c0990435ed 100644 --- a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp +++ b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp @@ -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; diff --git a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h index 6d33e2116a..4d62ff6414 100644 --- a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h +++ b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h @@ -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(); diff --git a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h index 4d0a11cdf3..610c637a76 100644 --- a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h +++ b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h @@ -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