nvm.h
Go to the documentation of this file.00001
00015 #ifndef __NVM_H
00016 #define __NVM_H
00017
00018 #include <stdint.h>
00019 #include <stdbool.h>
00020 #include "em_device.h"
00021 #include "nvm_hal.h"
00022 #include "nvm_config.h"
00023 #include "ecode.h"
00024
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028
00029
00034
00042
00043
00044
00045
00047 #define ECODE_EMDRV_NVM_OK ( ECODE_OK ) ///< Success return value
00048 #define ECODE_EMDRV_NVM_ADDR_INVALID ( ECODE_EMDRV_SPIDRV_BASE | 0x00000001 ) ///< Invalid address
00049 #define ECODE_EMDRV_NVM_ALIGNMENT_INVALID ( ECODE_EMDRV_SPIDRV_BASE | 0x00000002 ) ///< Invalid data alignment
00050 #define ECODE_EMDRV_NVM_DATA_INVALID ( ECODE_EMDRV_SPIDRV_BASE | 0x00000003 ) ///< Invalid input data or format
00051 #define ECODE_EMDRV_NVM_WRITE_LOCK ( ECODE_EMDRV_SPIDRV_BASE | 0x00000004 ) ///< A write is currently in progress
00052 #define ECODE_EMDRV_NVM_NO_PAGES_AVAILABLE ( ECODE_EMDRV_SPIDRV_BASE | 0x00000005 ) ///< Initialization didn't find any pages available to allocate
00053 #define ECODE_EMDRV_NVM_PAGE_INVALID ( ECODE_EMDRV_SPIDRV_BASE | 0x00000006 ) ///< Could not find the page specified
00054 #define ECODE_EMDRV_NVM_ERROR ( ECODE_EMDRV_SPIDRV_BASE | 0x00000007 ) ///< General error
00055
00057 #define NVM_WRITE_ALL_CMD 0xff
00058
00059 #define NVM_WRITE_NONE_CMD 0xfe
00060
00061 #define NVM_READ_ALL_CMD 0xff
00062
00064 #define NVM_ERASE_RETAINCOUNT 0xffffffffUL
00065
00067 #define NVM_PAGE_TERMINATION { NULL, 0, (NVM_Object_Ids) 0 }
00068
00069
00070
00071
00072
00073
00074 Ecode_t NVM_Init(NVM_Config_t const *nvmConfig);
00075 Ecode_t NVM_Erase(uint32_t erasureCount);
00076 Ecode_t NVM_Write(uint16_t pageId, uint8_t objectId);
00077 Ecode_t NVM_Read(uint16_t pageId, uint8_t objectId);
00078
00080 #ifndef NVM_FEATURE_WEARLEVELGET_ENABLED
00081 #define NVM_FEATURE_WEARLEVELGET_ENABLED true
00082 #endif
00083
00084 #if (NVM_FEATURE_WEARLEVELGET_ENABLED == true)
00085 uint32_t NVM_WearLevelGet(void);
00086 #endif
00087
00091 #ifdef __cplusplus
00092 }
00093 #endif
00094
00095 #endif