Files
allwpilib/wpilibc/wpilibC++/include/I2C.h
Kevin O'Connor 605148456e * Add WriteBulk and ReadOnly to C++ I2C
Change-Id: If6082f6b92b4be5e328278ba536d5a7681082c9f (+4 squashed commit)

Squashed commit:

[86b4ae7] * Port I2C to roboRIO in JNI and Java. Left read method as a transaction and added readOnly. Left write as a single byte and added writeBulk. Need to go back to C++ and update to match.

Change-Id: I290d84211a4b7bb942d785730c0e6929449cf69f

[7d37419] * Remove HiTechnic sensors from Java. May be added back later as examples

Change-Id: Ie93e23a70fd953c99c03d50d9529220f86d32e03

[e62bfbf] * I2C ported to roboRIO i2clib in HAL and C++

Change-Id: Idb0e8cee5a1e8c1a0b0733ca94b528f659352915

[1059a48] * Remove HiTechnic sensors (Lego connector) may be added back as examples later

Change-Id: I84b8e1e022db2c69d487ed9ad5b3ec0e7ea57282 (+2 squashed commit)

Squashed commit:

[e62bfbf] * I2C ported to roboRIO i2clib in HAL and C++

Change-Id: Idb0e8cee5a1e8c1a0b0733ca94b528f659352915

[1059a48] * Remove HiTechnic sensors (Lego connector) may be added back as examples later

Change-Id: I84b8e1e022db2c69d487ed9ad5b3ec0e7ea57282
2014-06-23 18:23:14 -04:00

41 lines
1.2 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "SensorBase.h"
class DigitalModule;
/**
* I2C bus interface class.
*
* This class is intended to be used by sensor (and other I2C device) drivers.
* It probably should not be used directly.
*
*/
class I2C : SensorBase
{
public:
enum Port {kOnboard, kMXP};
I2C(Port port, uint8_t deviceAddress);
virtual ~I2C();
bool Transaction(uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived,
uint8_t receiveSize);
bool AddressOnly();
bool Write(uint8_t registerAddress, uint8_t data);
bool WriteBulk(uint8_t* data, uint8_t count);
bool Read(uint8_t registerAddress, uint8_t count, uint8_t *data);
bool ReadOnly(uint8_t count, uint8_t *buffer);
void Broadcast(uint8_t registerAddress, uint8_t data);
bool VerifySensor(uint8_t registerAddress, uint8_t count, const uint8_t *expected);
private:
Port m_port;
uint8_t m_deviceAddress;
};