mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
630:825f75ca301e
Parent:
441:d2c15dda23c1
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_flash.h	Mon Sep 28 10:30:09 2015 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_flash.h	Mon Sep 28 10:45:10 2015 +0100
@@ -2,13 +2,13 @@
   ******************************************************************************
   * @file    stm32f0xx_hal_flash.h
   * @author  MCD Application Team
-  * @version V1.2.0
-  * @date    11-December-2014
+  * @version V1.3.0
+  * @date    26-June-2015
   * @brief   Header file of Flash HAL module.
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -45,67 +45,43 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f0xx_hal_def.h"
-
+   
 /** @addtogroup STM32F0xx_HAL_Driver
   * @{
   */
 
 /** @addtogroup FLASH
   * @{
-  */ 
+  */
+  
+/** @addtogroup FLASH_Private_Constants
+  * @{
+  */
+#define FLASH_TIMEOUT_VALUE   ((uint32_t)50000)/* 50 s */
+/**
+  * @}
+  */
+
+/** @addtogroup FLASH_Private_Macros
+  * @{
+  */
+
+#define IS_FLASH_TYPEPROGRAM(VALUE)  (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
+                                      ((VALUE) == FLASH_TYPEPROGRAM_WORD)     || \
+                                      ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))  
+
+#define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
+                                       ((__LATENCY__) == FLASH_LATENCY_1))
+
+/**
+  * @}
+  */  
 
 /* Exported types ------------------------------------------------------------*/ 
-
 /** @defgroup FLASH_Exported_Types FLASH Exported Types
   * @{
   */  
 
-/**
-  * @brief  FLASH Erase structure definition
-  */
-typedef struct
-{
-  uint32_t TypeErase;   /*!< TypeErase: Mass erase or page erase.
-                             This parameter can be a value of @ref FLASH_Type_Erase */
-
-  uint32_t PageAddress; /*!< PageAdress: Initial FLASH page address to erase when mass erase is disabled
-                             This parameter must be a value of @ref FLASHEx_Address */
-  
-  uint32_t NbPages;     /*!< NbPages: Number of pagess to be erased.
-                             This parameter must be a value between 1 and (max number of pages - value of initial page)*/           
-                                                          
-} FLASH_EraseInitTypeDef;
-
-/**
-  * @brief  FLASH Options bytes program structure definition
-  */
-typedef struct
-{
-  uint32_t OptionType;  /*!< OptionType: Option byte to be configured.
-                             This parameter can be a value of @ref FLASH_OB_Type */
-
-  uint32_t WRPState;    /*!< WRPState: Write protection activation or deactivation.
-                             This parameter can be a value of @ref FLASH_OB_WRP_State */
-
-  uint32_t WRPPage;     /*!< WRPSector: specifies the page(s) to be write protected
-                             This parameter can be a value of @ref FLASHEx_OB_Write_Protection */
-
-  uint8_t RDPLevel;     /*!< RDPLevel: Set the read protection level..
-                             This parameter can be a value of @ref FLASH_OB_Read_Protection */
-
-  uint8_t USERConfig;   /*!< USERConfig: Program the FLASH User Option Byte: 
-                             IWDG / STOP / STDBY / BOOT1 / VDDA_ANALOG / SRAM_PARITY
-                             This parameter can be a combination of @ref FLASH_OB_Watchdog, @ref FLASH_OB_nRST_STOP,
-                             @ref FLASH_OB_nRST_STDBY, @ref FLASH_OB_BOOT1, @ref FLASH_OB_VDDA_Analog_Monitoring and
-                             @ref FLASH_OB_RAM_Parity_Check_Enable */
-
-  uint32_t DATAAddress; /*!< DATAAddress: Address of the option byte DATA to be prgrammed
-                             This parameter can be a value of @ref FLASH_OB_Data_Address */
-  
-  uint8_t DATAData;     /*!< DATAData: Data to be stored in the option byte DATA
-                             This parameter can have any value */
-  
-} FLASH_OBProgramInitTypeDef;
 
 /**
   * @brief  FLASH Procedure structure definition
@@ -136,8 +112,7 @@
   HAL_LockTypeDef             Lock;             /*!< FLASH locking object                */
 
   __IO uint32_t               ErrorCode;        /*!< FLASH error code                    
-                                                     This parameter can be a value of @ref FLASH_Error  */
-
+                                                     This parameter can be a value of @ref FLASH_Error_Codes  */
 } FLASH_ProcessTypeDef;
 
 /**
@@ -145,29 +120,18 @@
   */
 
 /* Exported constants --------------------------------------------------------*/
