PIC18 LaurTec Library  3.2.0
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
PCF8574.c File Reference
#include "PCF8574.h"

Go to the source code of this file.

Functions

void initialize_PCF8574 (unsigned char crystal_frequency_MHz, unsigned int baud_rate_KHz)
 
signed char write_data_PCF8574 (unsigned char control, unsigned char data)
 
signed char read_data_PCF8574 (unsigned char control, unsigned char *data)
 

Function Documentation

void initialize_PCF8574 ( unsigned char  crystal_frequency_MHz,
unsigned int  baud_rate_KHz 
)

This function initialize the I2C module accordingly to the clock and baud rate.

Parameters
crystal_frequency_MHzClock frequency expressed in MHz
baud_rate_KHzBaud rate expressed in KHz
Returns
Note
If other devices are connected on the I2C bus the baud rate would be changed by the function. Among several calls from different device initializations, only the last one will be reflected in the I2C module configuration.

Definition at line 53 of file PCF8574.c.

signed char read_data_PCF8574 ( unsigned char  control,
unsigned char *  data 
)

This function reads to the data Port of the I2C I/O expander.

Parameters
controlIs the address of the PCF8574 (Internal Address + Pin address
dataAddress where the data is written into.
Returns
status 1: The byte has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
Note
PCF8574 Address : 0100xxx0 PCF8574A Address : 0111xxx0

xxx = A2 A1 A0 (External Address Pins)

Definition at line 151 of file PCF8574.c.

signed char write_data_PCF8574 ( unsigned char  control,
unsigned char  data 
)

This function writes to the data Port of the I2C I/O expander.

Parameters
controlIs the address of the PCF8574 (Internal Address + Pin address)
dataByte to write [min: 0, max: 255]
Returns
status 1: The byte has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
Note
PCF8574 Address : 0100xxx0 PCF8574A Address : 0111xxx0

xxx = A2 A1 A0 (External Address Pins)

Definition at line 65 of file PCF8574.c.