New LiquidCrystal library  1.5.0
Generic LCD control library
/Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/SI2CIO.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 // Thread Safe: No
22 // Extendable: Yes
23 //
24 // @file SI2CIO.h
25 // This file implements a basic IO library using the PCF8574 I2C IO Expander
26 // chip, but using software I2C.
27 //
28 // @brief
29 // Implement a basic IO library to drive the PCF8574* I2C IO Expander ASIC.
30 // The library implements basic IO general methods to configure IO pin direction
31 // read and write uint8_t operations and basic pin level routines to set or read
32 // a particular IO port.
33 //
34 // @version API 1.0.0
35 //
36 // @author F. Malpartida - fmalpartida@gmail.com
37 // Adapted to SoftIC2 by Adrian Piccioli - adrianpiccioli@gmail.com
38 // ---------------------------------------------------------------------------
39 
40 #ifndef _SI2CIO_H_
41 #define _SI2CIO_H_
42 
43 #if defined (__AVR__)
44 
45 #include <inttypes.h>
46 
47 #define _SI2CIO_VERSION "1.0.0"
48 
56 class SI2CIO
57 {
58 public:
64  SI2CIO ( );
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 
161 };
162 
163 #else
164 #error "ONLY SUPPORTED ON AVR PROCESSORS"
165 #endif // defined (__AVR__)
166 
167 #endif