Changed the bitwise OR.
PCF8575.h@3:e45eb11841df, 2010-09-09 (annotated)
- Committer:
- Lerche
- Date:
- Thu Sep 09 08:05:54 2010 +0000
- Revision:
- 3:e45eb11841df
- Parent:
- 0:37337b5a13c0
- Child:
- 4:032e37009fc1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:37337b5a13c0 | 1 | /* mbed PCF8574 Library, for driving the I2C I/O Expander |
Lerche | 0:37337b5a13c0 | 2 | * Copyright (c) 2008-2010, cstyles, sford (Originally PCF8574 lib) |
Lerche | 0:37337b5a13c0 | 3 | * new created by Lerche |
Lerche | 0:37337b5a13c0 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
Lerche | 0:37337b5a13c0 | 5 | * of this software and associated documentation files (the "Software"), to deal |
Lerche | 0:37337b5a13c0 | 6 | * in the Software without restriction, including without limitation the rights |
Lerche | 0:37337b5a13c0 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
Lerche | 0:37337b5a13c0 | 8 | * copies of the Software, and to permit persons to whom the Software is |
Lerche | 0:37337b5a13c0 | 9 | * furnished to do so, subject to the following conditions: |
Lerche | 0:37337b5a13c0 | 10 | * |
Lerche | 0:37337b5a13c0 | 11 | * The above copyright notice and this permission notice shall be included in |
Lerche | 0:37337b5a13c0 | 12 | * all copies or substantial portions of the Software. |
Lerche | 0:37337b5a13c0 | 13 | * |
Lerche | 0:37337b5a13c0 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Lerche | 0:37337b5a13c0 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Lerche | 0:37337b5a13c0 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
Lerche | 0:37337b5a13c0 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Lerche | 0:37337b5a13c0 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Lerche | 0:37337b5a13c0 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
Lerche | 0:37337b5a13c0 | 20 | * THE SOFTWARE. |
Lerche | 0:37337b5a13c0 | 21 | */ |
Lerche | 0:37337b5a13c0 | 22 | |
Lerche | 0:37337b5a13c0 | 23 | #include "mbed.h" |
Lerche | 0:37337b5a13c0 | 24 | |
Lerche | 0:37337b5a13c0 | 25 | #ifndef MBED_PCF8575_H |
Lerche | 0:37337b5a13c0 | 26 | #define MBED_PCF8575_H |
Lerche | 0:37337b5a13c0 | 27 | |
Lerche | 3:e45eb11841df | 28 | /** Interface to the PCF8575 I2C 16 Bit IO expander */ |
Lerche | 0:37337b5a13c0 | 29 | class PCF8575 { |
Lerche | 0:37337b5a13c0 | 30 | public: |
Lerche | 3:e45eb11841df | 31 | /** Create an instance of the PCF8575 connected to specfied I2C pins, with the specified address. |
Lerche | 0:37337b5a13c0 | 32 | * |
Lerche | 0:37337b5a13c0 | 33 | * @param sda The I2C data pin |
Lerche | 0:37337b5a13c0 | 34 | * @param scl The I2C clock pin |
Lerche | 0:37337b5a13c0 | 35 | * @param address The I2C address for this PCF8575 |
Lerche | 0:37337b5a13c0 | 36 | */ |
Lerche | 0:37337b5a13c0 | 37 | PCF8575(PinName sda, PinName scl, int address); |
Lerche | 0:37337b5a13c0 | 38 | |
Lerche | 0:37337b5a13c0 | 39 | /** Read the IO pin level |
Lerche | 0:37337b5a13c0 | 40 | * |
Lerche | 0:37337b5a13c0 | 41 | * @return The byte read |
Lerche | 0:37337b5a13c0 | 42 | */ |
Lerche | 0:37337b5a13c0 | 43 | int read(); |
Lerche | 0:37337b5a13c0 | 44 | |
Lerche | 0:37337b5a13c0 | 45 | /** Write to the IO pins |
Lerche | 0:37337b5a13c0 | 46 | * |
Lerche | 3:e45eb11841df | 47 | * @param data The 16 bits to write to the IO port |
Lerche | 0:37337b5a13c0 | 48 | */ |
Lerche | 0:37337b5a13c0 | 49 | void write(int data); |
Lerche | 0:37337b5a13c0 | 50 | |
Lerche | 0:37337b5a13c0 | 51 | private: |
Lerche | 0:37337b5a13c0 | 52 | I2C _i2c; |
Lerche | 0:37337b5a13c0 | 53 | int _address; |
Lerche | 0:37337b5a13c0 | 54 | }; |
Lerche | 0:37337b5a13c0 | 55 | |
Lerche | 0:37337b5a13c0 | 56 | #endif |