Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PreferenceWriter.cpp
00001 #include "PreferenceWriter.h" 00002 #include "FlashWriter.h" 00003 00004 #include "globals.h" 00005 00006 float __float_reg[64]; 00007 int __int_reg[64]; 00008 00009 PreferenceWriter::PreferenceWriter(uint32_t sector) { 00010 writer = new FlashWriter(sector); 00011 __sector = sector; 00012 __ready = false; 00013 } 00014 00015 void PreferenceWriter::open() { 00016 writer->open(); 00017 __ready = true; 00018 } 00019 00020 bool PreferenceWriter::ready() { 00021 return __ready; 00022 } 00023 00024 void PreferenceWriter::write(int x, int index) { 00025 __int_reg[index] = x; 00026 } 00027 00028 void PreferenceWriter::write(float x, int index) { 00029 __float_reg[index] = x; 00030 } 00031 00032 void PreferenceWriter::flush() { 00033 int offs; 00034 for (offs = 0; offs < 64; offs++) { 00035 writer->write(offs, __int_reg[offs]); 00036 } 00037 for (; offs < 128; offs++) { 00038 writer->write(offs, __float_reg[offs - 64]); 00039 } 00040 __ready = false; 00041 } 00042 00043 void PreferenceWriter::load() { 00044 int offs; 00045 for (offs = 0; offs < 64; offs++) { 00046 __int_reg[offs] = flashReadInt(__sector, offs); 00047 } 00048 for(; offs < 128; offs++) { 00049 __float_reg[offs - 64] = flashReadFloat(__sector, offs); 00050 } 00051 } 00052 00053 void PreferenceWriter::close() { 00054 __ready = false; 00055 writer->close(); 00056 }
Generated on Tue Jul 12 2022 21:21:55 by