-
 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
   * @{
   */  
 
-/** @defgroup FLASH_Error FLASH Error
+/** @defgroup FLASH_Error_Codes FLASH Error Codes
   * @{
-  */ 
-#define FLASH_ERROR_NONE      ((uint32_t)0x00000000)
-#define FLASH_ERROR_PG        ((uint32_t)0x00000001)
-#define FLASH_ERROR_WRP       ((uint32_t)0x00000002)
-/**
-  * @}
   */
+ 
+#define HAL_FLASH_ERROR_NONE      ((uint32_t)0x00)
+#define HAL_FLASH_ERROR_PROG      ((uint32_t)0x01)
+#define HAL_FLASH_ERROR_WRP       ((uint32_t)0x02)
 
-/** @defgroup FLASH_Type_Erase FLASH Type Erase
-  * @{
-  */ 
-#define TYPEERASE_PAGES     ((uint32_t)0x00)  /*!<Pages erase only*/
-#define TYPEERASE_MASSERASE ((uint32_t)0x01)  /*!<Flash mass erase activation*/
-
-#define IS_TYPEERASE(VALUE) (((VALUE) == TYPEERASE_PAGES) || \
-                             ((VALUE) == TYPEERASE_MASSERASE))  
 /**
   * @}
   */
@@ -175,38 +139,10 @@
 /** @defgroup FLASH_Type_Program FLASH Type Program
   * @{
   */ 
-#define TYPEPROGRAM_HALFWORD   ((uint32_t)0x01)  /*!<Program a half-word (16-bit) at a specified address.*/
-#define TYPEPROGRAM_WORD       ((uint32_t)0x02)  /*!<Program a word (32-bit) at a specified address.*/
-#define TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03)  /*!<Program a double word (64-bit) at a specified address*/
-
-#define IS_TYPEPROGRAM(VALUE)  (((VALUE) == TYPEPROGRAM_HALFWORD) || \
-                                ((VALUE) == TYPEPROGRAM_WORD)     || \
-                                ((VALUE) == TYPEPROGRAM_DOUBLEWORD))  
-/**
-  * @}
-  */
+#define FLASH_TYPEPROGRAM_HALFWORD   ((uint32_t)0x01)  /*!<Program a half-word (16-bit) at a specified address.*/
+#define FLASH_TYPEPROGRAM_WORD       ((uint32_t)0x02)  /*!<Program a word (32-bit) at a specified address.*/
+#define FLASH_TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03)  /*!<Program a double word (64-bit) at a specified address*/
 
-/** @defgroup FLASH_OB_WRP_State FLASH WRP State
-  * @{
-  */ 
-#define WRPSTATE_DISABLE   ((uint32_t)0x00)  /*!<Disable the write protection of the desired pages*/
-#define WRPSTATE_ENABLE    ((uint32_t)0x01)  /*!<Enable the write protection of the desired pagess*/
-
-#define IS_WRPSTATE(VALUE) (((VALUE) == WRPSTATE_DISABLE) || \
-                            ((VALUE) == WRPSTATE_ENABLE))  
-/**
-  * @}
-  */
-
-/** @defgroup FLASH_OB_Type FLASH Option Bytes Type
-  * @{
-  */
-#define OPTIONBYTE_WRP       ((uint32_t)0x01)  /*!<WRP option byte configuration*/
-#define OPTIONBYTE_RDP       ((uint32_t)0x02)  /*!<RDP option byte configuration*/
-#define OPTIONBYTE_USER      ((uint32_t)0x04)  /*!<USER option byte configuration*/
-#define OPTIONBYTE_DATA      ((uint32_t)0x08)  /*!<DATA option byte configuration*/
-
-#define IS_OPTIONBYTE(VALUE) ((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_DATA))
 /**
   * @}
   */
