当前位置: 首页>>代码示例>>C++>>正文


C++ FLASH_ClearFlag函数代码示例

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


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

示例1: FlashWRDPUnlock

/*******************************************************************************************************
 *
 *         函数名称: 
 *
 *         函数功能: 
 *
 *         入口参数: 
 *
 *         出口参数: 无
 *
 *             说明:
 *
 *******************************************************************************************************/
void FlashWRDPUnlock(void)
{
    uint32_t rt;
    FlagStatus   RDP_state;
    FLASH_Status Flash_state;
    uint32_t     optcr_byte;
    //如果匹配,进行Flash的读写解锁
    FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_OPERR|FLASH_FLAG_WRPERR| FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); 
    FLASH_Unlock();
    FLASH_OB_Unlock();
    FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_OPERR|FLASH_FLAG_WRPERR| FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); 

    rt = FLASH_OB_GetWRP();
    
    do
    {
        //FlashWRPLock(WRITE, WRP_Sector_All);
        FLASH_OB_WRPConfig(WRP_Sector_All, DISABLE); //开启写保护
    }while(FLASH_OB_Launch() != FLASH_COMPLETE);
    
    rt = FLASH_OB_GetWRP();
    
    RDP_state = FLASH_OB_GetRDP();
    do
    {
        FLASH_OB_RDPConfig(OB_RDP_Level_0);//关闭读保护
    }while(FLASH_OB_Launch() != FLASH_COMPLETE);
    
    RDP_state = FLASH_OB_GetRDP();    
    FLASH_OB_Lock();
    FLASH_Lock();
    
}
开发者ID:meterhu,项目名称:stm32F4,代码行数:46,代码来源:WRProtect.c

示例2: writeEEPROM

bool writeEEPROM(void)
{
    // Generate compile time error if the config does not fit in the reserved area of flash.
    BUILD_BUG_ON(sizeof(master_t) > FLASH_TO_RESERVE_FOR_CONFIG);

    FLASH_Status status = 0;
    uint32_t wordOffset;
    int8_t attemptsRemaining = 3;
    bool changed;

    // prepare checksum/version constants
    masterConfig.version = EEPROM_CONF_VERSION;
    masterConfig.size = sizeof(master_t);
    masterConfig.magic_be = 0xBE;
    masterConfig.magic_ef = 0xEF;
    masterConfig.chk = 0; // erase checksum before recalculating
    masterConfig.chk = calculateChecksum((const uint8_t *) &masterConfig, sizeof(master_t));

    changed = (memcmp((const master_t *)CONFIG_START_FLASH_ADDRESS, &masterConfig, sizeof(master_t)) != 0);

    // write it
    if(changed) {
      FLASH_Unlock();
      while (attemptsRemaining--) {
#ifdef STM32F303
        FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPERR);
#endif
#ifdef STM32F10X
          FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
#endif
          for (wordOffset = 0; wordOffset < sizeof(master_t); wordOffset += 4) {
              if (wordOffset % FLASH_PAGE_SIZE == 0) {
                  status = FLASH_ErasePage(CONFIG_START_FLASH_ADDRESS + wordOffset);
                  if (status != FLASH_COMPLETE) {
                      break;
                  }
              }

              status = FLASH_ProgramWord(CONFIG_START_FLASH_ADDRESS + wordOffset,
                      *(uint32_t *) ((char *) &masterConfig + wordOffset));
              if (status != FLASH_COMPLETE) {
                  break;
              }
          }
          if (status == FLASH_COMPLETE) {
              break;
          }
      }
      FLASH_Lock();

      // Flash write failed - just die now
      if (status != FLASH_COMPLETE || !isEEPROMContentValid()) {
          failureMode(10);
      }
    }

    return changed;
}
开发者ID:wiresharks,项目名称:cleanflight,代码行数:58,代码来源:config.c

示例3: eeprom_init_hw

