STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f4xx_flash.h File Reference

This file contains all the functions prototypes for the FLASH firmware library. More...

#include "stm32f4xx.h"

Go to the source code of this file.

Macros

#define FLASH_Latency_0   ((uint8_t)0x0000)
 
#define FLASH_Latency_1   ((uint8_t)0x0001)
 
#define FLASH_Latency_2   ((uint8_t)0x0002)
 
#define FLASH_Latency_3   ((uint8_t)0x0003)
 
#define FLASH_Latency_4   ((uint8_t)0x0004)
 
#define FLASH_Latency_5   ((uint8_t)0x0005)
 
#define FLASH_Latency_6   ((uint8_t)0x0006)
 
#define FLASH_Latency_7   ((uint8_t)0x0007)
 
#define IS_FLASH_LATENCY(LATENCY)
 
#define VoltageRange_1   ((uint8_t)0x00)
 
#define VoltageRange_2   ((uint8_t)0x01)
 
#define VoltageRange_3   ((uint8_t)0x02)
 
#define VoltageRange_4   ((uint8_t)0x03)
 
#define IS_VOLTAGERANGE(RANGE)
 
#define FLASH_Sector_0   ((uint16_t)0x0000)
 
#define FLASH_Sector_1   ((uint16_t)0x0008)
 
#define FLASH_Sector_2   ((uint16_t)0x0010)
 
#define FLASH_Sector_3   ((uint16_t)0x0018)
 
#define FLASH_Sector_4   ((uint16_t)0x0020)
 
#define FLASH_Sector_5   ((uint16_t)0x0028)
 
#define FLASH_Sector_6   ((uint16_t)0x0030)
 
#define FLASH_Sector_7   ((uint16_t)0x0038)
 
#define FLASH_Sector_8   ((uint16_t)0x0040)
 
#define FLASH_Sector_9   ((uint16_t)0x0048)
 
#define FLASH_Sector_10   ((uint16_t)0x0050)
 
#define FLASH_Sector_11   ((uint16_t)0x0058)
 
#define IS_FLASH_SECTOR(SECTOR)
 
#define IS_FLASH_ADDRESS(ADDRESS)
 
#define OB_WRP_Sector_0   ((uint32_t)0x00000001)
 
#define OB_WRP_Sector_1   ((uint32_t)0x00000002)
 
#define OB_WRP_Sector_2   ((uint32_t)0x00000004)
 
#define OB_WRP_Sector_3   ((uint32_t)0x00000008)
 
#define OB_WRP_Sector_4   ((uint32_t)0x00000010)
 
#define OB_WRP_Sector_5   ((uint32_t)0x00000020)
 
#define OB_WRP_Sector_6   ((uint32_t)0x00000040)
 
#define OB_WRP_Sector_7   ((uint32_t)0x00000080)
 
#define OB_WRP_Sector_8   ((uint32_t)0x00000100)
 
#define OB_WRP_Sector_9   ((uint32_t)0x00000200)
 
#define OB_WRP_Sector_10   ((uint32_t)0x00000400)
 
#define OB_WRP_Sector_11   ((uint32_t)0x00000800)
 
#define OB_WRP_Sector_All   ((uint32_t)0x00000FFF)
 
#define IS_OB_WRP(SECTOR)   ((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
 
#define OB_RDP_Level_0   ((uint8_t)0xAA)
 
#define OB_RDP_Level_1   ((uint8_t)0x55)
 
#define IS_OB_RDP(LEVEL)
 
#define OB_IWDG_SW   ((uint8_t)0x20)
 
#define OB_IWDG_HW   ((uint8_t)0x00)
 
#define IS_OB_IWDG_SOURCE(SOURCE)   (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
 
#define OB_STOP_NoRST   ((uint8_t)0x40)
 
#define OB_STOP_RST   ((uint8_t)0x00)
 
#define IS_OB_STOP_SOURCE(SOURCE)   (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
 
#define OB_STDBY_NoRST   ((uint8_t)0x80)
 
#define OB_STDBY_RST   ((uint8_t)0x00)
 
#define IS_OB_STDBY_SOURCE(SOURCE)   (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
 
#define OB_BOR_LEVEL3   ((uint8_t)0x00)
 
#define OB_BOR_LEVEL2   ((uint8_t)0x04)
 
#define OB_BOR_LEVEL1   ((uint8_t)0x08)
 
#define OB_BOR_OFF   ((uint8_t)0x0C)
 
#define IS_OB_BOR(LEVEL)
 
#define FLASH_IT_EOP   ((uint32_t)0x01000000)
 
#define FLASH_IT_ERR   ((uint32_t)0x02000000)
 
#define IS_FLASH_IT(IT)   ((((IT) & (uint32_t)0xFCFFFFFF) == 0x00000000) && ((IT) != 0x00000000))
 
#define FLASH_FLAG_EOP   ((uint32_t)0x00000001)
 
#define FLASH_FLAG_OPERR   ((uint32_t)0x00000002)
 
#define FLASH_FLAG_WRPERR   ((uint32_t)0x00000010)
 
#define FLASH_FLAG_PGAERR   ((uint32_t)0x00000020)
 
#define FLASH_FLAG_PGPERR   ((uint32_t)0x00000040)
 
#define FLASH_FLAG_PGSERR   ((uint32_t)0x00000080)
 
#define FLASH_FLAG_BSY   ((uint32_t)0x00010000)
 
#define IS_FLASH_CLEAR_FLAG(FLAG)   ((((FLAG) & (uint32_t)0xFFFFFF0C) == 0x00000000) && ((FLAG) != 0x00000000))
 
