summaryrefslogtreecommitdiff
path: root/i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'i2c.c')
-rw-r--r--i2c.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/i2c.c b/i2c.c
index 6571798..767e4f6 100644
--- a/i2c.c
+++ b/i2c.c
@@ -10,6 +10,9 @@
#define I2C_BUS "/dev/i2c-3"
+gboolean write_error_flagged;
+gboolean read_error_flagged;
+
void I2C_Write(gulong address, guchar value)
{
@@ -23,7 +26,8 @@ void I2C_Write(gulong address, guchar value)
int device = open(I2C_BUS, O_RDWR);
- if (device == -1) {
+ if ((device == -1) && !write_error_flagged) {
+ write_error_flagged = TRUE;
g_print_debug("ERROR: could not open I2C bus %s for writing\n", I2C_BUS);
return;
}
@@ -48,7 +52,8 @@ guchar I2C_Read(gulong address)
int device = open(I2C_BUS, O_RDWR);
- if (device == -1) {
+ if ((device == -1) && !read_error_flagged) {
+ read_error_flagged = TRUE;
g_print_debug("ERROR: could not open I2C bus %s for reading\n", I2C_BUS);
return 0;
}