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

Feature/i2c slave ack nack update #520

Merged
merged 6 commits into from
Sep 26, 2022
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
2 changes: 1 addition & 1 deletion modules/rtos
6 changes: 3 additions & 3 deletions test/rtos_drivers/hil/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ echo "****************"
echo "* Run Tests *"
echo "****************"
if [ "$UNAME" == "Linux" ] ; then
timeout ${TIMEOUT_S}s xrun --xscope ${XCORE_SDK_PATH}/dist/${FIRMWARE} 2>&1 | tee -a ${REPORT}
timeout ${TIMEOUT_S}s xrun --xscope ${XCORE_SDK_ROOT}/dist/${FIRMWARE} 2>&1 | tee -a ${REPORT}
elif [ "$UNAME" == "Darwin" ] ; then
gtimeout ${TIMEOUT_S}s xrun --xscope ${XCORE_SDK_PATH}/dist/${FIRMWARE} 2>&1 | tee -a ${REPORT}
gtimeout ${TIMEOUT_S}s xrun --xscope ${XCORE_SDK_ROOT}/dist/${FIRMWARE} 2>&1 | tee -a ${REPORT}
fi

echo "****************"
echo "* Parse Result *"
echo "****************"
python ${XCORE_SDK_PATH}/test/rtos_drivers/python/parse_test_output.py testing/test.rpt -outfile="testing/test_results" --print_test_results --verbose
python ${XCORE_SDK_ROOT}/test/rtos_drivers/python/parse_test_output.py testing/test.rpt -outfile="testing/test_results" --print_test_results --verbose

pytest
17 changes: 16 additions & 1 deletion test/rtos_drivers/hil/src/individual_tests/i2c/i2c_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,26 @@ static void i2c_slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *da
i2c_printf("SLAVE missing i2c_slave_tx_done callback on test %d", test_ctx->cur_test);
}
}

RTOS_I2C_SLAVE_RX_BYTE_CHECK_CALLBACK_ATTR
void i2c_slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
if (test_ctx->slave_rx_check_byte[test_ctx->cur_test] != NULL)
{
I2C_SLAVE_RX_BYTE_CHECK_ATTR i2c_slave_rx_byte_check_cb_t fn;
fn = test_ctx->slave_rx_check_byte[test_ctx->cur_test];
fn(ctx, app_data, data, cur_status);
} else {
i2c_printf("SLAVE missing slave_rx_check_byte callback on test %d", test_ctx->cur_test);
}
}

#endif /* ON_TILE(1) */

static int run_i2c_tests(i2c_test_ctx_t *test_ctx, chanend_t c)
{
int retval = 0;

do
{
sync(c);
Expand Down Expand Up @@ -116,6 +130,7 @@ static void start_i2c_devices(i2c_test_ctx_t *test_ctx)
i2c_slave_rx,
i2c_slave_tx_start,
i2c_slave_tx_done,
i2c_slave_rx_byte_check,
I2C_SLAVE_ISR_CORE,
configMAX_PRIORITIES-1);
#endif
Expand Down
11 changes: 7 additions & 4 deletions test/rtos_drivers/hil/src/individual_tests/i2c/i2c_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

#define I2C_MAX_TESTS 12

#define I2C_MAIN_TEST_ATTR __attribute__((fptrgroup("rtos_test_i2c_main_test_fptr_grp")))
#define I2C_SLAVE_RX_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_rx_fptr_grp")))
#define I2C_SLAVE_TX_START_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_tx_start_fptr_grp")))
#define I2C_SLAVE_TX_DONE_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_tx_done_fptr_grp")))
#define I2C_MAIN_TEST_ATTR __attribute__((fptrgroup("rtos_test_i2c_main_test_fptr_grp")))
#define I2C_SLAVE_RX_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_rx_fptr_grp")))
#define I2C_SLAVE_TX_START_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_tx_start_fptr_grp")))
#define I2C_SLAVE_TX_DONE_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_tx_done_fptr_grp")))
#define I2C_SLAVE_RX_BYTE_CHECK_ATTR __attribute__((fptrgroup("rtos_test_i2c_slave_rx_byte_check_fptr_grp")))

typedef struct i2c_test_ctx i2c_test_ctx_t;

Expand All @@ -30,12 +31,14 @@ struct i2c_test_ctx {
I2C_SLAVE_RX_ATTR void (*slave_rx[I2C_MAX_TESTS])(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_t len);
I2C_SLAVE_TX_START_ATTR size_t (*slave_tx_start[I2C_MAX_TESTS])(rtos_i2c_slave_t *ctx, void *app_data, uint8_t **data);
I2C_SLAVE_TX_DONE_ATTR void (*slave_tx_done[I2C_MAX_TESTS])(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_t len);
I2C_SLAVE_RX_BYTE_CHECK_ATTR void (*slave_rx_check_byte[I2C_MAX_TESTS])(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status);
};

typedef int (*i2c_main_test_t)(i2c_test_ctx_t *ctx);
typedef void (*i2c_slave_rx_t)(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_t len);
typedef size_t (*i2c_slave_tx_start_t)(rtos_i2c_slave_t *ctx, void *app_data, uint8_t **data);
typedef void (*i2c_slave_tx_done_t)(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_t len);
typedef void (*i2c_slave_rx_byte_check_cb_t)(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status);

int i2c_device_tests(rtos_i2c_master_t *i2c_master_ctx, rtos_i2c_slave_t *i2c_slave_ctx, chanend_t c);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ static void slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data,
test_slave_iters++;
}

