STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

FLASH driver modules. More...

Modules

 FLASH_Exported_Constants
 
 FLASH_Private_Functions
 

Enumerations

enum  FLASH_Status {
  FLASH_BUSY = 1, FLASH_ERROR_WRP, FLASH_ERROR_PROGRAM, FLASH_COMPLETE,
  FLASH_TIMEOUT
}
 FLASH Status.
 

Functions

void FLASH_SetLatency (uint32_t FLASH_Latency)
 FLASH memory functions that can be executed from FLASH. More...
 
void FLASH_PrefetchBufferCmd (FunctionalState NewState)
 Enables or disables the Prefetch Buffer. More...
 
FlagStatus FLASH_GetPrefetchBufferStatus (void)
 Checks whether the FLASH Prefetch Buffer status is set or not. More...
 
void FLASH_Unlock (void)
 Unlocks the FLASH control register and program memory access. More...
 
void FLASH_Lock (void)
 Locks the Program memory access. More...
 
FLASH_Status FLASH_ErasePage (uint32_t Page_Address)
 Erases a specified page in program memory. More...
 
FLASH_Status FLASH_EraseAllPages (void)
 Erases all FLASH pages. More...
 
FLASH_Status FLASH_ProgramWord (uint32_t Address, uint32_t Data)
 Programs a word at a specified address. More...
 
FLASH_Status FLASH_ProgramHalfWord (uint32_t Address, uint16_t Data)
 Programs a half word at a specified address. More...
 
void FLASH_OB_Unlock (void)
 Unlocks the option bytes block access. More...
 
void FLASH_OB_Lock (void)
 Locks the option bytes block access. More...
 
void FLASH_OB_Launch (void)
 Launch the option byte loading. More...
 
FLASH_Status FLASH_OB_Erase (void)
 Erases the FLASH option bytes. More...
 
FLASH_Status FLASH_OB_EnableWRP (uint32_t OB_WRP)
 Write protects the desired pages. More...
 
FLASH_Status FLASH_OB_RDPConfig (uint8_t OB_RDP)
 Enables or disables the read out protection. More...
 
FLASH_Status 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...
 
FLASH_Status FLASH_OB_BOOTConfig (uint8_t OB_BOOT1)
 Sets or resets the BOOT1 option bit. More...
 
FLASH_Status FLASH_OB_VDDAConfig (uint8_t OB_VDDA_ANALOG)
 Sets or resets the analogue monitoring on VDDA Power source. More...
 
FLASH_Status FLASH_OB_SRAMParityConfig (uint8_t OB_SRAM_Parity)
 Sets or resets the SRAM parity. More...
 
FLASH_Status FLASH_OB_WriteUser (uint8_t OB_USER)
 Programs the FLASH User Option Byte: IWDG_SW, RST_STOP, RST_STDBY, BOOT1 and VDDA ANALOG monitoring. More...
 
FLASH_Status FLASH_ProgramOptionByteData (uint32_t Address, uint8_t Data)
 Programs a half word at a specified Option Byte Data address. More...
 
uint8_t FLASH_OB_GetUser (void)
 Returns the FLASH User Option Bytes values. More...
 
uint32_t FLASH_OB_GetWRP (void)
 Returns the FLASH Write Protection Option Bytes value. More...
 
FlagStatus FLASH_OB_GetRDP (void)
 Checks whether the FLASH Read out Protection Status is set or not. 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 (uint32_t Timeout)
 Waits for a FLASH operation to complete or a TIMEOUT to occur. More...
 

Detailed Description

FLASH driver modules.

Function Documentation

void FLASH_ClearFlag ( uint32_t  FLASH_FLAG)

Clears the FLASH's pending flags.

Parameters
FLASH_FLAG,:specifies the FLASH flags to clear. This parameter can be any combination of the following values:
  • FLASH_FLAG_PGERR: FLASH Programming error flag flag
  • FLASH_FLAG_WRPERR: FLASH Write protected error flag
  • FLASH_FLAG_EOP: FLASH End of Programming flag
Return values
None
FLASH_Status FLASH_EraseAllPages ( void  )

Erases all FLASH pages.

Note
To correctly run this function, the FLASH_Unlock() function must be called before.
Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
None
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FLASH_Status FLASH_ErasePage ( uint32_t  Page_Address)

Erases a specified page in program memory.

