nrf_flash.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef NRF_FLASH_H__
  2. #define NRF_FLASH_H__
  3. #include <stdbool.h>
  4. #include <stdio.h>
  5. #include <stdint.h>
  6. #include "boards.h"
  7. #include "bsp.h"
  8. #ifndef FLASH_PAGE_SIZE
  9. #define FLASH_PAGE_SIZE 4096
  10. #endif
  11. #define FLASH_BASE_ADDRESS 0x6D000
  12. #define FLASH_SIZE (FLASH_PAGE_SIZE<<1)
  13. enum {
  14. WSYS_FLASH_OK = 0,
  15. WSYS_FLASH_INVALID_ADDRESS,
  16. WSYS_FLASH_INVALID_LENGTH
  17. };
  18. /*******************************************************************
  19. * Function Nume: flash_write_data
  20. * Descriptions : write data from flash
  21. * In Para : address: address to access(address must be word-aligned), length: length to be read(4 integer multiple)
  22. * In-Out Para : none
  23. * Out Para : data: data buffer to be read
  24. * Return Value : FLASH_SUCCESS: success, FLASH_ERROR_INVALID_ADDRESS: address error
  25. *******************************************************************/
  26. uint8_t flash_write_data(uint32_t address, uint8_t *data, uint16_t length);
  27. /*******************************************************************
  28. * Function Nume: flash_read_data
  29. * Descriptions : read data from flash
  30. * In Para : address: address to access(align=2), length: length to be read(4 integer multiple)
  31. * In-Out Para : none
  32. * Out Para : data: data buffer to be read
  33. * Return Value : FLASH_SUCCESS: success, FLASH_ERROR_INVALID_ADDRESS: address error
  34. *******************************************************************/
  35. uint8_t flash_read_data(uint32_t address, uint32_t *data, uint16_t length);
  36. /*******************************************************************
  37. * Function Nume: flash_erase_data
  38. * Descriptions : erase flash data
  39. * In Para : address: address to access(align=2), length: length to be erased(4 integer multiple)
  40. * In-Out Para : none
  41. * Out Para : none
  42. * Return Value : FLASH_SUCCESS: success, FLASH_ERROR_INVALID_ADDRESS: address error
  43. *******************************************************************/
  44. uint8_t flash_erase_data(uint32_t address, uint16_t length);
  45. #endif //NRF_FLASH_H__