/******************************************************************************* * File Name : FLASH_EE.h * Author : MCD Application Team * Description : This file contains all the functions prototypes for the * EEPROM emulation firmware library. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef _FLASHEE_H #define _FLASHEE_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_conf.h" #include "EE_Dataset.h" /* Exported constants --------------------------------------------------------*/ /* EEPROM start address in Flash */ //128k的最后2k,stm32F103CB 有128k,(共128页,每页1k) #define EEPROM_START_ADDRESS ((unsigned int)(0x08000000+(128-2)*1024)) /* EEPROM emulation start address:*/ /* Pages 0 and 1 base and end addresses */ #define PAGE0_BASE_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + 0x000)) #define PAGE0_END_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) #define PAGE1_BASE_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + PAGE_SIZE)) #define PAGE1_END_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) /* Used Flash pages for EEPROM emulation */ #define PAGE0 ((unsigned short)0x0000) #define PAGE1 ((unsigned short)0x0001) /* No valid page define */ #define NO_VALID_PAGE ((unsigned short)0x00AB) /* Page status definitions */ #define ERASED ((unsigned short)0xFFFF) /* PAGE is empty */ #define RECEIVE_DATA ((unsigned short)0xEEEE) /* PAGE is marked to receive data */ #define VALID_PAGE ((unsigned short)0x0000) /* PAGE containing valid data */ /* Valid pages in read and write defines */ #define READ_FROM_VALID_PAGE ((char)0x00) #define WRITE_IN_VALID_PAGE ((char)0x01) /* Page full define */ #define PAGE_FULL ((char)0x80) /* Variables' number */ //#define NumbOfVar (char)(sizeof(tPrg) * 6) /* DNJ - Since we have 6 programs to store, this variable is no more char ! */ #define NumbOfVar (unsigned short)(sizeof(SysPara)/2) /* Exported types ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ unsigned short EE_Init ( void ); unsigned short EE_ReadVariable ( unsigned short, unsigned short* ); unsigned short EE_WriteVariable ( unsigned short, unsigned short ); void EE_XX ( void ); #endif