Subversion Repositories DashDisplay

Rev

Rev 16 | Rev 18 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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>&copy; 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.  
  42. typedef uint8_t FlashPage_t[PAGE_SIZE];
  43.  
  44.  
  45. extern FlashPage_t FlashPage[2];
  46.  
  47.  
  48. typedef uint16_t FLASH_Status;
  49.  
  50. /* EEPROM start address in Flash */
  51. #define EEPROM_START_ADDRESS    ((uint32_t)0x08010000) /* EEPROM emulation start address:
  52.                                                   after 64KByte of used Flash memory */
  53.  
  54. /* Pages 0 and 1 base and end addresses */
  55. #define PAGE0_BASE_ADDRESS      ((uint32_t)(&FlashPage[0]))
  56. #define PAGE0_END_ADDRESS       ((uint32_t)(&FlashPage[0] + (PAGE_SIZE - 1)))
  57.  
  58. #define PAGE1_BASE_ADDRESS      ((uint32_t)(&FlashPage[1]))
  59. #define PAGE1_END_ADDRESS       ((uint32_t)(&FlashPage[1] +(PAGE_SIZE - 1)))
  60.  
  61. /* Used Flash pages for EEPROM emulation */
  62. #define PAGE0                   ((uint16_t)0x0000)
  63. #define PAGE1                   ((uint16_t)0x0001)
  64.  
  65. /* No valid page define */
  66. #define NO_VALID_PAGE           ((uint16_t)0x00AB)
  67.  
  68. /* Page status definitions */
  69. #define ERASED                  ((uint16_t)0xFFFF)     /* PAGE is empty */
  70. #define RECEIVE_DATA            ((uint16_t)0xEEEE)     /* PAGE is marked to receive data */
  71. #define VALID_PAGE              ((uint16_t)0x0000)     /* PAGE containing valid data */
  72.  
  73. /* Valid pages in read and write defines */
  74. #define READ_FROM_VALID_PAGE    ((uint8_t)0x00)
  75. #define WRITE_IN_VALID_PAGE     ((uint8_t)0x01)
  76.  
  77. /* Page full define */
  78. #define PAGE_FULL               ((uint8_t)0x80)
  79.  
  80. /* Variables' number */
  81. #define NumbOfVar               ((uint8_t)0x02)
  82.  
  83. /* Exported types ------------------------------------------------------------*/
  84. /* Exported macro ------------------------------------------------------------*/
  85. /* Exported functions ------------------------------------------------------- */
  86. uint16_t EE_Init(void);
  87. uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
  88. uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
  89.  
  90. #endif /* __EEPROM_H */
  91.  
  92. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
  93.