Hanna
Sourcecode Batteriemanagementsystem
Makrodefinitionen | Funktionen
eeprom_driver.h-Dateireferenz

XMEGA EEPROM driver header file. Mehr ...

#include "compiler.h"
Include-Abhängigkeitsdiagramm für eeprom_driver.h:
Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define EEPROM(_pageAddr, _byteAddr)   ((uint8_t *) MAPPED_EEPROM_START)[_pageAddr*EEPROM_PAGESIZE + _byteAddr]
 
#define EEPROM_DisableMapping()   ( NVM.CTRLB &= ~NVM_EEMAPEN_bm )
 Disable EEPROM mapping into data space. Mehr ...
 
#define EEPROM_DisablePowerReduction()   ( NVM.CTRLB &= ~NVM_EPRM_bm )
 Disable EEPROM block sleep-when-not-used mode. Mehr ...
 
#define EEPROM_EnableMapping()   ( NVM.CTRLB |= NVM_EEMAPEN_bm )
 Enable EEPROM mapping into data space. Mehr ...
 
#define EEPROM_EnablePowerReduction()   ( NVM.CTRLB |= NVM_EPRM_bm )
 Enable EEPROM block sleep-when-not-used mode. Mehr ...
 
#define EEPROM_PAGESIZE   32
 
#define NVM_EXEC()
 Non-Volatile Memory Execute Command. Mehr ...
 

Funktionen

void EEPROM_AtomicWritePage (uint8_t pageAddr)
 Write already loaded page into EEPROM. Mehr ...
 
void eeprom_demo (void)
 
void EEPROM_EraseAll (void)
 Erase entire EEPROM memory. Mehr ...
 
void EEPROM_ErasePage (uint8_t pageAddress)
 Erase EEPROM page. Mehr ...
 
void EEPROM_FlushBuffer (void)
 Flush temporary EEPROM page buffer. Mehr ...
 
void EEPROM_LoadByte (uint8_t byteAddr, uint8_t value)
 Load single byte into temporary page buffer. Mehr ...
 
void EEPROM_LoadPage (const uint8_t *values)
 Load entire page into temporary EEPROM page buffer. Mehr ...
 
uint8_t EEPROM_ReadByte (uint8_t pageAddr, uint8_t byteAddr)
 Read one byte from EEPROM using IO mapping. Mehr ...
 
uint32_t EEPROM_ReadBytes (uint8_t pageAddr, uint8_t byteAddr, uint8_t len)
 
void EEPROM_SplitWritePage (uint8_t pageAddr)
 Write (without erasing) EEPROM page. Mehr ...
 
void EEPROM_WaitForNVM (void)
 Wait for any NVM access to finish, including EEPROM. Mehr ...
 
void EEPROM_WriteByte (uint8_t pageAddr, uint8_t byteAddr, uint8_t value)
 Write one byte to EEPROM using IO mapping. Mehr ...
 
void EEPROM_WriteBytes (uint8_t pageAddr, uint8_t byteAddr, uint8_t len, uint32_t value)
 

Ausführliche Beschreibung

XMEGA EEPROM driver header file.

This file contains the function prototypes and enumerator definitions for various configuration parameters for the XMEGA EEPROM driver.

The driver is not intended for size and/or speed critical code, since most functions are just a few lines of code, and the function call overhead would decrease code performance. The driver is intended for rapid prototyping and documentation purposes for getting started with the XMEGA EEPROM module.

For size and/or speed critical code, it is recommended to copy the function contents directly into your application instead of making a function call.

Application note:
AVR1315: Accessing the XMEGA EEPROM
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Autor
Atmel Corporation: http://www.atmel.com
Support email: avr@a.nosp@m.tmel.nosp@m..com
Revision
351
Date
2016-03-19 23:27:55 +0100 (Sa, 19 Mrz 2016)


Copyright (c) 2008, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definiert in Datei eeprom_driver.h.

Makro-Dokumentation

#define EEPROM_DisableMapping ( )    ( NVM.CTRLB &= ~NVM_EEMAPEN_bm )

Disable EEPROM mapping into data space.

This macro disables mapping of EEPROM into data space. IO mapped access is now enabled.

Definiert in Zeile 102 der Datei eeprom_driver.h.

#define EEPROM_DisablePowerReduction ( )    ( NVM.CTRLB &= ~NVM_EPRM_bm )

Disable EEPROM block sleep-when-not-used mode.

This macro disables power reduction mode for EEPROM.

Definiert in Zeile 84 der Datei eeprom_driver.h.

#define EEPROM_EnableMapping ( )    ( NVM.CTRLB |= NVM_EEMAPEN_bm )

Enable EEPROM mapping into data space.

This macro enables mapping of EEPROM into data space. EEPROM starts at EEPROM_START in data memory. Read access can be done similar to ordinary SRAM access.

Zu beachten
This disables IO-mapped access to EEPROM, although page erase and write operations still needs to be done through IO register.

Definiert in Zeile 95 der Datei eeprom_driver.h.

#define EEPROM_EnablePowerReduction ( )    ( NVM.CTRLB |= NVM_EPRM_bm )

Enable EEPROM block sleep-when-not-used mode.

This macro enables power reduction mode for EEPROM. It means that the EEPROM block is disabled when not used. Note that there will be a penalty of 6 CPU cycles if EEPROM is accessed.

Definiert in Zeile 78 der Datei eeprom_driver.h.