#define IS_FLASH_GET_FLAG(FLAG)
 
#define FLASH_PSIZE_BYTE   ((uint32_t)0x00000000)
 
#define FLASH_PSIZE_HALF_WORD   ((uint32_t)0x00000100)
 
#define FLASH_PSIZE_WORD   ((uint32_t)0x00000200)
 
#define FLASH_PSIZE_DOUBLE_WORD   ((uint32_t)0x00000300)
 
#define CR_PSIZE_MASK   ((uint32_t)0xFFFFFCFF)
 
#define RDP_KEY   ((uint16_t)0x00A5)
 
#define FLASH_KEY1   ((uint32_t)0x45670123)
 
#define FLASH_KEY2   ((uint32_t)0xCDEF89AB)
 
#define FLASH_OPT_KEY1   ((uint32_t)0x08192A3B)
 
#define FLASH_OPT_KEY2   ((uint32_t)0x4C5D6E7F)
 
#define ACR_BYTE0_ADDRESS   ((uint32_t)0x40023C00)
 ACR register byte 0 (Bits[8:0]) base address.
 
#define OPTCR_BYTE0_ADDRESS   ((uint32_t)0x40023C14)
 OPTCR register byte 3 (Bits[24:16]) base address.
 
#define OPTCR_BYTE1_ADDRESS   ((uint32_t)0x40023C15)
 
#define OPTCR_BYTE2_ADDRESS   ((uint32_t)0x40023C16)
 

Enumerations

enum  FLASH_Status {
  FLASH_BUSY = 1, FLASH_ERROR_PGS, FLASH_ERROR_PGP, FLASH_ERROR_PGA,
  FLASH_ERROR_WRP, FLASH_ERROR_PROGRAM, FLASH_ERROR_OPERATION, FLASH_COMPLETE
}
 FLASH Status.
 

Functions

void FLASH_SetLatency (uint32_t FLASH_Latency)
 Sets the code latency value. More...
 
void FLASH_PrefetchBufferCmd (FunctionalState NewState)
 Enables or disables the Prefetch Buffer. More...
 
void FLASH_InstructionCacheCmd (FunctionalState NewState)
 Enables or disables the Instruction Cache feature. More...
 
void FLASH_DataCacheCmd (FunctionalState NewState)
 Enables or disables the Data Cache feature. More...
 
void FLASH_InstructionCacheReset (void)
 Resets the Instruction Cache. More...
 
void FLASH_DataCacheReset (void)
 Resets the Data Cache. More...
 
void FLASH_Unlock (void)
 Unlocks the FLASH control register access. More...
 
void FLASH_Lock (void)
 Locks the FLASH control register access. More...
 
FLASH_Status FLASH_EraseSector (uint32_t FLASH_Sector, uint8_t VoltageRange)
 Erases a specified FLASH Sector. More...
 
FLASH_Status FLASH_EraseAllSectors (uint8_t VoltageRange)
 Erases all FLASH Sectors. More...
 
FLASH_Status FLASH_ProgramDoubleWord (uint32_t Address, uint64_t Data)
 Programs a double word (64-bit) at a specified address. More...
 
FLASH_Status FLASH_ProgramWord (uint32_t Address, uint32_t Data)
 Programs a word (32-bit) at a specified address. More...
 
FLASH_Status FLASH_ProgramHalfWord (uint32_t Address, uint16_t Data)
 Programs a half word (16-bit) at a specified address. More...
 
FLASH_Status FLASH_ProgramByte (uint32_t Address, uint8_t Data)
 Programs a byte (8-bit) at a specified address. More...
 
void FLASH_OB_Unlock (void)
 Unlocks the FLASH Option Control Registers access. More...
 
void FLASH_OB_Lock (void)
 Locks the FLASH Option Control Registers access. More...
 
void FLASH_OB_WRPConfig (uint32_t OB_WRP, FunctionalState NewState)
 Enables or disables the write protection of the desired sectors. More...
 
void FLASH_OB_RDPConfig (uint8_t OB_RDP)
 Sets the read protection level. More...
 
void FLASH_OB_UserConfig (uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY)
 Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. More...
 
void FLASH_OB_BORConfig (uint8_t OB_BOR)
 Sets the BOR Level. More...
 
FLASH_Status FLASH_OB_Launch (void)
 Launch the option byte loading. More...
 
uint8_t FLASH_OB_GetUser (void)
 Returns the FLASH User Option Bytes values. More...
 
uint16_t FLASH_OB_GetWRP (void)
 Returns the FLASH Write Protection Option Bytes value. More...
 
FlagStatus FLASH_OB_GetRDP (void)
 Returns the FLASH Read Protection level. More...
 
uint8_t FLASH_OB_GetBOR (void)
 Returns the FLASH BOR level. More...
 
void FLASH_ITConfig (uint32_t FLASH_IT, FunctionalState NewState)
 Enables or disables the specified FLASH interrupts. More...
 
FlagStatus FLASH_GetFlagStatus (uint32_t FLASH_FLAG)
 Checks whether the specified FLASH flag is set or not. More...
 
void FLASH_ClearFlag (uint32_t FLASH_FLAG)
 Clears the FLASH's pending flags. More...
 
FLASH_Status FLASH_GetStatus (void)
 Returns the FLASH Status. More...
 
FLASH_Status FLASH_WaitForLastOperation (void)
 Waits for a FLASH operation to complete. More...
 

Detailed Description

This file contains all the functions prototypes for the FLASH firmware library.

Author
MCD Application Team
Version
V1.0.2
Date
05-March-2012
Attention

© COPYRIGHT 2012 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

   http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.