本文整理汇总了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 );
}
}
示例2: clear
void EEPROMWearLeveler::clear()
{
for (int i = 0; i < AVR_EEPROM_SIZE; i++)
{
EEPROM.write(i, 0);
}
}
示例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);
}
示例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;
}
}