Classes | |
struct | ReadyInterrupt |
The EEPROM Ready interrupt generates a constant interrupt when the write access time has elapsed. More... | |
Namespaces | |
namespace | Internal |
Only for library's internal use. | |
Enumerations | |
enum | Mode { EraseOnly = 0x10, WriteOnly = 0x20, EraseAndWrite = 0x10 | 0x20 } |
Functions | |
static bool | IsWritingFlash () |
static void | WaitWhileWritingFlash () |
static void | WriteOperation () |
bool | MoveNext () |
Increments current address unless it is pointing to the last byte in EEPROM memory. | |
void | Write (uint8_t data) |
Writes data to previously set address. It must not be interrupted by another request to read or write. | |
void | Write (uint16_t address, uint8_t data) |
Writes data to given address. It must not be interrupted by another request to read or write. | |
static bool | ErasingProcess (uint16_t lastByteAddr) |
static bool | EraseOperation (uint16_t numberOfBytes) |
bool | Erase (uint16_t numberOfBytes) |
Erase array of data from previously set address. After this operation, the address is set to the byte after last erased byte. | |
bool | IsWriting () |
Returns true if writing proccess is taking place. | |
void | WaitWhileWriting () |
Blocks while writing proccess is present. | |
void | SetAddressUnsafe (uint16_t address) |
Tries to set address even if previous writing operation has not finished. | |
void | SetAddress (uint16_t address) |
Waits for previous writing operation to finish, then sets address. | |
uint16_t | GetAddress () |
Returns current address. | |
uint8_t | Read () |
Read one byte from previously set (current) address. | |
uint8_t | Read (uint16_t address) |
Read one byte from given address. | |
void | SetMode (Mode mode) |
Sets EEPROM writing mode. | |
uint8_t | GetMode () |
Returns EEPROM writing mode. | |
template<typename T> | |
bool | Save (T data) |
Saves data to EEPROM to the current address. | |
template<typename T> | |
bool | Load (T &data) |
Reads data from EEPROM from the current address. | |
template<typename T> | |
bool | SaveArray (T *data, uint16_t elementsCount) |
Save array of data to previously set address. | |
template<typename T> | |
bool | LoadArray (T *data, uint16_t elementsCount) |
Load array of data from previously set address. |
enum AVRCpp::EEPROM::Mode |
Definition at line 160 of file EEPROM.h.
00161 { 00163 EraseOnly = _EEPM0, 00165 WriteOnly = _EEPM1, 00167 EraseAndWrite = _EEPM0 |_EEPM1 00168 00169 }; // enum Mode
bool AVRCpp::EEPROM::Erase | ( | uint16_t | numberOfBytes | ) |
Erase array of data from previously set address. After this operation, the address is set to the byte after last erased byte.
Definition at line 210 of file EEPROM.cpp.
00211 { 00212 uint8_t savedEECR = EECR; 00213 00214 SetMode(EraseOnly); 00215 00216 { 00217 bool result = EraseOperation(numberOfBytes); 00218 00219 ChangeBits<_EECR>(_EEPM1 | _EEPM0, savedEECR); 00220 00221 return result; 00222 } 00223 00224 } // Erase
static bool AVRCpp::EEPROM::EraseOperation | ( | uint16_t | numberOfBytes | ) | [inline, static] |
Definition at line 195 of file EEPROM.cpp.
00196 { 00197 // Is there anything to read or write ? 00198 if (numberOfBytes == 0) 00199 return true; 00200 00201 { 00202 uint16_t lastByteAddr = EEAR + numberOfBytes - 1; 00203 00204 return ErasingProcess(lastByteAddr); 00205 } 00206 00207 } // EraseOperation
static bool AVRCpp::EEPROM::ErasingProcess | ( | uint16_t | lastByteAddr | ) | [inline, static] |
Definition at line 163 of file EEPROM.cpp.
00164 { 00165 // Enough space ? 00166 if (lastByteAddr >= EEPROM_SIZE) 00167 return false; 00168 00169 // Erase byte by byte 00170 while (true) 00171 { 00172 00173 WaitWhileWriting(); 00174 00175 WaitWhileWritingFlash(); 00176 00177 WriteOperation(); 00178 00179 // Done ? 00180 if (EEAR == lastByteAddr) 00181 break; 00182 00183 WaitWhileWriting(); 00184 00185 EEAR++; 00186 } 00187 00188 MoveNext(); 00189 00190 return true; 00191 00192 } // ErasingProcess
uint16_t AVRCpp::EEPROM::GetAddress | ( | ) | [inline] |
uint8_t AVRCpp::EEPROM::GetMode | ( | ) | [inline] |
bool AVRCpp::EEPROM::IsWriting | ( | ) | [inline] |
static bool AVRCpp::EEPROM::IsWritingFlash | ( | ) | [inline, static] |
bool AVRCpp::EEPROM::Load | ( | T & | data | ) | [inline] |
bool AVRCpp::EEPROM::LoadArray | ( | T * | data, | |
uint16_t | elementsCount | |||
) | [inline] |
bool AVRCpp::EEPROM::MoveNext | ( | ) |
Increments current address unless it is pointing to the last byte in EEPROM memory.
Definition at line 58 of file EEPROM.cpp.
00059 { 00060 if (EEAR < EEPROM_SIZE - 1) 00061 { 00062 WaitWhileWriting(); 00063 EEAR++; 00064 00065 return true; 00066 } 00067 00068 return false; 00069 00070 } // MoveNext
Read one byte from given address.
Definition at line 148 of file EEPROM.h.
00149 { 00150 SetAddress(address); 00151 00152 SetBits<_EECR>(_EERE); 00153 00154 return EEDR; 00155 00156 } // Read 2
uint8_t AVRCpp::EEPROM::Read | ( | ) | [inline] |
Read one byte from previously set (current) address.
Definition at line 137 of file EEPROM.h.
00138 { 00139 WaitWhileWriting(); 00140 00141 SetBits<_EECR>(_EERE); 00142 00143 return EEDR; 00144 00145 } // Read 1
bool AVRCpp::EEPROM::Save | ( | T | data | ) | [inline] |
bool AVRCpp::EEPROM::SaveArray | ( | T * | data, | |
uint16_t | elementsCount | |||
) | [inline] |
void AVRCpp::EEPROM::SetAddress | ( | uint16_t | address | ) | [inline] |
Waits for previous writing operation to finish, then sets address.
Definition at line 126 of file EEPROM.h.
00126 { WaitWhileWriting(); SetAddressUnsafe(address); }
void AVRCpp::EEPROM::SetAddressUnsafe | ( | uint16_t | address | ) | [inline] |
void AVRCpp::EEPROM::SetMode | ( | Mode | mode | ) | [inline] |
void AVRCpp::EEPROM::WaitWhileWriting | ( | ) | [inline] |
static void AVRCpp::EEPROM::WaitWhileWritingFlash | ( | ) | [inline, static] |
Writes data to given address. It must not be interrupted by another request to read or write.
Definition at line 86 of file EEPROM.cpp.
00087 { 00088 WaitWhileWriting(); 00089 00090 WaitWhileWritingFlash(); 00091 00092 SetAddressUnsafe(address); 00093 00094 EEDR = data; 00095 00096 WriteOperation(); 00097 00098 } // Write 2
void AVRCpp::EEPROM::Write | ( | uint8_t | data | ) |
Writes data to previously set address. It must not be interrupted by another request to read or write.
Definition at line 73 of file EEPROM.cpp.
00074 { 00075 WaitWhileWriting(); 00076 00077 WaitWhileWritingFlash(); 00078 00079 EEDR = data; 00080 00081 WriteOperation(); 00082 00083 } // Write 1
static void AVRCpp::EEPROM::WriteOperation | ( | ) | [static] |
Definition at line 41 of file EEPROM.cpp.
00042 { 00043 // Save SREG_I bit. 00044 uint8_t savedSREG = SREG; 00045 00046 // __EEPE__ must be set immediately after setting __EEMPE__ 00047 GlobalInterrupts::Disable(); 00048 00049 SetBits<_EECR>(__EEMPE__); 00050 SetBits<_EECR>(__EEPE__); 00051 00052 // Restore the interrupt bit in Status Register 00053 SREG = savedSREG; 00054 00055 } // WriteOperation
MTÜ TTÜ Robotiklubi |