예제 #1
0
/*****************************************************************************
 * FUNCTION - SaveToFlash
 * DESCRIPTION: Returns true on success
 ****************************************************************************/
bool FlashBlock::SaveToFlash(void)
{
  bool success = false;

#ifndef __PC__

  int count = mpBlockHdr->blockSize;

  // flash is 16-bit - adjust to 2-byte boundary if necessary
  if ((count % 2) != 0)
  {
    count++;
  }

  success = FlashControl::GetInstance()->SaveData(mpBlockCache, count, mFlashControlBlockId);
#else
  success = SaveToDisk();
#endif

  // set / reset error flag
  if (success)
  {
    mErrorFlags &= ~ERROR_FLAG_SAVE_TO_FLASH_FAILED;
  }
  else
  {
    LoadFromFlash(); // Restore previous data (assumed to be valid)
    mErrorFlags |= ERROR_FLAG_SAVE_TO_FLASH_FAILED;
  }

  mModified = false; // Clear this flag here to avoid repeat of SaveToFlash in case of error

  return success;

}
예제 #2
0
파일: main.c 프로젝트: banksh/lAAAHzertag
void main(void)
{
    Setup();
    LoadFromFlash();
    if(!config.health) {
        super_dead_mode();
    }

    while(1)
    {
        handle_serial();
        handle_fire();
        handle_music();
    }
}