aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGergő J. Miklós2020-10-15 23:28:26 +0200
committerGergő J. Miklós2020-10-15 23:28:26 +0200
commit521dad36cb4533e423fe14602165a534080b7344 (patch)
tree99186a68d442ed18088ab06806304f580d6aff43 /src
parent06d3cf11147a363cbc5d0c5487beadbfc1e03306 (diff)
downloadi2sensors-521dad36cb4533e423fe14602165a534080b7344.tar.gz
i2sensors-521dad36cb4533e423fe14602165a534080b7344.zip
i2sensors: SMBUS lib loading
Diffstat (limited to 'src')
-rw-r--r--src/main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 26e79ba..d9644be 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,7 +12,9 @@
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
-#include <i2c/smbus.h>
+#ifdef WITH_I2C_SMBUS
+ #include <i2c/smbus.h>
+#endif
#include <sys/ioctl.h>
#include "deftypes.h"
@@ -83,10 +85,11 @@ void print_help(void) {
__uint8_t *xchg_data (__uint8_t *buf, __uint16_t wrlen, __uint16_t waitlen, __uint16_t rdlen){ //# [buf] = 32 byte
+#ifdef WITH_I2C_SMBUS
__int32_t data=0;
- if( funcs & I2C_FUNC_I2C ){
-
+ if( funcs & I2C_FUNC_I2C ){
+#endif
if(write(devicef, buf, 1) != 1){ //# write one byte to device
fprintf (stderr, "I2C write error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__);
}
@@ -95,6 +98,7 @@ __uint8_t *xchg_data (__uint8_t *buf, __uint16_t wrlen, __uint16_t waitlen, _
fprintf (stderr, "I2C read error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__);
}
+#ifdef WITH_I2C_SMBUS
} else if ( funcs && I2C_FUNC_SMBUS_WORD_DATA ){
if(i2c_smbus_write_byte(devicef, buf[0] ) == -1){ //# write one byte to device
fprintf (stderr, "I2C write error: [NO: %d, MSG: %s] at %s, line %d. (function: %s)\n", errno, strerror(errno), __FILE__, __LINE__, __func__);
@@ -107,6 +111,7 @@ __uint8_t *xchg_data (__uint8_t *buf, __uint16_t wrlen, __uint16_t waitlen, _
buf[1] = (data >> 8) & 0x0FF;
}
}
+#endif
return buf;
}