PageRenderTime 24ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/PentascanAP/Project/Common/drivers/Stellarisware/drivers/eeprom.h

http://thebirdfree-personal.googlecode.com/
C Header | 264 lines | 53 code | 26 blank | 185 comment | 0 complexity | fc42aa3a0c73ca99a71d381356992e1a MD5 | raw file
  1. //*****************************************************************************
  2. //
  3. // eeprom.h - Prototypes for the EEPROM driver.
  4. //
  5. // Copyright (c) 2010-2011 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __EEPROM_H__
  25. #define __EEPROM_H__
  26. //*****************************************************************************
  27. //
  28. // If building with a C++ compiler, make all of the definitions in this header
  29. // have a C binding.
  30. //
  31. //*****************************************************************************
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. //*****************************************************************************
  37. //
  38. //! \addtogroup eeprom_api
  39. //! @{
  40. //
  41. //*****************************************************************************
  42. //*****************************************************************************
  43. //
  44. // Values returned by EEPROMInit.
  45. //
  46. //*****************************************************************************
  47. //
  48. //! This value may be returned from a call to EEPROMInit(). It indicates that
  49. //! no previous write operations were interrupted by a reset event and that the
  50. //! EEPROM peripheral is ready for use.
  51. //
  52. #define EEPROM_INIT_OK 0
  53. //
  54. //! This value may be returned from a call to EEPROMInit(). It indicates that
  55. //! a previous data or protection write operation was interrupted by a reset
  56. //! event. The EEPROM peripheral has recovered its state but the last write
  57. //! operation may have been lost. The application must check the validity of
  58. //! data it has written and retry any writes as required.
  59. //
  60. #define EEPROM_INIT_RETRY 1
  61. //
  62. //! This value may be returned from a call to EEPROMInit(). It indicates that a
  63. //! previous data or protection write operation was interrupted by a reset
  64. //! event and that the EEPROM peripheral was unable to clean up after the
  65. //! problem. This situation may be resolved with another reset or may be fatal
  66. //! depending upon the cause of the problem. For example, if the voltage to
  67. //! the part is unstable, retrying once the voltage has stabilized may clear
  68. //! the error.
  69. //
  70. #define EEPROM_INIT_ERROR 2
  71. //*****************************************************************************
  72. //
  73. // Error indicators returned by various EEPROM API calls. These will be ORed
  74. // together into the final return code.
  75. //
  76. //*****************************************************************************
  77. //
  78. //! This return code bit indicates that the EEPROM programming state machine
  79. //! failed to write a value due to the voltage level dropping below that
  80. //! required for EEPROM programming. The operation may be retried once the
  81. //! voltage stabilizes.
  82. //
  83. #define EEPROM_RC_INVPL 0x00000100
  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 ulProtect
  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 ulAddr 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(ulAddr) ((ulAddr) >> 6)
  177. //*****************************************************************************
  178. //
  179. //! Returns the offset address of the first word in an EEPROM block.
  180. //!
  181. //! \param ulBlock 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(ulBlock) ((ulBlock) << 6)
  192. //*****************************************************************************
  193. //
  194. // Prototypes for the APIs.
  195. //
  196. //*****************************************************************************
  197. extern unsigned long EEPROMInit(void);
  198. extern unsigned long EEPROMSizeGet(void);
  199. extern unsigned long EEPROMBlockCountGet(void);
  200. extern void EEPROMRead(unsigned long *pulData, unsigned long ulAddress,
  201. unsigned long ulCount);
  202. extern unsigned long EEPROMProgram(unsigned long *pulData,
  203. unsigned long ulAddress,
  204. unsigned long ulCount);
  205. extern unsigned long EEPROMProgramNonBlocking(unsigned long ulData,
  206. unsigned long ulAddress);
  207. extern unsigned long EEPROMStatusGet(void);
  208. extern unsigned long EEPROMMassErase(void);
  209. extern unsigned long EEPROMBlockProtectGet(unsigned long ulBlock);
  210. extern unsigned long EEPROMBlockProtectSet(unsigned long ulBlock,
  211. unsigned long ulProtect);
  212. extern unsigned long EEPROMBlockPasswordSet(unsigned long ulBlock,
  213. unsigned long *pulPassword,
  214. unsigned long ulCount);
  215. extern unsigned long EEPROMBlockLock(unsigned long ulBlock);
  216. extern unsigned long EEPROMBlockUnlock(unsigned long ulBlock,
  217. unsigned long *pulPassword,
  218. unsigned long ulCount);
  219. extern void EEPROMBlockHide(unsigned long ulBlock);
  220. extern void EEPROMIntEnable(unsigned long ulIntFlags);
  221. extern void EEPROMIntDisable(unsigned long ulIntFlags);
  222. extern unsigned long EEPROMIntStatus(tBoolean bMasked);
  223. extern void EEPROMIntClear(unsigned long ulIntFlags);
  224. //*****************************************************************************
  225. //
  226. // Close the Doxygen group.
  227. //! @}
  228. //
  229. //*****************************************************************************
  230. //*****************************************************************************
  231. //
  232. // Mark the end of the C bindings section for C++ compilers.
  233. //
  234. //*****************************************************************************
  235. #ifdef __cplusplus
  236. }
  237. #endif
  238. #endif // __EEPROM_H__