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.h File Reference
#include "LTlib.h"

Go to the source code of this file.

Macros

#define PCF8574_I2C_MODULE_1
 
#define PCF8574_I2C_open   I2C1_open
 
#define PCF8574_I2C_baud_rate   I2C1_baud_rate
 
#define PCF8574_I2C_wait_bus_IDLE   I2C1_wait_bus_IDLE
 
#define PCF8574_I2C_start_bit   I2C1_start_bit
 
#define PCF8574_I2C_check_bus_collision   I2C1_check_bus_collision
 
#define PCF8574_I2C_write_byte   I2C1_write_byte
 
#define PCF8574_I2C_stop_bit   I2C1_stop_bit
 
#define PCF8574_I2C_check_ACK   I2C1_check_ACK
 
#define PCF8574_I2C_negative_ACK   I2C1_negative_ACK
 
#define PCF8574_I2C_read_byte   I2C1_read_byte
 
#define PCF8574_I2C_set_master_as_receiver   I2C1_set_master_as_receiver
 
#define USED_DEVICE_PCF8574   0x40
 
#define USED_DEVICE_PCF8574A   0x70
 
#define PCF8574_INTERNAL_ADDRESS   USED_DEVICE_PCF8574A
 
#define initialize_PCF8574   PCF8574_initialize
 
#define write_data_PCF8574   PCF8574_write_data
 
#define read_data_PCF8574   PCF8574_read_data
 

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)
 

Macro Definition Documentation

#define initialize_PCF8574   PCF8574_initialize

Definition at line 128 of file PCF8574.h.

#define PCF8574_I2C_baud_rate   I2C1_baud_rate

Definition at line 77 of file PCF8574.h.

#define PCF8574_I2C_check_ACK   I2C1_check_ACK

Definition at line 83 of file PCF8574.h.

#define PCF8574_I2C_check_bus_collision   I2C1_check_bus_collision

Definition at line 80 of file PCF8574.h.

#define PCF8574_I2C_MODULE_1

Definition at line 72 of file PCF8574.h.

#define PCF8574_I2C_negative_ACK   I2C1_negative_ACK

Definition at line 84 of file PCF8574.h.

#define PCF8574_I2C_open   I2C1_open

Definition at line 76 of file PCF8574.h.

#define PCF8574_I2C_read_byte   I2C1_read_byte

Definition at line 85 of file PCF8574.h.

#define PCF8574_I2C_set_master_as_receiver   I2C1_set_master_as_receiver

Definition at line 86 of file PCF8574.h.

#define PCF8574_I2C_start_bit   I2C1_start_bit

Definition at line 79 of file PCF8574.h.

#define PCF8574_I2C_stop_bit   I2C1_stop_bit

Definition at line 82 of file PCF8574.h.

#define PCF8574_I2C_wait_bus_IDLE   I2C1_wait_bus_IDLE

Definition at line 78 of file PCF8574.h.

#define PCF8574_I2C_write_byte   I2C1_write_byte

Definition at line 81 of file PCF8574.h.

#define PCF8574_INTERNAL_ADDRESS   USED_DEVICE_PCF8574A

Definition at line 112 of file PCF8574.h.

#define read_data_PCF8574   PCF8574_read_data

Definition at line 169 of file PCF8574.h.

#define USED_DEVICE_PCF8574   0x40

Definition at line 109 of file PCF8574.h.

#define USED_DEVICE_PCF8574A   0x70

Definition at line 110 of file PCF8574.h.

#define write_data_PCF8574   PCF8574_write_data

Definition at line 149 of file PCF8574.h.

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.