From 29fd45db239fc5beee5414f8e795ab0e6d14cb96 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Fri, 19 Jul 2019 15:05:17 -0700 Subject: [PATCH] Changed compiler behavior for i2c. I2C library is still broken - Firmware does still compile correctly when I2C is disabled --- .../Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.cpp | 22 ++++++++++++++----- .../Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.h | 10 ++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.cpp index ff8b56b..ccc093d 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.cpp @@ -1,16 +1,25 @@ +#ifdef I2C_INPUT + +#include +#include "pP_config.h" #include "pP_i2c.h" +#include + +pP_i2c::pP_i2c(){ + +} void pP_i2c::init() { - Wire.begin(pP_i2c_address) + Wire.begin(pP_i2c_address); } void pP_i2c::i2cInput(int bytesReceived) { for (int a = 0; a < bytesReceived; a++) { if (a < maxBytes) { - cmdRcvd[a] = Wire.receive(); + cmdRcvd[a] = Wire.read(); } else { - longRcvd[a] = Wire.receive(); + longRcvd[a] = Wire.read(); } } if (bytesReceived == 1 && (cmdRcvd[0] < regMapSize)) { @@ -22,11 +31,11 @@ void pP_i2c::i2cInput(int bytesReceived) { } switch (cmdRcvd[0]) { case 0x00: - senseInt = (uint8_t) cmdRcvd[1]; + senseInt = (long) cmdRcvd[1]; return; - break + break; case 0x01: - compInt = (uint8_t) cmdRcvd[1]; + compInt = (long) cmdRcvd[1]; return; break; case 0x02: @@ -53,3 +62,4 @@ void pP_i2c::i2cInput(int bytesReceived) { return; } } +#endif diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.h index 20c5611..6e49724 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_i2c.h @@ -1,10 +1,7 @@ -#ifdef I2C #ifndef _pP_i2c_h_ #define _pP_i2c_h_ +#ifdef I2C_INPUT -#include - -#define pP_i2c_address 0xa0 // I2C Bus Address #define senseInt_Offset 0x00 // Integer of sense threshold in millivolts #define compInt_Offset 0x01 // Integer of comparator threshold in millivolts @@ -16,13 +13,14 @@ /*-------------------------Variables------------------------*/ #define regMapSize 7 -#define maxBytes 2 +uint8_t maxBytes = 2; #define longBytes 4 byte regMap[regMapSize]; byte regMapTemp[regMapSize]; byte cmdRcvd[maxBytes]; byte longRcvd[longBytes]; + /*------------------------------------------------*/ class pP_i2c { @@ -30,7 +28,7 @@ class pP_i2c { pP_i2c(uint8_t address=pP_i2c_address); void init(); - void i2cInput(); + void i2cInput(int bytesReceived); }; #endif