FlashEE.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*******************************************************************************
  2. * File Name : FLASH_EE.h
  3. * Author : MCD Application Team
  4. * Description : This file contains all the functions prototypes for the
  5. * EEPROM emulation firmware library.
  6. *******************************************************************************/
  7. /* Define to prevent recursive inclusion -------------------------------------*/
  8. #ifndef _FLASHEE_H
  9. #define _FLASHEE_H
  10. /* Includes ------------------------------------------------------------------*/
  11. #include "stm32f10x_conf.h"
  12. #include "EE_Dataset.h"
  13. /* Exported constants --------------------------------------------------------*/
  14. /* EEPROM start address in Flash */
  15. //128k的最后2k,stm32F103CB 有128k,(共128页,每页1k)
  16. #define EEPROM_START_ADDRESS ((unsigned int)(0x08000000+(128-2)*1024)) /* EEPROM emulation start address:*/
  17. /* Pages 0 and 1 base and end addresses */
  18. #define PAGE0_BASE_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + 0x000))
  19. #define PAGE0_END_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
  20. #define PAGE1_BASE_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + PAGE_SIZE))
  21. #define PAGE1_END_ADDRESS ((unsigned int)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
  22. /* Used Flash pages for EEPROM emulation */
  23. #define PAGE0 ((unsigned short)0x0000)
  24. #define PAGE1 ((unsigned short)0x0001)
  25. /* No valid page define */
  26. #define NO_VALID_PAGE ((unsigned short)0x00AB)
  27. /* Page status definitions */
  28. #define ERASED ((unsigned short)0xFFFF) /* PAGE is empty */
  29. #define RECEIVE_DATA ((unsigned short)0xEEEE) /* PAGE is marked to receive data */
  30. #define VALID_PAGE ((unsigned short)0x0000) /* PAGE containing valid data */
  31. /* Valid pages in read and write defines */
  32. #define READ_FROM_VALID_PAGE ((char)0x00)
  33. #define WRITE_IN_VALID_PAGE ((char)0x01)
  34. /* Page full define */
  35. #define PAGE_FULL ((char)0x80)
  36. /* Variables' number */
  37. //#define NumbOfVar (char)(sizeof(tPrg) * 6) /* DNJ - Since we have 6 programs to store, this variable is no more char ! */
  38. #define NumbOfVar (unsigned short)(sizeof(SysPara)/2)
  39. /* Exported types ------------------------------------------------------------*/
  40. /* Exported macro ------------------------------------------------------------*/
  41. /* Exported functions ------------------------------------------------------- */
  42. unsigned short EE_Init ( void );
  43. unsigned short EE_ReadVariable ( unsigned short, unsigned short* );
  44. unsigned short EE_WriteVariable ( unsigned short, unsigned short );
  45. void EE_XX ( void );
  46. #endif