stm322xg_eval_eeprom.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**
  2. ******************************************************************************
  3. * @file stm322xg_eval_eeprom.h
  4. * @author MCD Application Team
  5. * @brief This file contains all the functions prototypes for
  6. * the stm322xg_eval_eeprom.c firmware driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  11. *
  12. * Redistribution and use in source and binary forms, with or without modification,
  13. * are permitted provided that the following conditions are met:
  14. * 1. Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  29. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  30. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  31. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ******************************************************************************
  35. */
  36. /* Define to prevent recursive inclusion -------------------------------------*/
  37. #ifndef __STM322xG_EVAL_EEPROM_H
  38. #define __STM322xG_EVAL_EEPROM_H
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /* Includes ------------------------------------------------------------------*/
  43. #include "stm322xg_eval.h"
  44. /** @addtogroup BSP
  45. * @{
  46. */
  47. /** @addtogroup STM322xG_EVAL
  48. * @{
  49. */
  50. /** @addtogroup STM322xG_EVAL_EEPROM
  51. * @brief This file includes the I2C EEPROM driver of STM322xG-EVAL evaluation board.
  52. * @{
  53. */
  54. /** @defgroup STM322xG_EVAL_EEPROM_Exported_Constants STM322xG EVAL EEPROM Exported Constants
  55. * @{
  56. */
  57. /* EEPROM hardware address and page size */
  58. #define EEPROM_PAGESIZE 32
  59. #define EEPROM_MAX_SIZE 0x2000 /* 64Kbit*/
  60. /* Maximum Timeout values for flags and events waiting loops: This timeout is based
  61. on systick set to 1ms.
  62. Timeout for read based if read all the EEPROM: EEPROM_MAX_SIZE * BSP_I2C_SPEED (640ms) */
  63. #define EEPROM_READ_TIMEOUT ((uint32_t)(1000))
  64. /* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * BSP_I2C_SPEED (320us)*/
  65. #define EEPROM_WRITE_TIMEOUT ((uint32_t)(1000))
  66. /* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */
  67. #define EEPROM_MAX_TRIALS 3000
  68. #define EEPROM_OK 0
  69. #define EEPROM_FAIL 1
  70. #define EEPROM_TIMEOUT 2
  71. /**
  72. * @}
  73. */
  74. /** @defgroup STM322xG_EVAL_EEPROM_Exported_Functions STM322xG EVAL EEPROM Exported Functions
  75. * @{
  76. */
  77. uint32_t BSP_EEPROM_Init(void);
  78. uint32_t BSP_EEPROM_ReadBuffer(uint8_t *pBuffer, uint16_t ReadAddr, uint16_t *NumByteToRead);
  79. uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
  80. /* USER Callbacks: This function is declared as __weak in EEPROM driver and
  81. should be implemented into user application.
  82. BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition
  83. occurs during communication (waiting on an event that doesn't occur, bus
  84. errors, busy devices ...). */
  85. void BSP_EEPROM_TIMEOUT_UserCallback(void);
  86. /* Link function for I2C EEPROM peripheral */
  87. void EEPROM_IO_Init(void);
  88. HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize);
  89. HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize);
  90. HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
  91. /**
  92. * @}
  93. */
  94. /**
  95. * @}
  96. */
  97. /**
  98. * @}
  99. */
  100. /**
  101. * @}
  102. */
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif /* __STM322xG_EVAL_EEPROM_H */
  107. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/