eBoard 🐉  ①⑧⑨
Written for SIA 2017/2018
eagle_I2C.h
Go to the documentation of this file.
1 #ifndef EAGLE_EBOARD_HELPLIB_I2C
2 #define EAGLE_EBOARD_HELPLIB_I2C
3 
19  inline optVAL_t sendI2C(optVAL_t deviceID,byte *buf, byte buf_len);
20 
35  inline optVAL_t sendI2C(optVAL_t deviceID, byte buf);
36 
45  inline void pingI2C(optVAL_t ret[], optVAL_t ret_len);
47  inline void pingI2C(optVAL_t ret[], optVAL_t ret_len){
48  optVAL_t count = 0;
49  for (byte i = 1; (i < 255 && !STOP); i++) /*ignore special*/ {
50  if(i==200)continue; //internal
51  Wire.beginTransmission (i);
52  if (Wire.endTransmission () == 0) {
53  if(count < ret_len) ret[count] = i;
54  count++;
55  delay (1);
56  }
57  }
58  }
59  inline optVAL_t sendI2C(optVAL_t deviceID,byte *buf, byte buf_len) {
60  Wire.beginTransmission(deviceID);
61  Wire.write(buf,buf_len);
62  return Wire.endTransmission();
63  }
64 
65  inline optVAL_t sendI2C(optVAL_t deviceID, byte buf){
66  Wire.beginTransmission(deviceID);
67  Wire.write(buf);
68  return Wire.endTransmission();
69  }
71 
82  inline void readI2C(optVAL_t deviceID, optVAL_t ret[], optVAL_t ret_len,bool blocking=true);
84  inline void readI2C(optVAL_t deviceID,optVAL_t ret[] , optVAL_t ret_len,bool blocking) {
85  for(optVAL_t rect = 0x0; (Wire.available() || (((blocking && (rect < ret_len))) && (!STOP))); rect++)
86  ret[rect] = Wire.read();
87  }
89 #endif
const unsigned char * buf[11]
to enable &#39;smooth&#39; access (:
optVAL_t sendI2C(optVAL_t deviceID, byte *buf, byte buf_len)
Sends a buffer of bytes to a certain I²C-Device.
void readI2C(optVAL_t deviceID, optVAL_t ret[], optVAL_t ret_len, bool blocking=true)
Reads a special amount of bits from a certain I²C-Device.
static bool STOP
Definition: eBoard.h:186
TwoWire Wire
this is the well-known Arduino Wire Interface, just a little bit &#39;modified&#39; ;P
int optVAL_t
Definition: eBoard.h:196
void pingI2C(optVAL_t ret[], optVAL_t ret_len)
Sends a byte to a certain I²C-Device.