MG32F157 Standard Peripherals Firmware Library
Functions
FLASH_Private_Functions

Functions

void FLASH_SetLatency (uint32_t FLASH_Latency)
 Sets the code latency value. More...
 
void FLASH_HalfCycleAccessCmd (uint32_t FLASH_HalfCycleAccess)
 Enables or disables the Half cycle flash access. More...
 
void FLASH_PrefetchBufferCmd (uint32_t FLASH_PrefetchBuffer)
 Enables or disables the Prefetch Buffer. More...
 
void FLASH_Unlock (void)
 Unlocks the FLASH Program Erase Controller. More...
 
void FLASH_UnlockBank1 (void)
 Unlocks the FLASH Bank1 Program Erase Controller. More...
 
void FLASH_Lock (void)
 Locks the FLASH Program Erase Controller. More...
 
void FLASH_LockBank1 (void)
 Locks the FLASH Bank1 Program Erase Controller. More...
 
FLASH_Status FLASH_ErasePage (uint32_t Page_Address)
 Erases a specified FLASH page. More...
 
FLASH_Status FLASH_EraseAllPages (void)
 Erases all FLASH pages. More...
 
FLASH_Status FLASH_EraseAllBank1Pages (void)
 Erases all Bank1 FLASH pages. More...
 
FLASH_Status FLASH_EraseOptionBytes (void)
 Erases the FLASH option bytes. 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...
 
FLASH_Status FLASH_ProgramOptionByteData (uint32_t Address, uint8_t Data)
 Programs a half word at a specified Option Byte Data address. More...
 
FLASH_Status FLASH_EnableWriteProtection (uint32_t FLASH_Pages)
 Write protects the desired pages. More...
 
FLASH_Status FLASH_ReadOutProtection (FunctionalState NewState)
 Enables or disables the read out protection. More...
 
FLASH_Status FLASH_UserOptionByteConfig (uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY)
 Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. More...
 
uint32_t FLASH_GetUserOptionByte (void)
 Returns the FLASH User Option Bytes values. More...
 
uint32_t FLASH_GetWriteProtectionOptionByte (void)
 Returns the FLASH Write Protection Option Bytes Register value. More...
 
FlagStatus FLASH_GetReadOutProtectionStatus (void)
 Checks whether the FLASH Read Out Protection Status is set or not. More...
 
FlagStatus FLASH_GetPrefetchBufferStatus (void)
 Checks whether the FLASH Prefetch Buffer 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_GetBank1Status (void)
 Returns the FLASH Bank1 Status. More...
 
FLASH_Status FLASH_WaitForLastOperation (uint32_t Timeout)
 Waits for a Flash operation to complete or a TIMEOUT to occur. More...
 
FLASH_Status FLASH_WaitForLastBank1Operation (uint32_t Timeout)
 Waits for a Flash operation on Bank1 to complete or a TIMEOUT to occur. More...
 

Detailed Description

Function Documentation

◆ FLASH_ClearFlag()

void FLASH_ClearFlag ( uint32_t  FLASH_FLAG)

Clears the FLASH's pending flags.

Parameters
FLASH_FLAGspecifies the FLASH flags to clear. This parameter can be any combination of the following values:
  • FLASH_FLAG_PGERR: FLASH Program error flag
  • FLASH_FLAG_WRPRTERR: FLASH Write protected error flag
  • FLASH_FLAG_EOP: FLASH End of Operation flag
Returns
None

◆ FLASH_EnableWriteProtection()

FLASH_Status FLASH_EnableWriteProtection ( uint32_t  FLASH_Pages)

Write protects the desired pages.

Parameters
FLASH_Pagesspecifies the address of the pages to be write protected. This parameter can be:
  • value between FLASH_WRProt_Pages0to1 and FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to255
  • FLASH_WRProt_AllPages
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_EraseAllBank1Pages()

FLASH_Status FLASH_EraseAllBank1Pages ( void  )

Erases all Bank1 FLASH pages.

Parameters
None
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_EraseAllPages()

FLASH_Status FLASH_EraseAllPages ( void  )

Erases all FLASH pages.

Parameters
None
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_EraseOptionBytes()

FLASH_Status FLASH_EraseOptionBytes ( void  )

Erases the FLASH option bytes.

Note
This functions erases all option bytes except the Read protection (RDP).
Parameters
None
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_ErasePage()

FLASH_Status FLASH_ErasePage ( uint32_t  Page_Address)

Erases a specified FLASH page.

Parameters
Page_AddressThe page address to be erased.
Returns
FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_GetBank1Status()

FLASH_Status FLASH_GetBank1Status ( void  )

Returns the FLASH Bank1 Status.

Note
It is equivalent to FLASH_GetStatus function.
Parameters
None
Returns
FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, FLASH_ERROR_WRP or FLASH_COMPLETE

◆ FLASH_GetFlagStatus()

FlagStatus FLASH_GetFlagStatus ( uint32_t  FLASH_FLAG)

Checks whether the specified FLASH flag is set or not.

Parameters
FLASH_FLAGspecifies the FLASH flag to check. This parameter can be one of the following values:
  • FLASH_FLAG_BSY: FLASH Busy flag
  • FLASH_FLAG_PGERR: FLASH Program error flag
  • FLASH_FLAG_WRPRTERR: FLASH Write protected error flag
  • FLASH_FLAG_EOP: FLASH End of Operation flag
  • FLASH_FLAG_OPTERR: FLASH Option Byte error flag
Returns
The new state of FLASH_FLAG (SET or RESET).

◆ FLASH_GetPrefetchBufferStatus()

FlagStatus FLASH_GetPrefetchBufferStatus ( void  )

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

Parameters
None
Returns
FLASH Prefetch Buffer Status (SET or RESET).

