stm320518_eval_i2c_ee.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. ******************************************************************************
  3. * @file stm320518_eval_i2c_ee.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 20-April-2012
  7. * @brief This file contains all the functions prototypes for
  8. * the stm320518_eval_i2c_ee.c firmware driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM320518_EVAL_I2C_EE_H
  30. #define __STM320518_EVAL_I2C_EE_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm320518_eval.h"
  36. /** @addtogroup Utilities
  37. * @{
  38. */
  39. /** @addtogroup STM32_EVAL
  40. * @{
  41. */
  42. /** @addtogroup STM320518_EVAL
  43. * @{
  44. */
  45. /** @addtogroup STM320518_EVAL_I2C_EE
  46. * @{
  47. */
  48. /** @defgroup STM320518_EVAL_I2C_EE_Exported_Types
  49. * @{
  50. */
  51. /**
  52. * @}
  53. */
  54. /** @defgroup STM320518_EVAL_I2C_EE_Exported_Constants
  55. * @{
  56. */
  57. /* Select which EEPROM will be used with this driver */
  58. #define sEE_M24LR64
  59. /* Uncomment the following line to use the default sEE_TIMEOUT_UserCallback()
  60. function implemented in stm320518_evel_i2c_ee.c file.
  61. sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition
  62. occure during communication (waiting on an event that doesn't occur, bus
  63. errors, busy devices ...). */
  64. /* #define USE_DEFAULT_TIMEOUT_CALLBACK */
  65. #if !defined (sEE_M24C08) && !defined (sEE_M24C64_32) && !defined (sEE_M24LR64)
  66. /* Use the defines below the choose the EEPROM type */
  67. /* #define sEE_M24C08*/ /* Support the device: M24C08. */
  68. /* note: Could support: M24C01, M24C02, M24C04 and M24C16 if the blocks and
  69. HW address are correctly defined*/
  70. /*#define sEE_M24C64_32*/ /* Support the devices: M24C32 and M24C64 */
  71. #define sEE_M24LR64 /*Support the devices: M24LR64 */
  72. #endif
  73. #ifdef sEE_M24C64_32
  74. /* For M24C32 and M24C64 devices, E0,E1 and E2 pins are all used for device
  75. address selection (ne need for additional address lines). According to the
  76. Harware connection on the board. */
  77. #define sEE_HW_ADDRESS 0xA0 /* E0 = E1 = E2 = 0 */
  78. #elif defined (sEE_M24C08)
  79. /* The M24C08W contains 4 blocks (128byte each) with the adresses below: E2 = 0
  80. EEPROM Addresses defines */
  81. #define sEE_HW_ADDRESS 0xA0 /* E2 = 0 */
  82. /*#define sEE_HW_ADDRESS 0xA2*/ /* E2 = 0 */
  83. /*#define sEE_HW_ADDRESS 0xA4*/ /* E2 = 0 */
  84. /*#define sEE_HW_ADDRESS 0xA6*/ /* E2 = 0 */
  85. #elif defined (sEE_M24LR64)
  86. #define sEE_HW_ADDRESS 0xA0
  87. #endif /* sEE_M24C64_32 */
  88. #define sEE_I2C_TIMING 0x00210507
  89. #if defined (sEE_M24C08)
  90. #define sEE_PAGESIZE 16
  91. #elif defined (sEE_M24C64_32)
  92. #define sEE_PAGESIZE 32
  93. #elif defined (sEE_M24LR64)
  94. #define sEE_PAGESIZE 4
  95. #endif
  96. /* Maximum Timeout values for flags and events waiting loops. These timeouts are
  97. not based on accurate values, they just guarantee that the application will
  98. not remain stuck if the I2C communication is corrupted.
  99. You may modify these timeout values depending on CPU frequency and application
  100. conditions (interrupts routines ...). */
  101. #define sEE_FLAG_TIMEOUT ((uint32_t)0x1000)
  102. #define sEE_LONG_TIMEOUT ((uint32_t)(10 * sEE_FLAG_TIMEOUT))
  103. /* Maximum number of trials for sEE_WaitEepromStandbyState() function */
  104. #define sEE_MAX_TRIALS_NUMBER 300
  105. #define sEE_OK 0
  106. #define sEE_FAIL 1
  107. /**
  108. * @}
  109. */
  110. /** @defgroup STM320518_EVAL_I2C_EE_Exported_Macros
  111. * @{
  112. */
  113. /**
  114. * @}
  115. */
  116. /** @defgroup STM320518_EVAL_I2C_EE_Exported_Functions
  117. * @{
  118. */
  119. void sEE_DeInit(void);
  120. void sEE_Init(void);
  121. uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead);
  122. uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite);
  123. void sEE_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
  124. uint32_t sEE_WaitEepromStandbyState(void);
  125. /* USER Callbacks: These are functions for which prototypes only are declared in
  126. EEPROM driver and that should be implemented into user applicaiton. */
  127. /* sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition
  128. occure during communication (waiting on an event that doesn't occur, bus
  129. errors, busy devices ...).
  130. You can use the default timeout callback implementation by uncommenting the
  131. define USE_DEFAULT_TIMEOUT_CALLBACK in stm320518_evel_i2c_ee.h file.
  132. Typically the user implementation of this callback should reset I2C peripheral
  133. and re-initialize communication or in worst case reset all the application. */
  134. uint32_t sEE_TIMEOUT_UserCallback(void);
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif /* __STM320518_EVAL_I2C_EE_H */
  139. /**
  140. * @}
  141. */
  142. /**
  143. * @}
  144. */
  145. /**
  146. * @}
  147. */
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/