aboutsummaryrefslogtreecommitdiff
path: root/lib/pbdrv/drv/arduino/mod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pbdrv/drv/arduino/mod.cpp')
-rw-r--r--lib/pbdrv/drv/arduino/mod.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp
index 2eef8d5..c381077 100644
--- a/lib/pbdrv/drv/arduino/mod.cpp
+++ b/lib/pbdrv/drv/arduino/mod.cpp
@@ -1,7 +1,3 @@
-#ifndef ARDUINO
-#error This driver only works on the Arduino platform!
-#endif
-
#include <Arduino.h>
#include <Wire.h>
#include <avr/delay.h>
@@ -42,8 +38,17 @@ static void pb_setup() {
Wire.onReceive(recv_event);
}
-/// \ingroup pb_drv_arduino
+/**
+ * \ingroup pb_drv_arduino
+ * \warning This function includes a hard-coded 10ms delay before sending. This
+ * is to work around a weird issue where the Arduino pulls both SDA and SCL low
+ * while attempting to initiate an I2C transmission. We were able to verify
+ * that the Arduino correctly handles bus arbitration under a test scenario
+ * with 2 Uno's, but ran into issues while integrating the Arduino's with the
+ * RP2040.
+ */
__weak void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) {
+ vTaskDelay(10 / portTICK_PERIOD_MS); // prevent bus collisions
Wire.beginTransmission((int) addr);
Wire.write(buf, sz);
Wire.endTransmission(true);
@@ -69,6 +74,10 @@ void loop_task() {
* \ingroup pb_drv_arduino
* \brief Application entrypoint
*
+ * This function overrides the default (weak) implementation of the \c main()
+ * function in the Arduino framework. No additional setup is required to use
+ * this driver.
+ *
* \note I should really be able to use Arduino's initVariant function for
* this, but I can't seem to get it to link properly using the CMake setup in
* this repository. Overriding the main() function seems to work, and the