Bayley Wang
/
flash_configuration
flash based config testing
Embed:
(wiki syntax)
Show/hide line numbers
PrefrenceWriter.cpp
00001 #include "PreferenceWriter.h" 00002 #include "FlashWriter.h" 00003 #include "config.h" 00004 00005 PreferenceWriter::PreferenceWriter(uint32_t sector) { 00006 writer = new FlashWriter(sector); 00007 __sector = sector; 00008 __ready = false; 00009 } 00010 00011 void PreferenceWriter::open() { 00012 writer->open(); 00013 __ready = true; 00014 } 00015 00016 bool PreferenceWriter::ready() { 00017 return __ready; 00018 } 00019 00020 void PreferenceWriter::write(int x, int index) { 00021 __int_reg[index] = x; 00022 } 00023 00024 void PreferenceWriter::write(float x, int index) { 00025 __float_reg[index] = x; 00026 } 00027 00028 void PreferenceWriter::flush() { 00029 int offs; 00030 for (offs = 0; offs < 64; offs++) { 00031 writer->write(offs, __int_reg[offs]); 00032 } 00033 for (; offs < 128; offs++) { 00034 writer->write(offs, __float_reg[offs - 64]); 00035 } 00036 } 00037 00038 void PreferenceWriter::load() { 00039 int offs; 00040 for (offs = 0; offs < 64; offs++) { 00041 __int_reg[offs] = flashReadInt(__sector, offs); 00042 } 00043 for(; offs < 128; offs++) { 00044 __float_reg[offs - 64] = flashReadFloat(__sector, offs); 00045 } 00046 } 00047 00048 void PreferenceWriter::close() { 00049 writer->close(); 00050 }
Generated on Wed Jul 13 2022 04:37:22 by 1.7.2