// Initialise EEPROM hardware
void eeprom_init_hw(void)
{
  // unlock flash
  FLASH_Unlock();
  // Clear Flags
  FLASH_ClearFlag(FLASH_FLAG_PGERR |FLASH_FLAG_WRPERR|FLASH_FLAG_EOP);
  
  uint8_t mirror;
  uint16_t page;
  uint32_t addr;
  
  // Read pages status
  eFEE_STATUS pages_status[FEE_MIRROR_NUMBER];
  eFEE_STATUS status;
  
  for(page = 0; page < FEE_SECTORS; page++)
  {
    fee_pages_map[page] = 0xFF;
    for(mirror = 0; mirror < FEE_MIRROR_NUMBER; mirror++)
    {
      addr = FEE_BASE_ADDRESS + FEE_EEPROM_SIZE * mirror + FEE_SECTOR_SIZE * page;
      status = *(uint16_t *)(addr);
      pages_status[mirror] = status;
      
      if((status == eFEE_PAGE_VALID) && (fee_pages_map[page] == 0xFF))
      {
        fee_pages_map[page] = mirror;
      }
      else if(status != eFEE_PAGE_ERASED)
      {
        if(FLASH_ErasePage(addr) == FLASH_COMPLETE)
          pages_status[mirror] = eFEE_PAGE_ERASED;
        else
        {
          FLASH_ClearFlag(FLASH_FLAG_PGERR |FLASH_FLAG_WRPERR|FLASH_FLAG_EOP);
          pages_status[mirror] = eFEE_PAGE_INVALID;
        }
      }
    }

    if(fee_pages_map[page] == 0xFF) //  No Valid mirror
      for(mirror = 0; mirror < FEE_MIRROR_NUMBER; mirror++)
      {
        if(pages_status[mirror] == eFEE_PAGE_ERASED)
        {
          addr = FEE_BASE_ADDRESS + FEE_EEPROM_SIZE * mirror + FEE_SECTOR_SIZE * page;
          if(FLASH_ProgramHalfWord(addr, eFEE_PAGE_VALID) == FLASH_COMPLETE)
          {
            fee_pages_map[page] = mirror;
            break;
          }
          else
            FLASH_ClearFlag(FLASH_FLAG_PGERR |FLASH_FLAG_WRPERR|FLASH_FLAG_EOP);
        }
      }
  }
}
开发者ID:Wassili-Hense,项目名称:Vers3,代码行数:58,代码来源:hal_eeprom_flash.c

示例4: 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

示例5: 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

示例6: bsp_Firmware_Write

u8* bsp_Firmware_Write(u8* writebuffer,u32 writeaddress,u16 writelength)
{	
	
	u8 status=0;
	u16 index=0;
	SleepTime=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);
	
   __set_PRIMASK(1);  
		  for(index=0;index<writelength;index++)
		{
			status=FLASH_ProgramByte(writeaddress+index,writebuffer[index]);  
		}
   __set_PRIMASK(0);  

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

示例7: write_flash

int write_flash(uint32_t addr, uint8_t *data, uint32_t data_len)
{
	FLASH_Status FLASHStatus = FLASH_COMPLETE;
	int rep = 0, i;
	uint32_t tmp;

	__disable_irq();

	rep = (data_len / 4);
	if(data_len % 4)
		rep++;

	FLASH_Unlock();
	FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);	

	for(i = 0 ; i < rep ; i++) {
		tmp = *((uint32_t *)data + i);
		FLASHStatus = FLASH_ProgramWord(addr, tmp);
		if(FLASHStatus != FLASH_COMPLETE) {
			myprintf("FLASH_ProgramWord Error\r\n");
			return -1;
		}

		addr += 4;
	}

	FLASH_Lock();

	__enable_irq();

	return data_len;
}
开发者ID:Wiznet,项目名称:WIZ550web,代码行数:32,代码来源:flashHandler.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: 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

示例10: flash_helper_write_new_app_data

uint16_t flash_helper_write_new_app_data(uint32_t offset, uint8_t *data, uint32_t len) {
	FLASH_Unlock();
	FLASH_ClearFlag(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR |
			FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);

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

	for (uint32_t i = 0;i < len;i++) {
		uint16_t res = FLASH_ProgramByte(flash_addr[NEW_APP_BASE] + offset + i, data[i]);
		if (res != FLASH_COMPLETE) {
			FLASH_Lock();
			return res;
		}
	}
	FLASH_Lock();

	timeout_configure_IWDT();

	utils_sys_unlock_cnt();

	return FLASH_COMPLETE;
}
开发者ID:vedderb,项目名称:bldc,代码行数:25,代码来源:flash_helper.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_inside_write

