15 #ifdef PRU_PSTORAGE_ENABLE
19 #include "nrf_error.h"
23 #define PRU_PSTORAGE_EMPTY_FLASH_PATTERN 0xffffffff
24 #define PRU_PSTORAGE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE)
25 #define PRU_PSTORAGE_FLASH_START_PAGE (NRF_FICR->CODESIZE - 4)
26 #define PRU_PSTORAGE_FLASH_START_ADDR \
27 (PRU_PSTORAGE_FLASH_PAGE_SIZE * PRU_PSTORAGE_FLASH_START_PAGE)
36 PRU_PSTORAGE_STATE_IDLE,
37 PRU_PSTORAGE_STATE_ERASE,
38 PRU_PSTORAGE_STATE_WRITE
53 m_state = PRU_PSTORAGE_STATE_IDLE;
56 case NRF_EVT_FLASH_OPERATION_ERROR:
60 case NRF_EVT_FLASH_OPERATION_SUCCESS:
71 uint32_t err_code = NRF_ERROR_BUSY;
76 APP_ERROR_HANDLER(NRF_ERROR_INVALID_PARAM);
81 while(
m_state != PRU_PSTORAGE_STATE_IDLE)
84 while(err_code == NRF_ERROR_BUSY)
86 m_state = PRU_PSTORAGE_STATE_WRITE;
88 (uint32_t *) p_appdata,
91 APP_ERROR_CHECK(err_code);
104 uint32_t err_code = NRF_ERROR_BUSY;
106 m_state = PRU_PSTORAGE_STATE_ERASE;
108 while(err_code == NRF_ERROR_BUSY)
113 APP_ERROR_CHECK(err_code);
118 *p_complete = (
m_state == PRU_PSTORAGE_STATE_IDLE);
pru_pstorage_state
Pstorage state.
static volatile pru_pstorage_state m_state
void pru_pstorage_erase_appdata(void)
Erase all of PRU appdata.
void pru_pstorage_write(pru_pstorage_appdata_t *p_appdata)
Writes application data to flash.
void pru_pstorage_status(bool *p_complete, bool *p_success)
Read status of pstorage operation.
void pru_pstorage_sys_evt_handler(uint32_t event)
Handles system callbacks.
#define PRU_PSTORAGE_FLASH_START_PAGE
PRU pstorage data container.
#define PRU_PSTORAGE_EMPTY_FLASH_PATTERN
static volatile bool m_operation_success
#define PRU_PSTORAGE_FLASH_START_ADDR
bool pru_pstorage_read(pru_pstorage_appdata_t *p_appdata)
Reads application data from flash.