WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
I2C.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef I2C_H
8 #define I2C_H
9 
10 #include "SensorBase.h"
11 
12 class DigitalModule;
13 
22 class I2C : SensorBase
23 {
24  friend class DigitalModule;
25 public:
26  virtual ~I2C();
27  bool Transaction(uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize);
28  bool AddressOnly();
29  bool Write(uint8_t registerAddress, uint8_t data);
30  bool Read(uint8_t registerAddress, uint8_t count, uint8_t *data);
31  void Broadcast(uint8_t registerAddress, uint8_t data);
32  void SetCompatibilityMode(bool enable);
33 
34  bool VerifySensor(uint8_t registerAddress, uint8_t count, const uint8_t *expected);
35 private:
36  static SEM_ID m_semaphore;
37  static uint32_t m_objCount;
38 
39  I2C(DigitalModule *module, uint8_t deviceAddress);
40 
41  DigitalModule *m_module;
42  uint8_t m_deviceAddress;
43  bool m_compatibilityMode;
44 };
45 
46 #endif
47 
bool Write(uint8_t registerAddress, uint8_t data)
Definition: I2C.cpp:140
virtual ~I2C()
Definition: I2C.cpp:40
void SetCompatibilityMode(bool enable)
Definition: I2C.cpp:197
bool Transaction(uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize)
Definition: I2C.cpp:61
Definition: SensorBase.h:20
bool VerifySensor(uint8_t registerAddress, uint8_t count, const uint8_t *expected)
Definition: I2C.cpp:219
bool AddressOnly()
Definition: I2C.cpp:125
void Broadcast(uint8_t registerAddress, uint8_t data)
Definition: I2C.cpp:185
bool Read(uint8_t registerAddress, uint8_t count, uint8_t *data)
Definition: I2C.cpp:161
Definition: I2C.h:22
Definition: DigitalModule.h:17