Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update I2CTester for fpga-ci-test-shield #10944

Merged
merged 3 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -71,9 +79,16 @@ uint8_t I2CTester::state_num()

uint8_t I2CTester::num_dev_addr_matches()
{
uint8_t num_correct = 0;
read(TESTER_I2C_NUMBER_DEV_ADDR_MATCHES, &num_correct, sizeof(num_correct));
return num_correct;
uint8_t num_dev_addr_matches = 0;
read(TESTER_I2C_NUMBER_DEV_ADDR_MATCHES, &num_dev_addr_matches, sizeof(num_dev_addr_matches));
return num_dev_addr_matches;
}

uint8_t I2CTester::num_dev_addr_mismatches()
{
uint8_t num_dev_addr_mismatches = 0;
read(TESTER_I2C_NUMBER_DEV_ADDR_MISMATCHES, &num_dev_addr_mismatches, sizeof(num_dev_addr_mismatches));
return num_dev_addr_mismatches;
}

void I2CTester::set_device_address(uint16_t addr)
Expand Down
22 changes: 18 additions & 4 deletions components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class I2CTester: public MbedTester {
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();

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

/**
* Read a checksum the tester calculated for data it has already sent
*
* @return The sum of all bytes the tester has sent since reset
*/
uint32_t get_send_checksum();

/**
* Get the I2C slave state number
*
Expand All @@ -89,6 +96,13 @@ class I2CTester: public MbedTester {
*/
uint8_t num_dev_addr_matches();

/**
* Get the number of times the device address has been sent incorrectly
*
* @return The number of times the device address has been sent incorrectly
*/
uint8_t num_dev_addr_mismatches();

/**
* Set the I2C slave device address
*
Expand Down Expand Up @@ -153,7 +167,7 @@ class I2CTester: public MbedTester {
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
Expand All @@ -164,7 +178,7 @@ class I2CTester: public MbedTester {
* 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,7 @@
#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
#define TESTER_I2C_NUMBER_DEV_ADDR_MISMATCHES (0x01E + 0x00105000)
#define TESTER_I2C_NUMBER_DEV_ADDR_MISMATCHES_SIZE 1