Libraries and Example of mbed parallel bus using I2C port expanders
Dependencies: HDSP253X mbed PCF8574_Bus
PCF8574_DataBus.h@0:2467aed99127, 2011-08-31 (annotated)
- Committer:
- wim
- Date:
- Wed Aug 31 19:45:31 2011 +0000
- Revision:
- 0:2467aed99127
First Version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:2467aed99127 | 1 | /* PCF8574_DataBus - Use the PCF8574 I2C Port Extender for controlling the Data Bus |
wim | 0:2467aed99127 | 2 | * Copyright (c) 2011 Wim Huiskamp |
wim | 0:2467aed99127 | 3 | * |
wim | 0:2467aed99127 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
wim | 0:2467aed99127 | 5 | * |
wim | 0:2467aed99127 | 6 | * version 0.2 Initial Release |
wim | 0:2467aed99127 | 7 | */ |
wim | 0:2467aed99127 | 8 | #ifndef _PCF8574_DATABUS_H |
wim | 0:2467aed99127 | 9 | #define _PCF8574_DATABUS_H |
wim | 0:2467aed99127 | 10 | |
wim | 0:2467aed99127 | 11 | //Pin Defines for PCF8574 Data Bus |
wim | 0:2467aed99127 | 12 | #define D_D0 0x01 |
wim | 0:2467aed99127 | 13 | #define D_D1 0x02 |
wim | 0:2467aed99127 | 14 | #define D_D2 0x04 |
wim | 0:2467aed99127 | 15 | #define D_D3 0x08 |
wim | 0:2467aed99127 | 16 | #define D_D4 0x10 |
wim | 0:2467aed99127 | 17 | #define D_D5 0x20 |
wim | 0:2467aed99127 | 18 | #define D_D6 0x40 |
wim | 0:2467aed99127 | 19 | #define D_D7 0x80 |
wim | 0:2467aed99127 | 20 | |
wim | 0:2467aed99127 | 21 | #define D_DATA_MSK 0xFF |
wim | 0:2467aed99127 | 22 | |
wim | 0:2467aed99127 | 23 | //Enums for Data Bus |
wim | 0:2467aed99127 | 24 | #include "BusEnums.h" |
wim | 0:2467aed99127 | 25 | |
wim | 0:2467aed99127 | 26 | |
wim | 0:2467aed99127 | 27 | /** Create an PCF8574_DataBus object connected to the specified I2C object and using the specified deviceAddress |
wim | 0:2467aed99127 | 28 | * |
wim | 0:2467aed99127 | 29 | * @param I2C &i2c the I2C port to connect to |
wim | 0:2467aed99127 | 30 | * @param char deviceAddress the address of the PCF8574 |
wim | 0:2467aed99127 | 31 | */ |
wim | 0:2467aed99127 | 32 | class PCF8574_DataBus { |
wim | 0:2467aed99127 | 33 | public: |
wim | 0:2467aed99127 | 34 | PCF8574_DataBus(I2C &i2c, char deviceAddress); |
wim | 0:2467aed99127 | 35 | char read(); |
wim | 0:2467aed99127 | 36 | void write(char byte); |
wim | 0:2467aed99127 | 37 | void busdir (Bus_Dir bus_dir); |
wim | 0:2467aed99127 | 38 | protected: |
wim | 0:2467aed99127 | 39 | I2C &_i2c; |
wim | 0:2467aed99127 | 40 | char _readOpcode; |
wim | 0:2467aed99127 | 41 | char _writeOpcode; |
wim | 0:2467aed99127 | 42 | void _init(); |
wim | 0:2467aed99127 | 43 | }; |
wim | 0:2467aed99127 | 44 | |
wim | 0:2467aed99127 | 45 | #endif |