📄 flash.h
字号:
/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
* File Name : flash.h
* Author : MCD Application Team
* Date First Issued : 07/28/2003
* Description : This file contains all the functions prototypes for the
* Embedded Flash software library.
********************************************************************************
* History:
* 07/28/2003 : Created
* 11/24/2004 : IAP Version 1.0
********************************************************************************
THE PRESENT SOFTWARE 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
SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN
IN CONNECTION WITH THEIR PRODUCTS.
********************************************************************************/
#ifndef __FLASH_H
#define __FLASH_H
#include "71x_lib.h"
#include "common.h"
#define FLASH_B0F0 0x00000001
#define FLASH_B0F1 0x00000002
#define FLASH_B0F2 0x00000004
#define FLASH_B0F3 0x00000008
#define FLASH_B0F4 0x00000010
#define FLASH_B0F5 0x00000020
#define FLASH_B0F6 0x00000040
#define FLASH_B0F7 0x00000080
#define FLASH_B1F0 0x00010000
#define FLASH_B1F1 0x00020000
#define FLASH_B0 (FLASH_B0F0 | FLASH_B0F1 | FLASH_B0F2 | FLASH_B0F3 | FLASH_B0F4 | FLASH_B0F5 | FLASH_B0F6 | FLASH_B0F7)
#define FLASH_B1 (FLASH_B1F0 | FLASH_B1F1)
#define FLASH_WMS_Mask 0x80000000
#define FLASH_SUSP_Mask 0x40000000
#define FLASH_WPG_Mask 0x20000000
#define FLASH_DWPG_Mask 0x10000000
#define FLASH_SER_Mask 0x08000000
#define FLASH_SPR_Mask 0x01000000
#define FLASH_BER_Mask 0x04000000
#define FLASH_MER_Mask 0x02000000
#define FLASH_BSYA1_Mask 0x00000002
#define FLASH_BSYA2_Mask 0x00000004
#define FLASH_DBGP_Mask 0x00000002
#define FLASH_ACCP_Mask 0x00000001
#define FLASH_Reg_Mask 0xE0
#define FLASH_Flag_Mask 0x1F
#define FLASH_INTM_Mask 0x00200000
#define FLASH_INTP_Mask 0x00100000
/* base address of external flash */
#define INT_FLASH_BASE (u32 *)0x40000000
/* size of internal flash (by 16-bit) */
#define INT_FLASH_SIZE 0x200000
/* number of sectors in internal flash */
#define INT_FLASH_SECNUM 10
typedef enum
{
FLASH_FINISHED,
FLASH_ONGOING
} flashwriteoperation;
typedef enum
{
FLASH_BANK0 = 0x1000000,
FLASH_BANK1 = 0x2000000
} flashbanks;
typedef enum
{
FLASH_LPS = 0x2F, /* 001-01111 = 0010 1111 = 0x2F */
FLASH_LOCK = 0x24, /* 001-00100 = 0010 0100 = 0x24 */
FLASH_BSY1 = 0x22, /* 001-00010 = 0010 0010 = 0x22 */
FLASH_BSY0 = 0x21, /* 001-00001 = 0010 0001 = 0x21 */
FLASH_WPF = 0x48, /* 010-01000 = 0100 1000 = 0x48 */
FLASH_RESER = 0x47, /* 010-00111 = 0100 0111 = 0x47 */
FLASH_SEQER = 0x46, /* 010-00110 = 0100 0110 = 0x46 */
FLASH_10ER = 0x43, /* 010-00011 = 0100 0011 = 0x43 */
FLASH_PGER = 0x42, /* 010-00010 = 0100 0010 = 0x42 */
FLASH_ERER = 0x41, /* 010-00001 = 0100 0001 = 0x41 */
FLASH_ERR = 0x40 /* 010-00000 = 0100 0000 = 0x40 */
} flashflags;
/*******************************************************************************
* Function Name : FLASH_WordWrite
* Description : Writes a Word to the Flash
* Input 1 : Address of the Destination
* Input 2 : Word To program
* Return : None
*******************************************************************************/
void FLASH_WordWrite(u32 XtargetAdd, u32 Xdata);
/*******************************************************************************
* Function Name : FLASH_EraseSector
* Description : Erases a Flash sector
* Input : Sectors to be Erased
* Return : None
*******************************************************************************/
void FLASH_SectorErase(u32 Xsectors);
/*******************************************************************************
* Function Name : FLASH_WritePrConfig
* Description : Configures The Write Protection Bits
* Input 1 : Flash Bank
* Input 2 : Enable Or disable Protection
* Return : None
*******************************************************************************/
void FLASH_WritePrConfig(u32 Xsectors, functionalstate NewState);
/*******************************************************************************
* Function Name : Wait For Last Task
* Description : Waits for the end of last task on a Flash Bank
* Input : Bank number.
* Return : The value passed in parameter with the bit (Bitindex) reset
*******************************************************************************/
void WaitForLastTask(void);
/*******************************************************************************
* Function Name : FLASH_Delay
* Description : Add the delay required for the Flash Write & Erase operation
* Input : None
* Return : None
*******************************************************************************/
void FLASH_Delay(void);
/*******************************************************************************
* Function Name : IntFlashProgram
* Description : Program the internal Flash
* Input 1 : Flash address offset
* Input 2 : Size in byte
* Input 3 : A pointer to data
* Return : Status of the program operation
: -1 : Failed
: 0 : Success
*******************************************************************************/
s32 IntFlashProgram (u32 u32AddrOff, u32 u32SizeInByte, u32 *pu32Buf);
/*******************************************************************************
* Function Name : IntFlashSectorMask
* Description : Calculate the sector mask
* Input : The sector number
* Return : The sector mask
*******************************************************************************/
u32 IntFlashSectorMask(u32 SectorNumber);
void FLASH_WritePrConfig(u32 Xsectors, functionalstate NewState);
#endif // __FLASH_H
/*******************(C) COPYRIGHT 2004 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -