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

C++ FLASH_ProgramHalfWord函数代码示例

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

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



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

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


示例2: stm32f3_flash_write

static int
stm32f3_flash_write(uint32_t address, const void *src, uint32_t len)
{
    FLASH_Status rc;
    int num_half_words;
    int i;
    uint16_t *src16 = (uint16_t *)src;

    if (address % sizeof(uint16_t)) {
        /*
         * Unaligned write.
         */
        return -1;
    }
    num_half_words = len / 2;

    for (i = 0; i < num_half_words; i++) {
        rc = FLASH_ProgramHalfWord(address, src16[i]);
        if (rc != FLASH_COMPLETE) {
            goto err;
        }
        address += 2;
    }
    if (num_half_words * 2 != len) {
        rc = FLASH_ProgramHalfWord(address, ((uint8_t *)src)[len] << 8);
        if (rc != FLASH_COMPLETE) {
            goto err;
        }
    }
    return 0;
err:
    return -1;
}
开发者ID:leckie711,项目名称:incubator-mynewt-larva,代码行数:33,代码来源:hal_flash.c


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


示例4: PIOS_Flash_Internal_WriteData

static int32_t PIOS_Flash_Internal_WriteData(uintptr_t chip_id, uint32_t chip_offset, const uint8_t *data, uint16_t len)
{
	PIOS_Assert(data);
	PIOS_Assert((chip_offset & 0x0001) == 0)

	struct pios_internal_flash_dev *flash_dev = (struct pios_internal_flash_dev *)chip_id;

	if (!PIOS_Flash_Internal_Validate(flash_dev))
		return -1;

	/* Write the data */
	for (uint16_t i = 0; i < (len & ~1); i += 2) {
		/* Check if content has been changed prior to write.
		 * This should enhance performance and make this compatible with the F3 chip.
		 */
		uint8_t temp[2];
		if (PIOS_Flash_Internal_ReadData(chip_id, chip_offset + i, temp, sizeof(temp)) != 0)
			return -4;

		if (temp[0] == data[i] && temp[1] == data[i + 1])
			continue;

		FLASH_Status status;
		status = FLASH_ProgramHalfWord(FLASH_BASE + chip_offset + i, data[i + 1] << 8 | data[i]);
		PIOS_Assert(status == FLASH_COMPLETE);
	}
	/* Handle uneven writes by filling up with 0xff*/
	if ((len & 1) != 0) {
		FLASH_Status status;
		status = FLASH_ProgramHalfWord(FLASH_BASE + chip_offset + len - 1, 0xff << 8 | data[len - 1]);
		PIOS_Assert(status == FLASH_COMPLETE);
	}

	return 0;
}
开发者ID:1heinz,项目名称:TauLabs,代码行数:35,代码来源:pios_flash_internal.c


示例5: store_offsets

//Store the computed offsets to internal FLASH
void store_offsets()
{
	union
	{
		float val;
		struct
		{
			uint8_t bytes[4];
		};
	}extract_float;

	uint32_t ADDRESS = BACKUP_ADDRESS;
	uint8_t i,j;

	IWDG_ReloadCounter();
	FLASH_Unlock();				//unlock FLASH to enable writing
	FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);	//clear any pending flags
	FLASH_EraseSector(BACKUP_SECTOR,VoltageRange_3);		//Erase the sector where data is to be written too

	FLASH_ProgramHalfWord(ADDRESS, ASI_ZERO);
	ADDRESS+=2;
	for(j=0;j<6;j++)
	{
		extract_float.val = AN_OFFSET[j];
		for(i=0;i<4;i++)
		{
			FLASH_ProgramByte(ADDRESS, extract_float.bytes[i]);
			ADDRESS+=1;
		}
	}

	for(i=0;i<3;i++)
	{
		FLASH_ProgramHalfWord(ADDRESS, MAG_OFFSET[i]);
		ADDRESS+=2;
	}

	for(j=0;j<3;j++)
	{
		extract_float.val = MAG_SCALE[j];
		for(i=0;i<4;i++)
		{
			FLASH_ProgramByte(ADDRESS, extract_float.bytes[i]);
			ADDRESS+=1;
		}
	}
	FLASH_ProgramHalfWord(ADDRESS, ground_alt_offset);
	ADDRESS+=2;

	for(i=0;i<8;i++)
	{
		FLASH_ProgramHalfWord(ADDRESS, RC_trim[i]);
		ADDRESS+=2;
	}
	FLASH_Lock();
}
开发者ID:satyasrmist,项目名称:Datalogger,代码行数:57,代码来源:flash.c


示例6: EE_VerifyPageFullWriteVariable

