mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-26 11:37:10 +00:00
test/flash_tlv: only validate when BTSTACK_TEST is defined
This commit is contained in:
parent
03cec12ed2
commit
d5ff883d67
@ -16,6 +16,7 @@ VPATH = \
|
||||
${BTSTACK_ROOT}/src
|
||||
|
||||
CFLAGS = \
|
||||
-DBTSTACK_TEST \
|
||||
-g \
|
||||
-Wall \
|
||||
-Wmissing-prototypes \
|
||||
|
@ -40,9 +40,10 @@
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
|
||||
// validate
|
||||
#ifdef BTSTACK_TEST
|
||||
#include "stdio.h"
|
||||
#include <stdlib.h> // exit(..)
|
||||
#endif
|
||||
|
||||
#define HAL_FLASH_SECTOR_SIZE 128
|
||||
#define HAL_FLASH_SECTOR_NUM 2
|
||||
@ -51,10 +52,11 @@ static uint8_t hal_flash_storage_bank_1[HAL_FLASH_SECTOR_SIZE];
|
||||
static uint8_t hal_flash_storage_bank_2[HAL_FLASH_SECTOR_SIZE];
|
||||
static uint8_t * hal_flash_storage_banks[] = {hal_flash_storage_bank_1, hal_flash_storage_bank_2};
|
||||
|
||||
// validate that memory isn't written twice
|
||||
#ifdef BTSTACK_TEST
|
||||
static uint8_t hal_flash_storage_bank_1_written[HAL_FLASH_SECTOR_SIZE];
|
||||
static uint8_t hal_flash_storage_bank_2_written[HAL_FLASH_SECTOR_SIZE];
|
||||
static uint8_t * hal_flash_storage_banks_written[] = {hal_flash_storage_bank_1_written, hal_flash_storage_bank_2_written};
|
||||
#endif
|
||||
|
||||
uint32_t hal_flash_sector_get_size(void){
|
||||
return HAL_FLASH_SECTOR_SIZE;
|
||||
@ -63,8 +65,9 @@ uint32_t hal_flash_sector_get_size(void){
|
||||
void hal_flash_sector_erase(int bank){
|
||||
if (bank > 1) return;
|
||||
memset(hal_flash_storage_banks[bank], 0xff, HAL_FLASH_SECTOR_SIZE);
|
||||
// validate
|
||||
#ifdef BTSTACK_TEST
|
||||
memset(hal_flash_storage_banks_written[bank], 0, HAL_FLASH_SECTOR_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void hal_flash_sector_init(void){
|
||||
@ -91,7 +94,7 @@ void hal_flash_sector_write(int bank, uint32_t offset, const uint8_t * data, uin
|
||||
if (offset > HAL_FLASH_SECTOR_SIZE) return;
|
||||
if ((offset + size) > HAL_FLASH_SECTOR_SIZE) return;
|
||||
|
||||
// validate start
|
||||
#ifdef BTSTACK_TEST
|
||||
int i;
|
||||
for (i=0;i<size;i++){
|
||||
if (hal_flash_storage_banks_written[bank][offset+i]) {
|
||||
@ -101,7 +104,7 @@ void hal_flash_sector_write(int bank, uint32_t offset, const uint8_t * data, uin
|
||||
}
|
||||
}
|
||||
memset(&hal_flash_storage_banks_written[bank][offset], 1, size);
|
||||
// validate end
|
||||
#endif
|
||||
|
||||
memcpy(&hal_flash_storage_banks[bank][offset], data, size);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user