◆ FLASH_GetReadOutProtectionStatus()

FlagStatus FLASH_GetReadOutProtectionStatus ( void  )

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

Parameters
None
Returns
FLASH ReadOut Protection Status(SET or RESET)

◆ FLASH_GetStatus()

FLASH_Status FLASH_GetStatus ( void  )

Returns the FLASH Status.

Note
It is equivalent to FLASH_GetBank1Status function.
Parameters
None
Returns
FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, FLASH_ERROR_WRP or FLASH_COMPLETE

◆ FLASH_GetUserOptionByte()

uint32_t FLASH_GetUserOptionByte ( void  )

Returns the FLASH User Option Bytes values.

Parameters
None
Returns
The FLASH User Option Bytes values:IWDG_SW(Bit0), RST_STOP(Bit1) and RST_STDBY(Bit2).

◆ FLASH_GetWriteProtectionOptionByte()

uint32_t FLASH_GetWriteProtectionOptionByte ( void  )

Returns the FLASH Write Protection Option Bytes Register value.

Parameters
None
Returns
The FLASH Write Protection Option Bytes Register value

◆ FLASH_HalfCycleAccessCmd()

void FLASH_HalfCycleAccessCmd ( uint32_t  FLASH_HalfCycleAccess)

Enables or disables the Half cycle flash access.

Parameters
FLASH_HalfCycleAccessspecifies the FLASH Half cycle Access mode. This parameter can be one of the following values:
  • FLASH_HalfCycleAccess_Enable: FLASH Half Cycle Enable
  • FLASH_HalfCycleAccess_Disable: FLASH Half Cycle Disable
Returns
None

◆ FLASH_ITConfig()

void FLASH_ITConfig ( uint32_t  FLASH_IT,
FunctionalState  NewState 
)

Enables or disables the specified FLASH interrupts.

Parameters
FLASH_ITspecifies the FLASH interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:
  • FLASH_IT_ERROR: FLASH Error Interrupt
  • FLASH_IT_EOP: FLASH end of operation Interrupt
NewStatenew state of the specified Flash interrupts. This parameter can be: ENABLE or DISABLE.
Returns
None

◆ FLASH_Lock()

void FLASH_Lock ( void  )

Locks the FLASH Program Erase Controller.

Parameters
None
Returns
None

◆ FLASH_LockBank1()

void FLASH_LockBank1 ( void  )

Locks the FLASH Bank1 Program Erase Controller.

Parameters
None
Returns
None

◆ FLASH_PrefetchBufferCmd()

void FLASH_PrefetchBufferCmd ( uint32_t  FLASH_PrefetchBuffer)

Enables or disables the Prefetch Buffer.

Parameters
FLASH_PrefetchBufferspecifies the Prefetch buffer status. This parameter can be one of the following values:
  • FLASH_PrefetchBuffer_Enable: FLASH Prefetch Buffer Enable
  • FLASH_PrefetchBuffer_Disable: FLASH Prefetch Buffer Disable
Returns
None

◆ FLASH_ProgramHalfWord()

FLASH_Status FLASH_ProgramHalfWord ( uint32_t  Address,
uint16_t  Data 
)

Programs a half word at a specified address.

Parameters
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed.
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_ProgramOptionByteData()

FLASH_Status FLASH_ProgramOptionByteData ( uint32_t  Address,
uint8_t  Data 
)

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

Parameters
Addressspecifies the address to be programmed. This parameter can be 0x1FFFF804 or 0x1FFFF806.
Dataspecifies the data to be programmed.
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_ProgramWord()

FLASH_Status FLASH_ProgramWord ( uint32_t  Address,
uint32_t  Data 
)

Programs a word at a specified address.

Parameters
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed.
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_ReadOutProtection()

FLASH_Status FLASH_ReadOutProtection ( FunctionalState  NewState)

Enables or disables the read out protection.

Note
If the user has already programmed the other option bytes before calling this function, he must re-program them since this function erases all option bytes.
Parameters
Newstatenew state of the ReadOut Protection. This parameter can be: ENABLE or DISABLE.
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_SetLatency()

void FLASH_SetLatency ( uint32_t  FLASH_Latency)

Sets the code latency value.

Parameters
FLASH_Latencyspecifies 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
  • FLASH_Latency_2: FLASH Two Latency cycles
Returns
None

◆ FLASH_Unlock()

void FLASH_Unlock ( void  )

Unlocks the FLASH Program Erase Controller.

Parameters
None
Returns
None

◆ FLASH_UnlockBank1()

void FLASH_UnlockBank1 ( void  )

Unlocks the FLASH Bank1 Program Erase Controller.

Parameters
None
Returns
None

◆ FLASH_UserOptionByteConfig()

FLASH_Status FLASH_UserOptionByteConfig ( uint16_t  OB_IWDG,
uint16_t  OB_STOP,
uint16_t  OB_STDBY 
)

Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

Parameters
OB_IWDGSelects the IWDG mode This parameter can be one of the following values:
  • OB_IWDG_SW: Software IWDG selected
  • OB_IWDG_HW: Hardware IWDG selected
OB_STOPReset 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_STDBYReset 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
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_WaitForLastBank1Operation()

FLASH_Status FLASH_WaitForLastBank1Operation ( uint32_t  Timeout)

Waits for a Flash operation on Bank1 to complete or a TIMEOUT to occur.

Note
It is equivalent to FLASH_WaitForLastOperation.
Parameters
TimeoutFLASH programming Timeout
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

◆ FLASH_WaitForLastOperation()

FLASH_Status FLASH_WaitForLastOperation ( uint32_t  Timeout)

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

Parameters
TimeoutFLASH programming Timeout
Returns
FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.