EEPROM EMULATION STM32F429 - MBED
Dependents: DISCO-F429ZI_LCDTS_RET15-01
eeprom.h@0:9599d2d2296a, 2018-09-21 (annotated)
- Committer:
- Gabriel_2112
- Date:
- Fri Sep 21 11:27:40 2018 +0000
- Revision:
- 0:9599d2d2296a
LENGTH FLASH
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gabriel_2112 | 0:9599d2d2296a | 1 | /** |
Gabriel_2112 | 0:9599d2d2296a | 2 | ****************************************************************************** |
Gabriel_2112 | 0:9599d2d2296a | 3 | * @file EEPROM/EEPROM_Emulation/inc/eeprom.h |
Gabriel_2112 | 0:9599d2d2296a | 4 | * @author MCD Application Team |
Gabriel_2112 | 0:9599d2d2296a | 5 | * @version V1.0.1 |
Gabriel_2112 | 0:9599d2d2296a | 6 | * @date 29-January-2016 |
Gabriel_2112 | 0:9599d2d2296a | 7 | * @brief This file contains all the functions prototypes for the EEPROM |
Gabriel_2112 | 0:9599d2d2296a | 8 | * emulation firmware library. |
Gabriel_2112 | 0:9599d2d2296a | 9 | ****************************************************************************** |
Gabriel_2112 | 0:9599d2d2296a | 10 | * @attention |
Gabriel_2112 | 0:9599d2d2296a | 11 | * |
Gabriel_2112 | 0:9599d2d2296a | 12 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
Gabriel_2112 | 0:9599d2d2296a | 13 | * |
Gabriel_2112 | 0:9599d2d2296a | 14 | * Redistribution and use in source and binary forms, with or without modification, |
Gabriel_2112 | 0:9599d2d2296a | 15 | * are permitted provided that the following conditions are met: |
Gabriel_2112 | 0:9599d2d2296a | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
Gabriel_2112 | 0:9599d2d2296a | 17 | * this list of conditions and the following disclaimer. |
Gabriel_2112 | 0:9599d2d2296a | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Gabriel_2112 | 0:9599d2d2296a | 19 | * this list of conditions and the following disclaimer in the documentation |
Gabriel_2112 | 0:9599d2d2296a | 20 | * and/or other materials provided with the distribution. |
Gabriel_2112 | 0:9599d2d2296a | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Gabriel_2112 | 0:9599d2d2296a | 22 | * may be used to endorse or promote products derived from this software |
Gabriel_2112 | 0:9599d2d2296a | 23 | * without specific prior written permission. |
Gabriel_2112 | 0:9599d2d2296a | 24 | * |
Gabriel_2112 | 0:9599d2d2296a | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Gabriel_2112 | 0:9599d2d2296a | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Gabriel_2112 | 0:9599d2d2296a | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Gabriel_2112 | 0:9599d2d2296a | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Gabriel_2112 | 0:9599d2d2296a | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Gabriel_2112 | 0:9599d2d2296a | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Gabriel_2112 | 0:9599d2d2296a | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Gabriel_2112 | 0:9599d2d2296a | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Gabriel_2112 | 0:9599d2d2296a | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Gabriel_2112 | 0:9599d2d2296a | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Gabriel_2112 | 0:9599d2d2296a | 35 | * |
Gabriel_2112 | 0:9599d2d2296a | 36 | ****************************************************************************** |
Gabriel_2112 | 0:9599d2d2296a | 37 | */ |
Gabriel_2112 | 0:9599d2d2296a | 38 | |
Gabriel_2112 | 0:9599d2d2296a | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Gabriel_2112 | 0:9599d2d2296a | 40 | #ifndef __EEPROM_H |
Gabriel_2112 | 0:9599d2d2296a | 41 | #define __EEPROM_H |
Gabriel_2112 | 0:9599d2d2296a | 42 | |
Gabriel_2112 | 0:9599d2d2296a | 43 | /* Includes ------------------------------------------------------------------*/ |
Gabriel_2112 | 0:9599d2d2296a | 44 | #include "stm32f4xx_hal.h" |
Gabriel_2112 | 0:9599d2d2296a | 45 | |
Gabriel_2112 | 0:9599d2d2296a | 46 | /* Exported constants --------------------------------------------------------*/ |
Gabriel_2112 | 0:9599d2d2296a | 47 | /* EEPROM emulation firmware error codes */ |
Gabriel_2112 | 0:9599d2d2296a | 48 | #define EE_OK (uint32_t)HAL_OK |
Gabriel_2112 | 0:9599d2d2296a | 49 | #define EE_ERROR (uint32_t)HAL_ERROR |
Gabriel_2112 | 0:9599d2d2296a | 50 | #define EE_BUSY (uint32_t)HAL_BUSY |
Gabriel_2112 | 0:9599d2d2296a | 51 | #define EE_TIMEOUT (uint32_t)HAL_TIMEOUT |
Gabriel_2112 | 0:9599d2d2296a | 52 | |
Gabriel_2112 | 0:9599d2d2296a | 53 | /* Define the size of the sectors to be used */ |
Gabriel_2112 | 0:9599d2d2296a | 54 | #define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */ |
Gabriel_2112 | 0:9599d2d2296a | 55 | |
Gabriel_2112 | 0:9599d2d2296a | 56 | /* Device voltage range supposed to be [2.7V to 3.6V], the operation will |
Gabriel_2112 | 0:9599d2d2296a | 57 | be done by word */ |
Gabriel_2112 | 0:9599d2d2296a | 58 | #define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3 |
Gabriel_2112 | 0:9599d2d2296a | 59 | |
Gabriel_2112 | 0:9599d2d2296a | 60 | /* EEPROM start address in Flash */ |
Gabriel_2112 | 0:9599d2d2296a | 61 | #define EEPROM_START_ADDRESS ((uint32_t)0x08020000) /* EEPROM emulation start address: |
Gabriel_2112 | 0:9599d2d2296a | 62 | from sector2 : after 16KByte of used |
Gabriel_2112 | 0:9599d2d2296a | 63 | Flash memory */ |
Gabriel_2112 | 0:9599d2d2296a | 64 | |
Gabriel_2112 | 0:9599d2d2296a | 65 | /* Pages 0 and 1 base and end addresses */ |
Gabriel_2112 | 0:9599d2d2296a | 66 | #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000)) |
Gabriel_2112 | 0:9599d2d2296a | 67 | #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) |
Gabriel_2112 | 0:9599d2d2296a | 68 | #define PAGE0_ID FLASH_SECTOR_2 |
Gabriel_2112 | 0:9599d2d2296a | 69 | |
Gabriel_2112 | 0:9599d2d2296a | 70 | #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000)) |
Gabriel_2112 | 0:9599d2d2296a | 71 | #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) |
Gabriel_2112 | 0:9599d2d2296a | 72 | #define PAGE1_ID FLASH_SECTOR_13 |
Gabriel_2112 | 0:9599d2d2296a | 73 | |
Gabriel_2112 | 0:9599d2d2296a | 74 | /* Used Flash pages for EEPROM emulation */ |
Gabriel_2112 | 0:9599d2d2296a | 75 | #define PAGE0 ((uint16_t)0x0000) |
Gabriel_2112 | 0:9599d2d2296a | 76 | #define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/ |
Gabriel_2112 | 0:9599d2d2296a | 77 | |
Gabriel_2112 | 0:9599d2d2296a | 78 | /* No valid page define */ |
Gabriel_2112 | 0:9599d2d2296a | 79 | #define NO_VALID_PAGE ((uint16_t)0x00AB) |
Gabriel_2112 | 0:9599d2d2296a | 80 | |
Gabriel_2112 | 0:9599d2d2296a | 81 | /* Page status definitions */ |
Gabriel_2112 | 0:9599d2d2296a | 82 | #define ERASED ((uint16_t)0xFFFF) /* Page is empty */ |
Gabriel_2112 | 0:9599d2d2296a | 83 | #define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */ |
Gabriel_2112 | 0:9599d2d2296a | 84 | #define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */ |
Gabriel_2112 | 0:9599d2d2296a | 85 | |
Gabriel_2112 | 0:9599d2d2296a | 86 | /* Valid pages in read and write defines */ |
Gabriel_2112 | 0:9599d2d2296a | 87 | #define READ_FROM_VALID_PAGE ((uint8_t)0x00) |
Gabriel_2112 | 0:9599d2d2296a | 88 | #define WRITE_IN_VALID_PAGE ((uint8_t)0x01) |
Gabriel_2112 | 0:9599d2d2296a | 89 | |
Gabriel_2112 | 0:9599d2d2296a | 90 | /* Page full define */ |
Gabriel_2112 | 0:9599d2d2296a | 91 | #define PAGE_FULL ((uint8_t)0x80) |
Gabriel_2112 | 0:9599d2d2296a | 92 | |
Gabriel_2112 | 0:9599d2d2296a | 93 | /* Variables' number */ |
Gabriel_2112 | 0:9599d2d2296a | 94 | #define NB_OF_VAR ((uint8_t)0x06) |
Gabriel_2112 | 0:9599d2d2296a | 95 | |
Gabriel_2112 | 0:9599d2d2296a | 96 | /* Exported types ------------------------------------------------------------*/ |
Gabriel_2112 | 0:9599d2d2296a | 97 | /* Exported macro ------------------------------------------------------------*/ |
Gabriel_2112 | 0:9599d2d2296a | 98 | /* Exported functions ------------------------------------------------------- */ |
Gabriel_2112 | 0:9599d2d2296a | 99 | uint16_t EE_Init(void); |
Gabriel_2112 | 0:9599d2d2296a | 100 | uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data); |
Gabriel_2112 | 0:9599d2d2296a | 101 | uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data); |
Gabriel_2112 | 0:9599d2d2296a | 102 | |
Gabriel_2112 | 0:9599d2d2296a | 103 | #endif /* __EEPROM_H */ |
Gabriel_2112 | 0:9599d2d2296a | 104 | |
Gabriel_2112 | 0:9599d2d2296a | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |