• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ FLASH_EraseSector函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FLASH_EraseSector函数的典型用法代码示例。如果您正苦于以下问题:C++ FLASH_EraseSector函数的具体用法?C++ FLASH_EraseSector怎么用?C++ FLASH_EraseSector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FLASH_EraseSector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: EE_Format

/**
 * @brief  Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE
 * @param  None
 * @retval Status of the last operation (Flash write or erase) done during
 *         EEPROM formating
 */
static FLASH_Status EE_Format(void) {
	FLASH_Status FlashStatus = FLASH_COMPLETE;

	/* Erase Page0 */
	FlashStatus = FLASH_EraseSector(PAGE0_ID, FLASH_VOLTAGE_RANGE );

	/* 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_EraseSector(PAGE1_ID, FLASH_VOLTAGE_RANGE );

	/* Return Page1 erase operation status */
	return FlashStatus;
}
开发者ID:Tenkiv,项目名称:Tekdaqc-Firmware-Depricated,代码行数:31,代码来源:eeprom.c


示例2: eraseHelper

FLASH_Status eraseHelper(uint32_t pageAddress)
{  
#if defined(SERIES_STM32F37x) || defined(SERIES_STM32F30x)
  return FLASH_ErasePage(pageAddress);
#else
  if (pageAddress == PAGE0_BASE_ADDRESS)
    return FLASH_EraseSector(PAGE0_ID, VOLTAGE_RANGE);
  else if (pageAddress == PAGE1_BASE_ADDRESS)
    return FLASH_EraseSector(PAGE1_ID, VOLTAGE_RANGE);
  else
    return FLASH_ERROR_PROGRAM;
#endif
}
开发者ID:japina,项目名称:koduino,代码行数:13,代码来源:eeprom_stm32.c


示例3: bsp_Firmware_Erase

u8 bsp_Firmware_Erase(u8 APP_Select)
{
	u8 status=0;
	FLASH_Unlock();									//解锁 
  FLASH_DataCacheCmd(DISABLE);//FLASH擦除期间,必须禁止数据缓存
 	FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_OPERR|FLASH_FLAG_WRPERR|  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
	if(APP_Select)
	status=FLASH_EraseSector(FLASH_Sector_6 ,VoltageRange_3);//VCC=2.7~3.6V之间!!
	else
	status=FLASH_EraseSector(FLASH_Sector_5 ,VoltageRange_3);//VCC=2.7~3.6V之间!!
	
	MCU_WriteStatus=status;
	return MCU_WriteStatus;

}
开发者ID:CaptainJe,项目名称:BlueShiled,代码行数:15,代码来源:bsp_FileSystem.c


示例4: Flash_EraseDataBuffer

void Flash_EraseDataBuffer()
{
    FLASH_Unlock();
    FLASH_ClearFlag( FLASH_FLAG_EOP |  FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);

    // Erase Sectors
    // 8-10 is data logger
    FLASH_EraseSector(FLASH_Sector_8, VoltageRange_3);
    FLASH_EraseSector(FLASH_Sector_9, VoltageRange_3);
    FLASH_EraseSector(FLASH_Sector_10, VoltageRange_3);

    Flash_ResetFlashAddress();

    FLASH_Lock();
}
开发者ID:JMarple,项目名称:Micromouse-2016,代码行数:15,代码来源:setupFlash.c


示例5: eep_erase

/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
ErrorStatus eep_erase( void )
{
	ErrorStatus Err = SUCCESS;
	
	/* Enable the flash control register access */
	FLASH_Unlock();

	/* Erase the user Flash area ************************************************/
	/* area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR */

	/* Clear pending flags (if any) */  
	FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | 
				  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); 

	/* Get the number of the start and end sectors */
	uwStartSector = GetSector(FLASH_USER_START_ADDR);

	/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
	   be done by word */ 
	if (FLASH_EraseSector(uwStartSector, VoltageRange_3) != FLASH_COMPLETE)
	{ 
	  /* Error occurred while sector erase. 
		 User can add here some code to deal with this error  */
		Err = ERROR;
	}
	
	FLASH_Lock(); 
	
	return Err;
}
开发者ID:dasuimao,项目名称:DTS-2500_HMI0030_BOOT,代码行数:35,代码来源:bsp_flash.c


