Skip to content

Commit

Permalink
fix memset bug (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
consanii authored Jan 19, 2024
1 parent 98568f0 commit 507fea3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sw/applications/example_spi_read/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ uint32_t test_read(uint32_t *test_buffer, uint32_t len) {
if (status != FLASH_OK) exit(EXIT_FAILURE);

// Check if what we read is correct (i.e. flash_data == test_buffer)
return check_result(test_buffer, len);
uint32_t res = check_result(test_buffer, len);

// Reset the flash data buffer
memset(flash_data, 0, len * sizeof(uint8_t));

return res;
}

uint32_t test_read_dma(uint32_t *test_buffer, uint32_t len) {
Expand All @@ -129,10 +131,12 @@ uint32_t test_read_dma(uint32_t *test_buffer, uint32_t len) {
if (status != FLASH_OK) exit(EXIT_FAILURE);

// Check if what we read is correct (i.e. flash_data == test_buffer)
return check_result(test_buffer, len);
uint32_t res = check_result(test_buffer, len);

// Reset the flash data buffer
memset(flash_data, 0, len * sizeof(uint8_t));

return res;
}

uint32_t test_read_quad(uint32_t *test_buffer, uint32_t len) {
Expand All @@ -141,10 +145,12 @@ uint32_t test_read_quad(uint32_t *test_buffer, uint32_t len) {
if (status != FLASH_OK) exit(EXIT_FAILURE);

// Check if what we read is correct (i.e. flash_data == test_buffer)
return check_result(test_buffer, len);
uint32_t res = check_result(test_buffer, len);

// Reset the flash data buffer
memset(flash_data, 0, len * sizeof(uint8_t));

return res;
}

uint32_t test_read_quad_dma(uint32_t *test_buffer, uint32_t len) {
Expand All @@ -153,10 +159,12 @@ uint32_t test_read_quad_dma(uint32_t *test_buffer, uint32_t len) {
if (status != FLASH_OK) exit(EXIT_FAILURE);

// Check if what we read is correct (i.e. flash_data == test_buffer)
return check_result(test_buffer, len);
uint32_t res = check_result(test_buffer, len);

// Reset the flash data buffer
memset(flash_data, 0, len * sizeof(uint8_t));

return res;
}

uint32_t check_result(uint8_t *test_buffer, uint32_t len) {
Expand Down

0 comments on commit 507fea3

Please sign in to comment.