STM8L15x Standard Peripherals Drivers: stm8l15x_flash.c File Reference

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_flash.c File Reference

This file provides all the Flash firmware functions. These functions can be executed from Internal FLASH or Internal RAM memories.

  • FLASH program and Data EEPROM memories interface configuration
  • FLASH program and Data EEPROM memories Programming
  • Option Bytes Programming
  • Interrupts and flags management
  • Functions to be executed from RAM.
More...
#include "stm8l15x_flash.h"

Go to the source code of this file.

Defines

#define FLASH_CLEAR_BYTE   ((uint8_t)0x00)
#define FLASH_SET_BYTE   ((uint8_t)0xFF)
#define OPERATION_TIMEOUT   ((uint16_t)0xFFFF)

Functions

void FLASH_DeInit (void)
 Deinitializes the FLASH registers to their default reset values.
void FLASH_EraseByte (uint32_t Address)
 Erases one byte in the program or data EEPROM memory.
void FLASH_EraseOptionByte (uint16_t Address)
 Erases option byte.
uint16_t FLASH_GetBootSize (void)
 Returns the Boot memory size in bytes.
uint16_t FLASH_GetCodeSize (void)
 Returns the Code Area size in bytes.
FlagStatus FLASH_GetFlagStatus (FLASH_FLAG_TypeDef FLASH_FLAG)
 Checks whether the specified FLASH flag is set or not.
FLASH_ProgramTime_TypeDef FLASH_GetProgrammingTime (void)
 Returns the fixed programming time.
FunctionalState FLASH_GetReadOutProtectionStatus (void)
 Returns the FLASH Read Out Protection Status.
void FLASH_ITConfig (FunctionalState NewState)
 Enables or Disables the Flash interrupt mode.
void FLASH_Lock (FLASH_MemType_TypeDef FLASH_MemType)
 Locks the program or data EEPROM memory.
void FLASH_PowerWaitModeConfig (FLASH_Power_TypeDef FLASH_Power)
 Configures the power state for Flash program and data EEPROM during wait for interrupt mode.
void FLASH_ProgramByte (uint32_t Address, uint8_t Data)
 Programs one byte in program or data EEPROM memory.
void FLASH_ProgramOptionByte (uint16_t Address, uint8_t Data)
 Programs option byte.
void FLASH_ProgramWord (uint32_t Address, uint32_t Data)
 Programs one word (4 bytes) in program or data EEPROM memory.
uint8_t FLASH_ReadByte (uint32_t Address)
 Reads one byte from flash memory.
void FLASH_SetProgrammingTime (FLASH_ProgramTime_TypeDef FLASH_ProgTime)
 Sets the fixed programming time.
void FLASH_Unlock (FLASH_MemType_TypeDef FLASH_MemType)
 Unlocks the program or data EEPROM memory.

Detailed Description

This file provides all the Flash firmware functions. These functions can be executed from Internal FLASH or Internal RAM memories.

  • FLASH program and Data EEPROM memories interface configuration
  • FLASH program and Data EEPROM memories Programming
  • Option Bytes Programming
  • Interrupts and flags management
  • Functions to be executed from RAM.
Author:
MCD Application Team
Version:
V1.5.0
Date:
13-May-2011
  *  
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *                           
  *          This driver provides functions to configure and program the Flash 
  *          memory of all STM8L15x devices
  *          These functions are split in 4 groups
  * 
  *           1. FLASH program and Data EEPROM memories interface configuration 
  *              functions: this group includes the management of the following 
  *              features:
  *                    - Set the fixed programming time
  *                    - Configure the power state during WFI mode
  *                    - Configure the power state during run, low power run and
  *                      WFE modes (should be executed from internal RAM) 
  *  
  *           2. FLASH program and Data EEPROM memories Programming functions: 
  *              this group includes all needed functions to erase and program 
  *              the FLASH program or the Data EEPROM memory.
  *                    - Lock and Unlock the Flash program interface.
  *                    - Lock and Unlock the Data EEPROM interface.  
  *                    - Erase function: Erase Byte, Erase Word and Erase Block 
  *                      (should be executed from internal RAM). 
  *                    - Program functions: Program Byte, Program Word, 
  *                      Program Block (should be executed from internal RAM) 
  *                      and Fast Program Block (should be executed from internal
  *                      RAM).
  *    
  *           3. FLASH Option Bytes Programming functions: this group includes 
  *              all needed functions to:
  *                    - Program/erase the user option Bytes 
  *                    - Get the Read Out Protection status (ROP option byte)
  *                    - Get the User Boot Code size (UBC option byte)
  *                    - Get the Protected Code size (PCODE option byte) 
  *                    
  *            Note: Option byte programming is very similar to data EEPROM byte
  *                  programming.          
  *  
  *           4. FLASH Interrupts and flag management functions: this group 
  *              includes all needed functions to:
  *                    - Enable/Disable the flash interrupt sources
  *                    - Get flags status
  *                    - Wait for last flash operation(can be executed from 
  *                      internal RAM)
  *                        
  *           5. Functions to be executed from RAM: this group includes the functions
  *              that should be executed from RAM and provides description on how 
  *              to handle this with the different supported toolchains
  *   
  *  The table below lists the functions that can be executed from RAM.
  *  
  *   +--------------------------------------------------------------------------------|
  *   |   Functions prototypes      |    RAM execution            |     Comments       |
  *   ---------------------------------------------------------------------------------|
  *   |                             | Mandatory in case of block  | Can be executed    |
  *   | FLASH_WaitForLastOperation  | Operation:                  | from Flash in case |
  *   |                             | - Block programming         | of byte and word   |
  *   |                             | - Block erase               | Operations         |
  *   |--------------------------------------------------------------------------------|
  *   | FLASH_PowerRunModeConfig    |       Exclusively           | useless from Flash |
  *   |--------------------------------------------------------------------------------|
  *   | FLASH_GetPowerStatus        |       Exclusively           | useless from Flash |
  *   |--------------------------------------------------------------------------------|
  *   | FLASH_ProgramBlock          |       Exclusively           | useless from Flash |
  *   |--------------------------------------------------------------------------------|
  *   | FLASH_EraseBlock            |       Exclusively           | useless from Flash |
  *   |--------------------------------------------------------------------------------|
  *  
  *  To be able to execute functions from RAM several steps have to be followed.
  *   These steps may differ from one toolchain to another.
  *   A detailed description is available below within this driver.
  *   You can also refer to the Flash_DataProgram example provided within the
  *   STM8L15x_StdPeriph_Lib package.
  * 
  *  
Attention:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

Definition in file stm8l15x_flash.c.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com