示例6: restoreCalibrateParamToFlash

static bool restoreCalibrateParamToFlash ( CalibrateParam* p )
{
  int i ;
  int n  =  sizeof(*p) / sizeof(uint32_t) ;
  uint32_t Address = CALIBRATE_PARAM_ADDR ;
  uint32_t *d = (uint32_t *) p ;
  
  
  FLASH_Unlock();
  FLASH_EraseSector(FLASH_Sector_5,VoltageRange_3);
  
  for ( i=0;i<n;i++){
    FLASH_ProgramWord( Address, *d );
    d ++ ;
    Address += 4;
  }
  FLASH_Lock();
  

  // 检验是否正确写入
  bool ret = true ;
  d = (uint32_t *) p ;
  uint32_t *d2 = (uint32_t*)CALIBRATE_PARAM_ADDR ;
  for ( i=0; i<n; i++ )
  {
    if ( d[i] != d2[i] )
    {
      ret = false ;
      break ;
    }
  }
  
  return ret ;
}
开发者ID:NewThinker-Jiwey,项目名称:AjefGmaj,代码行数:34,代码来源:attitudeSensor.c


示例7: write

bool write(uint32_t addr, uint16_t * data, const uint16_t data_len)
{
  int sector;

  /* Check bounds */
  if ((addr >= (SECTOR11_START_ADDR + SECTOR_SIZE_128KB)) ||
      (addr < SECTOR0_START_ADDR))
    return false;

  /* Need to compute sector to erase */
  if (addr >= SECTOR5_START_ADDR)
    sector = 5 + ((addr - SECTOR5_START_ADDR)/SECTOR_SIZE_128KB);
  else if (addr >= SECTOR4_START_ADDR)
    sector = 4;
  else
    sector = (addr - SECTOR0_START_ADDR)/SECTOR_SIZE_16KB;

  /* Unlock flash */
  FLASH_Unlock();
  FLASH_EraseSector(sector * 0x08, VoltageRange_3);

  /* Write data */
  for (int i = 0; i < data_len; i += 2)
  {
    FLASH_ProgramHalfWord(addr, *data);
    data++; addr += 2; 
  }

  return true;
}
开发者ID:alemoke,项目名称:stm32,代码行数:30,代码来源:flash_storage.cpp


示例8: stm32_flash_erase

int stm32_flash_erase(uint32_t offset, uint16_t len)
{
	uint32_t StartSector, EndSector;
	uint32_t flash_user_start_addr, flash_user_end_addr;
	uint32_t addr;
	uint8_t i;
	

	/* Get the number of the start and end sectors */
	flash_user_start_addr = ADDR_FLASH_SECTOR_0 + offset;
	flash_user_end_addr = flash_user_start_addr + len;
  StartSector = GetSector(flash_user_start_addr);
	EndSector = GetSector(flash_user_end_addr);
	
	/* Erase sector */
	for (i = StartSector; i <= EndSector; i += 8) {
    /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
       be done by word */ 
    if (FLASH_EraseSector(i, VoltageRange_3) != FLASH_COMPLETE) { 
			return -1;
    }
	}

	return 0;
}
开发者ID:MaoxiaoHu,项目名称:stm32f4-bootloader,代码行数:25,代码来源:bsp_stm32_flash.c


示例9: Flash_WriteParams

/**
  * @brief  ½«²ÎÊýдÈëFLASHÖÐ
  *         
  * @param  b:ÊÇ·ñÓÐLEDÌáʾ
  * @retval none
  */
void Flash_WriteParams(uint8_t b)
{
	FLASH_Status status;
	uint32_t i;

	FLASH_Unlock();

	FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGPERR | FLASH_FLAG_WRPERR);