#define NVM_EXEC ( )
Wert:
asm("push r30" "\n\t" \
"push r31" "\n\t" \
"push r16" "\n\t" \
"push r18" "\n\t" \
"ldi r30, 0xCB" "\n\t" \
"ldi r31, 0x01" "\n\t" \
"ldi r16, 0xD8" "\n\t" \
"ldi r18, 0x01" "\n\t" \
"out 0x34, r16" "\n\t" \
"st Z, r18" "\n\t" \
"pop r18" "\n\t" \
"pop r16" "\n\t" \
"pop r31" "\n\t" \
"pop r30" "\n\t" \
)

Non-Volatile Memory Execute Command.

This macro set the CCP register before setting the CMDEX bit in the NVM.CTRLA register.

Zu beachten
The CMDEX bit must be set within 4 clock cycles after setting the protection byte in the CCP register.

Definiert in Zeile 112 der Datei eeprom_driver.h.

Dokumentation der Funktionen

void EEPROM_AtomicWritePage ( uint8_t  pageAddr)

Write already loaded page into EEPROM.

This function writes the contents of an already loaded EEPROM page buffer into EEPROM memory.

As this is an atomic write, the page in EEPROM will be erased automatically before writing. Note that only the page buffer locations that have been loaded will be used when writing to EEPROM. Page buffer locations that have not been loaded will be left untouched in EEPROM.

Parameter
pageAddrEEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGESIZE

Definiert in Zeile 263 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

void EEPROM_EraseAll ( void  )

Erase entire EEPROM memory.

This function erases the entire EEPROM memory block to 0xFF.

Definiert in Zeile 337 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

void EEPROM_ErasePage ( uint8_t  pageAddr)

Erase EEPROM page.

This function erases one EEPROM page, so that every location reads 0xFF.

Parameter
pageAddrEEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGESIZE

Definiert in Zeile 287 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

void EEPROM_FlushBuffer ( void  )

Flush temporary EEPROM page buffer.

This function flushes the EEPROM page buffers. This function will cancel any ongoing EEPROM page buffer loading operations, if any. This function also works for memory mapped EEPROM access.

Zu beachten
The EEPROM write operations will automatically flush the buffer for you.

Definiert in Zeile 173 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

void EEPROM_LoadByte ( uint8_t  byteAddr,
uint8_t  value 
)

Load single byte into temporary page buffer.

This function loads one byte into the temporary EEPROM page buffers. If memory mapped EEPROM is enabled, this function will not work. Make sure that the buffer is flushed before starting to load bytes. Also, if multiple bytes are loaded into the same location, they will be ANDed together, thus 0x55 and 0xAA will result in 0x00 in the buffer.

Zu beachten
Only one page buffer exist, thus only one page can be loaded with data and programmed into one page. If data needs to be written to different pages, the loading and writing needs to be repeated.
Parameter
byteAddrEEPROM Byte address, between 0 and EEPROM_PAGESIZE.
valueByte value to write to buffer.

Definiert in Zeile 201 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

void EEPROM_LoadPage ( const uint8_t *  values)

Load entire page into temporary EEPROM page buffer.

This function loads an entire EEPROM page from an SRAM buffer to the EEPROM page buffers. If memory mapped EEPROM is enabled, this function will not work. Make sure that the buffer is flushed before starting to load bytes.

Zu beachten
Only the lower part of the address is used to address the buffer. Therefore, no address parameter is needed. In the end, the data is written to the EEPROM page given by the address parameter to the EEPROM write page operation.
Parameter
valuesPointer to SRAM buffer containing an entire page.

Definiert in Zeile 230 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

uint8_t EEPROM_ReadByte ( uint8_t  pageAddr,
uint8_t  byteAddr 
)

Read one byte from EEPROM using IO mapping.

This function reads one byte from EEPROM using IO-mapped access. If memory mapped EEPROM is enabled, this function will not work.

Parameter
pageAddrEEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGESIZE
byteAddrEEPROM Byte address, between 0 and EEPROM_PAGESIZE.
Rückgabe
Byte value read from EEPROM.

Definiert in Zeile 119 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

void EEPROM_SplitWritePage ( uint8_t  pageAddr)

Write (without erasing) EEPROM page.

This function writes the contents of an already loaded EEPROM page buffer into EEPROM memory.

As this is a split write, the page in EEPROM will not be erased before writing.

Parameter
pageAddrEEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGESIZE

Definiert in Zeile 315 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

void EEPROM_WaitForNVM ( void  )

Wait for any NVM access to finish, including EEPROM.

This function is blcoking and waits for any NVM access to finish, including EEPROM. Use this function before any EEPROM accesses, if you are not certain that any previous operations are finished yet, like an EEPROM write.

Definiert in Zeile 156 der Datei eeprom_driver.c.

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

void EEPROM_WriteByte ( uint8_t  pageAddr,
uint8_t  byteAddr,
uint8_t  value 
)

Write one byte to EEPROM using IO mapping.

This function writes one byte to EEPROM using IO-mapped access. If memory mapped EEPROM is enabled, this function will not work. This functiom will cancel all ongoing EEPROM page buffer loading operations, if any.

Parameter
pageAddrEEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGESIZE
byteAddrEEPROM Byte address, between 0 and EEPROM_PAGESIZE.
valueByte value to write to EEPROM.

Definiert in Zeile 72 der Datei eeprom_driver.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird: