diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-07 17:01:48 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-07 17:01:48 +0200 |
commit | 1f01917a4d339f7c68b452afbf2275c4cbda6c80 (patch) | |
tree | eb481a0de54c5c1b84428e811d18cdb824ba7ac6 /lib/pbdrv | |
parent | 3f1e5a5c6a594601e597a43a125883d5e3c618c1 (diff) |
remove overengineered code
Diffstat (limited to 'lib/pbdrv')
-rw-r--r-- | lib/pbdrv/drv/arduino/mod.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp index a522ff8..518a8a4 100644 --- a/lib/pbdrv/drv/arduino/mod.cpp +++ b/lib/pbdrv/drv/arduino/mod.cpp @@ -14,9 +14,8 @@ static void recv_event(int bytes) { uint8_t * data = (uint8_t *) malloc(bytes); size_t size = 0; - while (Wire.available()) { + while (Wire.available()) data[size++] = Wire.read(); - } pbdrv_i2c_recv(data, size); } @@ -29,22 +28,8 @@ void pbdrv_setup() { } __weak void pbdrv_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) { - uint8_t error; - uint8_t retry = 4; - do { - error = 0; - Wire.beginTransmission((int) addr); - size_t written = Wire.write(buf, sz); - if (written != sz) - error++; - error += Wire.endTransmission(true); - Wire.setWireTimeout(PB_TIMEOUT_US, true); - - if(retry == 0) break; - retry--; - } while (error); - - if (error) - Serial.print(error, DEC); + Wire.beginTransmission((int) addr); + Wire.write(buf, sz); + Wire.endTransmission(true); } |