// 	//if (FLASH_ErasePage(FLASH_WRITE_ADDR) == FLASH_COMPLETE)
	if(FLASH_EraseSector(FLASH_WRITE_SECTOR, VoltageRange_3) == FLASH_COMPLETE)
	{
		for (i = 0; i < sizeof(config_t); i += 4) 
		{
			status = FLASH_ProgramWord(FLASH_WRITE_ADDR + i, *(uint32_t *) ((char *) &cfg + i));
			if (status != FLASH_COMPLETE)
			{
				System_FailureMode(1);
				break;          // TODO: fail
			}
		}
	}
	else
		System_FailureMode(1);

	FLASH_Lock();

	Flash_Read();
}
开发者ID:BobLiu20,项目名称:AirPilot,代码行数:35,代码来源:AP_Flash.c


示例10: FLASH_eraseSector

const DC3Error_t FLASH_eraseSector( const uint32_t sectorAddr )
{
    DC3Error_t status = ERR_NONE;

    /* These flags have to be cleared before any operation can be done on the
     * flash memory */
    //	DBG_printf("Clearing flash flags. Status before clear: %x\n",FLASH->SR );
    FLASH_ClearFlag(
        FLASH_FLAG_PGSERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGAERR |
        FLASH_FLAG_WRPERR | FLASH_FLAG_OPERR | FLASH_FLAG_EOP
    );
    //	DBG_printf("Status after clear: %x\n",FLASH->SR );
    WRN_printf("*** Erasing Flash sector addr 0x%08x ***\n", sectorAddr);

    /*Look up the STM32 value of the sector given the sector address */
    uint16_t sector = FLASH_sectorAddrToFlashSect( sectorAddr );

    DBG_printf("Erasing sector (0x%04x) with base addr: 0x%08x...\n",
               sector, sectorAddr);
    /* This is a blocking operation but it's only for a single sector so should
     * not take that long */
    FLASH_Status flash_status = FLASH_EraseSector(sector, VoltageRange_3);
    status = FLASH_statusToErrorCode( flash_status );

    if (ERR_NONE != status) {
        ERR_printf("Flash error %d ( error 0x%08x) while erasing sector "
                   "0x%04x (base addr: 0x%08x)\n",
                   flash_status, status, sector, sectorAddr);
        DBG_printf("FLASH SR:%lx\n", FLASH->SR);
    }

    return( status );
}
开发者ID:trigrass2,项目名称:STM32491_CPLR,代码行数:33,代码来源:flash.c


示例11: flash_helper_erase_new_app

uint16_t flash_helper_erase_new_app(uint32_t new_app_size) {
	FLASH_Unlock();
	FLASH_ClearFlag(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR |
			FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);

	new_app_size += flash_addr[NEW_APP_BASE];

	mcpwm_unlock();
	mcpwm_release_motor();
	utils_sys_lock_cnt();
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, DISABLE);

	for (int i = 0;i < NEW_APP_SECTORS;i++) {
		if (new_app_size > flash_addr[NEW_APP_BASE + i]) {
			uint16_t res = FLASH_EraseSector(flash_sector[NEW_APP_BASE + i], VoltageRange_3);
			if (res != FLASH_COMPLETE) {
				return res;
			}
		} else {
			break;
		}
	}

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE);
	utils_sys_unlock_cnt();

	return FLASH_COMPLETE;
}
开发者ID:zidane1980slab,项目名称:bldc,代码行数:28,代码来源:flash_helper.c


示例12: flash_write_word

bool flash_write_word(uint32_t add, uint32_t value)
{
	/* Unlock the Flash to enable the flash control register access *************/ 
	FLASH_Unlock();
	
	/* Clear pending flags (if any) */  
	FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | 
					FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
	
	if (FLASH_EraseSector(FLASH_Sector_11, VoltageRange_4) != FLASH_COMPLETE)
	{ 
		goto fop_error;
	}
	
	//Program the user Flash area word by word
	if (FLASH_ProgramWord(add, value) != FLASH_COMPLETE)
	{ 
		goto fop_error;
	}
	FLASH_Lock();
	return true;
	
fop_error:
		FLASH_Lock(); 
		return false;	
}
开发者ID:kwikius,项目名称:PlayuavOSD,代码行数:26,代码来源:osdconfig.c


示例13: FLASH_If_Erase

