Defines | Functions

lib/eeprom/lib_eeprom.c File Reference

#include "hal_flash.h"
#include "lib_eeprom.h"

Go to the source code of this file.

Defines

#define EEPROM_SIZE   16
#define EEPROM_PAGES   (HAL_FLASH_PAGE_SIZE/EEPROM_SIZE)

Functions

uint8_t xdata * get_eeprom_address (uint8_t a)
void lib_eeprom_byte_write (uint8_t adr, uint8_t dat)
void lib_eeprom_bytes_write (uint8_t adr, uint8_t *p, uint8_t n)
uint8_t lib_eeprom_byte_read (uint8_t adr)
void lib_eeprom_bytes_read (uint8_t adr, uint8_t *p, uint8_t n)

Detailed Description

Author:
Ole Saether

Definition in file lib_eeprom.c.


Define Documentation

#define EEPROM_SIZE   16

Definition at line 21 of file lib_eeprom.c.

#define EEPROM_PAGES   (HAL_FLASH_PAGE_SIZE/EEPROM_SIZE)

Definition at line 23 of file lib_eeprom.c.


Function Documentation

uint8_t xdata* get_eeprom_address ( uint8_t  a )

Definition at line 28 of file lib_eeprom.c.

{
    uint8_t i;
    uint8_t xdata *p;

    fa = (uint8_t xdata *)HAL_DATA_NV_BASE_ADDRESS;
    p = (uint8_t xdata *)(HAL_DATA_NV_BASE_ADDRESS + EEPROM_SIZE + a);
    for(i=0;i<EEPROM_PAGES;)
    {
        if (*fa == 0xff)
            break;
        i++;
        p = (uint8_t xdata *)(p + EEPROM_SIZE);
        if (*fa == 0xf0)
            break;
        i++;
        p = (uint8_t xdata *)(p + EEPROM_SIZE);
        fa++;
    }
    return p;
}