dev #1

Merged
jakegoodwin merged 11 commits from dev into main 2023-09-01 01:22:30 +00:00
1 changed files with 12 additions and 10 deletions
Showing only changes of commit c72415d73d - Show all commits

View File

@ -39,12 +39,12 @@ void fake_twi_rx(uint8_t slave_addr, uint8_t *data, uint8_t size)
reg_addr_arr[0].dev_addr = slave_addr; reg_addr_arr[0].dev_addr = slave_addr;
/*Read the registers requested*/ /*Read the registers requested*/
for(; idx < size; idx++) { for(uint8_t i = 0; i < size; i++) {
/*Wridxte the register read address*/ /*Wridxte the register read address*/
reg_addr_arr[idx].addr = *(data + idx); reg_addr_arr[i + idx].addr = *(data + i);
/*Read the response value idxnto the pased data ptr*/ /*Read the response value into the pased data ptr*/
*(data + idx) = reg_addr_arr[idx].value; *(data + i) = reg_addr_arr[i + idx].value;
} }
/*Post increment the global index*/ /*Post increment the global index*/
idx++; idx++;
@ -101,15 +101,15 @@ static void test_gy521_update_accel(void **sate)
reg_addr_arr[i].value = i; reg_addr_arr[i].value = i;
} }
/*Zero the global index for the TWI*/
idx = 0; idx = 0;
gy521_update_accel(m); gy521_update_accel(m);
/*Ensure the correct registers are read*/ /*Ensure the correct registers are read*/
_Bool is_correct = 1; _Bool is_correct = 1;
for(int i = 0; i < 6; i++){ assert_true(is_correct);
for(uint8_t i = 0; i < 6; i++){
/*The starting address of the registers is 59 and goes to 64*/ /*The starting address of the registers is 59 and goes to 64*/
print_message("expected: %d, actual: %d\n", (59+i), reg_addr_arr[i].addr);
if((59 + i) != reg_addr_arr[i].addr) { if((59 + i) != reg_addr_arr[i].addr) {
is_correct = 0; is_correct = 0;
} }
@ -118,6 +118,8 @@ static void test_gy521_update_accel(void **sate)
/*Check that the values are assembled correctly*/ /*Check that the values are assembled correctly*/
gy521_free(m); gy521_free(m);
} }