I2CEEprom (OP-LIB-010)

From openPicus Wiki
Jump to: navigation, search

Contents

Description

This library allows you to use an I2C EEPROM connected to FlyPort.

Content

  • i2ceeprom.h
  • i2ceeprom.c

Download

OP-LIB-010

Connections

See the datasheet of the EEPROM.

Importing into OpenPicus IDE

Import ALL the files of the library using the button “external lib” of the IDE, then Include i2ceeprom.h in the files in which you want to use the functions (using the directive #include “i2ceeprom.h”). How To import external Lib Tutorial

Commands


EEPROMInit

This function initializes the EEPROM on the I2C bus.

void EEPROMInit(BYTE ControlByte, BYTE Speed)
Argument Description
BYTE ControlByte Control Byte of the specific I2C EEPROM
BYTE Speed use only the following parameters to set the bus speed
  • HIGH_SPEED to set @400kHz
  • LOW_SPEED to set @100kHz


EEPROMWriteByte

This function writes a char in a specific memory address.

void EEPROMWriteByte(WORD Address, BYTE DataByte)
Argument Description
WORD Address memory address to write, made by the union of the two bytes: address high byte and address low byte
BYTE DataByte the data that you want to write into the EEPROM


EEPROMWriteAT

This function writes any type of data (byte, word, dword).

void EEPROMWriteAT(WORD Address, DWORD Data, BYTE Type)
Argument Description
WORD Address memory address to write, made by the union of the two bytes: address high byte and address low byte.
DWORD Data the data that you want to write into the EEPROM.
BYTE Type only the following parameters to set the type of data entered or the type of data to be stored:
  • UCHAR → BYTE
  • UINT → WORD
  • UFLOAT → DWORD


EEPROMWritePage

This function writes more bytes with a single instruction.

void EEPROMWritePage(WORD Address, BYTE DataPage[ ], int NByte)
Argument Description
WORD Address memory address to write, made by the union of the two bytes: address high byte and address low byte. Function automatically increase the entered value.
BYTE DataPage[ ] array of byte data.
int NByte number of array elements to be written.


EEPROMWriteString

This function writes a typical ASCII string (NOT UNICODE).

void EEPROMWriteString(WORD Address, char DataPage[ ])
Argument Description
WORD Address memory address to write, made by the union of the two bytes: address high byte and address low byte.
char DataPage[ ] ASCII string to write.


EEPROMReadByte

This function reads a byte in a specific memory address. Returns: BYTE value read by the function.

BYTE EEPROMReadByte(WORD Address)
Argument Description
WORD Address memory address in which to read, made by the union of the two bytes: address high byte and address low byte.


EEPROMReadBlock

This function reads multiple bytes with a single instruction (sequential read).

void EEPROMReadBlock(WORD Address, BYTE DataRead[ ], int NByte)
Argument Description
WORD Address memory address in which to read, made by the union of the two bytes: address high byte and address low byte.
BYTE DataRead[ ] Array to store read data
int NByte number of bytes to read.


EEPROMEraseAll

This function erases (writing 0xFF) all data in the EEPROM.

void EEPROMEraseAll( )


Related Resources

Credits

Personal tools
Namespaces

Variants
Actions
START HERE
DEVELOPMENT
HARDWARE INFO
RESOURCES
PHASED OUT
Toolbox