void flash_inside_write(void* address,void* data,long length) {
    char old_data[2]={0};
    int  old_data_int=0; 
    long the_last=length-1;

    if (!is_valid_address(address)) return;
    
    FLASH_Unlock();
    if ((long)address%2!=0) {
        flash_inside_read((void*)((long)address-1),old_data,2);
        old_data[1]=*(char*)data;
        memcpy(&old_data_int,old_data,sizeof(int));
        FLASH_ProgramHalfWord((uint32_t)(FLASH_INSIDE_ADDRESS_START+(long)address-1),old_data_int);
        --length;
    }
    for (;length>1;length-=2)
        FLASH_ProgramHalfWord((uint32_t)(FLASH_INSIDE_ADDRESS_START+(long)address+length-2),*(uint16_t*)((long)data+length-2));
    if (length) {
        flash_inside_read((void*)((long)address+the_last),old_data,2);
        old_data[0]=*(char*)((long)data+the_last);
        memcpy(&old_data_int,old_data,sizeof(int));
        FLASH_ProgramHalfWord((uint32_t)(FLASH_INSIDE_ADDRESS_START+(long)address+the_last),old_data_int);
    }
    FLASH_Lock();
    FLASH_ClearFlag(FLASH_FLAG_BSY|FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
}
开发者ID:chenyuwen,项目名称:Small-System,代码行数:26,代码来源:flash_inside_api.c

示例13: flashAddress

int flashAddress(uint32_t startAddr, uint32_t *data, uint32_t len) {
    FLASH_Status status;
    int retries;
    int ret = 1;
    int i;

    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);

    for (i = 0; i < len; i++) {
        retries = 0;
        do {
            status = FLASH_ProgramWord(startAddr + i*4, *(data + i));
            retries++;
        } while (status != FLASH_COMPLETE && retries < FLASH_RETRIES);

        if (retries == FLASH_RETRIES) {
            ret = 0;
            break;
        }
    }

    FLASH_Lock();

    return ret;
}
开发者ID:jiezhi320,项目名称:autoquadfc,代码行数:28,代码来源:flash.c

示例14: mal_flash_write_uint32_values

mal_error_e mal_flash_write_uint32_values(unsigned int start_address, uint32_t *values, uint32_t count) {
	FLASH_Status result = FLASH_BUSY;
	// Unlock flash registers
	FLASH_Unlock();
	// Clear pending flags
	FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPERR);
	// Write values
	uint32_t i;
	uint32_t address = start_address;
	for (i = 0; i < count; i++) {
		// Write data
		result = FLASH_ProgramWord(address, values[i]);
		if (FLASH_COMPLETE != result) {
			// We stop at first sign of error
			break;
		}
		// Increment address
		address += sizeof(uint32_t);
	}
	// Lock flash registers
	FLASH_Lock();
	// Return result
	if (FLASH_COMPLETE != result) {
		return MAL_ERROR_MEMORY;
	}
	return MAL_ERROR_OK;
}
开发者ID:MAL-Organization,项目名称:MAL,代码行数:27,代码来源:mal_hspec_stm32f0_flash.c

示例15: fee_write_page

// write data to FLASH, only within 1 page.
static bool fee_write_page(uint32_t fee_addr, uint32_t len, uint8_t *pData)
{
  uint16_t din, dout;

  for(; len > 0; len--)
  {
    din = (uint16_t)(*(pData++)) | 0xFF00;
    dout = *(uint16_t *)(fee_addr);

    if(din != dout)
    {
      if(dout != 0xFFFF)
        return false;

      if(FLASH_ProgramHalfWord(fee_addr, din) != FLASH_COMPLETE)
      {
        FLASH_ClearFlag(FLASH_FLAG_PGERR |FLASH_FLAG_WRPERR|FLASH_FLAG_EOP);
        return false;
      }
    }
    fee_addr += 2;
  }

  return true;
}
开发者ID:Wassili-Hense,项目名称:Vers3,代码行数:26,代码来源:hal_eeprom_flash.c


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