logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

avr_eeprom - <avr/eeprom.h>: EEPROM handling

Author

       Generated automatically by Doxygen for AVR-LibC from the source code.

AVR-LibC                                          Version 2.2.1                                 avr_eeprom(3avr)

Detailed Description

       #include <avr/eeprom.h>

       This header file declares the interface to some simple library routines suitable for handling the data
       EEPROM contained in the AVR microcontrollers. The implementation uses a simple polled mode interface.
       Applications that require interrupt-controlled EEPROM access to ensure that no time will be wasted in
       spinloops will have to deploy their own implementation.

       Notes:

       • In  addition  to the write functions there is a set of update ones. This functions read each byte first
         and skip the burning if the old value is the same with new. The scaning direction is from high  address
         to low, to obtain quick return in common cases.

       • All  of  the  read/write  functions  first make sure the EEPROM is ready to be accessed. Since this may
         cause long delays if a write operation is still pending, time-critical applications should  first  poll
         the  EEPROM e. g. using eeprom_is_ready() before attempting any actual I/O. But this functions does not
         wait until SELFPRGEN in SPMCSR becomes zero. Do this manually, if  your  softwate  contains  the  Flash
         burning.

       • As  these  functions modify IO registers, they are known to be non-reentrant. If any of these functions
         are used from both, standard and interrupt context, the  applications  must  ensure  proper  protection
         (e.g. by disabling interrupts before accessing them).

       • All write functions force erase_and_write programming mode.

       • For Xmega the EEPROM start address is 0, like other architectures. The reading functions add the 0x2000
         value to use EEPROM mapping into data space.

Function Documentation

voideeprom_read_block(void*__dst,constvoid*__src,size_t__n)
       Read a block of __n bytes from EEPROM address __src to SRAM __dst.

   uint8_teeprom_read_byte(constuint8_t*__p)
       Read one byte from EEPROM address __p.

   doubleeeprom_read_double(constdouble*__p)
       Read one double value (little endian) from EEPROM address __p.

   uint32_teeprom_read_dword(constuint32_t*__p)
       Read one 32-bit double word (little endian) from EEPROM address __p.

   floateeprom_read_float(constfloat*__p)
       Read one float value (little endian) from EEPROM address __p.

   longdoubleeeprom_read_long_double(constlongdouble*__p)
       Read one long double value (little endian) from EEPROM address __p.

   uint64_teeprom_read_qword(constuint64_t*__p)
       Read one 64-bit quad word (little endian) from EEPROM address __p.

   uint16_teeprom_read_word(constuint16_t*__p)
       Read one 16-bit word (little endian) from EEPROM address __p.

   voideeprom_update_block(constvoid*__src,void*__dst,size_t__n)
       Update a block of __n bytes at EEPROM address __dst from __src.

       Note
           The argument order is mismatch with common functions like strcpy().

   voideeprom_update_byte(uint8_t*__p,uint8_t__value)
       Update a byte __value at EEPROM address __p.

   voideeprom_update_double(double*__p,double__value)
       Update a double __value at EEPROM address __p.

   voideeprom_update_dword(uint32_t*__p,uint32_t__value)
       Update a 32-bit double word __value at EEPROM address __p.

   voideeprom_update_float(float*__p,float__value)
       Update a float __value at EEPROM address __p.

   voideeprom_update_long_double(longdouble*__p,longdouble__value)
       Update a long double __value at EEPROM address __p.

   voideeprom_update_qword(uint64_t*__p,uint64_t__value)
       Update a 64-bit quad word __value at EEPROM address __p.

   voideeprom_update_word(uint16_t*__p,uint16_t__value)
       Update a word __value at EEPROM address __p.

   voideeprom_write_block(constvoid*__src,void*__dst,size_t__n)
       Write a block of __n bytes to EEPROM address __dst from __src.

       Note
           The argument order is mismatch with common functions like strcpy().

   voideeprom_write_byte(uint8_t*__p,uint8_t__value)
       Write a byte __value to EEPROM address __p.

   voideeprom_write_double(double*__p,double__value)
       Write a double __value to EEPROM address __p.

   voideeprom_write_dword(uint32_t*__p,uint32_t__value)
       Write a 32-bit double word __value to EEPROM address __p.

   voideeprom_write_float(float*__p,float__value)
       Write a float __value to EEPROM address __p.

   voideeprom_write_long_double(longdouble*__p,longdouble__value)
       Write a long double __value to EEPROM address __p.

   voideeprom_write_qword(uint64_t*__p,uint64_t__value)
       Write a 64-bit quad word __value to EEPROM address __p.

   voideeprom_write_word(uint16_t*__p,uint16_t__value)
       Write a word __value to EEPROM address __p.

