include file to be used in conjuction of the at24c32 library
More...
#include <stdio.h>
#include <sys/ioctl.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <linux/fs.h>
#include <fcntl.h>
#include <errno.h>
#include <smbus_access.h>
#include <stdbool.h>
Go to the source code of this file.
|
|
#define | I2C_DRIVER "/dev/i2c-1" |
| |
|
#define | AT24C32 0x50 |
| |
|
#define | AT24C32_SUCCESS 0 |
| |
|
#define | AT24C32_SIZE 4096 |
| |
include file to be used in conjuction of the at24c32 library
Copyright U. Raich Dec. 2016
This program is part of a course on embedded systems held at the University of Cape Coast, Ghana in 2017
It is released under the GNU Public License For details please see https://www.gnu.org/licenses/gpl.html
| unsigned char* at24c32BlockRead |
( |
int |
fd, |
|
|
unsigned short |
address, |
|
|
unsigned short |
length |
|
) |
| |
reads a block of data from the EEPROM
- Parameters
-
| int | fd: the file descriptor returned by a24c32Open |
| unsigned | short address: the memory address to read from |
| unsigned | short length: the number of bytes to be read |
- Returns
- the data are put into a unsigned char array
| int at24c32BlockWrite |
( |
int |
fd, |
|
|
unsigned short |
address, |
|
|
unsigned short |
length, |
|
|
unsigned char * |
data |
|
) |
| |
writes a block of data to the EEPROM
- Parameters
-
| int | fd: the file descriptor returned by a24c32Open |
| unsigned | short address: the memory address to write to |
| unsigned | short length: the length of the data array |
| unsigned | char *data: a pointer to the data that must be written |
- Returns
- 0 if successful
a negative error code otherwise
| unsigned char at24c32ByteRead |
( |
int |
fd, |
|
|
unsigned short |
address |
|
) |
| |
reads a byte from the EEPROM
- Parameters
-
| int | fd: the file descriptor returned by a24c32Open |
| unsigned | short address: the memory address to read from |
- Returns
- the data byte read
| int at24c32ByteWrite |
( |
int |
fd, |
|
|
unsigned short |
address, |
|
|
unsigned char |
data |
|
) |
| |
writes a byte to the EEPROM
- Parameters
-
| int | fd: the file descriptor returned by a24c32Open |
| unsigned | short address: the memory address to write to |
| unsigned | char data: the data word to be written |
- Returns
- 0 if successful
a negative error code otherwise
| int at24c32Close |
( |
int |
fd | ) |
|
closes the i2c driver
- Parameters
-
| the | file descriptor to be close |
- Returns
- 0 if successful a negative error code otherwise
opens the i2c driver
- Returns
- a file descriptor to be used as input parameter for all subsequent calls
| void at24c32SetDebug |
( |
bool |
onOff | ) |
|
switches debug mode on or off
- Parameters
-
| onOff | true: switches debug mode on
false: switches debug mode off |