37 #ifndef TASK_FLASH_LOG_LEVEL
38 #define TASK_FLASH_LOG_LEVEL RI_LOG_LEVEL_INFO
41 #ifndef RT_FLASH_ERROR_FILE
42 # define RT_FLASH_ERROR_FILE 0xBFFE
45 #ifndef RT_FLASH_ERROR_RECORD
46 # define RT_FLASH_ERROR_RECORD 0xBFFE
49 #define LOG(msg) ri_log(TASK_FLASH_LOG_LEVEL, msg)
50 #define LOGD(msg) ri_log(RI_LOG_DEBUG, msg)
51 #define LOGW(msg) ri_log(RI_LOG_WARNING, msg)
52 #define LOGHEX(msg, len) ri_log_hex(TASK_FLASH_LOG_LEVEL, msg, len)
59 } rt_flash_error_cause_t;
72 error_cause_t error = {.error = err, .line = line };
75 strncpy (error.filename, file, sizeof (error.filename));
78 APPLICATION_FLASH_ERROR_RECORD,
79 &error,
sizeof (error));
101 void print_error_cause (
void)
103 rt_flash_error_cause_t error;
106 RT_FLASH_ERROR_RECORD,
107 &error,
sizeof (error));
113 index += snprintf (error_str,
sizeof (error_str),
"Previous fatal error: %s:%d: ",
114 error.filename, error.line);
116 sizeof (error_str) - index);
117 snprintf (error_str + index,
sizeof (error_str) - index,
"\r\n");
144 const void *
const message,
const size_t message_length)
165 void *
const message,
const size_t message_length)
198 const void *
const message,
const size_t message_length)
204 void *
const message,
const size_t message_length)
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_NO_MEM
No Memory for operation.
#define RD_ERROR_NOT_FOUND
Not found.
rd_status_t ri_flash_gc_run(void)
Run garbage collection.
bool ri_flash_is_busy()
Check if flash is busy.
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_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.
size_t ri_error_to_string(rd_status_t error, char *error_string, size_t space_remaining)
Write text description of error message into given string pointer and null-terminate it....
bool rt_flash_busy(void)
Check if flash is running an operation.
rd_status_t rt_flash_gc_run(void)
Trigger garbage collection.
rd_status_t rt_flash_init(void)
Initialize flash storage.
rd_status_t rt_flash_free(const uint16_t file_id, const uint16_t record_id)
Free data from flash.
rd_status_t rt_flash_load(const uint16_t page_id, const uint16_t record_id, void *const message, const size_t message_length)
Load data from flash.
rd_status_t rt_flash_store(const uint16_t file_id, const uint16_t record_id, const void *const message, const size_t message_length)
Store data to flash.
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Ruuvi sensor interface Lifecycle: Beta
Interface functions to persistent flash storage.
void ri_power_enter_bootloader(void)
Enter bootloader.
void ri_power_reset(void)
Reset IC.
rd_status_t ri_yield(void)
Function which will release execution.
rd_status_t ri_delay_us(uint32_t time)
Delay a given number of microseconds.