@@ -217,93 +153,10 @@
 #define FLASH_LATENCY_0            ((uint32_t)0x00000000)    /*!< FLASH Zero Latency cycle */
 #define FLASH_LATENCY_1            FLASH_ACR_LATENCY         /*!< FLASH One Latency cycle */
 
-#define IS_FLASH_LATENCY(LATENCY)  (((LATENCY) == FLASH_LATENCY_0) || \
-                                    ((LATENCY) == FLASH_LATENCY_1))
-/**
-  * @}
-  */ 
-  
-/** @defgroup FLASH_OB_Data_Address FLASH OB Data Address
-  * @{
-  */  
-#define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806)) 
-/**
-  * @}
-  */
-
-/** @defgroup FLASH_OB_Read_Protection FLASH OB Read Protection
-  * @{
-  */
-#define OB_RDP_LEVEL_0             ((uint8_t)0xAA)
-#define OB_RDP_LEVEL_1             ((uint8_t)0xBB)
-#define OB_RDP_LEVEL_2             ((uint8_t)0xCC) /*!< Warning: When enabling read protection level 2 
-                                                      it's no more possible to go back to level 1 or 0 */
-#define IS_OB_RDP_LEVEL(LEVEL)     (((LEVEL) == OB_RDP_LEVEL_0)   ||\
-                                    ((LEVEL) == OB_RDP_LEVEL_1))/*||\
-                                    ((LEVEL) == OB_RDP_LEVEL_2))*/
-/**
-  * @}
-  */ 
-  
-/** @defgroup FLASH_OB_Watchdog FLASH OB Watchdog
-  * @{
-  */ 
-#define OB_WDG_SW                 ((uint8_t)0x01)  /*!< Software WDG selected */
-#define OB_WDG_HW                 ((uint8_t)0x00)  /*!< Hardware WDG selected */
-#define IS_OB_WDG_SOURCE(SOURCE)  (((SOURCE) == OB_WDG_SW) || ((SOURCE) == OB_WDG_HW))
-/**
-  * @}
-  */ 
-  
-/** @defgroup FLASH_OB_nRST_STOP FLASH OB nRST STOP
-  * @{
-  */ 
-#define OB_STOP_NO_RST             ((uint8_t)0x02) /*!< No reset generated when entering in STOP */
-#define OB_STOP_RST                ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
-#define IS_OB_STOP_SOURCE(SOURCE)  (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
 /**
   * @}
   */ 
 
-/** @defgroup FLASH_OB_nRST_STDBY FLASH OB nRST STDBY 
-  * @{
-  */ 
-#define OB_STDBY_NO_RST            ((uint8_t)0x04) /*!< No reset generated when entering in STANDBY */
-#define OB_STDBY_RST               ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
-#define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
-/**
-  * @}
-  */    
-
-/** @defgroup FLASH_OB_BOOT1 FLASH OB BOOT1
-  * @{
-  */
-#define OB_BOOT1_RESET             ((uint8_t)0x00) /*!< BOOT1 Reset */
-#define OB_BOOT1_SET               ((uint8_t)0x10) /*!< BOOT1 Set */
-#define IS_OB_BOOT1(BOOT1)         (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET))
-/**
-  * @}
-  */  
-
-/** @defgroup FLASH_OB_VDDA_Analog_Monitoring FLASH OB VDDA Analog Monitoring
-  * @{
-  */
-#define OB_VDDA_ANALOG_ON          ((uint8_t)0x20) /*!< Analog monitoring on VDDA Power source ON */
-#define OB_VDDA_ANALOG_OFF         ((uint8_t)0x00) /*!< Analog monitoring on VDDA Power source OFF */
-#define IS_OB_VDDA_ANALOG(ANALOG)  (((ANALOG) == OB_VDDA_ANALOG_ON) || ((ANALOG) == OB_VDDA_ANALOG_OFF))
-/**
-  * @}
-  */ 
-
-/** @defgroup FLASH_OB_RAM_Parity_Check_Enable FLASH OB RAM Parity Check Enable
-  * @{
-  */
-#define OB_RAM_PARITY_CHECK_SET    ((uint8_t)0x00) /*!< RAM parity check enable set */
-#define OB_RAM_PARITY_CHECK_RESET  ((uint8_t)0x40) /*!< RAM parity check enable reset */
-#define IS_OB_SRAM_PARITY(PARITY)  (((PARITY) == OB_RAM_PARITY_CHECK_SET) || ((PARITY) == OB_RAM_PARITY_CHECK_RESET))
-/**
-  * @}
-  */ 
 
 /** @defgroup FLASH_Flag_definition FLASH Flag definition
   * @{
@@ -325,15 +178,6 @@
   * @}
   */  
 
