Sample I2C Functions For Teensy Soc - FLIR ADK Getting Started

Hide thumbs Also See for ADK:
Table of Contents

Advertisement

FLI R
ADK
write val 0x01 to reg 0x19 to device reg 0xD8
Configure heater GPIO as an OUTPUT (step can be skipped if already done this power cycle)
write val 0x0F to reg 0x18 to device reg 0xD8
Turn Heater ON
Set GPIO state register on ADK side to configure heater on
write val 0x09 to reg 0x19 of device reg 0xD8
Configure heater GPIO as an OUTPUT
write val 0x0F to reg 0x18 of device reg 0xD8

4.5 Sample I2C Functions for Teensy SOC

Below are sample functions for i2cwrite and i2cread as well as a function to send an array
of bytes.
I2C Read and Write:
void i2cwrite(byte
{
byte
err;
Wire.beginTransmission(addy);
Wire.write(reg);
Wire.write(val);
err
= Wire.endTransmission();
if
(err
!= 0) {
I2Cerror
}
}
byte i2cread(byte
{
byte
err;
byte
res
= 0;
Wire.beginTransmission(addy);
Wire.write(reg);
err
= Wire.endTransmission();
if
(err
!= 0) {
I2Cerror
}
Wire.requestFrom((int) addy, (int) 1, false);
while
(Wire.available()) {
res
= Wire.read();
}
return
res;
}
addy,
byte
reg,
= 1;
addy,
byte
reg)
= 1;
// slave may send less than requested
// receive a byte
// send the byte
The information contained herein does not contain technology as
defined by EAR,15 CFR772, is publicly available, and therefore
byte
val)
not subject to EAR.
Ge tt in g S ta rt ed
11

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents