Jan Kamidra / PCF8574
Committer:
JohnnyK
Date:
Mon Jan 31 17:49:53 2022 +0000
Revision:
2:e076d7b30aea
Parent:
0:ab4e14b911ee
Child:
3:47c298d4a41b
Reworked Constructor to I2C object instead of I2C pins. I can be usefull with anoter I2C slave on same bus

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:ab4e14b911ee 1 /* mbed PCF8574 Library, for driving the I2C I/O Expander
simon 0:ab4e14b911ee 2 * Copyright (c) 2008-2010, cstyles, sford
JohnnyK 2:e076d7b30aea 3 * 2022, 001: JohnnyK, Reworked Constructor to I2C object instead of I2C pins. I can be usefull with anoter I2C slave on same bus
simon 0:ab4e14b911ee 4 *
simon 0:ab4e14b911ee 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 0:ab4e14b911ee 6 * of this software and associated documentation files (the "Software"), to deal
simon 0:ab4e14b911ee 7 * in the Software without restriction, including without limitation the rights
simon 0:ab4e14b911ee 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 0:ab4e14b911ee 9 * copies of the Software, and to permit persons to whom the Software is
simon 0:ab4e14b911ee 10 * furnished to do so, subject to the following conditions:
simon 0:ab4e14b911ee 11 *
simon 0:ab4e14b911ee 12 * The above copyright notice and this permission notice shall be included in
simon 0:ab4e14b911ee 13 * all copies or substantial portions of the Software.
simon 0:ab4e14b911ee 14 *
simon 0:ab4e14b911ee 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 0:ab4e14b911ee 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 0:ab4e14b911ee 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 0:ab4e14b911ee 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 0:ab4e14b911ee 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 0:ab4e14b911ee 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 0:ab4e14b911ee 21 * THE SOFTWARE.
simon 0:ab4e14b911ee 22 */
simon 0:ab4e14b911ee 23
simon 0:ab4e14b911ee 24 #include "mbed.h"
simon 0:ab4e14b911ee 25
simon 0:ab4e14b911ee 26 #ifndef MBED_PCF8574_H
simon 0:ab4e14b911ee 27 #define MBED_PCF8574_H
simon 0:ab4e14b911ee 28
simon 0:ab4e14b911ee 29 /** Interface to the popular PCF8574 I2C 8 Bit IO expander */
simon 0:ab4e14b911ee 30 class PCF8574 {
simon 0:ab4e14b911ee 31 public:
JohnnyK 2:e076d7b30aea 32 /** Create an instance of the PCF8574 connected I2C object, with the specified address.
simon 0:ab4e14b911ee 33 *
JohnnyK 2:e076d7b30aea 34 * @param Mbed I2C object
simon 0:ab4e14b911ee 35 * @param address The I2C address for this PCF8574
simon 0:ab4e14b911ee 36 */
JohnnyK 2:e076d7b30aea 37 PCF8574(I2C *i2c, int address);
simon 0:ab4e14b911ee 38
simon 0:ab4e14b911ee 39 /** Read the IO pin level
simon 0:ab4e14b911ee 40 *
simon 0:ab4e14b911ee 41 * @return The byte read
simon 0:ab4e14b911ee 42 */
simon 0:ab4e14b911ee 43 int read();
simon 0:ab4e14b911ee 44
simon 0:ab4e14b911ee 45 /** Write to the IO pins
simon 0:ab4e14b911ee 46 *
simon 0:ab4e14b911ee 47 * @param data The 8 bits to write to the IO port
simon 0:ab4e14b911ee 48 */
simon 0:ab4e14b911ee 49 void write(int data);
simon 0:ab4e14b911ee 50
simon 0:ab4e14b911ee 51 private:
JohnnyK 2:e076d7b30aea 52 I2C *_i2c;
simon 0:ab4e14b911ee 53 int _address;
simon 0:ab4e14b911ee 54 };
simon 0:ab4e14b911ee 55
simon 0:ab4e14b911ee 56 #endif