eeprom.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. //*****************************************************************************
  2. //
  3. // eeprom.h - Prototypes for the EEPROM driver.
  4. //
  5. // Copyright (c) 2010-2014 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 2.1.0.12573 of the Tiva Peripheral Driver Library.
  37. //
  38. //*****************************************************************************
  39. #ifndef __DRIVERLIB_EEPROM_H__
  40. #define __DRIVERLIB_EEPROM_H__
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. //! \addtogroup eeprom_api
  54. //! @{
  55. //
  56. //*****************************************************************************
  57. //*****************************************************************************
  58. //
  59. // Values returned by EEPROMInit.
  60. //
  61. //*****************************************************************************
  62. //
  63. //! This value may be returned from a call to EEPROMInit(). It indicates that
  64. //! no previous write operations were interrupted by a reset event and that the
  65. //! EEPROM peripheral is ready for use.
  66. //
  67. #define EEPROM_INIT_OK 0
  68. //
  69. //! This value may be returned from a call to EEPROMInit(). It indicates that
  70. //! a previous data or protection write operation was interrupted by a reset
  71. //! event and that the EEPROM peripheral was unable to clean up after the
  72. //! problem. This situation may be resolved with another reset or may be fatal
  73. //! depending upon the cause of the problem. For example, if the voltage to
  74. //! the part is unstable, retrying once the voltage has stabilized may clear
  75. //! the error.
  76. //
  77. #define EEPROM_INIT_ERROR 2
  78. //*****************************************************************************
  79. //
  80. // Error indicators returned by various EEPROM API calls. These will be ORed
  81. // together into the final return code.
  82. //
  83. //*****************************************************************************
  84. //
  85. //! This return code bit indicates that an attempt was made to read from
  86. //! the EEPROM while a write operation was in progress.
  87. //
  88. #define EEPROM_RC_WRBUSY 0x00000020
  89. //
  90. //! This return code bit indicates that an attempt was made to write a
  91. //! value but the destination permissions disallow write operations. This
  92. //! may be due to the destination block being locked, access protection set
  93. //! to prohibit writes or an attempt to write a password when one is already
  94. //! written.
  95. //
  96. #define EEPROM_RC_NOPERM 0x00000010
  97. //
  98. //! This return code bit indicates that the EEPROM programming state machine
  99. //! is currently copying to or from the internal copy buffer to make room for
  100. //! a newly written value. It is provided as a status indicator and does not
  101. //! indicate an error.
  102. //
  103. #define EEPROM_RC_WKCOPY 0x00000008
  104. //
  105. //! This return code bit indicates that the EEPROM programming state machine
  106. //! is currently erasing the internal copy buffer. It is provided as a
  107. //! status indicator and does not indicate an error.
  108. //
  109. #define EEPROM_RC_WKERASE 0x00000004
  110. //
  111. //! This return code bit indicates that the EEPROM programming state machine
  112. //! is currently working. No new write operations should be attempted until
  113. //! this bit is clear.
  114. //
  115. #define EEPROM_RC_WORKING 0x00000001
  116. //*****************************************************************************
  117. //
  118. // Values that can be passed to EEPROMBlockProtectSet() in the ui32Protect
  119. // parameter, and returned by EEPROMBlockProtectGet().
  120. //
  121. //*****************************************************************************
  122. //
  123. //! This bit may be ORed with the protection option passed to
  124. //! EEPROMBlockProtectSet() or returned from EEPROMBlockProtectGet(). It
  125. //! restricts EEPROM access to threads running in supervisor mode and prevents
  126. //! access to an EEPROM block when the CPU is in user mode.
  127. //
  128. #define EEPROM_PROT_SUPERVISOR_ONLY 0x00000008
  129. //
  130. //! This value may be passed to EEPROMBlockProtectSet() or returned from
  131. //! EEPROMBlockProtectGet(). It indicates that the block should offer
  132. //! read/write access when no password is set or when a password is set and
  133. //! the block is unlocked, and read-only access when a password is set but
  134. //! the block is locked.
  135. //
  136. #define EEPROM_PROT_RW_LRO_URW 0x00000000
  137. //
  138. //! This value may be passed to EEPROMBlockProtectSet() or returned from
  139. //! EEPROMBlockProtectGet(). It indicates that the block should offer neither
  140. //! read nor write access unless it is protected by a password and unlocked.
  141. //
  142. #define EEPROM_PROT_NA_LNA_URW 0x00000001
  143. //
  144. //! This value may be passed to EEPROMBlockProtectSet() or returned from
  145. //! EEPROMBlockProtectGet(). It indicates that the block should offer
  146. //! read-only access when no password is set or when a password is set and the
  147. //! block is unlocked. When a password is set and the block is locked, neither
  148. //! read nor write access is permitted.
  149. //
  150. #define EEPROM_PROT_RO_LNA_URO 0x00000002
  151. //*****************************************************************************
  152. //
  153. //! This value may be passed to EEPROMIntEnable() and EEPROMIntDisable() and is
  154. //! returned by EEPROMIntStatus() if an EEPROM interrupt is currently being
  155. //! signaled.
  156. //
  157. //*****************************************************************************
  158. #define EEPROM_INT_PROGRAM 0x00000004
  159. //*****************************************************************************
  160. //
  161. //! Returns the EEPROM block number containing a given offset address.
  162. //!
  163. //! \param ui32Addr is the linear, byte address of the EEPROM location whose
  164. //! block number is to be returned. This is a zero-based offset from the start
  165. //! of the EEPROM storage.
  166. //!
  167. //! This macro may be used to translate an EEPROM address offset into a
  168. //! block number suitable for use in any of the driver's block protection
  169. //! functions. The address provided is expressed as a byte offset from the
  170. //! base of the EEPROM.
  171. //!
  172. //! \return Returns the zero-based block number which contains the passed
  173. //! address.
  174. //
  175. //*****************************************************************************
  176. #define EEPROMBlockFromAddr(ui32Addr) ((ui32Addr) >> 6)
  177. //*****************************************************************************
  178. //
  179. //! Returns the offset address of the first word in an EEPROM block.
  180. //!
  181. //! \param ui32Block is the index of the EEPROM block whose first word address
  182. //! is to be returned.
  183. //!
  184. //! This macro may be used to determine the address of the first word in a
  185. //! given EEPROM block. The address returned is expressed as a byte offset
  186. //! from the base of EEPROM storage.
  187. //!
  188. //! \return Returns the address of the first word in the given EEPROM block.
  189. //
  190. //*****************************************************************************
  191. #define EEPROMAddrFromBlock(ui32Block) ((ui32Block) << 6)
  192. //*****************************************************************************
  193. //
  194. // Close the Doxygen group.
  195. //! @}
  196. //
  197. //*****************************************************************************
  198. //*****************************************************************************
  199. //
  200. // Prototypes for the APIs.
  201. //
  202. //*****************************************************************************
  203. extern uint32_t EEPROMInit(void);
  204. extern uint32_t EEPROMSizeGet(void);
  205. extern uint32_t EEPROMBlockCountGet(void);
  206. extern void EEPROMRead(uint32_t *pui32Data, uint32_t ui32Address,
  207. uint32_t ui32Count);
  208. extern uint32_t EEPROMProgram(uint32_t *pui32Data,
  209. uint32_t ui32Address,
  210. uint32_t ui32Count);
  211. extern uint32_t EEPROMProgramNonBlocking(uint32_t ui32Data,
  212. uint32_t ui32Address);
  213. extern uint32_t EEPROMStatusGet(void);
  214. extern uint32_t EEPROMMassErase(void);
  215. extern uint32_t EEPROMBlockProtectGet(uint32_t ui32Block);
  216. extern uint32_t EEPROMBlockProtectSet(uint32_t ui32Block,
  217. uint32_t ui32Protect);
  218. extern uint32_t EEPROMBlockPasswordSet(uint32_t ui32Block,
  219. uint32_t *pui32Password,
  220. uint32_t ui32Count);
  221. extern uint32_t EEPROMBlockLock(uint32_t ui32Block);
  222. extern uint32_t EEPROMBlockUnlock(uint32_t ui32Block,
  223. uint32_t *pui32Password,
  224. uint32_t ui32Count);
  225. extern void EEPROMBlockHide(uint32_t ui32Block);
  226. extern void EEPROMIntEnable(uint32_t ui32IntFlags);
  227. extern void EEPROMIntDisable(uint32_t ui32IntFlags);
  228. extern uint32_t EEPROMIntStatus(bool bMasked);
  229. extern void EEPROMIntClear(uint32_t ui32IntFlags);
  230. #ifndef DEPRECATED
  231. //*****************************************************************************
  232. //
  233. // The following definitions appeared in previous revisions of this file
  234. // but have been deprecated and should not be used by applications.
  235. //
  236. //*****************************************************************************
  237. //
  238. // This value used to be one of those which could be returned from a call to
  239. // EEPROMInit(). It transpires that it is was incorrect and has been removed
  240. // after EEPROMInit() was reworked for TivaWare 2.1.
  241. //
  242. #define EEPROM_INIT_RETRY 1
  243. //
  244. // This return code is not available from any Tiva part and has been removed.
  245. //
  246. #define EEPROM_RC_INVPL 0x00000100
  247. #endif
  248. //*****************************************************************************
  249. //
  250. // Mark the end of the C bindings section for C++ compilers.
  251. //
  252. //*****************************************************************************
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #endif // __DRIVERLIB_EEPROM_H__