nvs.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * \file nvs.h
  3. *
  4. *
  5. */
  6. /*
  7. * Copyright (C) 2013. Mindtree Limited.
  8. * All rights reserved.
  9. */
  10. #ifndef _H_NVS_
  11. #define _H_NVS_
  12. /* --------------------------------------------- Header File Inclusion */
  13. #include "EM_os.h"
  14. /* --------------------------------------------- Global Definitions */
  15. /** NVS Bank types */
  16. #define NVS_BANK_PERSISTENT 0
  17. #define NVS_NUM_BANKS 1
  18. /** NVS Access modes */
  19. #define NVS_ACCESS_WRITE 0
  20. #define NVS_ACCESS_READ 1
  21. /** Bank size for the NVS in number of bytes */
  22. #define NVS_BLOCK_SIZE 4096
  23. #define NVS_NUM_BLOCKS 2
  24. /* NVS bank states */
  25. #define NVS_CLOSE 0x00
  26. #define NVS_WROPEN 0x01
  27. #define NVS_RDOPEN 0x02
  28. #define NVS_FLASH_BASE1 0x05000
  29. #define NVS_FLASH_BASE2 0x07000
  30. #define NVS_TOTAL_BASE 2
  31. #define NVS_FLASH_UNUSED 0x07
  32. #define NVS_FLASH_WRITING 0x03
  33. #define NVS_FLASH_READY 0x01
  34. #define NVS_FLASH_BAD 0x00
  35. #define NVS_FLASH_FIRST_OK 1
  36. #define NVS_FLASH_SECOND_OK 2
  37. #define NVS_FLASH_INVAILD 0xFF
  38. #define NVS_FLASH_SIZE MS_PS_RECORD_CORE_MODULES_OFFSET
  39. /* --------------------------------------------- Structures/Data Types */
  40. /* --------------------------------------------- Macros */
  41. /* --------------------------------------------- Internal Functions */
  42. /* --------------------------------------------- API Declarations */
  43. UINT16 nvs_init (UINT8 bank);
  44. void nvs_shutdown (UINT8 bank);
  45. void nvs_reset (UINT8 bank);
  46. INT8 nvs_open (UINT8 bank, UINT8 mode, UINT16 offset);
  47. INT8 nvs_close (UINT8 bank);
  48. INT16 nvs_write (UINT8 bank, void * buffer, UINT16 size);
  49. INT16 nvs_read (UINT8 bank, void * buffer, UINT16 size);
  50. INT16 nvs_seek(UINT8 bank, UINT32 offset);
  51. INT16 nvs_write_header (UINT8 bank,UINT32 svalue);
  52. INT16 nvs_read_crc16 (UINT8 bank, UINT16 * buffer, UINT16 size);
  53. INT16 nvs_erase (UINT8 bank);
  54. void nvs_test (void);
  55. #endif /* _H_NVS_ */