#ifndef NRF_FLASH_H__ #define NRF_FLASH_H__ #include #include #include #include "boards.h" #include "bsp.h" #ifndef FLASH_PAGE_SIZE #define FLASH_PAGE_SIZE 4096 #endif #define FLASH_BASE_ADDRESS 0x6D000 #define FLASH_SIZE (FLASH_PAGE_SIZE<<1) enum { WSYS_FLASH_OK = 0, WSYS_FLASH_INVALID_ADDRESS, WSYS_FLASH_INVALID_LENGTH }; /******************************************************************* * Function Nume: flash_write_data * Descriptions : write data from flash * In Para : address: address to access(address must be word-aligned), length: length to be read(4 integer multiple) * In-Out Para : none * Out Para : data: data buffer to be read * Return Value : FLASH_SUCCESS: success, FLASH_ERROR_INVALID_ADDRESS: address error *******************************************************************/ uint8_t flash_write_data(uint32_t address, uint8_t *data, uint16_t length); /******************************************************************* * Function Nume: flash_read_data * Descriptions : read data from flash * In Para : address: address to access(align=2), length: length to be read(4 integer multiple) * In-Out Para : none * Out Para : data: data buffer to be read * Return Value : FLASH_SUCCESS: success, FLASH_ERROR_INVALID_ADDRESS: address error *******************************************************************/ uint8_t flash_read_data(uint32_t address, uint32_t *data, uint16_t length); /******************************************************************* * Function Nume: flash_erase_data * Descriptions : erase flash data * In Para : address: address to access(align=2), length: length to be erased(4 integer multiple) * In-Out Para : none * Out Para : none * Return Value : FLASH_SUCCESS: success, FLASH_ERROR_INVALID_ADDRESS: address error *******************************************************************/ uint8_t flash_erase_data(uint32_t address, uint16_t length); #endif //NRF_FLASH_H__