Guillaume Fricker / KS0108_PCF8574

Dependencies:   BusEnums

Dependents:   Menu

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PCF8574_DataBus.h Source File

PCF8574_DataBus.h

00001 /* PCF8574_DataBus - Use the PCF8574 I2C Port Extender for controlling the Data Bus
00002  * Copyright (c) 2011 Wim Huiskamp
00003  *
00004  * Released under the MIT License: http://mbed.org/license/mit
00005  *
00006  * version 0.2 Initial Release
00007 */
00008 #ifndef _PCF8574_DATABUS_H
00009 #define _PCF8574_DATABUS_H
00010 
00011 //Pin Defines for PCF8574 Data Bus
00012 #define D_D0                   0x01
00013 #define D_D1                   0x02
00014 #define D_D2                   0x04
00015 #define D_D3                   0x08
00016 #define D_D4                   0x10
00017 #define D_D5                   0x20
00018 #define D_D6                   0x40
00019 #define D_D7                   0x80
00020 
00021 #define D_DATA_MSK             0xFF
00022 
00023 //Enums for Data Bus
00024 #include "BusEnums.h"
00025 
00026 
00027 /** Create an PCF8574_DataBus object connected to the specified I2C object and using the specified deviceAddress
00028  *
00029  * @param I2C &i2c the I2C port to connect to 
00030  * @param char deviceAddress the address of the PCF8574
00031 */
00032 class PCF8574_DataBus {
00033 public:
00034     PCF8574_DataBus(I2C &i2c, char deviceAddress);
00035     char read();
00036     void write(char byte);
00037     void busdir (Bus_Dir bus_dir); 
00038     void output(void);
00039     void input(void);  
00040 protected:
00041     I2C &_i2c;
00042     char _readOpcode;
00043     char _writeOpcode; 
00044     void _init(); 
00045 };
00046 
00047 #endif