/*******************************************************************************
* Function Name  : EE_VerifyPageFullWriteVariable
* Description    : Verify if active page is full and Writes variable in EEPROM.
* Input          : - VirtAddress: 16 bit virtual address of the variable
*                  - Data: 16 bit data to be written as variable value
* Output         : None
* Return         : - Success or error status:
*                      - FLASH_COMPLETE: on success
*                      - PAGE_FULL: if valid page is full
*                      - NO_VALID_PAGE: if no valid page was found
*                      - Flash error code: on write Flash error
*******************************************************************************/
u16 EE_VerifyPageFullWriteVariable(u16 VirtAddress, u16 Data)
{
  FLASH_Status FlashStatus = FLASH_COMPLETE;
  u16 ValidPage = PAGE0;
  u32 Address = 0x08010000, PageEndAddress = 0x080107FF;

  /* Get valid Page for write operation */
  ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);

  /* Check if there is no valid page */
  if (ValidPage == NO_VALID_PAGE)
  {
    return  NO_VALID_PAGE;
  }

  /* Get the valid Page start Address */
  Address = (u32)(EEPROM_START_ADDRESS + (u32)(ValidPage * PAGE_SIZE));

  /* Get the valid Page end Address */
  PageEndAddress = (u32)((EEPROM_START_ADDRESS - 2) + (u32)((1 + ValidPage) * PAGE_SIZE));

  /* Check each active page address starting from beginning */
  while (Address < PageEndAddress)
  {
    /* Verify each time if Address and Address+2 contents are equal to Data and VirtAddress respectively */
    if (((*(vu16*)Address) == Data) && ((*(vu16*)(Address + 2)) == VirtAddress))
    {
      return FLASH_COMPLETE;
    }

    /* Verify if Address and Address+2 contents are 0xFFFFFFFF */
    if ((*(vu32*)Address) == 0xFFFFFFFF)
    {
      /* Set variable data */
      FlashStatus = FLASH_ProgramHalfWord(Address, Data);
      /* If program operation was failed, a Flash error code is returned */
      if (FlashStatus != FLASH_COMPLETE)
      {
        return FlashStatus;
      }
      /* Set variable virtual address */
      FlashStatus = FLASH_ProgramHalfWord(Address + 2, VirtAddress);
      /* Return program operation status */
      return FlashStatus;
    }
    else
    {
      /* Next address location */
      Address = Address + 4;
    }
  }

  /* Return PAGE_FULL in case the valid page is full */
  return PAGE_FULL;
}
开发者ID:Farewellly,项目名称:STM32,代码行数:67,代码来源:eeprom.c


示例7: EE_VerifyPageFullWriteVariable

/**
  * @brief  Verify if active page is full and Writes variable in EEPROM.
  * @param  VirtAddress: 16 bit virtual address of the variable
  * @param  Data: 16 bit data to be written as variable value
  * @retval Success or error status:
  *           - FLASH_COMPLETE: on success
  *           - PAGE_FULL: if valid page is full
  *           - NO_VALID_PAGE: if no valid page was found
  *           - Flash error code: on write Flash error
  */
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data)
{
  FLASH_Status FlashStatus = FLASH_COMPLETE;
  uint16_t ValidPage = PAGE0;
  uint32_t Address = EEPROM_START_ADDRESS, PageEndAddress = EEPROM_START_ADDRESS+PAGE_SIZE-1;

  /* Get valid Page for write operation */
  ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);

  /* Check if there is no valid page */
  if (ValidPage == NO_VALID_PAGE)
  {
    return  NO_VALID_PAGE;
  }

  //FLASH_Unlock();

  /* Get the valid Page start Address */
  Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));

  /* Get the valid Page end Address */
  PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));

  /* Check each active page address starting from begining */
  while (Address < PageEndAddress)
  {
    /* Verify if Address and Address+2 contents are 0xFFFFFFFF */
    if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF)
    {
      /* Set variable data */
      FlashStatus = FLASH_ProgramHalfWord(Address, Data);
      /* If program operation was failed, a Flash error code is returned */
      if (FlashStatus != FLASH_COMPLETE)
      {
        //FLASH_Lock();
        return FlashStatus;
      }
      /* Set variable virtual address */
      FlashStatus = FLASH_ProgramHalfWord(Address + 2, VirtAddress);
      /* Return program operation status */
      //FLASH_Lock();
      return FlashStatus;
    }
    else
    {
      /* Next address location */
      Address = Address + 4;
    }
  }
  //FLASH_Lock();

  /* Return PAGE_FULL in case the valid page is full */
  return PAGE_FULL;
}
开发者ID:japina,项目名称:koduino,代码行数:64,代码来源:eeprom_stm32.c


示例8: FlashWriteStr

/******************************************************
flash 字符串写入
每次存入两个字节
*******************************************************/
void FlashWriteStr( u32 flash_add, u16 len, u8* data )
{
    //char cp[12];
    //u8 s = 0;
    u16 byteN = 0;
    uint32_t FlashData;


    //FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
    //FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
    //FLASH_ErasePage(flash_add+FLASH_PAGE_SIZE * 1);
    //FLASH_ErasePage(flash_add);
    //sprintf( cp, "len:%d", len);
    //USART1_Puts(cp);
    while( len )
    {
        FlashData=*(vu32*)(flash_add+byteN);	 /* 读取地址中的16位数据 */
        my_unTemp16.un_temp8[0] = *(data+byteN);
        my_unTemp16.un_temp8[1] = *(data+byteN+1);
        //my_unTemp16.un_temp8[2] = *(data+byteN+2);
        //my_unTemp16.un_temp8[3] = *(data+byteN+3);
        //my_unTemp16.un_temp16=(*(data+byteN))|((*(data+byteN+1))<<8)|((*(data+byteN+2))<<16)|((*(data+byteN+3))<<24);
        if(FlashData==0xffffffff)
        {
            FLASH_Unlock();
            FLASH_ProgramHalfWord(flash_add+byteN , my_unTemp16.un_temp16 );
            FLASH_Lock();
        }
//		else if(FlashData==my_unTemp16.un_temp16)
//		{  FLASH_COMPLETE
//		}
        else
        {
            FLASH_Unlock();
            FLASH_ErasePage(flash_add+byteN);		  /* 擦除页 */
            FLASH_ProgramHalfWord(flash_add+byteN , my_unTemp16.un_temp16 );
            FLASH_Lock();
        }

        //sprintf( cp, "bye:%d\r\n", s);
        //USART1_Puts(cp);
        if( 1==len )
        {
            //如果数据长度是奇数,为1的时候跳出
            break;
        }
        else
        {
            byteN += 2;
            len -= 2;
        }
    }
    //FLASH_Lock();
}
开发者ID:remina,项目名称:AHRS_AGV,代码行数:58,代码来源:FLASH.c


示例9: PIOS_Flash_Internal_WriteData

static int32_t PIOS_Flash_Internal_WriteData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
	PIOS_Assert(data);
	PIOS_Assert((addr & 0x0001) == 0)

	struct pios_internal_flash_dev * flash_dev = (struct pios_internal_flash_dev *)flash_id;

	if (!PIOS_Flash_Internal_Validate(flash_dev))
		return -1;

	uint32_t sector_start;
	uint32_t sector_size;

	/* Ensure that the base address is in a valid sector */
	if (!PIOS_Flash_Internal_GetSectorInfo(addr,
						&sector_start,
						&sector_size)) {
		/* We're asking for an invalid flash address */
		return -2;
	}

	/* Ensure that the entire write occurs within the same sector */
	if ((uintptr_t)addr + len > sector_start + sector_size) {
		/* Write crosses the end of the sector */
		return -3;
	}

	/* Write the data */
	for (uint16_t i = 0; i < (len & ~1); i += 2) {
		/* Check if content has been changed prios to write.
		 * This should enhance performance and make this compatible with the F3 chip.
		 */
		uint8_t temp[2];
		if (PIOS_Flash_Internal_ReadData(flash_id, addr + i, temp, sizeof(temp)) != 0)
			return -4;

		if (temp[0] == data[i] && temp[1] == data[i + 1])
			continue;

		FLASH_Status status;
		status = FLASH_ProgramHalfWord(addr + i, data[i + 1] << 8 | data[i]);
		PIOS_Assert(status == FLASH_COMPLETE);
	}
	/* Handle uneven writes by filling up with 0xff*/
	if ((len & 1) != 0) {
		FLASH_Status status;
		status = FLASH_ProgramHalfWord(addr + len - 1, 0xff << 8 | data[len - 1]);
		PIOS_Assert(status == FLASH_COMPLETE);
	}

	return 0;
}
开发者ID:johnm1,项目名称:flyingf4_int_flash,代码行数:52,代码来源:pios_flash_internal.c


示例10: RCFS_Write

