本文整理汇总了C++中FLASH_ErasePage函数的典型用法代码示例。如果您正苦于以下问题:C++ FLASH_ErasePage函数的具体用法?C++ FLASH_ErasePage怎么用?C++ FLASH_ErasePage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FLASH_ErasePage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: EE_Format
/*******************************************************************************
* Function Name : EE_Format
* Description : Erases PAGE0 and PAGE1 and writes VALID_PAGE header to PAGE0
* Input : None
* Output : None
* Return : Status of the last operation (Flash write or erase) done during
* EEPROM formating
*******************************************************************************/
FLASH_Status EE_Format(void)
{
FLASH_Status FlashStatus = FLASH_COMPLETE;
/* Erase Page0 */
FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS);
/* If erase operation was failed, a Flash error code is returned */
if (FlashStatus != FLASH_COMPLETE)
{
return FlashStatus;
}
/* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE);
/* If program operation was failed, a Flash error code is returned */
if (FlashStatus != FLASH_COMPLETE)
{
return FlashStatus;
}
/* Erase Page1 */
FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
/* Return Page1 erase operation status */
return FlashStatus;
}
开发者ID:Farewellly,项目名称:STM32,代码行数:36,代码来源:eeprom.c
示例2: hw_flash_erase
/*************************************************
Function: hw_flash_erase
Descroption:
Input:
1.SectorAddress
Output:
Return:
Other:
*************************************************/
uint32_t hw_flash_erase(uint32_t SectorAddress)
{
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS)
FLASH_ClearFlag(FLASH_FLAG_PGAERR | FLASH_FLAG_OPTVERR);
return FLASH_ErasePage(SectorAddress);
#else
return FLASH_ErasePage(SectorAddress);
#endif /* STM32L1XX_XD */
}
开发者ID:txl0591,项目名称:PileDevices,代码行数:18,代码来源:hw_flash.c
示例3: write_mem
//================================================
static void write_mem(void)
{
u32 addr = 0;
u16 i = 0;
u8 temp[4];
u16 length = 0;
u32 data = 0;
u8 crc = 0;
FLASH_Status status = FLASH_COMPLETE;
// Receive start address
for(i=0;i<4;i++)
temp[i] = USART_GetC();
crc = USART_GetC();
if(crc == (temp[0]^temp[1]^temp[2]^temp[3]))
{
mem_cpy(&addr,temp,4);
USART_PutC(ACK);
length = USART_GetC();
length = (length<<8) | USART_GetC();
for(i = 0;i<length;i++)
fwBuff[i] = USART_GetC();
crc = USART_GetC();
// Write memmory
FLASH_UnlockBank1();
if(!fUpdating)
{
// Disable systick
SysTick->CTRL &=~( SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk);
status = FLASH_ErasePage(FLAG_ADDR);
if(status == FLASH_COMPLETE)
status = FLASH_ProgramWord(FLAG_ADDR,(u32)FLAG_UPDATING);
fUpdating = true;
}
if(status == FLASH_COMPLETE)
status = FLASH_ErasePage(addr);
for(i = 0;i<length;i+=4)
{
mem_cpy(&data,&fwBuff[i],((length-i)>4?4:(length-i)));
if(status != FLASH_COMPLETE)
break;
status = FLASH_ProgramWord(addr,data);
addr += 4;
}
FLASH_LockBank1();
if(status == FLASH_COMPLETE)
USART_PutC(ACK);
else
USART_PutC(NACK);
}
else
USART_PutC(NACK);
}
开发者ID:thaigiang,项目名称:VMS,代码行数:56,代码来源:updateFW.c
示例4: FLASH_If_Erase
/*******************************************************************************
* Function Name : FLASH_If_Erase
* Description : Erase sector
* Input : None
* Output : None
* Return : None
*******************************************************************************/
uint16_t FLASH_If_Erase(uint32_t SectorAddress)
{
#ifdef STM32L1XX_MD
FLASH_ClearFlag(FLASH_FLAG_PGAERR | FLASH_FLAG_OPTVERR);
FLASH_ErasePage(SectorAddress);
#else
FLASH_ErasePage(SectorAddress);
#endif /* STM32L1XX_MD */
return MAL_OK;
}
开发者ID:crystalfontz,项目名称:cfa_735_simple,代码行数:18,代码来源:flash_if.c
示例5: Erase_All_User_id
void Erase_All_User_id(void)
{
uint8_t i;
FLASH_Unlock();
FLASH_ErasePage(USER_ID_PAGE0_ADDR_START);
FLASH_ErasePage(USER_ID_PAGE1_ADDR_START);
FLASH_ErasePage(USER_ID_PAGE2_ADDR_START);
FLASH_Lock();
for(i=1; i<96; i++)
lock_infor.index_map[(i-1)/MAP_SIZE] &= (~(1<<((i-1)%MAP_SIZE)));
Index_Save();
}
开发者ID:fanqh,项目名称:SmartDoor,代码行数:12,代码来源:index.c
示例6: writeEEPROM
bool writeEEPROM(bool blink)
{
FLASH_Status status;
uint8_t chk = 0;
const uint8_t *p;
// prepare checksum/version constants
_params.version = EEPROM_CONF_VERSION;
_params.size = sizeof(params_t);
_params.magic_be = 0xBE;
_params.magic_ef = 0xEF;
_params.chk = 0;
// recalculate checksum before writing
for (p = (const uint8_t *)&_params; p < ((const uint8_t *)&_params + sizeof(params_t)); p++)
chk ^= *p;
_params.chk = chk;
// write it
FLASH_Unlock();
for (unsigned int tries = 3; tries; tries--)
{
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
FLASH_ErasePage(FLASH_WRITE_ADDR);
status = FLASH_ErasePage(FLASH_WRITE_ADDR + FLASH_PAGE_SIZE);
for (unsigned int i = 0; i < sizeof(params_t) && status == FLASH_COMPLETE; i += 4)
status = FLASH_ProgramWord(FLASH_WRITE_ADDR + i, *(uint32_t *)((char *)&_params + i));
if (status == FLASH_COMPLETE)
break;
}
FLASH_Lock();
// Flash write failed - just die now
if (status != FLASH_COMPLETE || !validEEPROM())
{
return false;
}
if (blink)
{
for (uint8_t i=0; i < 3; i++)
{
LED0_TOGGLE;
delay(100);
LED0_TOGGLE;
delay(50);
}
}
return true;
}
开发者ID:byu-magicc,项目名称:ROSflight,代码行数:52,代码来源:flash.c
示例7: writeEEPROM
void writeEEPROM(uint8_t b, uint8_t updateProfile)
{
FLASH_Status status;
int i, tries = 3;
uint8_t chk = 0;
const uint8_t *p;
// prepare checksum/version constants
mcfg.version = EEPROM_CONF_VERSION;
mcfg.size = sizeof(master_t);
mcfg.magic_be = 0xBE;
mcfg.magic_ef = 0xEF;
mcfg.chk = 0;
// when updateProfile = true, we copy contents of cfg to global configuration. when false, only profile number is updated, and then that profile is loaded on readEEPROM()
if (updateProfile) {
// copy current in-memory profile to stored configuration
memcpy(&mcfg.profile[mcfg.current_profile], &cfg, sizeof(config_t));
}
// recalculate checksum before writing
for (p = (const uint8_t *)&mcfg; p < ((const uint8_t *)&mcfg + sizeof(master_t)); p++)
chk ^= *p;
mcfg.chk = chk;
// write it
FLASH_Unlock();
while (tries--) {
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
FLASH_ErasePage(FLASH_WRITE_ADDR);
status = FLASH_ErasePage(FLASH_WRITE_ADDR + FLASH_PAGE_SIZE);
for (i = 0; i < sizeof(master_t) && status == FLASH_COMPLETE; i += 4)
status = FLASH_ProgramWord(FLASH_WRITE_ADDR + i, *(uint32_t *)((char *)&mcfg + i));
if (status == FLASH_COMPLETE)
break;
}
FLASH_Lock();
// Flash write failed - just die now
if (status != FLASH_COMPLETE || !validEEPROM()) {
failureMode(10);
}
// re-read written data
loadAndActivateConfig();
if (b)
blinkLED(15, 20, 1);
}
开发者ID:creyc,项目名称:baseflight,代码行数:49,代码来源:config.c
示例8: ef_port_erase
/**
* Erase data on flash.
* @note This operation is irreversible.
* @note This operation's units is different which on many chips.
*
* @param addr flash address
* @param size erase bytes size
*
* @return result
*/
EfErrCode ef_port_erase(uint32_t addr, size_t size) {
EfErrCode result = EF_NO_ERR;
FLASH_Status flash_status;
size_t erase_pages, i;
/* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
EF_ASSERT(addr % ERASE_MIN_SIZE == 0);
/* calculate pages */
erase_pages = size / PAGE_SIZE;
if (size % PAGE_SIZE != 0) {
erase_pages++;
}
/* start erase */
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
for (i = 0; i < erase_pages; i++) {
flash_status = FLASH_ErasePage(addr + (PAGE_SIZE * i));
if (flash_status != FLASH_COMPLETE) {
result = EF_ERASE_ERR;
break;
}
}
FLASH_Lock();
return result;
}
开发者ID:pushuang,项目名称:EasyFlash,代码行数:38,代码来源:ef_port.c
示例9: WriteflashMPeriod
/***********************************************************
* 函数名:WriteflashMPeriod
* 描述 :把interval_s从CPU写入Flash
* 输入 : 无
* 输出 : 无
***********************************************************/
void WriteflashMPeriod(void)
{
FLASHStatus = FLASH_COMPLETE;
MemoryProgramStatus = PASSED;
FLASH_Unlock(); //FLASH解锁
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);//清标志位
NbrOfPage = (EndAddr[4] - StartAddr[4]) / FLASH_PAGE_SIZE;//页面擦除子程序
FLASHStatus = FLASH_ErasePage(StartAddr[4] + (FLASH_PAGE_SIZE * NbrOfPage));
FlashAddress = StartAddr[4];
FLASHStatus = FLASH_ProgramWord(FlashAddress, gps_invalid);
FlashAddress = FlashAddress + 4;
FLASHStatus = FLASH_ProgramWord(FlashAddress, intervalA);
FlashAddress = FlashAddress + 4;
FLASHStatus = FLASH_ProgramWord(FlashAddress, intervalB);
FlashAddress = FlashAddress + 4;
FLASHStatus = FLASH_ProgramWord(FlashAddress, interval_num);
FlashAddress = FlashAddress + 4;
// FLASHStatus = FLASH_ProgramWord(FlashAddress, time_o);
FlashAddress = FlashAddress + 4;
FLASHStatus = FLASH_ProgramHalfWord(FlashAddress, interval_s);
BKP_WriteBackupRegister(BKP_DR1,interval_num);
//BKP_WriteBackupRegister(BKP_DR2,time_o);
BKP_WriteBackupRegister(BKP_DR3,interval_s);
}
开发者ID:baidcwsse,项目名称:NETMARK_W100,代码行数:38,代码来源:flashwr.c
示例10: ErasePage
void ErasePage(uint32_t p_addr, unsigned char with_lock)
{
FLASH_Unlock();
FLASH_ErasePage(p_addr);
if (with_lock)
FLASH_Lock();
}
开发者ID:MarianoDel,项目名称:eclipse_vapore_remota_keypad,代码行数:7,代码来源:flash_program.c
示例11: PIOS_BL_HELPER_FLASH_Start
uint8_t PIOS_BL_HELPER_FLASH_Start()
{
const struct pios_board_info * bdinfo = &pios_board_info_blob;
uint32_t pageAdress = bdinfo->fw_base;
uint8_t fail = false;
while ((pageAdress < (bdinfo->fw_base + bdinfo->fw_size + bdinfo->desc_size))
&& (fail == false)) {
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) {
fail = false;
break;
} else {
fail = true;
}
}
#ifdef STM32F10X_HD
pageAdress += 2048;
#elif defined (STM32F10X_MD)
pageAdress += 1024;
#endif
}
return (fail == true) ? 0 : 1;
}
开发者ID:1heinz,项目名称:TauLabs,代码行数:25,代码来源:pios_bl_helper.c
示例12: clear_CardID
//----清除全部刷卡记录-----------------------------------------------------
void clear_CardID()
{
char DateSt[12], TimeSt[12];
storeaddrlist.RecordCount = 0;
storeaddrlist.CountAddrOffset = 0;
timeoutaddrlist.RecordCount = 0;
timeoutaddrlist.CountAddrOffset = 0;
LastSaveTime = GetRTC(DateSt, TimeSt);///获取当前时间,秒数 //需要优化;
//清除记录区
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
FLASH_ErasePage(PLACELASTID);
FLASH_ErasePage(POINTOFSECTION);
FLASH_Lock();
}
开发者ID:fanqh,项目名称:stm32f103_RFID-cola-,代码行数:17,代码来源:file.c
示例13: FLASH_Start
uint8_t FLASH_Start()
{
uint32_t pageAdress;
pageAdress = START_OF_USER_CODE;
uint8_t fail = FALSE;
while ((pageAdress < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION)
|| (fail == TRUE)) {
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) {
fail = FALSE;
break;
} else {
fail = TRUE;
}
}
#ifdef STM32F10X_HD
pageAdress += 2048;
#elif defined (STM32F10X_MD)
pageAdress += 1024;
#endif
}
return (fail == TRUE) ? 0 : 1;
}
开发者ID:CorvusCorax,项目名称:my_OpenPilot_mods,代码行数:26,代码来源:pios_bl_helper.c
示例14: EE_WriteVariable
WORD EE_WriteVariable(WORD offset, WORD newValue)
{
FLASH_Status stat = FLASH_COMPLETE;
volatile WORD *pCurrentValue = (__IO uint16_t*) (PAGE0_BASE_ADDRESS + 2 + (offset * 2));
WORD PageStatus0 = *((__IO uint16_t*) PAGE0_BASE_ADDRESS);
WORD currentValue = *pCurrentValue;
// first check is page is valid, and if the value did change
if(PageStatus0 == VALID_PAGE && (currentValue == newValue)) { // page is valid, value didn't change? Good, quit
return FLASH_COMPLETE;
}
// if we got here, then either page is not valid, or the value changed
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
stat = FLASH_ErasePage(PAGE0_BASE_ADDRESS); // erase page
if(stat != FLASH_COMPLETE) {
return stat;
}
stat = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE); // write VALID_PAGE marker
if(stat != FLASH_COMPLETE) {
return stat;
}
stat = FLASH_ProgramHalfWord((uint32_t) pCurrentValue, newValue); // wite new vale
if(stat != FLASH_COMPLETE) {
return stat;
}
FLASH_Lock();
return stat;
}
开发者ID:atarijookie,项目名称:ce-atari,代码行数:35,代码来源:eeprom.c
示例15: PIOS_BL_HELPER_FLASH_Start
uint8_t PIOS_BL_HELPER_FLASH_Start()
{
const struct pios_board_info * bdinfo = &pios_board_info_blob;
uint32_t pageAdress = bdinfo->fw_base;
uint8_t fail = FALSE;
while ((pageAdress < (bdinfo->fw_base + bdinfo->fw_size + bdinfo->desc_size))
|| (fail == TRUE)) {
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) {
fail = FALSE;
break;
} else {
fail = TRUE;
}
}
#ifdef STM32F10X_HD
pageAdress += 2048;
#else /* everything else */
pageAdress += 1024;
#endif
}
return (fail == TRUE) ? 0 : 1;
}
开发者ID:hearingthings,项目名称:openpilot,代码行数:26,代码来源:pios_bl_helper.c
示例16: Flash_EEPROM_ErasePage
/***************************
Function : Erase the internal Flash data
Input :- start address
- Number of page
Output: return the FLASH status
***************************/
u16 Flash_EEPROM_ErasePage( u32 Start_Address, u16 No_of_Size)
{
FLASH_Unlock();
FLASHStatus=FLASH_COMPLETE;
FLASH_EEPROM_ProgramStatus= PASSED;
Flash_EEPROM_Nb_Of_Page= No_of_Size; //
/*Clear all the flash */
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR | FLASH_FLAG_OPTERR);
/*erase the page*/
for(EraseCounter=0; EraseCounter<Flash_EEPROM_Nb_Of_Page; EraseCounter++)
{
FLASHStatus = FLASH_ErasePage(Start_Address +(FL_EEPROM_PageSize* EraseCounter));
if (FLASHStatus != FLASH_COMPLETE)
{
return FLASHStatus;
}
}
FLASH_Lock();
return FLASHStatus;
}
开发者ID:aelwakeil,项目名称:spi,代码行数:33,代码来源:flash_eeprom.c
示例17: STMFLASH_Write
//写多个数据到一个页
u8 STMFLASH_Write(u32 PageAddr,u16 *pBuffer,u16 NumToWrite)
{
FLASH_Status temp_status;//状态
u16 i;
FLASH_Unlock();//解锁
temp_status = FLASH_ErasePage(PageAddr);//擦除一个页
if(temp_status != FLASH_COMPLETE)
{
FLASH_Lock();
return 0;
}
for(i=0;i<NumToWrite;i++)//数据写入
{
temp_status = FLASH_ProgramHalfWord(PageAddr+2*i,pBuffer[i]);
if(temp_status != FLASH_COMPLETE)
{
FLASH_Lock();
return 0;
}
}
FLASH_Lock();//上锁
return 1;
}
开发者ID:zou-can,项目名称:zou-liu-feng-ji,代码行数:29,代码来源:stmflash.c
示例18: StoreApInfo
int StoreApInfo()
{
rtw_wifi_config_t wifi_config;
uint32_t address;
#ifdef STM32F10X_XL
address = 0x08080000; //bank2 domain
#else
uint16_t sector_nb = FLASH_Sector_11;
address = flash_SectorAddress(sector_nb);
#endif
wifi_config.boot_mode = 0x77665502;
memcpy(wifi_config.ssid, wifi_setting.ssid, strlen((char*)wifi_setting.ssid));
wifi_config.ssid_len = strlen((char*)wifi_setting.ssid);
wifi_config.security_type = wifi_setting.security_type;
memcpy(wifi_config.password, wifi_setting.password, strlen((char*)wifi_setting.password));
wifi_config.password_len= strlen((char*)wifi_setting.password);
wifi_config.channel = wifi_setting.channel;
printf("\n\rWritting boot mode 0x77665502 and Wi-Fi setting to flash ...");
#ifdef STM32F10X_XL
FLASH_ErasePage(address);
#else
flash_EraseSector(sector_nb);
#endif
flash_Wrtie(address, (char *)&wifi_config, sizeof(rtw_wifi_config_t));
return 0;
}
开发者ID:KuanYuChen,项目名称:ameba-sdk-gcc-make,代码行数:28,代码来源:webserver.c
示例19: saveFont
//=====================================
void saveFont(u32 addr,u8* fontData,u16 length)
{
u32 i = 0;
u32 addr_temp;
u32 data_temp = 0;
FLASH_Status status = FLASH_COMPLETE;
addr_temp = addr;
// Unlock flash to rewrite to flash
FLASH_UnlockBank1();
// Erase pages used to store font
for(i = 0;i<3;i++)
{
status = FLASH_ErasePage(addr_temp);
addr_temp += FLASH_PAGE_SIZE;
}
// Write font data to flash
for(i = 0;i<length;i+=4)
{
memcpy(&data_temp,&fontData[i],((length-i)>4?4:(length-i)));
status = FLASH_ProgramWord(addr,data_temp);
addr += sizeof(u32);
}
FLASH_LockBank1();
}
开发者ID:thaigiang,项目名称:VMS,代码行数:27,代码来源:font.c
示例20: write_whole_poweroff_info_tbl
int write_whole_poweroff_info_tbl(struct poweroff_info_st *data)
{
u32 *ps, *pd;
int i;
FLASH_Status status;
if (NULL == data)
return -RT_ERROR;
FLASH_Unlock();
/* Clear pending flags (if any) */
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPTERR | FLASH_FLAG_WRPRTERR |
FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
status = FLASH_ErasePage((rt_uint32_t)POWEROFF_INFO_TBL_BASE_OF_FLASH); /* wait for complete in FLASH_ErasePage() */
if (FLASH_COMPLETE != status)
while(1); //return status;
ps = (u32 *)data;
pd = (u32 *)POWEROFF_INFO_TBL_BASE_OF_FLASH;
for (i=0; i < RT_ALIGN(POWEROFF_INFO_TBL_SIZE_OF_FLASH, 4)/4; i++) {
status = FLASH_ProgramWord((u32)pd, *ps); /* wait for complete in FLASH_ProgramWord() */
if (FLASH_COMPLETE != status)
while(1); //return status;
++pd;
++ps;
}
FLASH_Lock();
return FLASH_COMPLETE;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:31,代码来源:syscfgdata.c
注:本文中的FLASH_ErasePage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论