WPILib 2012
WPILibRoboticsLibraryforFRC
|
00001 /*----------------------------------------------------------------------------*/ 00002 /* Copyright (c) FIRST 2008. All Rights Reserved. */ 00003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ 00005 /*----------------------------------------------------------------------------*/ 00006 00007 #ifndef I2C_H 00008 #define I2C_H 00009 00010 #include "SensorBase.h" 00011 00012 class DigitalModule; 00013 00022 class I2C : SensorBase 00023 { 00024 friend class DigitalModule; 00025 public: 00026 virtual ~I2C(); 00027 bool Transaction(UINT8 *dataToSend, UINT8 sendSize, UINT8 *dataReceived, UINT8 receiveSize); 00028 bool AddressOnly(); 00029 bool Write(UINT8 registerAddress, UINT8 data); 00030 bool Read(UINT8 registerAddress, UINT8 count, UINT8 *data); 00031 void Broadcast(UINT8 registerAddress, UINT8 data); 00032 void SetCompatibilityMode(bool enable); 00033 00034 bool VerifySensor(UINT8 registerAddress, UINT8 count, const UINT8 *expected); 00035 private: 00036 static SEM_ID m_semaphore; 00037 static UINT32 m_objCount; 00038 00039 I2C(DigitalModule *module, UINT8 deviceAddress); 00040 00041 DigitalModule *m_module; 00042 UINT8 m_deviceAddress; 00043 bool m_compatibilityMode; 00044 }; 00045 00046 #endif 00047