ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_flash.h
1 
18 #ifndef ADI_FLASH_H
19 #define ADI_FLASH_H
20 
22 #include <adi_processor.h>
23 #include <adi_callback.h>
24 #include <rtos_map/adi_rtos_map.h> /* for ADI_SEM_SIZE */
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 
35  typedef enum {
55 
56 
58 typedef struct __ADI_FEE_DEV_DATA_TYPE* ADI_FEE_HANDLE;
59 
60 
66 #define ADI_FEE_MEMORY_SIZE (44u + ADI_SEM_SIZE)
67 
69 #define ADI_FEE_NUM_INSTANCES (1u)
70 
71 #if defined (__ADUCM4x50__)
72 #define FEE_FLASH_SIZE (0x80000u)
73 #define FEE_BLOCK_SHIFT (14u)
74 #elif defined (__ADUCM302x__)
75 #define FEE_FLASH_SIZE (0x40000u)
76 #define FEE_BLOCK_SHIFT (13u)
77 #else
78 #error processor not supported
79 #endif
80 
97 #define FEE_PAGE_SHIFT (11u)
98 #define FEE_MAX_NUM_PAGES (FEE_FLASH_SIZE >> FEE_PAGE_SHIFT)
99 #define FEE_MAX_NUM_BLOCKS (FEE_FLASH_SIZE >> FEE_BLOCK_SHIFT)
106 typedef enum {
110 
115 typedef enum {
119 
124 typedef enum {
129 
130 
135 typedef struct {
136  uint32_t *pWriteAddr;
137  uint32_t *pWriteData;
138  uint32_t nSize;
139  bool bUseDma;
141 
142 
143 /*================ E X T E R N A L S ==================*/
144 /* Flash Controller API */
145 
146 ADI_FEE_RESULT adi_fee_Open (uint32_t const nDeviceNum, void* const pMemory, uint32_t const nMemorySize, ADI_FEE_HANDLE* const phDevice);
148 ADI_FEE_RESULT adi_fee_RegisterCallback (ADI_FEE_HANDLE const hDevice, ADI_CALLBACK const pfCallback, void* const pCBParam);
149 
150 ADI_FEE_RESULT adi_fee_PageErase (ADI_FEE_HANDLE const hDevice, uint32_t const nPageNumStart, uint32_t const nPageNumEnd, uint32_t* const pHwErrors);
151 ADI_FEE_RESULT adi_fee_MassErase (ADI_FEE_HANDLE const hDevice, uint32_t* const pHwErrors);
152 
153 ADI_FEE_RESULT adi_fee_Write (ADI_FEE_HANDLE const hDevice, ADI_FEE_TRANSACTION* const pTransaction, uint32_t* const pHwErrors);
154 ADI_FEE_RESULT adi_fee_SubmitBuffer (ADI_FEE_HANDLE const hDevice, ADI_FEE_TRANSACTION* const pTransaction);
155 
156 ADI_FEE_RESULT adi_fee_IsBufferAvailable (ADI_FEE_HANDLE const hDevice, bool* const pbCompletionState);
157 ADI_FEE_RESULT adi_fee_GetBuffer (ADI_FEE_HANDLE const hDevice, uint32_t* const pHwErrors);
158 
159 ADI_FEE_RESULT adi_fee_GetPageNumber (ADI_FEE_HANDLE const hDevice, uint32_t const nAddress, uint32_t* const pnPageNum);
160 ADI_FEE_RESULT adi_fee_GetBlockNumber (ADI_FEE_HANDLE const hDevice, uint32_t const nAddress, uint32_t* const pnBlockNum);
161 
162 ADI_FEE_RESULT adi_fee_VerifySignature (ADI_FEE_HANDLE const hDevice, uint32_t const nStartPage, uint32_t const nEndPage, uint32_t* const pSigResult, uint32_t* const pHwErrors);
163 ADI_FEE_RESULT adi_fee_WriteProtectBlock (ADI_FEE_HANDLE const hDevice, uint32_t const nBlockNum);
164 
165 ADI_FEE_RESULT adi_fee_Sleep (ADI_FEE_HANDLE const hDevice, bool const bSleep);
167 ADI_FEE_RESULT adi_fee_GetAbortAddr (ADI_FEE_HANDLE const hDevice, uint32_t* const pnAddress);
168 
169 ADI_FEE_RESULT adi_fee_ConfigECC (ADI_FEE_HANDLE const hDevice, uint32_t const nStartPage, bool const bInfoECCEnable);
170 ADI_FEE_RESULT adi_fee_EnableECC (ADI_FEE_HANDLE const hDevice, bool const bEnable);
172 ADI_FEE_RESULT adi_fee_GetECCErrAddr (ADI_FEE_HANDLE const hDevice, uint32_t* const pnAddress);
173 ADI_FEE_RESULT adi_fee_GetECCCorrections (ADI_FEE_HANDLE const hDevice, uint32_t* const pnNumCorrections);
174 
175 #if defined (__ADUCM4x50__)
176 ADI_FEE_RESULT adi_fee_ConfigureWaitStates (ADI_FEE_HANDLE const hDevice, uint8_t numWaitStates);
177 #endif
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* include guard */
184 
185 /*
186 ** EOF
187 */
188 
ADI_FEE_RESULT adi_fee_GetBuffer(ADI_FEE_HANDLE const hDevice, uint32_t *const pHwErrors)
Blocking mode call to await transaction completion.
Definition: adi_flash.c:828
ADI_FEE_RESULT adi_fee_IsBufferAvailable(ADI_FEE_HANDLE const hDevice, bool *const pbCompletionState)
Non-blocking check if a write transaction complete.
Definition: adi_flash.c:773
ADI_FEE_RESULT adi_fee_GetECCCorrections(ADI_FEE_HANDLE const hDevice, uint32_t *const pnNumCorrections)
Get the number of 1-bit error corrections.
Definition: adi_flash.c:1454
ADI_FEE_RESULT adi_fee_MassErase(ADI_FEE_HANDLE const hDevice, uint32_t *const pHwErrors)
Erase the entire flash user space memory. This is a blocking call.
Definition: adi_flash.c:540
ADI_FEE_RESULT adi_fee_GetBlockNumber(ADI_FEE_HANDLE const hDevice, uint32_t const nAddress, uint32_t *const pnBlockNum)
Get the zero-based (16kB) block number within which a flash address resides.
Definition: adi_flash.c:927
ADI_FEE_ECC_EVENT_TYPE
Definition: adi_flash.h:115
ADI_FEE_RESULT adi_fee_GetECCErrAddr(ADI_FEE_HANDLE const hDevice, uint32_t *const pnAddress)
Get the address for which the ECC event is detected.
Definition: adi_flash.c:1416
ADI_FEE_RESULT adi_fee_GetAbortAddr(ADI_FEE_HANDLE const hDevice, uint32_t *const pnAddress)
Get the address of recently aborted write command.
Definition: adi_flash.c:1191
ADI_FEE_RESULT adi_fee_Sleep(ADI_FEE_HANDLE const hDevice, bool const bSleep)
Sleep or awake the flash controller. This is a blocking call.
Definition: adi_flash.c:1109
ADI_FEE_RESULT adi_fee_ConfigECC(ADI_FEE_HANDLE const hDevice, uint32_t const nStartPage, bool const bInfoECCEnable)
Configure ECC start page and enablement.
Definition: adi_flash.c:1238
struct __ADI_FEE_DEV_DATA_TYPE * ADI_FEE_HANDLE
Definition: adi_flash.h:58
ADI_FEE_RESULT adi_fee_Open(uint32_t const nDeviceNum, void *const pMemory, uint32_t const nMemorySize, ADI_FEE_HANDLE *const phDevice)
Open the flash controller.
Definition: adi_flash.c:199
ADI_FEE_RESULT adi_fee_ConfigECCEvents(ADI_FEE_HANDLE const hDevice, ADI_FEE_ECC_EVENT_TYPE const eEvent, ADI_FEE_ECC_RESPONSE const eResponse)
Confifure ECC event response.
Definition: adi_flash.c:1346
ADI_FEE_RESULT adi_fee_WriteProtectBlock(ADI_FEE_HANDLE const hDevice, uint32_t const nBlockNum)
Set write protection on an (16kB) block.
Definition: adi_flash.c:1064
ADI_FEE_CALLBACK_EVENT
Definition: adi_flash.h:106
ADI_FEE_RESULT adi_fee_Write(ADI_FEE_HANDLE const hDevice, ADI_FEE_TRANSACTION *const pTransaction, uint32_t *const pHwErrors)
Perform a blocking flash data write operation.
Definition: adi_flash.c:606
ADI_FEE_ECC_RESPONSE
Definition: adi_flash.h:124
ADI_FEE_RESULT adi_fee_EnableECC(ADI_FEE_HANDLE const hDevice, bool const bEnable)
Enable/Disable user space ECC for the device.
Definition: adi_flash.c:1296
ADI_FEE_RESULT adi_fee_ConfigureWaitStates(ADI_FEE_HANDLE const hDevice, uint8_t numWaitStates)
Configure the flash wait states.
Definition: adi_flash.c:352
ADI_FEE_RESULT
Definition: adi_flash.h:35
ADI_FEE_RESULT adi_fee_RegisterCallback(ADI_FEE_HANDLE const hDevice, ADI_CALLBACK const pfCallback, void *const pCBParam)
Register an application-defined callback function.
Definition: adi_flash.c:407
uint32_t * pWriteAddr
Definition: adi_flash.h:136
ADI_FEE_RESULT adi_fee_SubmitBuffer(ADI_FEE_HANDLE const hDevice, ADI_FEE_TRANSACTION *const pTransaction)
Submit a non-blocking flash data write operation for background processing.
Definition: adi_flash.c:705
ADI_FEE_RESULT adi_fee_GetPageNumber(ADI_FEE_HANDLE const hDevice, uint32_t const nAddress, uint32_t *const pnPageNum)
Get the zero-based (2kB) page number within which a flash address resides.
Definition: adi_flash.c:887
uint32_t * pWriteData
Definition: adi_flash.h:137
ADI_FEE_RESULT adi_fee_Abort(ADI_FEE_HANDLE const hDevice)
Forcefully ABORT an ongoing flash operation. This is a blocking call.
Definition: adi_flash.c:1154
ADI_FEE_RESULT adi_fee_VerifySignature(ADI_FEE_HANDLE const hDevice, uint32_t const nStartPage, uint32_t const nEndPage, uint32_t *const pSigResult, uint32_t *const pHwErrors)
Generate the CRC signature for a range of flash data page(s). This is a blocking call.
Definition: adi_flash.c:979
ADI_FEE_RESULT adi_fee_PageErase(ADI_FEE_HANDLE const hDevice, uint32_t const nPageNumStart, uint32_t const nPageNumEnd, uint32_t *const pHwErrors)
Erase the given range of (2kB) page(s) within the flash user space memory. This is a blocking call.
Definition: adi_flash.c:458
ADI_FEE_RESULT adi_fee_Close(ADI_FEE_HANDLE const hDevice)
Close the flash controller.
Definition: adi_flash.c:311