Note
To correctly run this function, the FLASH_Unlock() function must be called before.
Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
Page_Address,:The page address in program memory to be erased.
Note
A Page is erased in the Program memory only if the address to load is the start address of a page (multiple of 1024 bytes).
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FlagStatus FLASH_GetFlagStatus ( uint32_t  FLASH_FLAG)

Checks whether the specified FLASH flag is set or not.

Parameters
FLASH_FLAG,:specifies the FLASH flag to check. This parameter can be one of the following values:
  • FLASH_FLAG_BSY: FLASH write/erase operations in progress flag
  • FLASH_FLAG_PGERR: FLASH Programming error flag flag
  • FLASH_FLAG_WRPERR: FLASH Write protected error flag
  • FLASH_FLAG_EOP: FLASH End of Programming flag
Return values
Thenew state of FLASH_FLAG (SET or RESET).
FlagStatus FLASH_GetPrefetchBufferStatus ( void  )

Checks whether the FLASH Prefetch Buffer status is set or not.

Parameters
None
Return values
FLASHPrefetch Buffer Status (SET or RESET).
FLASH_Status FLASH_GetStatus ( void  )

Returns the FLASH Status.

Parameters
None
Return values
FLASHStatus: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP or FLASH_COMPLETE.
void FLASH_ITConfig ( uint32_t  FLASH_IT,
FunctionalState  NewState 
)

Enables or disables the specified FLASH interrupts.

Parameters
FLASH_IT,:specifies the FLASH interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:
  • FLASH_IT_EOP: FLASH end of programming Interrupt
  • FLASH_IT_ERR: FLASH Error Interrupt
Return values
None
void FLASH_Lock ( void  )

Locks the Program memory access.

Parameters
None
Return values
None
FLASH_Status FLASH_OB_BOOTConfig ( uint8_t  OB_BOOT1)

Sets or resets the BOOT1 option bit.

Parameters
OB_BOOT1,:Set or Reset the BOOT1 option bit. This parameter can be one of the following values:
  • OB_BOOT1_RESET: BOOT1 option bit reset
  • OB_BOOT1_SET: BOOT1 option bit set
Return values
None
FLASH_Status FLASH_OB_EnableWRP ( uint32_t  OB_WRP)

Write protects the desired pages.

Note
To correctly run this function, the FLASH_OB_Unlock() function must be called before.
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
OB_WRP,:specifies the address of the pages to be write protected. This parameter can be:
  • OB_WRP_Pages0to3..OB_WRP_Pages60to63
  • OB_WRP_AllPages
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FLASH_Status FLASH_OB_Erase ( void  )

Erases the FLASH option bytes.

Note
To correctly run this function, the FLASH_OB_Unlock() function must be called before.
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
This functions erases all option bytes except the Read protection (RDP).
Parameters
None
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FlagStatus FLASH_OB_GetRDP ( void  )

Checks whether the FLASH Read out Protection Status is set or not.

Parameters
None
Return values
FLASHReadOut Protection Status(SET or RESET)
uint8_t FLASH_OB_GetUser ( void  )

Returns the FLASH User Option Bytes values.

Parameters
None
Return values
TheFLASH User Option Bytes .
uint32_t FLASH_OB_GetWRP ( void  )

Returns the FLASH Write Protection Option Bytes value.

Parameters
None
Return values
TheFLASH Write Protection Option Bytes value
void FLASH_OB_Launch ( void  )

Launch the option byte loading.

Parameters
None
Return values
None
void FLASH_OB_Lock ( void  )

Locks the option bytes block access.

Parameters
None
Return values
None
FLASH_Status FLASH_OB_RDPConfig ( uint8_t  OB_RDP)

Enables or disables the read out protection.

Note
To correctly run this function, the FLASH_OB_Unlock() function must be called before.
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
FLASH_ReadProtection_Level,:specifies the read protection level. This parameter can be:
  • OB_RDP_Level_0: No protection
  • OB_RDP_Level_1: Read protection of the memory
  • OB_RDP_Level_2: Chip protection
Note
When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FLASH_Status FLASH_OB_SRAMParityConfig ( uint8_t  OB_SRAM_Parity)

Sets or resets the SRAM parity.

Parameters
OB_SRAM_Parity,:Set or Reset the SRAM parity enable bit. This parameter can be one of the following values:
  • OB_SRAM_PARITY_SET: Set SRAM parity.
  • OB_SRAM_PARITY_RESET: Reset SRAM parity.
Return values
None
void FLASH_OB_Unlock ( void  )

Unlocks the option bytes block access.

Parameters
None
Return values
None
FLASH_Status 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.

