AN2594: EEPROM emulation in STM32F10x microcontrollers: eeprom.h Source File

AN2594: EEPROM

eeprom.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    EEPROM_Emulation/inc/eeprom.h 
00004   * @author  MCD Application Team
00005   * @version V3.1.0
00006   * @date    07/27/2009
00007   * @brief   This file contains all the functions prototypes for the EEPROM 
00008   *          emulation firmware library.
00009   ******************************************************************************
00010   * @copy
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
00020   */
00021 
00022 /* Define to prevent recursive inclusion -------------------------------------*/
00023 #ifndef __EEPROM_H
00024 #define __EEPROM_H
00025 
00026 /* Includes ------------------------------------------------------------------*/
00027 #include "stm32f10x.h"
00028 
00029 /* Exported constants --------------------------------------------------------*/
00030 /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */
00031 #if defined (STM32F10X_LD) || defined (STM32F10X_MD)
00032   #define PAGE_SIZE  (uint16_t)0x400  /* Page size = 1KByte */
00033 #elif defined (STM32F10X_HD) || defined (STM32F10X_CL)
00034   #define PAGE_SIZE  (uint16_t)0x800  /* Page size = 2KByte */
00035 #endif
00036 
00037 /* EEPROM start address in Flash */
00038 #define EEPROM_START_ADDRESS    ((uint32_t)0x08010000) /* EEPROM emulation start address:
00039                                                   after 64KByte of used Flash memory */
00040 
00041 /* Pages 0 and 1 base and end addresses */
00042 #define PAGE0_BASE_ADDRESS      ((uint32_t)(EEPROM_START_ADDRESS + 0x000))
00043 #define PAGE0_END_ADDRESS       ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
00044 
00045 #define PAGE1_BASE_ADDRESS      ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE))
00046 #define PAGE1_END_ADDRESS       ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
00047 
00048 /* Used Flash pages for EEPROM emulation */
00049 #define PAGE0                   ((uint16_t)0x0000)
00050 #define PAGE1                   ((uint16_t)0x0001)
00051 
00052 /* No valid page define */
00053 #define NO_VALID_PAGE           ((uint16_t)0x00AB)
00054 
00055 /* Page status definitions */
00056 #define ERASED                  ((uint16_t)0xFFFF)     /* PAGE is empty */
00057 #define RECEIVE_DATA            ((uint16_t)0xEEEE)     /* PAGE is marked to receive data */
00058 #define VALID_PAGE              ((uint16_t)0x0000)     /* PAGE containing valid data */
00059 
00060 /* Valid pages in read and write defines */
00061 #define READ_FROM_VALID_PAGE    ((uint8_t)0x00)
00062 #define WRITE_IN_VALID_PAGE     ((uint8_t)0x01)
00063 
00064 /* Page full define */
00065 #define PAGE_FULL               ((uint8_t)0x80)
00066 
00067 /* Variables' number */
00068 #define NumbOfVar               ((uint8_t)0x03)
00069 
00070 /* Exported types ------------------------------------------------------------*/
00071 /* Exported macro ------------------------------------------------------------*/
00072 /* Exported functions ------------------------------------------------------- */
00073 uint16_t EE_Init(void);
00074 uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
00075 uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
00076 
00077 #endif /* __EEPROM_H */
00078 
00079 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit www.st.com/STM32