Macro Definition Documentation

#define__EEGET(var,addr)(var)=eeprom_read_byte((constuint8_t*)(addr))
       Read a byte from EEPROM. Compatibility define for IAR C.

   #define__EEPUT(addr,val)eeprom_write_byte((uint8_t*)(addr),(uint8_t)(val))
       Write a byte to EEPROM. Compatibility define for IAR C.

   #define_EEGET(var,addr)(var)=eeprom_read_byte((constuint8_t*)(addr))
       Read a byte from EEPROM. Compatibility define for IAR C.

   #define_EEPUT(addr,val)eeprom_write_byte((uint8_t*)(addr),(uint8_t)(val))
       Write a byte to EEPROM. Compatibility define for IAR C.

   #defineEEMEM__attribute__((__section__('.eeprom')))
       Attribute expression causing a variable to be allocated within the .eeprom section.

   #defineeeprom_busy_wait()do{}while(!eeprom_is_ready())
       Loops until the eeprom is no longer busy.

       Returns
           Nothing.

   #defineeeprom_is_ready()Returns
           1 if EEPROM is ready for a new read/write operation, 0 if not.

Name

       avr_eeprom - <avr/eeprom.h>: EEPROM handling

Synopsis

Macros
       #define EEMEM   __attribute__((__section__('.eeprom')))
       #define eeprom_is_ready()
       #define eeprom_busy_wait()   do {} while (!eeprom_is_ready())

   Functionsuint8_teeprom_read_byte (const uint8_t *__p)
       uint16_teeprom_read_word (const uint16_t *__p)
       uint32_teeprom_read_dword (const uint32_t *__p)
       uint64_teeprom_read_qword (const uint64_t *__p)
       float eeprom_read_float (const float *__p)
       double eeprom_read_double (const double *__p)
       long double eeprom_read_long_double (const long double *__p)
       void eeprom_read_block (void *__dst, const void *__src, size_t __n)
       void eeprom_write_byte (uint8_t *__p, uint8_t __value)
       void eeprom_write_word (uint16_t *__p, uint16_t __value)
       void eeprom_write_dword (uint32_t *__p, uint32_t __value)
       void eeprom_write_qword (uint64_t *__p, uint64_t __value)
       void eeprom_write_float (float *__p, float __value)
       void eeprom_write_double (double *__p, double __value)
       void eeprom_write_long_double (long double *__p, long double __value)
       void eeprom_write_block (const void *__src, void *__dst, size_t __n)
       void eeprom_update_byte (uint8_t *__p, uint8_t __value)
       void eeprom_update_word (uint16_t *__p, uint16_t __value)
       void eeprom_update_dword (uint32_t *__p, uint32_t __value)
       void eeprom_update_qword (uint64_t *__p, uint64_t __value)
       void eeprom_update_float (float *__p, float __value)
       void eeprom_update_double (double *__p, double __value)
       void eeprom_update_long_double (long double *__p, long double __value)
       void eeprom_update_block (const void *__src, void *__dst, size_t __n)

   IARCcompatibilitydefines
       #define _EEPUT(addr,  val)   eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(val))
       #define __EEPUT(addr,  val)   eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(val))
       #define _EEGET(var,  addr)   (var) = eeprom_read_byte ((const uint8_t *)(addr))
       #define __EEGET(var,  addr)   (var) = eeprom_read_byte ((const uint8_t *)(addr))

See Also