Libraries and Example of mbed parallel bus using I2C port expanders

Dependencies:   HDSP253X mbed PCF8574_Bus

Committer:
wim
Date:
Sat Aug 20 12:49:44 2011 +0000
Revision:
2:1dab1089c332
First commit, testloop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 2:1dab1089c332 1 /* PCF8574_AddressBus - Use the PCF8574 I2C Port Extender for controlling the Address Bus
wim 2:1dab1089c332 2 * Copyright (c) 2011 Wim Huiskamp
wim 2:1dab1089c332 3 *
wim 2:1dab1089c332 4 * Released under the MIT License: http://mbed.org/license/mit
wim 2:1dab1089c332 5 *
wim 2:1dab1089c332 6 * version 0.2 Initial Release
wim 2:1dab1089c332 7 */
wim 2:1dab1089c332 8 #ifndef _PCF8574_ADDRESSBUS_H
wim 2:1dab1089c332 9 #define _PCF8574_ADDRESSBUS_H
wim 2:1dab1089c332 10
wim 2:1dab1089c332 11
wim 2:1dab1089c332 12 //Pin Defines for PCF8574 Address Bus
wim 2:1dab1089c332 13 #define D_A0 0x01
wim 2:1dab1089c332 14 #define D_A1 0x02
wim 2:1dab1089c332 15 #define D_A2 0x04
wim 2:1dab1089c332 16 #define D_A3 0x08
wim 2:1dab1089c332 17 #define D_A4 0x10
wim 2:1dab1089c332 18 #define D_A5 0x20
wim 2:1dab1089c332 19 #define D_A6 0x40
wim 2:1dab1089c332 20 #define D_A7 0x80
wim 2:1dab1089c332 21
wim 2:1dab1089c332 22 #define D_ADDR_MSK 0x3F
wim 2:1dab1089c332 23
wim 2:1dab1089c332 24
wim 2:1dab1089c332 25 /** Create an PCF8574_AddressBus object connected to the specified I2C object and using the specified deviceAddress
wim 2:1dab1089c332 26 *
wim 2:1dab1089c332 27 * @param I2C &i2c the I2C port to connect to
wim 2:1dab1089c332 28 * @param char deviceAddress the address of the PCF8574
wim 2:1dab1089c332 29 */
wim 2:1dab1089c332 30 class PCF8574_AddressBus {
wim 2:1dab1089c332 31 public:
wim 2:1dab1089c332 32 PCF8574_AddressBus(I2C &i2c, char deviceAddress);
wim 2:1dab1089c332 33 void write(char address);
wim 2:1dab1089c332 34 protected:
wim 2:1dab1089c332 35 I2C &_i2c;
wim 2:1dab1089c332 36 char _readOpcode;
wim 2:1dab1089c332 37 char _writeOpcode;
wim 2:1dab1089c332 38 void _init();
wim 2:1dab1089c332 39 };
wim 2:1dab1089c332 40
wim 2:1dab1089c332 41 #endif