|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
3 #ifndef LIBPROPELLER_I2C_H_
4 #define LIBPROPELLER_I2C_H_
8 #include "libpropeller/i2c/i2c_base.h"
49 void Init(
const int scl = 28,
const int sda = 29,
const int frequency = 400000) {
50 base_.
Init(scl, sda, frequency);
64 bool Ping(
const unsigned char device) {
66 bool result = base_.
SendByte(device);
85 bool Put(
const unsigned char device,
const unsigned char address,
111 unsigned char Get(
const unsigned char device,
const unsigned char address) {
119 result &= base_.
SendByte(device | 0x01);
120 unsigned char dataByte = base_.
ReadByte(
false);
142 bool Put(
const unsigned char device,
const unsigned char address,
143 const char * bytes,
const int size) {
149 for (
int i = 0; i < size; ++i) {
174 bool Get(
const unsigned char device,
const unsigned char address,
175 char * bytes,
const int size) {
181 result &= base_.
SendByte(device | 0x01);
184 for (; i < size - 1; ++i) {
209 bool Put(
const unsigned char device,
const char byte) {
214 bool result = base_.
SendByte(device);
240 bool Get(
const unsigned char device,
char * bytes,
const int size) {
242 bool result = base_.
SendByte(device | 0x01);
244 for (; i < size - 1; ++i) {
282 #endif // LIBPROPELLER_I2C_H_
unsigned char Get(const unsigned char device, const unsigned char address)
void Init(const int scl=28, const int sda=29, const int frequency=400000)
void Init(const int scl=28, const int sda=29, const int frequency=400000)
bool Ping(const unsigned char device)
bool Put(const unsigned char device, const unsigned char address, const char *bytes, const int size)
bool Get(const unsigned char device, char *bytes, const int size)
bool SendByte(const unsigned char byte)
int SendByte(const unsigned char byte)
bool Put(const unsigned char device, const char byte)
bool Get(const unsigned char device, const unsigned char address, char *bytes, const int size)
unsigned char ReadByte(const bool acknowledge)
unsigned char ReadByte(const int acknowledge)
bool Put(const unsigned char device, const unsigned char address, const char byte)