/*******************************************************************************
* Function Name  : FLASH_If_Erase
* Description    : Erase sector
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t FLASH_If_Erase(uint32_t Add)
{
  /* Unlock the internal flash */
  FLASH_Unlock();

  FLASH_ClearFlags();

#if defined (STM32F2XX) || defined (STM32F4XX)
  /* Disable sector write protection if it's already protected */
  uint16_t OB_WRP_Sector = FLASH_SectorToWriteProtect(FLASH_INTERNAL, Add);
  FLASH_WriteProtection_Disable(OB_WRP_Sector);

  /* Check which sector has to be erased */
  uint16_t FLASH_Sector = FLASH_SectorToErase(FLASH_INTERNAL, Add);
  FLASH_Status status = FLASH_EraseSector(FLASH_Sector, VoltageRange_3);

#elif defined(STM32F10X_CL)
  /* Call the standard Flash erase function */
  FLASH_ErasePage(Add);
#endif /* STM32F2XX */

  /* Lock the internal flash */
  FLASH_Lock();

  if (status != FLASH_COMPLETE) return MAL_FAIL;

  return MAL_OK;
}
开发者ID:PencilDH,项目名称:firmware,代码行数:35,代码来源:usbd_flash_if.c


示例14: flash_helper_erase_new_app

uint16_t flash_helper_erase_new_app(uint32_t new_app_size) {
	FLASH_Unlock();
	FLASH_ClearFlag(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR |
			FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);

	new_app_size += flash_addr[NEW_APP_BASE];

	mc_interface_unlock();
	mc_interface_release_motor();
	utils_sys_lock_cnt();
	timeout_configure_IWDT_slowest();

	for (int i = 0;i < NEW_APP_SECTORS;i++) {
		if (new_app_size > flash_addr[NEW_APP_BASE + i]) {
			uint16_t res = FLASH_EraseSector(flash_sector[NEW_APP_BASE + i], VoltageRange_3);
			if (res != FLASH_COMPLETE) {
				FLASH_Lock();
				return res;
			}
		} else {
			break;
		}
	}
	FLASH_Lock();

	timeout_configure_IWDT();
	utils_sys_unlock_cnt();

	return FLASH_COMPLETE;
}
开发者ID:vedderb,项目名称:bldc,代码行数:30,代码来源:flash_helper.c


示例15: writeFlash

void writeFlash(u8 address_num,u32 data) //address_num should start from 0 up to 255
 {

const u8 data_count=255;
	 
	 u32 flash_data[data_count];
	 
	 for (u8 i = 0; i < data_count; ++i) {
			flash_data[i] = readFlash(i);
		}
		
		flash_data[address_num] = data;
	 
	 
 FLASH_Unlock();// you need to unlcok flash first
 /* Clear All pending flags */
 FLASH_ClearFlag( FLASH_FLAG_EOP |  FLASH_FLAG_WRPERR |  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);

//you need to erase entire sector before write anything
 FLASH_EraseSector(FLASH_Sector_11, VoltageRange_3);
 //VoltageRange_3        ((uint8_t)0x02)  /*!<Device operating range: 2.7V to 3.6V */

		for (u8 i = 0; i < data_count; ++i) {   //write back the whole sector memory
	
			FLASH_ProgramWord((u32)(startAddress + i * 4), flash_data[i]);
		}

 FLASH_Lock();//lock flash at the end

}
开发者ID:bobbyshashin,项目名称:RoboMasters,代码行数:30,代码来源:flash.c


示例16: internalFlashErase

OSStatus internalFlashErase(uint32_t StartAddress, uint32_t EndAddress)
{
  platform_log_trace();
  OSStatus err = kNoErr;
  uint32_t StartSector, EndSector, i = 0, j = 0;
  
  /* Get the sector where start the user flash area */
  StartSector = _GetSector(StartAddress);
  EndSector = _GetSector(EndAddress);
  
  for(i = StartSector; i <= EndSector; i += 8)
  {
    /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
    be done by word */
    _GetAddress(i, &StartAddress, &EndAddress);
    for(j=StartAddress; j<=EndAddress; j+=8){
      if( (*(uint32_t *)(j))!=0xFFFFFFFF )
        break;
    }
    if( j>EndAddress ) 
      continue;
    require_action(FLASH_EraseSector(i, VoltageRange_3) == FLASH_COMPLETE, exit, err = kWriteErr); 
  }
  
exit:
  return err;
}
开发者ID:FlynnShek,项目名称:MICO,代码行数:27,代码来源:platform_flash.c


