Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
PCF8574 Class Reference

#include <PCF8574.h>

Inheritance diagram for PCF8574:
Inheritance graph
Collaboration diagram for PCF8574:
Collaboration graph

Classes

class  GPIO
 

Public Member Functions

 PCF8574 (TWI &twi, uint8_t subaddr=7)
 
uint8_t ddr ()
 
void ddr (uint8_t ddr)
 
uint8_t read ()
 
uint8_t port ()
 
void write (uint8_t value)
 
void write (void *buf, size_t size)
 

Protected Member Functions

 PCF8574 (TWI &twi, uint8_t addr, uint8_t subaddr)
 
bool acquire ()
 
bool release ()
 
int read (void *buf, size_t count)
 
int write (const void *buf, size_t count)
 
int write (iovec_t *vp)
 

Protected Attributes

uint8_t m_ddr
 
uint8_t m_port
 
TWIm_twi
 
uint8_t m_addr
 

Detailed Description

Driver for the PCF8574/PCF8574A Remote 8-bit I/O expander for I2C-bus with interrupt.

Circuit

+------------+
(GND)---[ ]---------1-|A0 VCC|-16--------------(VCC)
(GND)---[ ]---------2-|A1 SDA|-15-----------(SDA/A4)
(GND)---[ ]---------3-|A2 SCL|-14-----------(SCL/A5)
(P0)----------------4-|P0 INT|-13--------------(EXT)
(P1)----------------5-|P1 P7|-12---------------(P7)
(P2)----------------6-|P2 P6|-11---------------(P6)
(P3)----------------7-|P3 P5|-10---------------(P5)
(GND)---------------8-|GND P4|-9----------------(P4)
+------------+

References

  1. NXP Semiconductors Product data sheet, Rev. 5, 27 May 2013.

Definition at line 46 of file PCF8574.h.

Constructor & Destructor Documentation

PCF8574::PCF8574 ( TWI twi,
uint8_t  subaddr = 7 
)
inline

Construct connection to PCF8574 Remote 8-bit I/O expander with given sub-address.

Parameters
[in]twibus manager.
[in]subaddrsub-address (0..7, default 7).

Definition at line 54 of file PCF8574.h.

PCF8574::PCF8574 ( TWI twi,
uint8_t  addr,
uint8_t  subaddr 
)
inlineprotected

Construct connection to PCF8574 Remote 8-bit I/O expander with given address.

Parameters
[in]twibus manager.
[in]addrbus address.
[in]subaddrdevice sub address.

Definition at line 229 of file PCF8574.h.

Member Function Documentation

bool TWI::Device::acquire ( )
inlineinherited

Start transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 52 of file TWI.h.

uint8_t PCF8574::ddr ( )
inline

Get data direction for port; 0 for output, 1 for input.

Returns
data direction.

Definition at line 64 of file PCF8574.h.

void PCF8574::ddr ( uint8_t  ddr)
inline

Set data direction for port pin P0..P7; 0 for output, 1 for input.

Parameters
[in]ddrdata direction mask.

Definition at line 73 of file PCF8574.h.

uint8_t PCF8574::port ( )
inline

Get data port values.

Returns
port value.

Definition at line 99 of file PCF8574.h.

int TWI::Device::read ( void *  buf,
size_t  count 
)
inlineinherited

Read data from device to given buffer.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes read or negative error code.

Definition at line 73 of file TWI.h.

uint8_t PCF8574::read ( )
inline

Read pins and return current values.

Returns
input pin values.

Definition at line 86 of file PCF8574.h.

bool TWI::Device::release ( )
inlineinherited

Stop transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 62 of file TWI.h.

int TWI::Device::write ( const void *  buf,
size_t  count 
)
inlineinherited

Write data from the given buffer to device.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes written or negative error code.

Definition at line 84 of file TWI.h.

int TWI::Device::write ( iovec_t *  vp)
inlineinherited

Write data to device with from given io vector.

Parameters
[in]vpio vector pointer.
Returns
number of bytes written or negative error code.

Definition at line 94 of file TWI.h.

void PCF8574::write ( uint8_t  value)
inline

Write given value to the output pins.

Parameters
[in]valueto write to port.

Definition at line 108 of file PCF8574.h.

void PCF8574::write ( void *  buf,
size_t  size 
)
inline

Write given values to the output pins.

Parameters
[in]bufpointer to data to write to device.
[in]sizeof buffer.

Definition at line 121 of file PCF8574.h.

Member Data Documentation

uint8_t TWI::Device::m_addr
protectedinherited

Device address.

Definition at line 104 of file TWI.h.

uint8_t PCF8574::m_ddr
protected

Data Direction Register, 0 = output, 1 = input.

Definition at line 217 of file PCF8574.h.

uint8_t PCF8574::m_port
protected

Port Register to mask and maintain output pin values.

Definition at line 220 of file PCF8574.h.

TWI& TWI::Device::m_twi
protectedinherited

Two-Wire Interface Manager.

Definition at line 101 of file TWI.h.


The documentation for this class was generated from the following file: