1 //***************************************************************************** 2 // 3 // eeprom.h - Prototypes for the EEPROM driver. 4 // 5 // Copyright (c) 2010-2012 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions 10 // are met: 11 // 12 // Redistributions of source code must retain the above copyright 13 // notice, this list of conditions and the following disclaimer. 14 // 15 // Redistributions in binary form must reproduce the above copyright 16 // notice, this list of conditions and the following disclaimer in the 17 // documentation and/or other materials provided with the 18 // distribution. 19 // 20 // Neither the name of Texas Instruments Incorporated nor the names of 21 // its contributors may be used to endorse or promote products derived 22 // from this software without specific prior written permission. 23 // 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 // 36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library. 37 // 38 //***************************************************************************** 39 40 #ifndef __EEPROM_H__ 41 #define __EEPROM_H__ 42 43 //***************************************************************************** 44 // 45 // If building with a C++ compiler, make all of the definitions in this header 46 // have a C binding. 47 // 48 //***************************************************************************** 49 #ifdef __cplusplus 50 extern "C" 51 { 52 #endif 53 54 //***************************************************************************** 55 // 56 //! \addtogroup eeprom_api 57 //! @{ 58 // 59 //***************************************************************************** 60 61 //***************************************************************************** 62 // 63 // Values returned by EEPROMInit. 64 // 65 //***************************************************************************** 66 67 // 68 //! This value may be returned from a call to EEPROMInit(). It indicates that 69 //! no previous write operations were interrupted by a reset event and that the 70 //! EEPROM peripheral is ready for use. 71 // 72 #define EEPROM_INIT_OK 0 73 74 // 75 //! This value may be returned from a call to EEPROMInit(). It indicates that 76 //! a previous data or protection write operation was interrupted by a reset 77 //! event. The EEPROM peripheral has recovered its state but the last write 78 //! operation may have been lost. The application must check the validity of 79 //! data it has written and retry any writes as required. 80 // 81 #define EEPROM_INIT_RETRY 1 82 83 // 84 //! This value may be returned from a call to EEPROMInit(). It indicates that a 85 //! previous data or protection write operation was interrupted by a reset 86 //! event and that the EEPROM peripheral was unable to clean up after the 87 //! problem. This situation may be resolved with another reset or may be fatal 88 //! depending upon the cause of the problem. For example, if the voltage to 89 //! the part is unstable, retrying once the voltage has stabilized may clear 90 //! the error. 91 // 92 #define EEPROM_INIT_ERROR 2 93 94 //***************************************************************************** 95 // 96 // Error indicators returned by various EEPROM API calls. These will be ORed 97 // together into the final return code. 98 // 99 //***************************************************************************** 100 101 // 102 //! This return code bit indicates that the EEPROM programming state machine 103 //! failed to write a value due to the voltage level dropping below that 104 //! required for EEPROM programming. The operation may be retried once the 105 //! voltage stabilizes. 106 // 107 #define EEPROM_RC_INVPL 0x00000100 108 109 // 110 //! This return code bit indicates that an attempt was made to read from 111 //! the EEPROM while a write operation was in progress. 112 // 113 #define EEPROM_RC_WRBUSY 0x00000020 114 115 // 116 //! This return code bit indicates that an attempt was made to write a 117 //! value but the destination permissions disallow write operations. This 118 //! may be due to the destination block being locked, access protection set 119 //! to prohibit writes or an attempt to write a password when one is already 120 //! written. 121 // 122 #define EEPROM_RC_NOPERM 0x00000010 123 124 // 125 //! This return code bit indicates that the EEPROM programming state machine 126 //! is currently copying to or from the internal copy buffer to make room for 127 //! a newly written value. It is provided as a status indicator and does not 128 //! indicate an error. 129 // 130 #define EEPROM_RC_WKCOPY 0x00000008 131 132 // 133 //! This return code bit indicates that the EEPROM programming state machine 134 //! is currently erasing the internal copy buffer. It is provided as a 135 //! status indicator and does not indicate an error. 136 // 137 #define EEPROM_RC_WKERASE 0x00000004 138 139 // 140 //! This return code bit indicates that the EEPROM programming state machine 141 //! is currently working. No new write operations should be attempted until 142 //! this bit is clear. 143 // 144 #define EEPROM_RC_WORKING 0x00000001 145 146 //***************************************************************************** 147 // 148 // Values that can be passed to EEPROMBlockProtectSet() in the ulProtect 149 // parameter, and returned by EEPROMBlockProtectGet(). 150 // 151 //***************************************************************************** 152 153 // 154 //! This bit may be ORed with the protection option passed to 155 //! EEPROMBlockProtectSet() or returned from EEPROMBlockProtectGet(). It 156 //! restricts EEPROM access to threads running in supervisor mode and prevents 157 //! access to an EEPROM block when the CPU is in user mode. 158 // 159 #define EEPROM_PROT_SUPERVISOR_ONLY 0x00000008 160 161 // 162 //! This value may be passed to EEPROMBlockProtectSet() or returned from 163 //! EEPROMBlockProtectGet(). It indicates that the block should offer 164 //! read/write access when no password is set or when a password is set and 165 //! the block is unlocked, and read-only access when a password is set but 166 //! the block is locked. 167 // 168 #define EEPROM_PROT_RW_LRO_URW 0x00000000 169 170 // 171 //! This value may be passed to EEPROMBlockProtectSet() or returned from 172 //! EEPROMBlockProtectGet(). It indicates that the block should offer neither 173 //! read nor write access unless it is protected by a password and unlocked. 174 // 175 #define EEPROM_PROT_NA_LNA_URW 0x00000001 176 177 // 178 //! This value may be passed to EEPROMBlockProtectSet() or returned from 179 //! EEPROMBlockProtectGet(). It indicates that the block should offer 180 //! read-only access when no password is set or when a password is set and the 181 //! block is unlocked. When a password is set and the block is locked, neither 182 //! read nor write access is permitted. 183 // 184 #define EEPROM_PROT_RO_LNA_URO 0x00000002 185 186 //***************************************************************************** 187 // 188 //! This value may be passed to EEPROMIntEnable() and EEPROMIntDisable() and is 189 //! returned by EEPROMIntStatus() if an EEPROM interrupt is currently being 190 //! signaled. 191 // 192 //***************************************************************************** 193 #define EEPROM_INT_PROGRAM 0x00000004 194 195 //***************************************************************************** 196 // 197 //! Returns the EEPROM block number containing a given offset address. 198 //! 199 //! \param ulAddr is the linear, byte address of the EEPROM location whose 200 //! block number is to be returned. This is a zero-based offset from the start 201 //! of the EEPROM storage. 202 //! 203 //! This macro may be used to translate an EEPROM address offset into a 204 //! block number suitable for use in any of the driver's block protection 205 //! functions. The address provided is expressed as a byte offset from the 206 //! base of the EEPROM. 207 //! 208 //! \return Returns the zero-based block number which contains the passed 209 //! address. 210 // 211 //***************************************************************************** 212 #define EEPROMBlockFromAddr(ulAddr) ((ulAddr) >> 6) 213 214 //***************************************************************************** 215 // 216 //! Returns the offset address of the first word in an EEPROM block. 217 //! 218 //! \param ulBlock is the index of the EEPROM block whose first word address 219 //! is to be returned. 220 //! 221 //! This macro may be used to determine the address of the first word in a 222 //! given EEPROM block. The address returned is expressed as a byte offset 223 //! from the base of EEPROM storage. 224 //! 225 //! \return Returns the address of the first word in the given EEPROM block. 226 // 227 //***************************************************************************** 228 #define EEPROMAddrFromBlock(ulBlock) ((ulBlock) << 6) 229 230 //***************************************************************************** 231 // 232 // Prototypes for the APIs. 233 // 234 //***************************************************************************** 235 extern unsigned long EEPROMInit(void); 236 extern unsigned long EEPROMSizeGet(void); 237 extern unsigned long EEPROMBlockCountGet(void); 238 extern void EEPROMRead(unsigned long *pulData, unsigned long ulAddress, 239 unsigned long ulCount); 240 extern unsigned long EEPROMProgram(unsigned long *pulData, 241 unsigned long ulAddress, 242 unsigned long ulCount); 243 extern unsigned long EEPROMProgramNonBlocking(unsigned long ulData, 244 unsigned long ulAddress); 245 extern unsigned long EEPROMStatusGet(void); 246 extern unsigned long EEPROMMassErase(void); 247 extern unsigned long EEPROMBlockProtectGet(unsigned long ulBlock); 248 extern unsigned long EEPROMBlockProtectSet(unsigned long ulBlock, 249 unsigned long ulProtect); 250 extern unsigned long EEPROMBlockPasswordSet(unsigned long ulBlock, 251 unsigned long *pulPassword, 252 unsigned long ulCount); 253 extern unsigned long EEPROMBlockLock(unsigned long ulBlock); 254 extern unsigned long EEPROMBlockUnlock(unsigned long ulBlock, 255 unsigned long *pulPassword, 256 unsigned long ulCount); 257 extern void EEPROMBlockHide(unsigned long ulBlock); 258 extern void EEPROMIntEnable(unsigned long ulIntFlags); 259 extern void EEPROMIntDisable(unsigned long ulIntFlags); 260 extern unsigned long EEPROMIntStatus(tBoolean bMasked); 261 extern void EEPROMIntClear(unsigned long ulIntFlags); 262 263 //***************************************************************************** 264 // 265 // Close the Doxygen group. 266 //! @} 267 // 268 //***************************************************************************** 269 270 //***************************************************************************** 271 // 272 // Mark the end of the C bindings section for C++ compilers. 273 // 274 //***************************************************************************** 275 #ifdef __cplusplus 276 } 277 #endif 278 279 #endif // __EEPROM_H__ 280