2 * @brief LPC18xx/40xx EEPROM driver
5 * Copyright(C) NXP Semiconductors, 2012
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.
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
32 #ifndef EEPROM_18XX_43XX_H_
33 #define EEPROM_18XX_43XX_H_
39 /** @defgroup EEPROM_18XX_43XX CHIP: LPC18xx/40xx EEPROM Driver
40 * @ingroup CHIP_18XX_43XX_Drivers
43 /** EEPROM start address */
44 #define EEPROM_START (0x20040000)
45 /** EEPROM byes per page */
46 #define EEPROM_PAGE_SIZE (128)
47 /**The number of EEPROM pages. The last page is not writable.*/
48 #define EEPROM_PAGE_NUM (128)
49 /** Get the eeprom address */
50 #define EEPROM_ADDRESS(page, offset) (EEPROM_START + (EEPROM_PAGE_SIZE * (page)) + offset)
53 * @brief Initializes EEPROM
54 * @param pEEPROM : Pointer to EEPROM peripheral block structure
57 void Chip_EEPROM_Init(LPC_EEPROM_T *pEEPROM);
60 * @brief De-initializes EEPROM
61 * @param pEEPROM : Pointer to EEPROM peripheral block structure
64 STATIC INLINE void Chip_EEPROM_DeInit(LPC_EEPROM_T *pEEPROM)
66 IP_EEPROM_DeInit(pEEPROM);
70 * @brief Set Auto program mode
71 * @param pEEPROM : Pointer to EEPROM peripheral block structure
72 * @param mode : Auto Program Mode (One of EEPROM_AUTOPROG_* value)
75 STATIC INLINE void Chip_EEPROM_SetAutoProg(LPC_EEPROM_T *pEEPROM, uint32_t mode)
77 IP_EEPROM_SetAutoProg(pEEPROM, mode);
81 * @brief Set EEPROM Read Wait State
82 * @param pEEPROM : Pointer to EEPROM peripheral block structure
83 * @param ws : Wait State value
85 * @note Bits 7:0 represents wait state for Read Phase 2 and
\r
86 * Bits 15:8 represents wait state for Read Phase1
88 STATIC INLINE void Chip_EEPROM_SetReadWaitState(LPC_EEPROM_T *pEEPROM, uint32_t ws)
90 IP_EEPROM_SetReadWaitState(pEEPROM, ws);
94 * @brief Set EEPROM wait state
95 * @param pEEPROM : Pointer to EEPROM peripheral block structure
96 * @param ws : Wait State value
98 * @note Bits 7:0 represents wait state for Phase 3,
\r
99 * Bits 15:8 represents wait state for Phase2, and
\r
100 * Bits 23:16 represents wait state for Phase1
102 STATIC INLINE void Chip_EEPROM_SetWaitState(LPC_EEPROM_T *pEEPROM, uint32_t ws)
104 IP_EEPROM_SetWaitState(pEEPROM, ws);
108 * @brief Select an EEPROM command
109 * @param pEEPROM : Pointer to EEPROM peripheral block structure
110 * @param cmd : EEPROM command
112 * @note The cmd is OR-ed bits value of EEPROM_CMD_*
114 STATIC INLINE void Chip_EEPROM_SetCmd(LPC_EEPROM_T *pEEPROM, uint32_t cmd)
116 IP_EEPROM_SetCmd(pEEPROM, cmd);
120 * @brief Erase/Program an EEPROM page
121 * @param pEEPROM : Pointer to EEPROM peripheral block structure
124 STATIC INLINE void Chip_EEPROM_EraseProgramPage(LPC_EEPROM_T *pEEPROM)
126 IP_EEPROM_EraseProgramPage(pEEPROM);
130 * @brief Wait for interrupt occurs
131 * @param pEEPROM : Pointer to EEPROM peripheral block structure
132 * @param mask : Expected interrupt
135 STATIC INLINE void Chip_EEPROM_WaitForIntStatus(IP_EEPROM_002_T *pEEPROM, uint32_t mask)
137 IP_EEPROM_WaitForIntStatus(pEEPROM, mask);
141 * @brief Put EEPROM device in power down mode
142 * @param pEEPROM : Pointer to EEPROM peripheral block structure
145 STATIC INLINE void Chip_EEPROM_EnablePowerDown(LPC_EEPROM_T *pEEPROM)
147 IP_EEPROM_EnablePowerDown(pEEPROM);
151 * @brief Bring EEPROM device out of power down mode
152 * @param pEEPROM : Pointer to EEPROM peripheral block structure
155 STATIC INLINE void Chip_EEPROM_DisablePowerDown(LPC_EEPROM_T *pEEPROM)
157 IP_EEPROM_DisablePowerDown(pEEPROM);
161 * @brief Enable EEPROM interrupt
162 * @param pEEPROM : Pointer to EEPROM peripheral block structure
163 * @param mask : Interrupt mask (or-ed bits value of EEPROM_INT_*)
166 STATIC INLINE void Chip_EEPROM_EnableInt(LPC_EEPROM_T *pEEPROM, uint32_t mask)
168 IP_EEPROM_EnableInt(pEEPROM, mask);
172 * @brief Disable EEPROM interrupt
173 * @param pEEPROM : Pointer to EEPROM peripheral block structure
174 * @param mask : Interrupt mask (or-ed bits value of EEPROM_INT_*)
177 STATIC INLINE void Chip_EEPROM_DisableInt(LPC_EEPROM_T *pEEPROM, uint32_t mask)
179 IP_EEPROM_DisableInt(pEEPROM, mask);
183 * @brief Get the value of the EEPROM interrupt enable register
184 * @param pEEPROM : Pointer to EEPROM peripheral block structure
185 * @return OR-ed bits value of EEPROM_INT_*
187 STATIC INLINE uint32_t Chip_EEPROM_GetIntEnable(LPC_EEPROM_T *pEEPROM)
189 return IP_EEPROM_GetIntEnable(pEEPROM);
193 * @brief Get EEPROM interrupt status
194 * @param pEEPROM : Pointer to EEPROM peripheral block structure
195 * @return OR-ed bits value of EEPROM_INT_*
197 STATIC INLINE uint32_t Chip_EEPROM_GetIntStatus(LPC_EEPROM_T *pEEPROM)
199 return IP_EEPROM_GetIntStatus(pEEPROM);
203 * @brief Set EEPROM interrupt status
204 * @param pEEPROM : Pointer to EEPROM peripheral block structure
205 * @param mask : Interrupt mask (or-ed bits value of EEPROM_INT_*)
208 STATIC INLINE void Chip_EEPROM_SetIntStatus(LPC_EEPROM_T *pEEPROM, uint32_t mask)
210 IP_EEPROM_SetIntStatus(pEEPROM, mask);
214 * @brief Clear EEPROM interrupt status
215 * @param pEEPROM : Pointer to EEPROM peripheral block structure
216 * @param mask : Interrupt mask (or-ed bits value of EEPROM_INT_*)
219 STATIC INLINE void Chip_EEPROM_ClearIntStatus(LPC_EEPROM_T *pEEPROM, uint32_t mask)
221 IP_EEPROM_ClearIntStatus(pEEPROM, mask);
232 #endif /* EEPROM_18XX_43XX_H_ */