Mercurial > ~darius > hgwebdir.cgi > stm32temp
comparison eeprom.h @ 76:f1c9a51e368a
Add EEPROM emulation from AN2594.
Fix emulated EEPROM size on large parts.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 22 Apr 2013 23:17:40 +0930 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:85f16813c730 | 76:f1c9a51e368a |
---|---|
1 /** | |
2 ****************************************************************************** | |
3 * @file EEPROM_Emulation/inc/eeprom.h | |
4 * @author MCD Application Team | |
5 * @version V3.1.0 | |
6 * @date 07/27/2009 | |
7 * @brief This file contains all the functions prototypes for the EEPROM | |
8 * emulation firmware library. | |
9 ****************************************************************************** | |
10 * @copy | |
11 * | |
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS | |
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE | |
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY | |
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING | |
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE | |
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. | |
18 * | |
19 * <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2> | |
20 */ | |
21 | |
22 /* Define to prevent recursive inclusion -------------------------------------*/ | |
23 #ifndef __EEPROM_H | |
24 #define __EEPROM_H | |
25 | |
26 /* Includes ------------------------------------------------------------------*/ | |
27 #include "stm32f10x.h" | |
28 | |
29 /* Exported constants --------------------------------------------------------*/ | |
30 /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */ | |
31 #if defined (STM32F10X_LD) || defined (STM32F10X_MD) | |
32 #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */ | |
33 #elif defined (STM32F10X_HD) || defined (STM32F10X_CL) | |
34 #define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */ | |
35 #endif | |
36 | |
37 /* EEPROM start address in Flash */ | |
38 extern uint32_t _seemul; | |
39 #define EEPROM_START_ADDRESS ((uint32_t)&_seemul) /* start of emulated EEPROM def'd in linker-script */ | |
40 | |
41 /* Pages 0 and 1 base and end addresses */ | |
42 #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000)) | |
43 #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) | |
44 | |
45 #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE)) | |
46 #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) | |
47 | |
48 /* Used Flash pages for EEPROM emulation */ | |
49 #define PAGE0 ((uint16_t)0x0000) | |
50 #define PAGE1 ((uint16_t)0x0001) | |
51 | |
52 /* No valid page define */ | |
53 #define NO_VALID_PAGE ((uint16_t)0x00AB) | |
54 | |
55 /* Page status definitions */ | |
56 #define ERASED ((uint16_t)0xFFFF) /* PAGE is empty */ | |
57 #define RECEIVE_DATA ((uint16_t)0xEEEE) /* PAGE is marked to receive data */ | |
58 #define VALID_PAGE ((uint16_t)0x0000) /* PAGE containing valid data */ | |
59 | |
60 /* Valid pages in read and write defines */ | |
61 #define READ_FROM_VALID_PAGE ((uint8_t)0x00) | |
62 #define WRITE_IN_VALID_PAGE ((uint8_t)0x01) | |
63 | |
64 /* Page full define */ | |
65 #define PAGE_FULL ((uint8_t)0x80) | |
66 | |
67 /* Variables' number */ | |
68 #define NumbOfVar ((uint8_t)0x03) | |
69 | |
70 /* Exported types ------------------------------------------------------------*/ | |
71 /* Exported macro ------------------------------------------------------------*/ | |
72 /* Exported functions ------------------------------------------------------- */ | |
73 uint16_t EE_Init(void); | |
74 uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data); | |
75 uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data); | |
76 FLASH_Status EE_Format(void); | |
77 void EE_Cmd(int argc, char **argv); | |
78 | |
79 #endif /* __EEPROM_H */ | |
80 | |
81 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ |