COSA
An Object-Oriented Platform for Arduino Programming
PCF8574 Class Reference

#include <PCF8574.hh>

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

Public Member Functions

 PCF8574 (uint8_t subaddr=7)
 
bool data_direction (uint8_t ddr)
 
bool input_pin (uint8_t pin)
 
bool output_pin (uint8_t pin)
 
bool read (uint8_t pin)
 
uint8_t read ()
 
bool write (uint8_t pin, uint8_t value)
 
bool write (uint8_t value)
 
bool write (void *buf, size_t size)
 

Protected Member Functions

 PCF8574 (uint8_t addr, uint8_t subaddr)
 

Protected Attributes

uint8_t m_ddr
 
uint8_t m_port
 

Static Protected Attributes

static const uint8_t PIN_MASK = 0x07
 

Private Member Functions

bool is_async () const
 
void sync_request ()
 
void async_request ()
 
virtual void on_completion (uint8_t type, int count)
 

Private Attributes

uint8_t m_addr
 
bool m_async
 

Detailed Description

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

Circuit

The I/0 expander used for LCD 1602 I2C communication.

+------------+
(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
(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 49 of file PCF8574.hh.

Constructor & Destructor Documentation

PCF8574::PCF8574 ( uint8_t  subaddr = 7)
inline

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

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

Definition at line 56 of file PCF8574.hh.

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

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

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

Definition at line 151 of file PCF8574.hh.

Member Function Documentation

bool PCF8574::data_direction ( uint8_t  ddr)

Set data direction for port pin P0..P7; 0 for output, 1 for input. Return true if set otherwise false.

Parameters
[in]ddrdata direction mask.
Returns
bool.

Definition at line 24 of file PCF8574.cpp.

bool PCF8574::input_pin ( uint8_t  pin)
inline

Set given pin as input. Return true if set otherwise false.

Parameters
[in]pinnumber (0..7).
Returns
bool.

Definition at line 75 of file PCF8574.hh.

bool PCF8574::output_pin ( uint8_t  pin)
inline

Set given pin as output. Return true if set otherwise false.

Parameters
[in]pinnumber (0..7).
Returns
bool.

Definition at line 86 of file PCF8574.hh.

bool PCF8574::read ( uint8_t  pin)
inline

Read given pin and return true is set otherwise false.

Parameters
[in]pinnumber (0..7).
Returns
bool.

Definition at line 97 of file PCF8574.hh.

uint8_t PCF8574::read ( )

Read pins and return current values.

Returns
input pin values.

Definition at line 35 of file PCF8574.cpp.

bool PCF8574::write ( uint8_t  pin,
uint8_t  value 
)

Write set given output pin if value is non-zero, otherwise clear. Return true if successful otherwise false.

Parameters
[in]pinnumber (0..7).
[in]value.
Returns
bool.

Definition at line 45 of file PCF8574.cpp.

bool PCF8574::write ( uint8_t  value)

Write given value to the output pins. Return true if successful otherwise false. Return true if successful otherwise false.

Parameters
[in]value.
Returns
bool.

Definition at line 59 of file PCF8574.cpp.

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

Write given values to the output pins. Return true if successful otherwise false. Return true if successful otherwise false.

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

Definition at line 69 of file PCF8574.cpp.

Member Data Documentation

uint8_t PCF8574::m_ddr
protected

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

Definition at line 140 of file PCF8574.hh.

uint8_t PCF8574::m_port
protected

Port Register to mask and maintain output pin values.

Definition at line 143 of file PCF8574.hh.

const uint8_t PCF8574::PIN_MASK = 0x07
staticprotected

Pin number mask.

Definition at line 137 of file PCF8574.hh.


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