示例17: flash_erase

int flash_erase(const uint32_t addr, const int32_t len)
{
  int start_sector, end_sector;

  /* Check bounds */
  if (addr < SECTOR0_START_ADDR)
    return -1;

  /* Need to compute sector to erase */
  start_sector = get_sector_num(addr);
  if (len == -1)
    end_sector = 11;
  else
    end_sector = get_sector_num(addr+(len*BYTES_PER_WORD)-1);

  FLASH_Unlock();
  for (int i = start_sector; i <= end_sector; ++i)
  {
    FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
                    FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
    FLASH_EraseSector(i * 0x08, VoltageRange_3);
  }
  FLASH_Lock();
  return 0;
}
开发者ID:InSoonPark,项目名称:stm32,代码行数:25,代码来源:flash.cpp


示例18: bsp_ChangeAPPtoRun

//void SD_TEST(void)
//{
//	u8 res;
//	UINT bw,index;
//	res=f_mount( &fatfs_SDCARD,"0:/",1 );
//	res=f_open(&file_sdif, "0:/sdif.dat",FA_OPEN_EXISTING|FA_WRITE|FA_READ);
//	res=f_write(&file_sdif,SDTEST_WriteBuffer,512,&bw);
//	res=f_close(&file_sdif);
//	res=f_open(&file_sdif, "0:/sdif.dat",FA_OPEN_EXISTING |FA_WRITE);
//	res=f_write(&file_sdif,SDTEST_WriteBuffer,512,&bw);
//	res=f_close(&file_sdif);
//	res=f_open(&file_sdif, "0:/sdif.dat",FA_OPEN_EXISTING | FA_READ);
//	index=0;
//	while(SDTEST_ReadBuffer[31]!=0x04)
//	{
//		index++;
//		res=f_read(&file_sdif,SDTEST_ReadBuffer,512,&bw);
//	}
//	f_close(&file_sdif);      
//	
//	
//}
u8 bsp_ChangeAPPtoRun(u8 App_Select)
{
  u8 status=0;
	u8 Flash_status=0;
	FLASH_Unlock();									//解锁 
  FLASH_DataCacheCmd(DISABLE);//FLASH擦除期间,必须禁止数据缓存
 	FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_OPERR|FLASH_FLAG_WRPERR|  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
	status=FLASH_EraseSector(FLASH_Sector_3 ,VoltageRange_3);//VCC=2.7~3.6V之间!!

	if(status==FLASH_COMPLETE)
	{
   __set_PRIMASK(1);  
	status=FLASH_ProgramByte(App_ToRun_Flag,App_Select);  //SysID
   __set_PRIMASK(0);  
	}
  FLASH_DataCacheCmd(ENABLE);	//FLASH擦除结束,开启数据缓存
	FLASH_Lock();//上锁	
	if(status==FLASH_COMPLETE)
	{
		Flash_status=0;
	}
	else
	{
		Flash_status=status;
	}
	return Flash_status;
		
}
开发者ID:CaptainJe,项目名称:BlueShiled,代码行数:50,代码来源:bsp_FileSystem.c


示例19: EE_WriteBuf

