Exemplo n.º 1
0
void eepromRead(uint32_t address, uint8_t * buffer, uint32_t size, bool blocking=true)
{
  // TRACE("eepromRead(%d, %p, %d)", address, buffer, size);

#if defined(SIMU)
  assert(size);
  eeprom_pointer = address;
  eeprom_buffer_data = buffer;
  eeprom_buffer_size = size;
  eeprom_read_operation = true;
  Spi_complete = false;
  sem_post(eeprom_write_sem);
#else
  eepromReadArray(address, buffer, size);
#endif

  if (blocking) {
    eepromWaitSpiComplete();
  }
}
Exemplo n.º 2
0
void eepromEraseBlock(uint32_t address, bool blocking=true)
{
  // TRACE("eepromEraseBlock(%d)", address);

#if defined(SIMU)
  static uint8_t erasedBlock[EEPROM_BLOCK_SIZE] = { 0xff };
  eeprom_pointer = address;
  eeprom_buffer_data = erasedBlock;
  eeprom_buffer_size = EEPROM_BLOCK_SIZE;
  eeprom_read_operation = false;
  Spi_complete = false;
  sem_post(eeprom_write_sem);
#else
  eepromWriteEnable();
  eepromBlockErase(address);
#endif

  if (blocking) {
    eepromWaitSpiComplete();
    eepromWaitReadStatus();
  }
}