AVRCpp::EEPROM Namespace Reference

Functionality of EEPROM memory. More...


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.

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.
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.
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.


Detailed Description

Functionality of EEPROM memory.

Function Documentation

uint16_t AVRCpp::EEPROM::GetAddress (  )  [inline]

Returns current address.

Definition at line 128 of file EEPROM.h.

00128 {       return EEAR; }

bool AVRCpp::EEPROM::IsWriting (  )  [inline]

Returns true if writing proccess is taking place.

Definition at line 120 of file EEPROM.h.

00120 {       return IsBitsSet<_EECR>(__EEPE__); }

static bool AVRCpp::EEPROM::IsWritingFlash (  )  [inline, static]

Definition at line 38 of file EEPROM.cpp.

00038 {       return IsBitsSet<__SPMCSR__>(__SPMEN__); }

template<typename T>
bool AVRCpp::EEPROM::Load ( T &  data  )  [inline]

Reads data from EEPROM from the current address.

Data can be from any type specified with template parameter 'T'.

Returns:
true on success.

Definition at line 218 of file EEPROM.h.

00218 { return Internal::LoadSaveOperation<T>(false, &data, 1); }

template<typename T>
bool AVRCpp::EEPROM::LoadArray ( T *  data,
uint16_t  elementsCount 
) [inline]

Load array of data from previously set address.

After this operation, the address points to the first byte after the written array.

Returns:
true on success.

Definition at line 230 of file EEPROM.h.

00230 { return Internal::LoadSaveOperation<T>(false, data, elementsCount); }

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

uint8_t AVRCpp::EEPROM::Read ( uint16_t  address  )  [inline]

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

template<typename T>
bool AVRCpp::EEPROM::Save ( data  )  [inline]

Saves data to EEPROM to the current address.

Data can be from any type specified with template parameter 'T'.

Returns:
true on success.

Definition at line 212 of file EEPROM.h.

00212 { return Internal::LoadSaveOperation<T>(true, &data, 1); }

template<typename T>
bool AVRCpp::EEPROM::SaveArray ( T *  data,
uint16_t  elementsCount 
) [inline]

Save array of data to previously set address.

After this operation, the address points to the first byte after the written array.

Returns:
true on success.

Definition at line 224 of file EEPROM.h.

00224 { return Internal::LoadSaveOperation<T>(true, data, elementsCount); }

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]

Tries to set address even if previous writing operation has not finished.

Definition at line 124 of file EEPROM.h.

00124 { EEAR = address; }

void AVRCpp::EEPROM::WaitWhileWriting (  )  [inline]

Blocks while writing proccess is present.

Definition at line 122 of file EEPROM.h.

00122 { while (IsWriting() ); }

static void AVRCpp::EEPROM::WaitWhileWritingFlash (  )  [inline, static]

Definition at line 39 of file EEPROM.cpp.

00039 { while (IsWritingFlash() ); }

void AVRCpp::EEPROM::Write ( uint16_t  address,
uint8_t  data 
)

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


Generated on Sat Sep 15 23:41:31 2007 for AVR C++ Lib for ATmega8 by  doxygen 1.5.2
SourceForge.net Logo MTÜ TTÜ Robotiklubi