uint16_t EE_WriteBuf(uint16_t EEAddress, uint16_t* _data, uint16_t len)
{
	uint16_t * rData, * fData;
	uint32_t adr;
	uint32_t ret;
	uint32_t i;
	volatile FLASH_Status FLASHStatus = FLASH_COMPLETE;

	ret = 0;
	// check data
	rData = (uint16_t *)_data;
	fData = (uint16_t *)(EEAddress + EEPROM_START_ADDRESS);
	adr = EEAddress + EEPROM_START_ADDRESS;
	for (i = 0; i < len; i++)
	{
		if (rData[i] != fData[i] )
		{
			ret = 1;
			if (fData[i] != 0xFFFF) 
			{
				ret = 2;
				i = len;
			}
		}
	}
	
	if (ret)
	{
		FLASH_Unlock();
		FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | 
			FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); 
		// Clear Page
		if (ret == 2)
			FLASHStatus = FLASH_EraseSector(PAGE0_ID, VOLTAGE_RANGE);
		ret = 0;
		if (FLASHStatus == FLASH_COMPLETE)
		{
			for (i = 0; i < len; i++)
			{
				FLASHStatus = FLASH_ProgramHalfWord(adr, rData[i]);
				adr += 2;
			}
			// check flash write
			rData = (uint16_t *)_data;
			fData = (uint16_t *)(EEAddress + EEPROM_START_ADDRESS);
			for (i = 0; i < len; i++)
			{
				if (rData[i] != fData[i] ) ret = 1;
			}
		}
		else
		{
			ret = 2;
		}
		FLASH_Lock();
	}
	return ret;
}
开发者ID:alepnm,项目名称:lcd,代码行数:58,代码来源:ee_emul.c


示例20: bsp_SysinfoSave

void bsp_SysinfoSave(void)
{
	u8 status=0;
	u16 index=0;
	SleepTime=0;
	memcpy(MCU_ROM_Write,(u8*)ADDR_FLASH_SECTOR_7,1024+16); //?????,???????????buffer
	memcpy(MCU_ROM_Write+1024,&char_SysID_Length,1); 
	memcpy(MCU_ROM_Write+1024+1,char_SysID,char_SysID_Length); 
	memcpy(MCU_ROM_Write+1024+9,&Battery_Threshold,1);
	memcpy(MCU_ROM_Write+1024+10,&Key_Sound,1);
	
	FLASH_Unlock();									//?? 
  FLASH_DataCacheCmd(DISABLE);//FLASH????,????????
 	FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_OPERR|FLASH_FLAG_WRPERR|  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
	status=FLASH_EraseSector(FLASH_Sector_7 ,VoltageRange_3);//VCC=2.7~3.6V??!!

	if(status==FLASH_COMPLETE)
	{

		  for(index=0;index<(1024+16);index++)
		{
			status=FLASH_ProgramByte(ADDR_FLASH_SECTOR_7+index,MCU_ROM_Write[index]);  //SysID
		}

	}
	
  FLASH_DataCacheCmd(ENABLE);	//FLASH????,??????
	FLASH_Lock();//??	
	if(status==FLASH_COMPLETE)
	{
		MCU_WriteStatus=0;
	}
	else
	{
		MCU_WriteStatus=status;
	}
//	FLASH_Unlock();									//?? 
//  FLASH_DataCacheCmd(DISABLE);//FLASH????,????????
// 	FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_OPERR|FLASH_FLAG_WRPERR|  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
//	status=FLASH_EraseSector(FLASH_Sector_7 ,VoltageRange_3);//VCC=2.7~3.6V??!!

//	if(status==FLASH_COMPLETE)
//	{

//			status=FLASH_ProgramByte(ADDR_FLASH_SECTOR_7+1024,char_SysID_Length);//????
//		  for(index=0;index<char_SysID_Length;index++)
//		{
//			status=FLASH_ProgramByte(ADDR_FLASH_SECTOR_7+1024+index+1,char_SysID[index]);  //SysID
//		}
//		  status=FLASH_ProgramByte(ADDR_FLASH_SECTOR_7+1024+9,Battery_Threshold);
//		  status=FLASH_ProgramByte(ADDR_FLASH_SECTOR_7+1024+10,Key_Sound);
//		  

//	}
//  FLASH_DataCacheCmd(ENABLE);	//FLASH????,??????
//	FLASH_Lock();//??
}
开发者ID:CaptainJe,项目名称:BlueShiled,代码行数:57,代码来源:bsp_FileSystem.c



注:本文中的FLASH_EraseSector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FLASH_PrefetchBufferCmd函数代码示例发布时间:2022-05-30
下一篇:
C++ FLASH_ErasePage函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap