Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

329 lines
8.8 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_flash.h
  4. * @author MCD Application Team
  5. * @brief Header file of Flash HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F1xx_HAL_FLASH_H
  21. #define __STM32F1xx_HAL_FLASH_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f1xx_hal_def.h"
  27. /** @addtogroup STM32F1xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup FLASH
  31. * @{
  32. */
  33. /** @addtogroup FLASH_Private_Constants
  34. * @{
  35. */
  36. #define FLASH_TIMEOUT_VALUE 50000U /* 50 s */
  37. /**
  38. * @}
  39. */
  40. /** @addtogroup FLASH_Private_Macros
  41. * @{
  42. */
  43. #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
  44. ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \
  45. ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))
  46. #if defined(FLASH_ACR_LATENCY)
  47. #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
  48. ((__LATENCY__) == FLASH_LATENCY_1) || \
  49. ((__LATENCY__) == FLASH_LATENCY_2))
  50. #else
  51. #define IS_FLASH_LATENCY(__LATENCY__) ((__LATENCY__) == FLASH_LATENCY_0)
  52. #endif /* FLASH_ACR_LATENCY */
  53. /**
  54. * @}
  55. */
  56. /* Exported types ------------------------------------------------------------*/
  57. /** @defgroup FLASH_Exported_Types FLASH Exported Types
  58. * @{
  59. */
  60. /**
  61. * @brief FLASH Procedure structure definition
  62. */
  63. typedef enum
  64. {
  65. FLASH_PROC_NONE = 0U,
  66. FLASH_PROC_PAGEERASE = 1U,
  67. FLASH_PROC_MASSERASE = 2U,
  68. FLASH_PROC_PROGRAMHALFWORD = 3U,
  69. FLASH_PROC_PROGRAMWORD = 4U,
  70. FLASH_PROC_PROGRAMDOUBLEWORD = 5U
  71. } FLASH_ProcedureTypeDef;
  72. /**
  73. * @brief FLASH handle Structure definition
  74. */
  75. typedef struct
  76. {
  77. __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
  78. __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */
  79. __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */
  80. __IO uint64_t Data; /*!< Internal variable to save data to be programmed */
  81. HAL_LockTypeDef Lock; /*!< FLASH locking object */
  82. __IO uint32_t ErrorCode; /*!< FLASH error code
  83. This parameter can be a value of @ref FLASH_Error_Codes */
  84. } FLASH_ProcessTypeDef;
  85. /**
  86. * @}
  87. */
  88. /* Exported constants --------------------------------------------------------*/
  89. /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
  90. * @{
  91. */
  92. /** @defgroup FLASH_Error_Codes FLASH Error Codes
  93. * @{
  94. */
  95. #define HAL_FLASH_ERROR_NONE 0x00U /*!< No error */
  96. #define HAL_FLASH_ERROR_PROG 0x01U /*!< Programming error */
  97. #define HAL_FLASH_ERROR_WRP 0x02U /*!< Write protection error */
  98. #define HAL_FLASH_ERROR_OPTV 0x04U /*!< Option validity error */
  99. /**
  100. * @}
  101. */
  102. /** @defgroup FLASH_Type_Program FLASH Type Program
  103. * @{
  104. */
  105. #define FLASH_TYPEPROGRAM_HALFWORD 0x01U /*!<Program a half-word (16-bit) at a specified address.*/
  106. #define FLASH_TYPEPROGRAM_WORD 0x02U /*!<Program a word (32-bit) at a specified address.*/
  107. #define FLASH_TYPEPROGRAM_DOUBLEWORD 0x03U /*!<Program a double word (64-bit) at a specified address*/
  108. /**
  109. * @}
  110. */
  111. #if defined(FLASH_ACR_LATENCY)
  112. /** @defgroup FLASH_Latency FLASH Latency
  113. * @{
  114. */
  115. #define FLASH_LATENCY_0 0x00000000U /*!< FLASH Zero Latency cycle */
  116. #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_0 /*!< FLASH One Latency cycle */
  117. #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_1 /*!< FLASH Two Latency cycles */
  118. /**
  119. * @}
  120. */
  121. #else
  122. /** @defgroup FLASH_Latency FLASH Latency
  123. * @{
  124. */
  125. #define FLASH_LATENCY_0 0x00000000U /*!< FLASH Zero Latency cycle */
  126. /**
  127. * @}
  128. */
  129. #endif /* FLASH_ACR_LATENCY */
  130. /**
  131. * @}
  132. */
  133. /* Exported macro ------------------------------------------------------------*/
  134. /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
  135. * @brief macros to control FLASH features
  136. * @{
  137. */
  138. /** @defgroup FLASH_Half_Cycle FLASH Half Cycle
  139. * @brief macros to handle FLASH half cycle
  140. * @{
  141. */
  142. /**
  143. * @brief Enable the FLASH half cycle access.
  144. * @note half cycle access can only be used with a low-frequency clock of less than
  145. 8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
  146. * @retval None
  147. */
  148. #define __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE() (FLASH->ACR |= FLASH_ACR_HLFCYA)
  149. /**
  150. * @brief Disable the FLASH half cycle access.
  151. * @note half cycle access can only be used with a low-frequency clock of less than
  152. 8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
  153. * @retval None
  154. */
  155. #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
  156. /**
  157. * @}
  158. */
  159. #if defined(FLASH_ACR_LATENCY)
  160. /** @defgroup FLASH_EM_Latency FLASH Latency
  161. * @brief macros to handle FLASH Latency
  162. * @{
  163. */
  164. /**
  165. * @brief Set the FLASH Latency.
  166. * @param __LATENCY__ FLASH Latency
  167. * The value of this parameter depend on device used within the same series
  168. * @retval None
  169. */
  170. #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
  171. /**
  172. * @brief Get the FLASH Latency.
  173. * @retval FLASH Latency
  174. * The value of this parameter depend on device used within the same series
  175. */
  176. #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
  177. /**
  178. * @}
  179. */
  180. #endif /* FLASH_ACR_LATENCY */
  181. /** @defgroup FLASH_Prefetch FLASH Prefetch
  182. * @brief macros to handle FLASH Prefetch buffer
  183. * @{
  184. */
  185. /**
  186. * @brief Enable the FLASH prefetch buffer.
  187. * @retval None
  188. */
  189. #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE)
  190. /**
  191. * @brief Disable the FLASH prefetch buffer.
  192. * @retval None
  193. */
  194. #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
  195. /**
  196. * @}
  197. */
  198. /**
  199. * @}
  200. */
  201. /* Include FLASH HAL Extended module */
  202. #include "stm32f1xx_hal_flash_ex.h"
  203. /* Exported functions --------------------------------------------------------*/
  204. /** @addtogroup FLASH_Exported_Functions
  205. * @{
  206. */
  207. /** @addtogroup FLASH_Exported_Functions_Group1
  208. * @{
  209. */
  210. /* IO operation functions *****************************************************/
  211. HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
  212. HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
  213. /* FLASH IRQ handler function */
  214. void HAL_FLASH_IRQHandler(void);
  215. /* Callbacks in non blocking modes */
  216. void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
  217. void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
  218. /**
  219. * @}
  220. */
  221. /** @addtogroup FLASH_Exported_Functions_Group2
  222. * @{
  223. */
  224. /* Peripheral Control functions ***********************************************/
  225. HAL_StatusTypeDef HAL_FLASH_Unlock(void);
  226. HAL_StatusTypeDef HAL_FLASH_Lock(void);
  227. HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
  228. HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
  229. void HAL_FLASH_OB_Launch(void);
  230. /**
  231. * @}
  232. */
  233. /** @addtogroup FLASH_Exported_Functions_Group3
  234. * @{
  235. */
  236. /* Peripheral State and Error functions ***************************************/
  237. uint32_t HAL_FLASH_GetError(void);
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. /* Private function -------------------------------------------------*/
  245. /** @addtogroup FLASH_Private_Functions
  246. * @{
  247. */
  248. HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
  249. #if defined(FLASH_BANK2_END)
  250. HAL_StatusTypeDef FLASH_WaitForLastOperationBank2(uint32_t Timeout);
  251. #endif /* FLASH_BANK2_END */
  252. /**
  253. * @}
  254. */
  255. /**
  256. * @}
  257. */
  258. /**
  259. * @}
  260. */
  261. #ifdef __cplusplus
  262. }
  263. #endif
  264. #endif /* __STM32F1xx_HAL_FLASH_H */
  265. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/