當前位置: 首頁>>代碼示例>>C++>>正文


C++ FLASH_EraseSector函數代碼示例

本文整理匯總了C++中FLASH_EraseSector函數的典型用法代碼示例。如果您正苦於以下問題:C++ FLASH_EraseSector函數的具體用法?C++ FLASH_EraseSector怎麽用?C++ FLASH_EraseSector使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了FLASH_EraseSector函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的FLASH_EraseSector函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。