Rev 18 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16 | mjames | 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 | #define HAL_FLASH_MODULE_ENABLED |
||
29 | #define STM32F10X_MD |
||
30 | #include "stm32f1xx_hal_flash.h" |
||
31 | |||
32 | |||
33 | /* Exported constants --------------------------------------------------------*/ |
||
34 | /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */ |
||
35 | #if defined (STM32F10X_LD) || defined (STM32F10X_MD) |
||
36 | #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */ |
||
37 | #elif defined (STM32F10X_HD) || defined (STM32F10X_CL) |
||
38 | #define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */ |
||
39 | #endif |
||
40 | |||
41 | |||
22 | mjames | 42 | |
43 | |||
16 | mjames | 44 | typedef uint8_t FlashPage_t[PAGE_SIZE]; |
45 | |||
46 | |||
47 | extern FlashPage_t FlashPage[2]; |
||
48 | |||
49 | |||
50 | typedef uint16_t FLASH_Status; |
||
51 | |||
52 | |||
53 | /* Pages 0 and 1 base and end addresses */ |
||
54 | #define PAGE0_BASE_ADDRESS ((uint32_t)(&FlashPage[0])) |
||
55 | #define PAGE0_END_ADDRESS ((uint32_t)(&FlashPage[0] + (PAGE_SIZE - 1))) |
||
56 | |||
57 | #define PAGE1_BASE_ADDRESS ((uint32_t)(&FlashPage[1])) |
||
58 | #define PAGE1_END_ADDRESS ((uint32_t)(&FlashPage[1] +(PAGE_SIZE - 1))) |
||
59 | |||
60 | /* Used Flash pages for EEPROM emulation */ |
||
61 | #define PAGE0 ((uint16_t)0x0000) |
||
62 | #define PAGE1 ((uint16_t)0x0001) |
||
63 | |||
64 | /* No valid page define */ |
||
65 | #define NO_VALID_PAGE ((uint16_t)0x00AB) |
||
66 | |||
67 | /* Page status definitions */ |
||
68 | #define ERASED ((uint16_t)0xFFFF) /* PAGE is empty */ |
||
69 | #define RECEIVE_DATA ((uint16_t)0xEEEE) /* PAGE is marked to receive data */ |
||
70 | #define VALID_PAGE ((uint16_t)0x0000) /* PAGE containing valid data */ |
||
71 | |||
72 | /* Valid pages in read and write defines */ |
||
73 | #define READ_FROM_VALID_PAGE ((uint8_t)0x00) |
||
74 | #define WRITE_IN_VALID_PAGE ((uint8_t)0x01) |
||
75 | |||
76 | /* Page full define */ |
||
77 | #define PAGE_FULL ((uint8_t)0x80) |
||
78 | |||
79 | /* Variables' number */ |
||
17 | mjames | 80 | #define NumbOfVar ((uint8_t)0x02) |
16 | mjames | 81 | |
82 | /* Exported types ------------------------------------------------------------*/ |
||
83 | /* Exported macro ------------------------------------------------------------*/ |
||
84 | /* Exported functions ------------------------------------------------------- */ |
||
85 | uint16_t EE_Init(void); |
||
86 | uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data); |
||
87 | uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data); |
||
88 | |||
89 | #endif /* __EEPROM_H */ |
||
90 | |||
91 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ |