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


C++ EEPROMClass::write方法代码示例

本文整理汇总了C++中EEPROMClass::write方法的典型用法代码示例。如果您正苦于以下问题:C++ EEPROMClass::write方法的具体用法?C++ EEPROMClass::write怎么用?C++ EEPROMClass::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EEPROMClass的用法示例。


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

示例1: write

void EEPROMWearLeveler::write( uint16_t address, uint8_t value )
{
  if ( _num_of_vars == AVR_EEPROM_SIZE )
  {
    // Revert back to EEPROM class if the nubmer of variables is
    // greater than AVR_EEPROM_SIZE/4
    EEPROM.write( address, value );
  }
  else
  {
    // bounds check
    if ( address >= _num_of_vars )
    {
      std::cout << " BAD address \n";           
      return;
    }
    uint16_t write_offset = findNextWriteAddress( address );
    std::cout << "write_offset: " << write_offset << std::endl;

    uint16_t pb_start_addr = parameterBufferAddress( address );
    std::cout << "pb_start_addr: " << pb_start_addr << std::endl;

    std::cout << "write address: " <<  pb_start_addr + write_offset << std::endl;

    // Write value to paramater buffer
    EEPROM.write( pb_start_addr + write_offset, value );
  
    // Update status buffer 
    uint16_t sb_start_addr = statusBufferAddress( address );
    uint16_t curr_index = sb_start_addr + write_offset;
    uint16_t prev_index;

    std::cout << "curr_index: " <<  (int)curr_index << std::endl;
    std::cout << "sb_start_addr: " <<  (int)sb_start_addr << std::endl;
    std::cout << "write_offset: " <<  (int)write_offset << std::endl;
    
    // Wrap around case
    if ( curr_index == sb_start_addr )
      prev_index = sb_start_addr + _buffer_len - 1;
    else
      prev_index = curr_index - 1;

    uint16_t sb_val = EEPROM.read(prev_index) + 1;
    std::cout << "write status buffer at: " <<  (int)curr_index << std::endl;
    std::cout << "\tstatus buffer value: " <<  (int)sb_val << std::endl;

    EEPROM.write( curr_index, sb_val );
  }
}
开发者ID:nabilt,项目名称:diy_eshift,代码行数:49,代码来源:EEPROMWearLeveler.cpp

示例2: clear

void EEPROMWearLeveler::clear()
{
  for (int i = 0; i < AVR_EEPROM_SIZE; i++)
  {
    EEPROM.write(i, 0);
  }  
}
开发者ID:nabilt,项目名称:diy_eshift,代码行数:7,代码来源:EEPROMWearLeveler.cpp

示例3: saveToEEPROM

//------------------------------------------------------------------
bool StateMachine::saveToEEPROM() {
	Serial.println(" Save to EEPROMprom!");
	EEPROM.write(CHANELSADDRES    , c1.threshold);
	EEPROM.write(CHANELSADDRES + 1, c1.timeS);
	EEPROM.write(CHANELSADDRES + 2, c1.timeBan);

	EEPROM.write(CHANELSADDRES + 3, c2.threshold);
	EEPROM.write(CHANELSADDRES + 4, c2.timeS);
	EEPROM.write(CHANELSADDRES + 5, c2.timeBan);

	EEPROM.write(CHANELSADDRES + 6, c3.threshold);
	EEPROM.write(CHANELSADDRES + 7, c3.timeS);
	EEPROM.write(CHANELSADDRES + 8, c3.timeBan);	
}
开发者ID:Nand-e,项目名称:STM32-Watering,代码行数:15,代码来源:FS.cpp

示例4:

//  save data to EEPROM
//  return: the size saved, 0 for error
static uint32_t EEPROM_Save(uint32_t addr, uint8_t * data, uint32_t size)
{
    //  the EEPROM size is 1K (0x000-0x3FF)
    if (addr + size < 0x400)
    {
        for (int i = 0; i < size; ++i)
        {
            EEPROM.write(addr + i, data[i]);
        }
        return size;
    }
    else
    {
        return 0;
    }
}
开发者ID:Makeblock-official,项目名称:Me_EncodeDriver,代码行数:18,代码来源:MotorParam.cpp


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