Add F0
This commit is contained in:
parent
e136dd98ee
commit
a52d4c2120
23
eeprom.c
23
eeprom.c
|
@ -2,7 +2,7 @@
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "eepromConfig.h"
|
#include "eepromConfig.h"
|
||||||
|
|
||||||
#ifdef _EEPROM_F1_LOW_DESTINY
|
#if ( _EEPROM_F1_LOW_DESTINY==1)
|
||||||
#define _EEPROM_FLASH_PAGE_SIZE 1024
|
#define _EEPROM_FLASH_PAGE_SIZE 1024
|
||||||
/* Base address of the Flash sectors */
|
/* Base address of the Flash sectors */
|
||||||
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */
|
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _EEPROM_F1_MEDIUM_DESTINY
|
#if (_EEPROM_F1_MEDIUM_DESTINY==1)
|
||||||
#define _EEPROM_FLASH_PAGE_SIZE 1024
|
#define _EEPROM_FLASH_PAGE_SIZE 1024
|
||||||
/* Base address of the Flash sectors */
|
/* Base address of the Flash sectors */
|
||||||
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */
|
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _EEPROM_F1_HIGH_DESTINY
|
#if (_EEPROM_F1_HIGH_DESTINY==1)
|
||||||
#define _EEPROM_FLASH_PAGE_SIZE 2048
|
#define _EEPROM_FLASH_PAGE_SIZE 2048
|
||||||
/* Base address of the Flash sectors */
|
/* Base address of the Flash sectors */
|
||||||
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */
|
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */
|
||||||
|
@ -34,6 +34,16 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (_EEPROM_F030x4_F030x6_F070x6_F030x8==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, 2 Kbytes */
|
||||||
|
#define _EEPROM_FLASH_PAGE_ADDRESS (ADDR_FLASH_PAGE_0|(_EEPROM_FLASH_PAGE_SIZE*_EEPROM_USE_FLASH_PAGE))
|
||||||
|
#if (_EEPROM_USE_FLASH_PAGE>63)
|
||||||
|
#error "Please Enter currect value _EEPROM_USE_FLASH_PAGE (0 to 63)"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t EEPROMPageBackup[_EEPROM_FLASH_PAGE_SIZE/4];
|
uint32_t EEPROMPageBackup[_EEPROM_FLASH_PAGE_SIZE/4];
|
||||||
|
|
||||||
//##########################################################################################################
|
//##########################################################################################################
|
||||||
|
@ -45,7 +55,9 @@ bool EE_Format(void)
|
||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
FLASH_EraseInitTypeDef flashErase;
|
FLASH_EraseInitTypeDef flashErase;
|
||||||
flashErase.NbPages=1;
|
flashErase.NbPages=1;
|
||||||
|
#if ( _EEPROM_F1_LOW_DESTINY==1 || _EEPROM_F1_MEDIUM_DESTINY==1 || _EEPROM_F1_HIGH_DESTINY==1 )
|
||||||
flashErase.Banks = FLASH_BANK_1;
|
flashErase.Banks = FLASH_BANK_1;
|
||||||
|
#endif
|
||||||
flashErase.PageAddress = _EEPROM_FLASH_PAGE_ADDRESS;
|
flashErase.PageAddress = _EEPROM_FLASH_PAGE_ADDRESS;
|
||||||
flashErase.TypeErase = FLASH_TYPEERASE_PAGES;
|
flashErase.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
if(HAL_FLASHEx_Erase(&flashErase,&error)==HAL_OK)
|
if(HAL_FLASHEx_Erase(&flashErase,&error)==HAL_OK)
|
||||||
|
@ -151,3 +163,8 @@ bool EE_Writes(uint16_t StartVirtualAddress,uint16_t HowMuchToWrite,uint32_t* D
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//##########################################################################################################
|
//##########################################################################################################
|
||||||
|
uint16_t EE_GetSize(void)
|
||||||
|
{
|
||||||
|
return _EEPROM_FLASH_PAGE_SIZE;
|
||||||
|
}
|
||||||
|
//##########################################################################################################
|
||||||
|
|
13
eeprom.h
13
eeprom.h
|
@ -2,15 +2,16 @@
|
||||||
#define __EEPROM_H
|
#define __EEPROM_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "stm32f1xx_hal.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
|
|
||||||
//################################################################################################################
|
//################################################################################################################
|
||||||
bool EE_Format(void);
|
bool EE_Format(void);
|
||||||
bool EE_Read(uint16_t VirtualAddress, uint32_t* Data);
|
bool EE_Read(uint16_t VirtualAddress, uint32_t* Data);
|
||||||
bool EE_Write(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_Reads(uint16_t StartVirtualAddress,uint16_t HowMuchToRead,uint32_t* Data);
|
||||||
bool EE_Writes(uint16_t StartVirtualAddress,uint16_t HowMuchToWrite,uint32_t* Data);
|
bool EE_Writes(uint16_t StartVirtualAddress,uint16_t HowMuchToWrite,uint32_t* Data);
|
||||||
|
uint16_t EE_GetSize(void);
|
||||||
//################################################################################################################
|
//################################################################################################################
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
#define __EEPROMCONFIG_H
|
#define __EEPROMCONFIG_H
|
||||||
|
|
||||||
|
|
||||||
//#define _EEPROM_F1_LOW_DESTINY
|
#define _EEPROM_F030x4_F030x6_F070x6_F030x8 (1)
|
||||||
//#define _EEPROM_F1_MEDIUM_DESTINY
|
#define _EEPROM_F1_LOW_DESTINY (0)
|
||||||
#define _EEPROM_F1_HIGH_DESTINY
|
#define _EEPROM_F1_MEDIUM_DESTINY (0)
|
||||||
|
#define _EEPROM_F1_HIGH_DESTINY (0)
|
||||||
|
|
||||||
#define _EEPROM_USE_FLASH_PAGE 127
|
#define _EEPROM_USE_FLASH_PAGE (31)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user