22 #define F_BIG_RECORD_SIZE 0x900U
23 #define F_TEST_PAGE 0x0002U
24 #define F_TEST_RECORD 0x0001U
25 static const char __attribute__ ( (aligned (4))) f_data1[] = "Flash test data 1";
26 static const
char __attribute__ ( (aligned (4))) f_data2[] = "Flash test data 2";
27 static uint32_t boot_count = 0;
42 printfp (
"\"init\":");
62 sizeof (uint32_t), &boot_count);
66 printfp (
"\"fail\",\r\n");
70 printfp (
"\"pass\",\r\n");
92 printfp (
"\"uninit\":");
113 printfp (
"\"fail\",\r\n");
117 printfp (
"\"pass\",\r\n");
133 printfp (
"\"store\":");
164 printfp (
"\"fail\",\r\n");
168 printfp (
"\"pass\",\r\n");
185 char load_buffer[
sizeof (f_data2) + 4] = {0};
186 printfp (
"\"load\":");
202 || strcmp (f_data2, load_buffer))
210 printfp (
"\"fail\",\r\n");
214 printfp (
"\"pass\",\r\n");
231 char load_buffer[
sizeof (f_data2) + 4] = {0};
232 printfp (
"\"free\":");
263 printfp (
"\"fail\",\r\n");
267 printfp (
"\"pass\",\r\n");
308 }
while ( ( (F_BIG_RECORD_SIZE < size) && (
RD_SUCCESS == err_code))
319 if ( (
RD_SUCCESS != err_code) || (F_BIG_RECORD_SIZE > size))
327 printfp (
"\"fail\"\r\n");
331 printfp (
"\"pass\"\r\n");
335 sizeof (uint32_t), &boot_count);
349 printfp (
"\"flash\":{\r\n");
350 status |= ri_flash_init_test (printfp);
351 status |= ri_flash_uninit_test (printfp);
352 status |= ri_flash_store_test (printfp);
353 status |= ri_flash_load_test (printfp);
354 status |= ri_flash_delete_test (printfp);
355 status |= ri_flash_gc_size_busy_test (printfp);
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_DATA_SIZE
Invalid Data size.
#define RD_ERROR_NOT_FOUND
Not found.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RD_ERROR_BUSY
Busy.
rd_status_t ri_flash_gc_run(void)
Run garbage collection.
bool ri_flash_run_integration_test(const rd_test_print_fp printfp)
Run all flash tests.
bool ri_flash_is_busy()
Check if flash is busy.
rd_status_t ri_flash_uninit(void)
Unintialize flash. After uninitialization only initialization can be used.
void ri_flash_purge(void)
Purge flash.
rd_status_t ri_flash_record_set(const uint32_t page_id, const uint32_t record_id, const size_t data_size, const void *const data)
Set data to record in page.
rd_status_t ri_flash_init(void)
rd_status_t ri_flash_record_delete(const uint32_t file_id, const uint32_t record_id)
Mark a record for deletion.
rd_status_t ri_flash_free_size_get(size_t *size)
Get total size of free flash.
rd_status_t ri_flash_record_get(const uint32_t page_id, const uint32_t record_id, const size_t data_size, void *const data)
Get data from record in page.
void(* rd_test_print_fp)(const char *const msg)
function pointer to print test information
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Functions for testing drivers.
Interface functions to persistent flash storage.
void ri_power_reset(void)
Reset IC.