Getting Started

(lily) #1

Chapter 8: C Pointers and Arrays


************************************
Function name : ReadEEPROM
r to string, number of bytes to read,
address in EEPROM
EEPROM
**************************/
uffer, char num_bytes, unsigned int EE_START_ADR)

eters

his function is to read data from the EEPROM. The parameter list
cludes a pointer to a string, ‘char *pBuffer’, the number of bytes to read, ‘char
address for the EEPROM, ‘EE_START_ADR’

ough space for the requested number of
OM with a pointer to the string, along with the
rting address of the EEPROM. The LoadEEPROM
for each pass the function eeprom_read_byte_169 is
e starting address of the EEPROM as a parameter, this
turns it so it can be put in the pBuffer array.

s:

ROM
ndexps, EEPROM_START + 1);

om vc

00

];

/






********************************



  • Returns : None




  • Parameters : Pointe




  • Purpose : Write byte(s) to the




    void LoadEEPROM(char *pB
    {
    unsigned char i;
    for (i=0;i<num_bytes;i++) {




pBuffer[i]=eeprom_read_byte_169(&EE_START_ADR); // Load param
EE_START_ADR++;
}
}


The purpose of t
in
num_bytes, and the starting


The caller sets up a string buffer with en
bytes and calls LoadEEPR
requested length and the sta
function runs a loop and
called with the address of th
function gets the byte and re


This function is used in vcard.c as follow


// Load name from EEP
LoadEEPROM(Name, i


using these declarations:


fr ard.h
#define STRLENGHT 25
#define EEPROM_START 0x1


at head of vcard.c:
uint8_t inde
har N


xps = 0;
c ame[STRLENGHT

Free download pdf