LTlib LaurTec Library  4.0.0 Beta
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 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 PCF8574_initialize (unsigned int baud_rate_KHz)
 
signed char PCF8574_write_data (unsigned char device_address, unsigned char data)
 
signed char PCF8574_read_data (unsigned char device_address, unsigned char *data)
 

Function Documentation

void PCF8574_initialize ( unsigned int  baud_rate_KHz)

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

Parameters
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 46 of file PCF8574.c.

References I2C_MASTER, PCF8574_I2C_baud_rate, and PCF8574_I2C_open.

signed char PCF8574_read_data ( unsigned char  device_address,
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 0: The byte has been properly written -1: Communication Error
Note
PCF8574 Address : 0100xxx0 PCF8574A Address : 0111xxx0

xxx = A2 A1 A0 (External Address Pins)

Definition at line 119 of file PCF8574.c.

References PCF8574_I2C_check_ACK, PCF8574_I2C_check_bus_collision, PCF8574_I2C_negative_ACK, PCF8574_I2C_read_byte, PCF8574_I2C_set_master_as_receiver, PCF8574_I2C_start_bit, PCF8574_I2C_stop_bit, PCF8574_I2C_wait_bus_IDLE, PCF8574_I2C_write_byte, and PCF8574_INTERNAL_ADDRESS.

signed char PCF8574_write_data ( unsigned char  device_address,
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 0: The byte has been properly written -1: Communication Error
Note
PCF8574 Address : 0100xxx0 PCF8574A Address : 0111xxx0

xxx = A2 A1 A0 (External Address Pins)

Definition at line 57 of file PCF8574.c.

References PCF8574_I2C_check_ACK, PCF8574_I2C_check_bus_collision, PCF8574_I2C_start_bit, PCF8574_I2C_stop_bit, PCF8574_I2C_wait_bus_IDLE, PCF8574_I2C_write_byte, and PCF8574_INTERNAL_ADDRESS.