| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
eeprom_001.h
Go to the documentation of this file.
1 /*
2 * @brief EEPROM registers and driver functions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
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 licensor 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 __EEPROM_001_H_
33 #define __EEPROM_001_H_
34
35 #include "sys_config.h"
36 #include "cmsis.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
51 typedef struct { /* EEPROM Structure */
52 __IO uint32_t CMD;
53 __IO uint32_t ADDR;
54 __O uint32_t WDATA;
55 __I uint32_t RDATA;
56 __IO uint32_t WSTATE;
57 __IO uint32_t CLKDIV;
58 __IO uint32_t PWRDWN;
59 uint32_t RESERVED0[975];
60 __O uint32_t INTENCLR;
61 __O uint32_t INTENSET;
62 __I uint32_t INTSTAT;
63 __I uint32_t INTEN;
64 __O uint32_t INTSTATCLR;
65 __O uint32_t INTSTATSET;
66 } IP_EEPROM_001_T;
67
68 #define EEPROM_PAGE_SIZE 64
69 #define EEPROM_PAGE_NUM 63
71 /*
72 * @brief Macro defines for EEPROM command register
73 */
74 #define EEPROM_CMD_8BITS_READ (0)
75 #define EEPROM_CMD_16BITS_READ (1)
76 #define EEPROM_CMD_32BITS_READ (2)
77 #define EEPROM_CMD_8BITS_WRITE (3)
78 #define EEPROM_CMD_16BITS_WRITE (4)
79 #define EEPROM_CMD_32BITS_WRITE (5)
80 #define EEPROM_CMD_ERASE_PRG_PAGE (6)
81 #define EEPROM_CMD_RDPREFETCH (1 << 3)
83 /*
84 * @brief Macro defines for EEPROM power down register
85 */
86 #define EEPROM_PWRDWN (1 << 0)
87
88 /*
89 * @brief Macro defines for EEPROM interrupt related registers
90 */
91 #define EEPROM_INT_ENDOFRW (1 << 26)
92 #define EEPROM_INT_ENDOFPROG (1 << 28)
93
97 typedef enum IP_EEPROM_RWSIZE {
98 EEPROM_RWSIZE_8BITS = 1,
99 EEPROM_RWSIZE_16BITS = 2,
100 EEPROM_RWSIZE_32BITS = 4
101 } IP_EEPROM_RWSIZE_T;
102
113 STATIC INLINE void IP_EEPROM_SetCmd(IP_EEPROM_001_T *pEEPROM, uint32_t cmd)
114 {
115 pEEPROM->CMD = cmd;
116 }
117
125 STATIC INLINE void IP_EEPROM_SetAddr(IP_EEPROM_001_T *pEEPROM, uint32_t pageAddr, uint32_t pageOffset)
126 {
127 pEEPROM->ADDR = (pageAddr << 6) | pageOffset;
128 }
129
136 STATIC INLINE void IP_EEPROM_WriteData(IP_EEPROM_001_T *pEEPROM, uint32_t data)
137 {
138 pEEPROM->WDATA = data;
139 }
140
146 STATIC INLINE uint32_t IP_EEPROM_ReadData(IP_EEPROM_001_T *pEEPROM)
147 {
148 return pEEPROM->RDATA;
149 }
150
157 STATIC INLINE void IP_EEPROM_SetWaitState(IP_EEPROM_001_T *pEEPROM, uint32_t ws)
158 {
159 pEEPROM->WSTATE = ws;
160 }
161
167 STATIC INLINE void IP_EEPROM_EnablePowerDown(IP_EEPROM_001_T *pEEPROM)
168 {
169 pEEPROM->PWRDWN = EEPROM_PWRDWN;
170 }
171
178 STATIC INLINE void IP_EEPROM_DisablePowerDown(IP_EEPROM_001_T *pEEPROM)
179 {
180 pEEPROM->PWRDWN = 0;
181 }
182
189 STATIC INLINE void IP_EEPROM_EnableInt(IP_EEPROM_001_T *pEEPROM, uint32_t mask)
190 {
191 pEEPROM->INTENSET = mask;
192 }
193
200 STATIC INLINE void IP_EEPROM_DisableInt(IP_EEPROM_001_T *pEEPROM, uint32_t mask)
201 {
202 pEEPROM->INTENCLR = mask;
203 }
204
210 STATIC INLINE uint32_t IP_EEPROM_GetIntEnable(IP_EEPROM_001_T *pEEPROM)
211 {
212 return pEEPROM->INTEN;
213 }
214
220 STATIC INLINE uint32_t IP_EEPROM_GetIntStatus(IP_EEPROM_001_T *pEEPROM)
221 {
222 return pEEPROM->INTSTAT;
223 }
224
231 STATIC INLINE void IP_EEPROM_SetIntStatus(IP_EEPROM_001_T *pEEPROM, uint32_t mask)
232 {
233 pEEPROM->INTSTATSET = mask;
234 }
235
242 STATIC INLINE void IP_EEPROM_ClearIntStatus(IP_EEPROM_001_T *pEEPROM, uint32_t mask)
243 {
244 pEEPROM->INTSTATCLR = mask;
245 }
246
253 void IP_EEPROM_Init(IP_EEPROM_001_T *pEEPROM, uint32_t div);
254
260 STATIC INLINE void IP_EEPROM_DeInit(IP_EEPROM_001_T *pEEPROM)
261 {
262 /* Enable EEPROM power down mode */
263 IP_EEPROM_EnablePowerDown(pEEPROM);
264 }
265
271 void IP_EEPROM_ErasePageRegister(IP_EEPROM_001_T *pEEPROM);
272
283 uint32_t IP_EEPROM_WritePageRegister(IP_EEPROM_001_T *pEEPROM, uint16_t pageOffset,
284 uint8_t *pData, uint8_t wsize, uint32_t byteNum);
285
297 uint32_t IP_EEPROM_ReadPage(IP_EEPROM_001_T *pEEPROM,
298 uint16_t pageOffset,
299 uint16_t pageAddr,
300 uint8_t *pData,
301 uint8_t rsize,
302 uint32_t byteNum);
303
310 void IP_EEPROM_EraseProgramPage(IP_EEPROM_001_T *pEEPROM, uint16_t pageAddr);
311
318 void IP_EEPROM_WaitForIntStatus(IP_EEPROM_001_T *pEEPROM, uint32_t mask);
319
336 Status IP_EEPROM_Write(IP_EEPROM_001_T *pEEPROM,
337 uint16_t pageOffset,
338 uint16_t pageAddr,
339 void *pData,
340 IP_EEPROM_RWSIZE_T wsize,
341 uint32_t byteNum);
342
357 Status IP_EEPROM_Read(IP_EEPROM_001_T *pEEPROM,
358 uint16_t pageOffset,
359 uint16_t pageAddr,
360 void *pData,
361 IP_EEPROM_RWSIZE_T rsize,
362 uint32_t byteNum);
363
370 void IP_EEPROM_Erase(IP_EEPROM_001_T *pEEPROM, uint16_t pageAddr);
371
376 #ifdef __cplusplus
377 }
378 #endif
379
380 #endif /* __EEPROM_001_H_ */