New LiquidCrystal library  1.5.0
Generic LCD control library
/Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/I2CIO.h
1 // ---------------------------------------------------------------------------
2 // Created by Francisco Malpartida on 20/08/11.
3 // Copyright (C) - 2018
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License v3.0
16 // along with this program.
17 // If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
18 //
19 // ---------------------------------------------------------------------------
20 //
21 // This software is furnished "as is", without technical support, and with no
22 // warranty, express or implied, as to its usefulness for any purpose.
23 //
24 // Thread Safe: No
25 // Extendable: Yes
26 //
27 // @file I2CIO.h
28 // This file implements a basic IO library using the PCF8574 I2C IO Expander
29 // chip.
30 //
31 // @brief
32 // Implement a basic IO library to drive the PCF8574* I2C IO Expander ASIC.
33 // The library implements basic IO general methods to configure IO pin direction
34 // read and write uint8_t operations and basic pin level routines to set or read
35 // a particular IO port.
36 //
37 // @version API 1.0.0
38 //
39 // @author F. Malpartida - fmalpartida@gmail.com
40 // ---------------------------------------------------------------------------
41 
42 #ifndef _I2CIO_H_
43 #define _I2CIO_H_
44 
45 #include <inttypes.h>
46 
47 #define _I2CIO_VERSION "1.0.0"
48 
56 class I2CIO
57 {
58 public:
64  I2CIO ( );
65 
77  int begin ( uint8_t i2cAddr );
78 
88  void pinMode ( uint8_t pin, uint8_t dir );
89 
98  void portMode ( uint8_t dir );
99 
109  uint8_t read ( void );
110 
123  uint8_t digitalRead ( uint8_t pin );
124 
138  int write ( uint8_t value );
139 
151  int digitalWrite ( uint8_t pin, uint8_t level );
152 
153 
154 
155 private:
156  uint8_t _shadow; // Shadow output
157  uint8_t _dirMask; // Direction mask
158  uint8_t _i2cAddr; // I2C address
159  bool _initialised; // Initialised object
160 
169  bool isAvailable (uint8_t i2cAddr);
170 
171 };
172 
173 #endif
Definition: I2CIO.h:56
void portMode(uint8_t dir)
Definition: I2CIO.cpp:123
int write(uint8_t value)
Definition: I2CIO.cpp:160
void pinMode(uint8_t pin, uint8_t dir)
Definition: I2CIO.cpp:106
int digitalWrite(uint8_t pin, uint8_t level)
Definition: I2CIO.cpp:204
uint8_t digitalRead(uint8_t pin)
Definition: I2CIO.cpp:187
I2CIO()
Definition: I2CIO.cpp:71
int begin(uint8_t i2cAddr)
Definition: I2CIO.cpp:85
uint8_t read(void)
Definition: I2CIO.cpp:141