Note
To correctly run this function, the FLASH_OB_Unlock() function must be called before.
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
OB_IWDG,:Selects the WDG mode This parameter can be one of the following values:
  • OB_IWDG_SW: Software WDG selected
  • OB_IWDG_HW: Hardware WDG selected
OB_STOP,:Reset event when entering STOP mode. This parameter can be one of the following values:
  • OB_STOP_NoRST: No reset generated when entering in STOP
  • OB_STOP_RST: Reset generated when entering in STOP
OB_STDBY,:Reset event when entering Standby mode. This parameter can be one of the following values:
  • OB_STDBY_NoRST: No reset generated when entering in STANDBY
  • OB_STDBY_RST: Reset generated when entering in STANDBY
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FLASH_Status FLASH_OB_VDDAConfig ( uint8_t  OB_VDDA_ANALOG)

Sets or resets the analogue monitoring on VDDA Power source.

Parameters
OB_VDDA_ANALOG,:Selects the analog monitoring on VDDA Power source. This parameter can be one of the following values:
  • OB_VDDA_ANALOG_ON: Analog monitoring on VDDA Power source ON
  • OB_VDDA_ANALOG_OFF: Analog monitoring on VDDA Power source OFF
Return values
None
FLASH_Status FLASH_OB_WriteUser ( uint8_t  OB_USER)

Programs the FLASH User Option Byte: IWDG_SW, RST_STOP, RST_STDBY, BOOT1 and VDDA ANALOG monitoring.

Note
To correctly run this function, the FLASH_OB_Unlock() function must be called before.
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
OB_USER,:Selects all user option bytes This parameter is a combination of the following values:
  • OB_IWDG_SW / OB_IWDG_HW: Software / Hardware WDG selected
  • OB_STOP_NoRST / OB_STOP_RST: No reset / Reset generated when entering in STOP
  • OB_STDBY_NoRST / OB_STDBY_RST: No reset / Reset generated when entering in STANDBY
  • OB_BOOT1_RESET / OB_BOOT1_SET: BOOT1 Reset / Set
  • OB_VDDA_ANALOG_ON / OB_VDDA_ANALOG_OFF: Analog monitoring on VDDA Power source ON / OFF
  • OB_SRAM_PARITY_SET / OB_SRAM_PARITY_RESET: SRAM Parity SET / RESET
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
void FLASH_PrefetchBufferCmd ( FunctionalState  NewState)

Enables or disables the Prefetch Buffer.

Parameters
NewState,:new state of the FLASH prefetch buffer. This parameter can be: ENABLE or DISABLE.
Return values
None
FLASH_Status FLASH_ProgramHalfWord ( uint32_t  Address,
uint16_t  Data 
)

Programs a half word at a specified address.

Note
To correctly run this function, the FLASH_Unlock() function must be called before.
Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
Address,:specifies the address to be programmed.
Data,:specifies the data to be programmed.
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FLASH_Status FLASH_ProgramOptionByteData ( uint32_t  Address,
uint8_t  Data 
)

Programs a half word at a specified Option Byte Data address.

Note
To correctly run this function, the FLASH_OB_Unlock() function must be called before.
Call the FLASH_OB_Lock() to disable the flash control register access and the option bytes (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
Address,:specifies the address to be programmed. This parameter can be 0x1FFFF804 or 0x1FFFF806.
Data,:specifies the data to be programmed.
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
FLASH_Status FLASH_ProgramWord ( uint32_t  Address,
uint32_t  Data 
)

Programs a word at a specified address.

Note
To correctly run this function, the FLASH_Unlock() function must be called before.
Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
Parameters
Address,:specifies the address to be programmed.
Data,:specifies the data to be programmed.
Return values
FLASHStatus: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
void FLASH_SetLatency ( uint32_t  FLASH_Latency)

FLASH memory functions that can be executed from FLASH.

FLASH memory functions that can be executed from FLASH.

Parameters
FLASH_Latency,:specifies the FLASH Latency value. This parameter can be one of the following values:
  • FLASH_Latency_0: FLASH Zero Latency cycle
  • FLASH_Latency_1: FLASH One Latency cycle
Return values
None
void FLASH_Unlock ( void  )

Unlocks the FLASH control register and program memory access.

Parameters
None
Return values
None
FLASH_Status FLASH_WaitForLastOperation ( uint32_t  Timeout)

Waits for a FLASH operation to complete or a TIMEOUT to occur.

Parameters
Timeout,:FLASH programming Timeout
Return values
FLASHStatus: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.