LPCOpen Platform for LPC18XX/43XX microcontrollers  18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
spifilib_api.h
Go to the documentation of this file.
1 /*
2  * @brief LPCSPIFILIB driver definitions and functions
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2014
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licenser disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef __SPIFILIB_API_H_
33 #define __SPIFILIB_API_H_
34 
35 #include "spifilib_dev.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
59 uint16_t spifiGetLibVersion(void);
60 
73 SPIFI_ERR_T spifiInit(uint32_t spifiCtrlAddr, uint8_t reset);
74 
83 
89 const char *spifiReturnErrString(SPIFI_ERR_T errCode);
90 
95 uint32_t spifiGetSuppFamilyCount(void);
96 
105 const char *spifiGetSuppFamilyName(uint32_t index);
106 
114 uint32_t spifiGetHandleMemSize(uint32_t spifiCtrlAddr);
115 
124 SPIFI_HANDLE_T *spifiInitDevice(void *pMem, uint32_t sizePMem, uint32_t spifiCtrlAddr, uint32_t baseAddr);
125 
136 SPIFI_ERR_T spifiDevSetOpts(SPIFI_HANDLE_T *pHandle, uint32_t options, uint8_t set);
137 
155 
161 static INLINE uint32_t spifiDevGetCount(const SPIFI_FAM_NODE_T *pFamily)
162 {
163  return *(pFamily->pDesc->pDevCount);
164 }
165 
172 const char *spifiDevEnumerateName(SPIFI_DEV_ENUMERATOR_T *pContext, uint8_t reset);
173 
179 SPIFI_ERR_T spifiDevInit(const SPIFI_HANDLE_T *pHandle);
180 
187 
197 SPIFI_ERR_T spifiDevSetMemMode(const SPIFI_HANDLE_T *pHandle, uint8_t enMMode);
198 
204 uint8_t spifiDevGetMemoryMode(const SPIFI_HANDLE_T *pSpifi);
205 
212 {
213  return pHandle->pFamFx->lockCmd(pHandle, SPIFI_PCMD_UNLOCK_DEVICE, 0);
214 }
215 
222 {
223  return pHandle->pFamFx->lockCmd(pHandle, SPIFI_PCMD_LOCK_DEVICE, 0);
224 }
225 
232 static INLINE SPIFI_ERR_T spifiDevUnlockBlock(const SPIFI_HANDLE_T *pHandle, uint32_t block)
233 {
234  return pHandle->pFamFx->lockCmd(pHandle, SPIFI_PCMD_UNLOCK_BLOCK, block);
235 }
236 
243 static INLINE SPIFI_ERR_T spifiDevLockBlock(const SPIFI_HANDLE_T *pHandle, uint32_t block)
244 {
245  return pHandle->pFamFx->lockCmd(pHandle, SPIFI_PCMD_LOCK_BLOCK, block);
246 }
247 
254 {
255  return pHandle->pFamFx->eraseAll(pHandle);
256 }
257 
264 static INLINE SPIFI_ERR_T spifiDevEraseSubBlock(const SPIFI_HANDLE_T *pHandle, uint32_t blknum)
265 {
266  return pHandle->pFamFx->eraseSubBlock(pHandle, blknum);
267 }
268 
279  uint32_t addr,
280  uint32_t *writeBuff,
281  uint32_t bytes)
282 {
283  return pHandle->pFamFx->pageProgram(pHandle, addr, writeBuff, bytes);
284 }
285 
295 static INLINE SPIFI_ERR_T spifiDevRead(const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes)
296 {
297  return pHandle->pFamFx->read(pHandle, addr, readBuff, bytes);
298 }
299 
306 static INLINE void spifiDevReset(const SPIFI_HANDLE_T *pHandle)
307 {
308  pHandle->pFamFx->reset(pHandle);
309 }
310 
316 static INLINE const char *spifiDevGetDeviceName(const SPIFI_HANDLE_T *pHandle)
317 {
318  return pHandle->pInfoData->pDevName;
319 }
320 
321 #define spifiDevGetFamilyName spifiDevGetDeviceName
329 uint32_t spifiDevGetInfo(const SPIFI_HANDLE_T *pHandle, SPIFI_INFO_ID_T infoId);
330 
345 uint32_t spifiGetAddrFromBlock(const SPIFI_HANDLE_T *pHandle, uint32_t blockNum);
346 
353 uint32_t spifiGetAddrFromSubBlock(const SPIFI_HANDLE_T *pHandle, uint32_t subBlockNum);
354 
361 uint32_t spifiGetBlockFromAddr(const SPIFI_HANDLE_T *pHandle, uint32_t addr);
362 
369 uint32_t spifiGetSubBlockFromAddr(const SPIFI_HANDLE_T *pHandle, uint32_t addr);
370 
377 uint32_t spifiGetSubBlockFromBlock(const SPIFI_HANDLE_T *pHandle, uint32_t blockNum);
378 
388 SPIFI_ERR_T spifiProgram(const SPIFI_HANDLE_T *pHandle, uint32_t addr, const uint32_t *writeBuff, uint32_t bytes);
389 
401 SPIFI_ERR_T spifiRead(const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes);
402 
412 SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint32_t numBlocks);
413 
424 SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr);
425 
434 #ifdef __cplusplus
435 }
436 #endif
437 
438 #endif /* __SPIFILIB_API_H_ */