Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __PCF8574_H__
00013 #define __PCF8574_H__
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #pragma systemFile
00035
00036 #ifndef __COMMON_H__
00037 #include "common.h"
00038 #endif
00039
00040 #define PCF8574_I2C_ADDR 0x70
00041
00042
00043 tByteArray PCF8574_I2CRequest;
00044 tByteArray PCF8574_I2CReply;
00045
00046
00047 bool PCF8574sendBytes(tSensors link, ubyte _byte);
00048 bool PCF8574readBytes(tSensors link, ubyte &_byte);
00049
00050
00051
00052
00053
00054
00055
00056
00057 bool PCF8574sendBytes(tSensors link, ubyte _byte) {
00058 memset(PCF8574_I2CRequest, 0, sizeof(tByteArray));
00059
00060 PCF8574_I2CRequest[0] = 2;
00061 PCF8574_I2CRequest[1] = PCF8574_I2C_ADDR;
00062 PCF8574_I2CRequest[2] = _byte;
00063
00064 return writeI2C(link, PCF8574_I2CRequest, 0);
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 bool PCF8574readBytes(tSensors link, ubyte &_byte) {
00076 memset(PCF8574_I2CRequest, 0, sizeof(tByteArray));
00077
00078 PCF8574_I2CRequest[0] = 1;
00079 PCF8574_I2CRequest[1] = PCF8574_I2C_ADDR;
00080 PCF8574_I2CRequest[2] = _byte;
00081
00082 if (!writeI2C(link, PCF8574_I2CRequest, 1))
00083 return false;
00084
00085 if (!readI2C(link, PCF8574_I2CReply, 1))
00086 return false;
00087
00088 _byte = PCF8574_I2CReply[0];
00089
00090 return true;
00091
00092 }
00093
00094
00095 #endif // __PCF8574_H__
00096
00097
00098
00099
00100
00101