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

C++ FLASH_ClearFlag函数代码示例

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

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



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


示例16: writeParams

void writeParams(void)
{
    FLASH_Status status;
    uint32_t i;
    uint8_t chk = 0;
    const uint8_t *p;
    
    cfg.version = EEPROM_CONF_VERSION;
    cfg.size = sizeof(config_t);
    cfg.magic_be = 0xBE;
    cfg.magic_ef = 0xEF;
    cfg.chk = 0;
    // recalculate checksum before writing
    for (p = (const uint8_t *)&cfg; p < ((const uint8_t *)&cfg + sizeof(config_t)); ++p)
        chk ^= *p;
    cfg.chk = chk;
    
    // write it
    FLASH_Unlock();
    FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);

    if (FLASH_ErasePage(FLASH_WRITE_ADDR) == 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)
                while(1);//break; // TODO: fail
        }
    }

    FLASH_Lock();

    readEEPROM();
}
开发者ID:Zero3nna,项目名称:Optima-PPM,代码行数:33,代码来源:config.c


示例17: write_embedded_flash_with_addr_len

// write to a specified page in flash
// page_addr: the page address that write to
void write_embedded_flash_with_addr_len(uint32_t page_addr, uint8_t *buf, uint16_t len) {
	uint32_t saddr = page_addr;			// start address for the page to write
	uint32_t eaddr = saddr+len;	// end addrees for that page
	uint32_t *pbuf = (uint32_t*)buf;

	// Unlock the Flash Program Erase controller
	FLASH_Unlock();

	// Clear All pending flags 
	FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR);

	// Erase the FLASH pages 
	FLASHStatus = FLASH_ErasePage(saddr);
	
	// write buf to that page
	while((saddr < eaddr) && (FLASHStatus == FLASH_COMPLETE)) {
		FLASHStatus = FLASH_FastProgramWord(saddr, *(pbuf));	//problem
		saddr = saddr + 4;
		pbuf++;
	}

	if (FLASHStatus != FLASH_COMPLETE) {
		HardFault_Handler();//enter_unexpected();  do something here;
	}


	// Lock flash
	FLASH_Lock();
}
开发者ID:xumiao-1,项目名称:AutoLPW,代码行数:31,代码来源:flash_funcs.c


示例18: eeprom_erase

//**************************************************************************
void eeprom_erase(void)
{
  DATA_EEPROM_Unlock(); // разблокировка перед записью
  
  /* Clear all pending flags */      
  FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR
                  | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR | FLASH_FLAG_OPTVERRUSR);	
  
  /*  Data EEPROM Fast Word program of FAST_DATA_32 at addresses defined by 
  DATA_EEPROM_START_ADDR and DATA_EEPROM_END_ADDR */  
  Address = DATA_EEPROM_START_ADDR;
  
  NbrOfPage = ((DATA_EEPROM_END_ADDR - Address) + 1 ) >> 2; 
  
  /* Erase the Data EEPROM Memory pages by Word (32-bit) */
  for(j = 0; j < NbrOfPage; j++)
  {
    FLASHStatus = DATA_EEPROM_EraseWord(Address + (4 * j));
  }
  DATA_EEPROM_Lock();
  
  /* Check the correctness of written data */
  while(Address < DATA_EEPROM_END_ADDR)
  {
    if(*(__IO uint32_t*)Address != 0x0)
    {
      DataMemoryProgramStatus = FAILED;
      //ОШИБКА стирания !!!!
      return;
    }
    Address = Address + 4;
  }
  
}
开发者ID:htol,项目名称:ultramicron,代码行数:35,代码来源:eeprom.c


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


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FLASH_ErasePage函数代码示例发布时间:2022-05-30
下一篇:
C++ FLAG_SET函数代码示例发布时间: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