From e728c9dfa3586b7c49aaf62740f442e2da9e6130 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Sun, 28 Apr 2024 17:35:53 +0200 Subject: [PATCH] #212 wiringPiI2CRawWrite and wiringPiI2CRawRead --- wiringPi/wiringPiI2C.c | 15 +++++++++++++-- wiringPi/wiringPiI2C.h | 6 ++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/wiringPi/wiringPiI2C.c b/wiringPi/wiringPiI2C.c index 51f92dd..0bd166a 100644 --- a/wiringPi/wiringPiI2C.c +++ b/wiringPi/wiringPiI2C.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -153,7 +154,7 @@ int wiringPiI2CReadReg16 (int fd, int reg) return data.word & 0xFFFF ; } -int wiringPiI2CReadBlockData (int fd, int reg, uint8_t size, uint8_t *values) +int wiringPiI2CReadBlockData (int fd, int reg, uint8_t *values, uint8_t size) { union i2c_smbus_data data; @@ -169,6 +170,11 @@ int wiringPiI2CReadBlockData (int fd, int reg, uint8_t size, uint8_t *values) return data.block[0]; } +int wiringPiI2CRawRead (int fd, uint8_t *values, uint8_t size) +{ + return(read(fd, values, size)); +} + /* * wiringPiI2CWrite: * Simple device write @@ -203,7 +209,7 @@ int wiringPiI2CWriteReg16 (int fd, int reg, int value) return i2c_smbus_access (fd, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, &data) ; } -int wiringPiI2CWriteBlockData (int fd, int reg, uint8_t size, const uint8_t *values) +int wiringPiI2CWriteBlockData (int fd, int reg, const uint8_t *values, uint8_t size) { union i2c_smbus_data data; @@ -215,6 +221,11 @@ int wiringPiI2CWriteBlockData (int fd, int reg, uint8_t size, const uint8_t *val return i2c_smbus_access (fd, I2C_SMBUS_WRITE, reg, I2C_SMBUS_BLOCK_DATA, &data) ; } +int wiringPiI2CRawWrite (int fd, const uint8_t *values, uint8_t size) +{ + return(write(fd, values, size)); +} + /* * wiringPiI2CSetupInterface: * Undocumented access to set the interface explicitly - might be used diff --git a/wiringPi/wiringPiI2C.h b/wiringPi/wiringPiI2C.h index 5734bdb..d9660b9 100644 --- a/wiringPi/wiringPiI2C.h +++ b/wiringPi/wiringPiI2C.h @@ -31,12 +31,14 @@ extern "C" { extern int wiringPiI2CRead (int fd) ; extern int wiringPiI2CReadReg8 (int fd, int reg) ; extern int wiringPiI2CReadReg16 (int fd, int reg) ; -extern int wiringPiI2CReadBlockData (int fd, int reg, uint8_t size, uint8_t *values); +extern int wiringPiI2CReadBlockData (int fd, int reg, uint8_t *values, uint8_t size); //Interface 3.3 +extern int wiringPiI2CRawRead (int fd, uint8_t *values, uint8_t size); //Interface 3.3 extern int wiringPiI2CWrite (int fd, int data) ; extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; -extern int wiringPiI2CWriteBlockData (int fd, int reg, uint8_t size, const uint8_t *values); +extern int wiringPiI2CWriteBlockData (int fd, int reg, const uint8_t *values, uint8_t size); //Interface 3.3 +extern int wiringPiI2CRawWrite (int fd, const uint8_t *values, uint8_t size); //Interface 3.3 extern int wiringPiI2CSetupInterface (const char *device, int devId) ; extern int wiringPiI2CSetup (const int devId) ;