Library with address set to hardware pins

Dependents:   Test2PCF8574 pcf8574-IO_expander

Committer:
Bas
Date:
Sat Sep 08 22:11:31 2012 +0000
Revision:
0:7913586369c2
changes in WriteByte. Array data added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bas 0:7913586369c2 1 /*
Bas 0:7913586369c2 2 * PCF8574(A) Remote 8-bit I/O expander for I2C-bus
Bas 0:7913586369c2 3 * Copyright (c) 2012 Bas van Drunen Littel
Bas 0:7913586369c2 4 *
Bas 0:7913586369c2 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
Bas 0:7913586369c2 6 * of this software and associated documentation files (the "Software"), to deal
Bas 0:7913586369c2 7 * in the Software without restriction, including without limitation the rights
Bas 0:7913586369c2 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Bas 0:7913586369c2 9 * copies of the Software, and to permit persons to whom the Software is
Bas 0:7913586369c2 10 * furnished to do so, subject to the following conditions:
Bas 0:7913586369c2 11 *
Bas 0:7913586369c2 12 * The above copyright notice and this permission notice shall be included in
Bas 0:7913586369c2 13 * all copies or substantial portions of the Software.
Bas 0:7913586369c2 14 *
Bas 0:7913586369c2 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Bas 0:7913586369c2 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Bas 0:7913586369c2 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Bas 0:7913586369c2 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Bas 0:7913586369c2 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Bas 0:7913586369c2 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Bas 0:7913586369c2 21 * THE SOFTWARE.
Bas 0:7913586369c2 22 */
Bas 0:7913586369c2 23
Bas 0:7913586369c2 24 #ifndef __PCF8574_H
Bas 0:7913586369c2 25 #define __PCF8574_H
Bas 0:7913586369c2 26
Bas 0:7913586369c2 27 #define VERSION 1.0
Bas 0:7913586369c2 28
Bas 0:7913586369c2 29 #include <mbed.h>
Bas 0:7913586369c2 30
Bas 0:7913586369c2 31 #define PCF8574_I2C_ADDRESS 0x40
Bas 0:7913586369c2 32 #define PCF8574A_I2C_ADDRESS 0x70
Bas 0:7913586369c2 33 #define PCF8574_TYPE false
Bas 0:7913586369c2 34 #define PCF8574A_TYPE true
Bas 0:7913586369c2 35
Bas 0:7913586369c2 36 class PCF8574 {
Bas 0:7913586369c2 37 public:
Bas 0:7913586369c2 38 PCF8574(I2C* _interface, unsigned char _chipselect, bool _type);
Bas 0:7913586369c2 39 ~PCF8574(void);
Bas 0:7913586369c2 40
Bas 0:7913586369c2 41 unsigned char ReadByte(void);
Bas 0:7913586369c2 42 void WriteByte(unsigned char byte);
Bas 0:7913586369c2 43 private:
Bas 0:7913586369c2 44 I2C* i2c; // Communication interface
Bas 0:7913586369c2 45 unsigned char address; //I2C address
Bas 0:7913586369c2 46 };
Bas 0:7913586369c2 47 #endif