From cc2bdff2ccde167def6765708b09c13d519af3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nima=20Askari=20-----=20=D9=86=DB=8C=D9=85=D8=A7=20=D8=B9?= =?UTF-8?q?=D8=B3=DA=A9=D8=B1=DB=8C?= Date: Sat, 11 Jan 2020 12:34:18 +0330 Subject: [PATCH] V 1.1.0 --- eeprom.c | 14 +++++++------- eeprom.h | 13 ++++++------- eepromConf.h | 13 +++++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 eepromConf.h diff --git a/eeprom.c b/eeprom.c index 02bc314..e346332 100644 --- a/eeprom.c +++ b/eeprom.c @@ -1,8 +1,8 @@ #include "eeprom.h" -#include "eepromConfig.h" +#include "eepromConf.h" -#if ( _EEPROM_F1_LOW_DESTINY==1) +#if ( _EEPROM_F1_LOW_DESTINY==1) #define _EEPROM_FLASH_PAGE_SIZE 1024 /* Base address of the Flash sectors */ #define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */ @@ -13,7 +13,7 @@ #endif -#if (_EEPROM_F1_MEDIUM_DESTINY==1) +#if (_EEPROM_F1_MEDIUM_DESTINY==1) #define _EEPROM_FLASH_PAGE_SIZE 1024 /* Base address of the Flash sectors */ #define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */ @@ -24,7 +24,7 @@ #endif -#if (_EEPROM_F1_HIGH_DESTINY==1) +#if (_EEPROM_F1_HIGH_DESTINY==1) #define _EEPROM_FLASH_PAGE_SIZE 2048 /* Base address of the Flash sectors */ #define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */ @@ -87,7 +87,7 @@ bool EE_Write(uint16_t VirtualAddress, uint32_t Data) if(VirtualAddress >= (_EEPROM_FLASH_PAGE_SIZE/4)) return false; - #if (_EEPROM_AUTO_ERASE___NEED_MORE_RAM==1) + #if (_EEPROM_STORE_BEFOR_ERASE___NEED_MORE_RAM==1) if((*(__IO uint32_t*)((VirtualAddress*4)+_EEPROM_FLASH_PAGE_ADDRESS)) != 0xFFFFFFFF) { @@ -144,7 +144,7 @@ bool EE_Writes(uint16_t StartVirtualAddress,uint16_t HowMuchToWrite,uint32_t* D { if((StartVirtualAddress+HowMuchToWrite) > (_EEPROM_FLASH_PAGE_SIZE/4)) return false; - #if (_EEPROM_AUTO_ERASE___NEED_MORE_RAM==1) + #if (_EEPROM_STORE_BEFOR_ERASE___NEED_MORE_RAM==1) if( EE_Reads(0,(_EEPROM_FLASH_PAGE_SIZE/4),EEPROMPageBackup)==false) return false; for(uint16_t i=StartVirtualAddress ; i #include "gpio.h" - //################################################################################################################ -bool EE_Format(void); -bool EE_Read(uint16_t VirtualAddress, uint32_t* Data); -bool EE_Write(uint16_t VirtualAddress, uint32_t Data); -bool EE_Reads(uint16_t StartVirtualAddress,uint16_t HowMuchToRead,uint32_t* Data); -bool EE_Writes(uint16_t StartVirtualAddress,uint16_t HowMuchToWrite,uint32_t* Data); -uint16_t EE_GetSize(void); +bool EE_Format(void); +bool EE_Read(uint16_t VirtualAddress, uint32_t* Data); +bool EE_Write(uint16_t VirtualAddress, uint32_t Data); +bool EE_Reads(uint16_t StartVirtualAddress, uint16_t HowMuchToRead, uint32_t* Data); +bool EE_Writes(uint16_t StartVirtualAddress, uint16_t HowMuchToWrite, uint32_t* Data); +uint16_t EE_GetSize(void); //################################################################################################################ #ifdef __cplusplus diff --git a/eepromConf.h b/eepromConf.h new file mode 100644 index 0000000..194b40c --- /dev/null +++ b/eepromConf.h @@ -0,0 +1,13 @@ +#ifndef __EEPROMCONFIG_H +#define __EEPROMCONFIG_H + +#define _EEPROM_STORE_BEFOR_ERASE___NEED_MORE_RAM (0) + +#define _EEPROM_F030x4_F030x6_F070x6_F030x8 (1) +#define _EEPROM_F1_LOW_DESTINY (0) +#define _EEPROM_F1_MEDIUM_DESTINY (0) +#define _EEPROM_F1_HIGH_DESTINY (0) + +#define _EEPROM_USE_FLASH_PAGE (15) + +#endif