static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_READ_MULTIPLE_TEST_SIZE;
slave_byte_check++;
if (test_vector[test_slave_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
}
#endif

void register_master_read_multiple_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -161,6 +175,7 @@ void register_master_read_multiple_test(i2c_test_ctx_t *test_ctx)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_tx_start[this_test_num] = slave_tx_start;
test_ctx->slave_tx_done[this_test_num] = slave_tx_done;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(I2C_MASTER_TILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ static void slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data,
test_slave_iters++;
}

static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_READ_TEST_SIZE;
slave_byte_check++;
if (test_vector[test_slave_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
}
#endif

void register_master_read_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -142,6 +156,7 @@ void register_master_read_test(i2c_test_ctx_t *test_ctx)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_tx_start[this_test_num] = slave_tx_start;
test_ctx->slave_tx_done[this_test_num] = slave_tx_done;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(I2C_MASTER_TILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ static void slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data,
}
}

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
}
#endif

void register_master_reg_read_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -163,6 +168,7 @@ void register_master_reg_read_test(i2c_test_ctx_t *test_ctx)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_tx_start[this_test_num] = slave_tx_start;
test_ctx->slave_tx_done[this_test_num] = slave_tx_done;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(I2C_MASTER_TILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ static void slave_rx(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_

test_slave_iters++;
}

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
}
#endif

void register_master_reg_write_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -124,6 +130,7 @@ void register_master_reg_write_test(i2c_test_ctx_t *test_ctx)

#if ON_TILE(I2C_SLAVE_TILE)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(I2C_MASTER_TILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ static void slave_rx(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_

test_slave_iters++;
}

static int slave_byte_check_iters = 0;
static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_WRITE_MULTIPLE_TEST_SIZE;
slave_byte_check++;
if (test_vector[slave_byte_check_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
if ((slave_byte_check % I2C_MASTER_WRITE_MULTIPLE_TEST_SIZE) == 0) {
slave_byte_check_iters++;
}
}
#endif

void register_master_write_multiple_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -143,6 +162,7 @@ void register_master_write_multiple_test(i2c_test_ctx_t *test_ctx)

#if ON_TILE(I2C_SLAVE_TILE)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(I2C_MASTER_TILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ static void slave_rx(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_

test_slave_iters++;
}

static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_WRITE_TEST_SIZE;
slave_byte_check++;
if (test_vector[test_slave_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
}
#endif

void register_master_write_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -120,6 +135,7 @@ void register_master_write_test(i2c_test_ctx_t *test_ctx)

#if ON_TILE(I2C_SLAVE_TILE)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(I2C_MASTER_TILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ static void slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data,
test_slave_iters++;
}

static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_READ_MULTIPLE_TEST_SIZE;
slave_byte_check++;
if (test_vector[test_slave_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
}
#endif

void register_rpc_master_read_multiple_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -161,6 +175,7 @@ void register_rpc_master_read_multiple_test(i2c_test_ctx_t *test_ctx)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_tx_start[this_test_num] = slave_tx_start;
test_ctx->slave_tx_done[this_test_num] = slave_tx_done;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ static void slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data,
test_slave_iters++;
}

static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_READ_TEST_SIZE;
slave_byte_check++;
if (test_vector[test_slave_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
}
#endif

void register_rpc_master_read_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -142,6 +156,7 @@ void register_rpc_master_read_test(i2c_test_ctx_t *test_ctx)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_tx_start[this_test_num] = slave_tx_start;
test_ctx->slave_tx_done[this_test_num] = slave_tx_done;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ static void slave_tx_done(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data,
}
}

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
}
#endif

void register_rpc_master_reg_read_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -163,6 +168,7 @@ void register_rpc_master_reg_read_test(i2c_test_ctx_t *test_ctx)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_tx_start[this_test_num] = slave_tx_start;
test_ctx->slave_tx_done[this_test_num] = slave_tx_done;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ static void slave_rx(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_

test_slave_iters++;
}

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
}
#endif

void register_rpc_master_reg_write_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -124,6 +130,7 @@ void register_rpc_master_reg_write_test(i2c_test_ctx_t *test_ctx)

#if ON_TILE(I2C_SLAVE_TILE)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ static void slave_rx(rtos_i2c_slave_t *ctx, void *app_data, uint8_t *data, size_

test_slave_iters++;
}

static int slave_byte_check_iters = 0;
static int slave_byte_check = 0;

I2C_SLAVE_RX_BYTE_CHECK_ATTR
static void slave_rx_byte_check(rtos_i2c_slave_t *ctx, void *app_data, uint8_t data, i2c_slave_ack_t *cur_status)
{
i2c_test_ctx_t *test_ctx = (i2c_test_ctx_t*)ctx->app_data;
local_printf("SLAVE rx byte check 0x%x status %d", data, *cur_status);
int i = slave_byte_check % I2C_MASTER_WRITE_MULTIPLE_TEST_SIZE;
slave_byte_check++;
if (test_vector[slave_byte_check_iters][i] != data) {
local_printf("SLAVE rx byte check failed");
test_ctx->slave_success[test_ctx->cur_test] = -1;
}
if ((slave_byte_check % I2C_MASTER_WRITE_MULTIPLE_TEST_SIZE) == 0) {
slave_byte_check_iters++;
}
}
#endif

void register_rpc_master_write_multiple_test(i2c_test_ctx_t *test_ctx)
Expand All @@ -143,6 +162,7 @@ void register_rpc_master_write_multiple_test(i2c_test_ctx_t *test_ctx)

#if ON_TILE(I2C_SLAVE_TILE)
test_ctx->slave_rx[this_test_num] = slave_rx;
test_ctx->slave_rx_check_byte[this_test_num] = slave_rx_byte_check;
#endif

#if ON_TILE(0)
Expand Down
Loading