6 #include <linux/i2c-dev.h>
11 #ifndef I2C_SMBUS_BLOCK_MAX
14 #include <linux/i2c.h>
15 typedef unsigned char i2c_char_t;
17 typedef char i2c_char_t;
19 #include <sys/ioctl.h>
21 #define MAX_BUF_NAME 64
31 ssize_t readBytes(
void* buf,
size_t count);
32 ssize_t writeBytes(
const void* buf,
size_t count);
35 int initI2C_RW(
int bus,
int address,
int file);
42 inline int I2c::initI2C_RW(
int bus,
int address,
int fileHnd)
45 i2C_address = address;
49 char namebuf[MAX_BUF_NAME];
50 snprintf(namebuf,
sizeof(namebuf),
"/dev/i2c-%d", i2C_bus);
52 if ((i2C_file = open(namebuf, O_RDWR)) < 0)
54 fprintf(stderr,
"Failed to open %s I2C Bus\n", namebuf);
59 if (ioctl(i2C_file, I2C_SLAVE, i2C_address) < 0){
60 fprintf(stderr,
"I2C_SLAVE address %#x failed...", i2C_address);
69 inline int I2c::closeI2C()
72 if(close(i2C_file) > 0)
80 inline ssize_t I2c::readBytes(
void *buf,
size_t count)
82 return read(i2C_file, buf, count);
85 inline ssize_t I2c::writeBytes(
const void *buf,
size_t count)
87 return write(i2C_file, buf, count);
int write(const std::string &filename, float *buf, unsigned int channels, unsigned int frames, unsigned int samplerate)
Definition: AudioFileUtilities.cpp:79