From f4ba3fd43ab3330a05dd85697ae70d0fd9bc5932 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 21 Apr 2025 11:18:41 -0500 Subject: [PATCH] Attempt to get sensor libraries compiling. --- cores/portduino/Arduino.h | 2 +- cores/portduino/linux/LinuxHardwareI2C.cpp | 3 ++- cores/portduino/linux/LinuxHardwareI2C.h | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cores/portduino/Arduino.h b/cores/portduino/Arduino.h index 4a905d2..efaf5ee 100644 --- a/cores/portduino/Arduino.h +++ b/cores/portduino/Arduino.h @@ -23,7 +23,7 @@ extern HardwareSPI SPI; using namespace arduino; -typedef HardwareI2C TwoWire; // Some Arduino ports use this terminology +#define TwoWire LinuxHardwareI2C // Some Arduino ports use this terminology /** Map a pin number to an interrupt # * We always map 1:1 diff --git a/cores/portduino/linux/LinuxHardwareI2C.cpp b/cores/portduino/linux/LinuxHardwareI2C.cpp index 15a7d3a..2aa3328 100644 --- a/cores/portduino/linux/LinuxHardwareI2C.cpp +++ b/cores/portduino/linux/LinuxHardwareI2C.cpp @@ -8,6 +8,7 @@ #include "LinuxHardwareI2C.h" #include #include +#include "Arduino.h" extern "C" @@ -21,7 +22,7 @@ namespace arduino { char buf[100] = {0}; int requestedBytes = 0; int sessionstatus; - LinuxHardwareI2C Wire; + TwoWire Wire; bool hasBegun = false; void LinuxHardwareI2C::begin() { diff --git a/cores/portduino/linux/LinuxHardwareI2C.h b/cores/portduino/linux/LinuxHardwareI2C.h index b4bd575..81a6a23 100644 --- a/cores/portduino/linux/LinuxHardwareI2C.h +++ b/cores/portduino/linux/LinuxHardwareI2C.h @@ -7,6 +7,7 @@ #include "HardwareI2C.h" #include "Utility.h" +#include "Arduino.h" namespace arduino { @@ -63,6 +64,7 @@ class LinuxHardwareI2C : public HardwareI2C { virtual int available(); virtual int read(); + size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } virtual uint8_t readBytes(uint8_t address, size_t len, bool stopBit) { notImplemented("requestFrom"); @@ -77,7 +79,6 @@ class LinuxHardwareI2C : public HardwareI2C { } }; -extern LinuxHardwareI2C Wire; } // namespace arduino - +extern LinuxHardwareI2C Wire; #endif // PORTDUINO_SIMHARDWAREI2C_H