STM32 EEPROM emulation AN2594

Committer:
olympux
Date:
Thu Sep 15 21:16:26 2016 +0000
Revision:
5:34cb334d111b
Parent:
3:4bf7c01c5a48
Remove _conf.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
olympux 0:0b8e4689a075 1 /**
olympux 0:0b8e4689a075 2 ******************************************************************************
olympux 0:0b8e4689a075 3 * @file EEPROM_Emulation/inc/eeprom.h
olympux 0:0b8e4689a075 4 * @author MCD Application Team
olympux 0:0b8e4689a075 5 * @version V3.1.0
olympux 0:0b8e4689a075 6 * @date 07/27/2009
olympux 0:0b8e4689a075 7 * @brief This file contains all the functions prototypes for the EEPROM
olympux 0:0b8e4689a075 8 * emulation firmware library.
olympux 0:0b8e4689a075 9 ******************************************************************************
olympux 0:0b8e4689a075 10 * @copy
olympux 0:0b8e4689a075 11 *
olympux 0:0b8e4689a075 12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
olympux 0:0b8e4689a075 13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
olympux 0:0b8e4689a075 14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
olympux 0:0b8e4689a075 15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
olympux 0:0b8e4689a075 16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
olympux 0:0b8e4689a075 17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
olympux 0:0b8e4689a075 18 *
olympux 0:0b8e4689a075 19 * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
olympux 0:0b8e4689a075 20 */
olympux 0:0b8e4689a075 21
olympux 0:0b8e4689a075 22 /* Define to prevent recursive inclusion -------------------------------------*/
olympux 0:0b8e4689a075 23 #ifndef __EEPROM_H
olympux 0:0b8e4689a075 24 #define __EEPROM_H
olympux 0:0b8e4689a075 25
olympux 0:0b8e4689a075 26 /* Includes ------------------------------------------------------------------*/
olympux 0:0b8e4689a075 27 #include "stm32f10x.h"
olympux 0:0b8e4689a075 28
olympux 0:0b8e4689a075 29 /* Exported constants --------------------------------------------------------*/
olympux 0:0b8e4689a075 30 /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */
olympux 5:34cb334d111b 31 #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */
olympux 5:34cb334d111b 32
olympux 0:0b8e4689a075 33
olympux 0:0b8e4689a075 34 /* EEPROM start address in Flash */
olympux 1:30f2f413f549 35 #define EEPROM_START_ADDRESS ((uint32_t)0x08019000) /* EEPROM emulation start address:
olympux 1:30f2f413f549 36 after 100KByte of used Flash memory */
olympux 0:0b8e4689a075 37
olympux 0:0b8e4689a075 38 /* Pages 0 and 1 base and end addresses */
olympux 0:0b8e4689a075 39 #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000))
olympux 0:0b8e4689a075 40 #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
olympux 0:0b8e4689a075 41
olympux 0:0b8e4689a075 42 #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE))
olympux 0:0b8e4689a075 43 #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
olympux 0:0b8e4689a075 44
olympux 0:0b8e4689a075 45 /* Used Flash pages for EEPROM emulation */
olympux 0:0b8e4689a075 46 #define PAGE0 ((uint16_t)0x0000)
olympux 0:0b8e4689a075 47 #define PAGE1 ((uint16_t)0x0001)
olympux 0:0b8e4689a075 48
olympux 0:0b8e4689a075 49 /* No valid page define */
olympux 0:0b8e4689a075 50 #define NO_VALID_PAGE ((uint16_t)0x00AB)
olympux 0:0b8e4689a075 51
olympux 0:0b8e4689a075 52 /* Page status definitions */
olympux 0:0b8e4689a075 53 #define ERASED ((uint16_t)0xFFFF) /* PAGE is empty */
olympux 0:0b8e4689a075 54 #define RECEIVE_DATA ((uint16_t)0xEEEE) /* PAGE is marked to receive data */
olympux 0:0b8e4689a075 55 #define VALID_PAGE ((uint16_t)0x0000) /* PAGE containing valid data */
olympux 0:0b8e4689a075 56
olympux 0:0b8e4689a075 57 /* Valid pages in read and write defines */
olympux 0:0b8e4689a075 58 #define READ_FROM_VALID_PAGE ((uint8_t)0x00)
olympux 0:0b8e4689a075 59 #define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
olympux 0:0b8e4689a075 60
olympux 0:0b8e4689a075 61 /* Page full define */
olympux 0:0b8e4689a075 62 #define PAGE_FULL ((uint8_t)0x80)
olympux 0:0b8e4689a075 63
olympux 0:0b8e4689a075 64 /* Variables' number */
olympux 3:4bf7c01c5a48 65 #define NumbOfVar ((uint8_t)0x80)
olympux 0:0b8e4689a075 66
olympux 0:0b8e4689a075 67 /* Exported types ------------------------------------------------------------*/
olympux 0:0b8e4689a075 68 /* Exported macro ------------------------------------------------------------*/
olympux 0:0b8e4689a075 69 /* Exported functions ------------------------------------------------------- */
olympux 0:0b8e4689a075 70 uint16_t EE_Init(void);
olympux 0:0b8e4689a075 71 uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
olympux 0:0b8e4689a075 72 uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
olympux 0:0b8e4689a075 73
olympux 0:0b8e4689a075 74 #endif /* __EEPROM_H */
olympux 0:0b8e4689a075 75
olympux 0:0b8e4689a075 76 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
olympux 0:0b8e4689a075 77