static void
RCFS_Write( flash_file *f )
{
    unsigned short *p;
    unsigned short *q;
    int   i;
    volatile FLASH_Status FLASHStatus = FLASH_COMPLETE;

    // check for valid address
    if( f->addr < baseaddr )
        return;

    if( f->data == NULL )
        return;

    // Init pointers (some wierd bug in ROBOTC here)
    long tmp = f->addr;
    p = (unsigned short *)tmp;
    q = (unsigned short *)&(f->name[0]);

    // Write header
    for(i=0;i<(FLASH_FILE_HEADER_SIZE/2);i++)
        {
        // Write 16 bit data
        FLASHStatus = FLASH_ProgramHalfWord( (uint32_t)p++, *q++ );
        }

    // point at the file data, we will write as words
    q = (unsigned short *)f->data;

    // Write Data, datalength is now in bytes so divide datalength by 2
    for(i=0;i<(f->datalength/2);i++)
        {
        // Write 16 bit data
        FLASHStatus = FLASH_ProgramHalfWord( (uint32_t)p++, *q++ );

        // every 128 bytes abort time slice
        if( (i % 128) == 0 )
            abortTimeslice();
        }

    // Was it an odd number of bytes ?
    if( (f->datalength & 1) == 1 )
        {
        // pad with 0xFF and write the last byte
        unsigned short b = (*(unsigned char *)q) | 0xFF00;
        FLASHStatus = FLASH_ProgramHalfWord( (uint32_t)p++, b);
        }
}
开发者ID:jpearman,项目名称:rcfs,代码行数:49,代码来源:flash_rcfs.c


示例11: mal_flash_write_uint16_values

mal_error_e mal_flash_write_uint16_values(unsigned int start_address, uint16_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_ProgramHalfWord(address, values[i]);
		if (FLASH_COMPLETE != result) {
			// We stop at first sign of error
			break;
		}
		// Increment address
		address += sizeof(uint16_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


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


示例13: Save_DoorInfor

void Save_DoorInfor(Door_Infor_t *infor)
{
			FLASH_Unlock();
			FLASH_ErasePage(DOOR_INFOR_ADDR);
			FLASH_ProgramHalfWord((uint32_t)DOOR_INFOR_ADDR, *(uint16_t*)infor);
			FLASH_Lock();
}
开发者ID:fanqh,项目名称:SmartDoor,代码行数:7,代码来源:motor.c


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


示例15: FLASH_Write_16BITS

uint32_t FLASH_Write_16BITS( uint32_t* FlashAddress, uint16_t* Data ,uint16_t DataLength)
{
    __disable_irq();
    
    for (u16 i = 0; i < (DataLength); i++)
    {
        if (FLASH_ProgramHalfWord(*FlashAddress, Data[i]) == FLASH_COMPLETE)
        {
            /* Check the written value */
            if (*(u16*)*FlashAddress != Data[i])
            {
               /* Flash content doesn't match SRAM content */
               return FLASH_WRITE_ERROR;
            }
         }
         else
         {
           return FLASH_ERASE_ERROR;
         }
         *FlashAddress += 2;
    }
    
      __enable_irq();
    
     return FLASH_OK;
}
开发者ID:barrylw,项目名称:lamp_project_slave,代码行数:26,代码来源:hal_falsh.c


示例16: FLASH_Unlock

bool HardwareEEPROM::put(char * src, size_t size)
{
    FLASH_Status status = (FLASH_Status)0;

    FLASH_Unlock();

    for (unsigned int tries = 3; tries; tries--) {

        FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);

        status = FLASH_COMPLETE;

        for (size_t i=0; i<size && status==FLASH_COMPLETE; i+=2) {

            uint16_t datum = 0;

            memcpy(&datum, &src[i], (i+2>size)?1:2); // handle odd-length data

            status = FLASH_ProgramHalfWord(FLASH_WRITE_ADDR+i, datum);
        }

        if (status == FLASH_COMPLETE)
            break;
    }

    FLASH_Lock();

    return status == FLASH_COMPLETE;
}
开发者ID:simondlevy,项目名称:BreezySTM32,代码行数:29,代码来源:EEPROM.cpp


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


示例18: Fls_Write

Std_ReturnType Fls_Write(Fls_AddressType TargetAddress, const uint8 *SourceAddressPtr, Fls_LengthType Length)
{
	FLASH_Status stResult;
	Fls_LengthType len = Length;
	Fls_AddressType addr = TargetAddress;
	const uint8 *srcPtr = SourceAddressPtr;

	while (len >= sizeof(uint32_t))
	{
		stResult = FLASH_ProgramWord((uint32_t)addr, (uint32_t)*(uint32_t *)srcPtr);
		srcPtr += sizeof(uint32_t);
		addr += sizeof(uint32_t);
		len -= sizeof(uint32_t);
	}

	if (len == sizeof(uint16_t))
	{
		FLASH_ProgramHalfWord((uint32_t)addr, (uint16_t)*(uint16_t *)srcPtr);
		srcPtr += sizeof(uint16_t);
		addr += sizeof(uint16_t);
		len -= sizeof(uint16_t);
	}

	return E_OK;
}
开发者ID:miaozhendaoren,项目名称:PWC-Demonstrator,代码行数:25,代码来源:Fls.c


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


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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