LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 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;
59  uint32_t RESERVED0[975];
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 {
102 
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 
137 {
138  pEEPROM->WDATA = data;
139 }
140 
147 {
148  return pEEPROM->RDATA;
149 }
150 
158 {
159  pEEPROM->WSTATE = ws;
160 }
161 
168 {
169  pEEPROM->PWRDWN = EEPROM_PWRDWN;
170 }
171 
179 {
180  pEEPROM->PWRDWN = 0;
181 }
182 
190 {
191  pEEPROM->INTENSET = mask;
192 }
193 
201 {
202  pEEPROM->INTENCLR = mask;
203 }
204 
211 {
212  return pEEPROM->INTEN;
213 }
214 
221 {
222  return pEEPROM->INTSTAT;
223 }
224 
232 {
233  pEEPROM->INTSTATSET = mask;
234 }
235 
243 {
244  pEEPROM->INTSTATCLR = mask;
245 }
246 
253 void IP_EEPROM_Init(IP_EEPROM_001_T *pEEPROM, uint32_t div);
254 
261 {
262  /* Enable EEPROM power down mode */
263  IP_EEPROM_EnablePowerDown(pEEPROM);
264 }
265 
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 
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 
319 
337  uint16_t pageOffset,
338  uint16_t pageAddr,
339  void *pData,
340  IP_EEPROM_RWSIZE_T wsize,
341  uint32_t byteNum);
342 
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_ */