stm32f1xx_hal_sram.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_sram.h
  4. * @author MCD Application Team
  5. * @brief Header file of SRAM HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F1xx_HAL_SRAM_H
  20. #define STM32F1xx_HAL_SRAM_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if defined(FSMC_BANK1)
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f1xx_ll_fsmc.h"
  27. /** @addtogroup STM32F1xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup SRAM
  31. * @{
  32. */
  33. /* Exported typedef ----------------------------------------------------------*/
  34. /** @defgroup SRAM_Exported_Types SRAM Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief HAL SRAM State structures definition
  39. */
  40. typedef enum
  41. {
  42. HAL_SRAM_STATE_RESET = 0x00U, /*!< SRAM not yet initialized or disabled */
  43. HAL_SRAM_STATE_READY = 0x01U, /*!< SRAM initialized and ready for use */
  44. HAL_SRAM_STATE_BUSY = 0x02U, /*!< SRAM internal process is ongoing */
  45. HAL_SRAM_STATE_ERROR = 0x03U, /*!< SRAM error state */
  46. HAL_SRAM_STATE_PROTECTED = 0x04U /*!< SRAM peripheral NORSRAM device write protected */
  47. } HAL_SRAM_StateTypeDef;
  48. /**
  49. * @brief SRAM handle Structure definition
  50. */
  51. #if (USE_HAL_SRAM_REGISTER_CALLBACKS == 1)
  52. typedef struct __SRAM_HandleTypeDef
  53. #else
  54. typedef struct
  55. #endif /* USE_HAL_SRAM_REGISTER_CALLBACKS */
  56. {
  57. FSMC_NORSRAM_TypeDef *Instance; /*!< Register base address */
  58. FSMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */
  59. FSMC_NORSRAM_InitTypeDef Init; /*!< SRAM device control configuration parameters */
  60. HAL_LockTypeDef Lock; /*!< SRAM locking object */
  61. __IO HAL_SRAM_StateTypeDef State; /*!< SRAM device access state */
  62. DMA_HandleTypeDef *hdma; /*!< Pointer DMA handler */
  63. #if (USE_HAL_SRAM_REGISTER_CALLBACKS == 1)
  64. void (* MspInitCallback)(struct __SRAM_HandleTypeDef *hsram); /*!< SRAM Msp Init callback */
  65. void (* MspDeInitCallback)(struct __SRAM_HandleTypeDef *hsram); /*!< SRAM Msp DeInit callback */
  66. void (* DmaXferCpltCallback)(DMA_HandleTypeDef *hdma); /*!< SRAM DMA Xfer Complete callback */
  67. void (* DmaXferErrorCallback)(DMA_HandleTypeDef *hdma); /*!< SRAM DMA Xfer Error callback */
  68. #endif /* USE_HAL_SRAM_REGISTER_CALLBACKS */
  69. } SRAM_HandleTypeDef;
  70. #if (USE_HAL_SRAM_REGISTER_CALLBACKS == 1)
  71. /**
  72. * @brief HAL SRAM Callback ID enumeration definition
  73. */
  74. typedef enum
  75. {
  76. HAL_SRAM_MSP_INIT_CB_ID = 0x00U, /*!< SRAM MspInit Callback ID */
  77. HAL_SRAM_MSP_DEINIT_CB_ID = 0x01U, /*!< SRAM MspDeInit Callback ID */
  78. HAL_SRAM_DMA_XFER_CPLT_CB_ID = 0x02U, /*!< SRAM DMA Xfer Complete Callback ID */
  79. HAL_SRAM_DMA_XFER_ERR_CB_ID = 0x03U /*!< SRAM DMA Xfer Complete Callback ID */
  80. } HAL_SRAM_CallbackIDTypeDef;
  81. /**
  82. * @brief HAL SRAM Callback pointer definition
  83. */
  84. typedef void (*pSRAM_CallbackTypeDef)(SRAM_HandleTypeDef *hsram);
  85. typedef void (*pSRAM_DmaCallbackTypeDef)(DMA_HandleTypeDef *hdma);
  86. #endif /* USE_HAL_SRAM_REGISTER_CALLBACKS */
  87. /**
  88. * @}
  89. */
  90. /* Exported constants --------------------------------------------------------*/
  91. /* Exported macro ------------------------------------------------------------*/
  92. /** @defgroup SRAM_Exported_Macros SRAM Exported Macros
  93. * @{
  94. */
  95. /** @brief Reset SRAM handle state
  96. * @param __HANDLE__ SRAM handle
  97. * @retval None
  98. */
  99. #if (USE_HAL_SRAM_REGISTER_CALLBACKS == 1)
  100. #define __HAL_SRAM_RESET_HANDLE_STATE(__HANDLE__) do { \
  101. (__HANDLE__)->State = HAL_SRAM_STATE_RESET; \
  102. (__HANDLE__)->MspInitCallback = NULL; \
  103. (__HANDLE__)->MspDeInitCallback = NULL; \
  104. } while(0)
  105. #else
  106. #define __HAL_SRAM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SRAM_STATE_RESET)
  107. #endif /* USE_HAL_SRAM_REGISTER_CALLBACKS */
  108. /**
  109. * @}
  110. */
  111. /* Exported functions --------------------------------------------------------*/
  112. /** @addtogroup SRAM_Exported_Functions SRAM Exported Functions
  113. * @{
  114. */
  115. /** @addtogroup SRAM_Exported_Functions_Group1 Initialization and de-initialization functions
  116. * @{
  117. */
  118. /* Initialization/de-initialization functions ********************************/
  119. HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FSMC_NORSRAM_TimingTypeDef *Timing,
  120. FSMC_NORSRAM_TimingTypeDef *ExtTiming);
  121. HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram);
  122. void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram);
  123. void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram);
  124. /**
  125. * @}
  126. */
  127. /** @addtogroup SRAM_Exported_Functions_Group2 Input Output and memory control functions
  128. * @{
  129. */
  130. /* I/O operation functions ***************************************************/
  131. HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pDstBuffer,
  132. uint32_t BufferSize);
  133. HAL_StatusTypeDef HAL_SRAM_Write_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pSrcBuffer,
  134. uint32_t BufferSize);
  135. HAL_StatusTypeDef HAL_SRAM_Read_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pDstBuffer,
  136. uint32_t BufferSize);
  137. HAL_StatusTypeDef HAL_SRAM_Write_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pSrcBuffer,
  138. uint32_t BufferSize);
  139. HAL_StatusTypeDef HAL_SRAM_Read_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer,
  140. uint32_t BufferSize);
  141. HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer,
  142. uint32_t BufferSize);
  143. HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer,
  144. uint32_t BufferSize);
  145. HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer,
  146. uint32_t BufferSize);
  147. void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma);
  148. void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma);
  149. #if (USE_HAL_SRAM_REGISTER_CALLBACKS == 1)
  150. /* SRAM callback registering/unregistering */
  151. HAL_StatusTypeDef HAL_SRAM_RegisterCallback(SRAM_HandleTypeDef *hsram, HAL_SRAM_CallbackIDTypeDef CallbackId,
  152. pSRAM_CallbackTypeDef pCallback);
  153. HAL_StatusTypeDef HAL_SRAM_UnRegisterCallback(SRAM_HandleTypeDef *hsram, HAL_SRAM_CallbackIDTypeDef CallbackId);
  154. HAL_StatusTypeDef HAL_SRAM_RegisterDmaCallback(SRAM_HandleTypeDef *hsram, HAL_SRAM_CallbackIDTypeDef CallbackId,
  155. pSRAM_DmaCallbackTypeDef pCallback);
  156. #endif /* USE_HAL_SRAM_REGISTER_CALLBACKS */
  157. /**
  158. * @}
  159. */
  160. /** @addtogroup SRAM_Exported_Functions_Group3 Control functions
  161. * @{
  162. */
  163. /* SRAM Control functions ****************************************************/
  164. HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram);
  165. HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram);
  166. /**
  167. * @}
  168. */
  169. /** @addtogroup SRAM_Exported_Functions_Group4 Peripheral State functions
  170. * @{
  171. */
  172. /* SRAM State functions ******************************************************/
  173. HAL_SRAM_StateTypeDef HAL_SRAM_GetState(const SRAM_HandleTypeDef *hsram);
  174. /**
  175. * @}
  176. */
  177. /**
  178. * @}
  179. */
  180. /**
  181. * @}
  182. */
  183. /**
  184. * @}
  185. */
  186. #endif /* FSMC_BANK1 */
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190. #endif /* STM32F1xx_HAL_SRAM_H */