-/** @defgroup FLASH_Timeout_definition  FLASH Timeout definition
-  * @brief FLASH Timeout definition
-  * @{
-  */ 
-#define HAL_FLASH_TIMEOUT_VALUE   ((uint32_t)50000)/* 50 s */
-/**
-  * @}
-  */  
-
 /**
   * @}
   */  
@@ -344,7 +188,7 @@
  *  @brief macros to control FLASH features 
  *  @{
  */
-
+ 
 /** @defgroup FLASH_Latency FLASH Latency
  *  @brief macros to handle FLASH Latency
  * @{
@@ -357,6 +201,15 @@
   * @retval None
   */ 
 #define __HAL_FLASH_SET_LATENCY(__LATENCY__)    (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
+
+
+/**
+  * @brief  Get the FLASH Latency.
+  * @retval FLASH Latency                   
+  *          The value of this parameter depend on device used within the same series
+  */ 
+#define __HAL_FLASH_GET_LATENCY()     (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
+
 /**
   * @}
   */
@@ -380,8 +233,8 @@
 /**
   * @}
   */
-
-/** @defgroup FLASH_Interrupt FLASH Interrupt
+  
+/** @defgroup FLASH_Interrupt FLASH Interrupts
  *  @brief macros to handle FLASH interrupts
  * @{
  */ 
@@ -394,7 +247,7 @@
   *     @arg FLASH_IT_ERR: Error Interrupt    
   * @retval none
   */  
-#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)  (FLASH->CR |= (__INTERRUPT__))
+#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)  SET_BIT((FLASH->CR), (__INTERRUPT__))
 
 /**
   * @brief  Disable the specified FLASH interrupt.
@@ -404,30 +257,31 @@
   *     @arg FLASH_IT_ERR: Error Interrupt    
   * @retval none
   */  
-#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__)  (FLASH->CR &= ~(uint32_t)(__INTERRUPT__))
+#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__)  CLEAR_BIT((FLASH->CR), (uint32_t)(__INTERRUPT__))
 
 /**
   * @brief  Get the specified FLASH flag status. 
   * @param  __FLAG__: specifies the FLASH flag to check.
   *          This parameter can be one of the following values:
-  *            @arg FLASH_FLAG_EOP   : FLASH End of Operation flag 
-  *            @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag 
-  *            @arg FLASH_FLAG_PGERR : FLASH Programming error flag
-  *            @arg FLASH_FLAG_BSY   : FLASH Busy flag
+  *            @arg FLASH_FLAG_BSY   :      FLASH Busy flag
+  *            @arg FLASH_FLAG_EOP   :      FLASH End of Operation flag 
+  *            @arg FLASH_FLAG_WRPERR:      FLASH Write protected error flag 
+  *            @arg FLASH_FLAG_PGERR :      FLASH Programming error flag
   * @retval The new state of __FLAG__ (SET or RESET).
   */
-#define __HAL_FLASH_GET_FLAG(__FLAG__)          ((FLASH->SR & (__FLAG__)) == (__FLAG__))
+#define __HAL_FLASH_GET_FLAG(__FLAG__)   (((FLASH->SR) & (__FLAG__)) == (__FLAG__))
 
 /**
   * @brief  Clear the specified FLASH flag.
   * @param  __FLAG__: specifies the FLASH flags to clear.
   *          This parameter can be any combination of the following values:
-  *            @arg FLASH_FLAG_EOP   : FLASH End of Operation flag 
-  *            @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag 
-  *            @arg FLASH_FLAG_PGERR : FLASH Programming error flag 
+  *            @arg FLASH_FLAG_BSY   :      FLASH Busy flag
+  *            @arg FLASH_FLAG_EOP   :      FLASH End of Operation flag 
+  *            @arg FLASH_FLAG_WRPERR:      FLASH Write protected error flag 
+  *            @arg FLASH_FLAG_PGERR :      FLASH Programming error flag
   * @retval none
   */
-#define __HAL_FLASH_CLEAR_FLAG(__FLAG__)        (FLASH->SR = (__FLAG__))
+#define __HAL_FLASH_CLEAR_FLAG(__FLAG__)   ((FLASH->SR) = (__FLAG__))
 
 /**
   * @}
@@ -436,56 +290,49 @@
 /**
   * @}
   */ 
-  
-/* Include FLASH HAL Extension module */
+
+/* Include FLASH HAL Extended module */
 #include "stm32f0xx_hal_flash_ex.h"  
 
 /* Exported functions --------------------------------------------------------*/
-
 /** @addtogroup FLASH_Exported_Functions
   * @{
-  */  
-
-/** @addtogroup FLASH_Exported_Functions_Group1 
- *  @brief   Data transfers functions
- * @{
- */
+  */
   
+/** @addtogroup FLASH_Exported_Functions_Group1
+  * @{
+  */
 /* IO operation functions *****************************************************/
-HAL_StatusTypeDef  HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
-HAL_StatusTypeDef  HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
+HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
+HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
 
 /* FLASH IRQ handler method */
-void               HAL_FLASH_IRQHandler(void);
+void       HAL_FLASH_IRQHandler(void);
 /* Callbacks in non blocking modes */ 
-void               HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
-void               HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
-
-/**
-  * @}
-  */  
-
-/** @addtogroup FLASH_Exported_Functions_Group2 
- *  @brief   management functions 
- * @{
- */
-   
-/* FLASH Memory Programming functions *****************************************/   
-HAL_StatusTypeDef  HAL_FLASH_Unlock(void);
-HAL_StatusTypeDef  HAL_FLASH_Lock(void);
-
-/* Option Bytes Programming functions *****************************************/
-HAL_StatusTypeDef  HAL_FLASH_OB_Unlock(void);
-HAL_StatusTypeDef  HAL_FLASH_OB_Lock(void);
-HAL_StatusTypeDef  HAL_FLASH_OB_Launch(void);
+void       HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
+void       HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
 
 /**
   * @}
   */
 
-/** @addtogroup FLASH_Exported_Functions_Group3 
- * @{
- */
+/** @addtogroup FLASH_Exported_Functions_Group2
+  * @{
+  */
+/* Peripheral Control functions ***********************************************/
+HAL_StatusTypeDef HAL_FLASH_Unlock(void);
+HAL_StatusTypeDef HAL_FLASH_Lock(void);
+HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
+HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
+HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
+
+/**
+  * @}
+  */
+
+/** @addtogroup FLASH_Exported_Functions_Group3
+  * @{
+  */
 /* Peripheral State and Error functions ***************************************/
 uint32_t HAL_FLASH_GetError(void);
 
@@ -497,6 +344,17 @@
   * @}
   */
 
+/* Private function -------------------------------------------------*/
+/** @addtogroup FLASH_Private_Functions
+ * @{
+ */
+void                    FLASH_PageErase(uint32_t PageAddress);
+HAL_StatusTypeDef       FLASH_WaitForLastOperation(uint32_t Timeout);
+
+/**
+  * @}
+  */
+
 /**
   * @}
   */