tdse-tp0_02-hw_sw_test

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