From 7228e872781cadeb3987a09ea8cac626f7e90c6e Mon Sep 17 00:00:00 2001 From: "Mr.Blinky" <4971163+MrBlinky@users.noreply.github.com> Date: Sat, 25 Apr 2020 19:42:14 +0200 Subject: [PATCH] I2C fix arduboy lib --- board-package-source/libraries/Arduboy/src/core/core.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/board-package-source/libraries/Arduboy/src/core/core.cpp b/board-package-source/libraries/Arduboy/src/core/core.cpp index 863c36e..dc446d7 100644 --- a/board-package-source/libraries/Arduboy/src/core/core.cpp +++ b/board-package-source/libraries/Arduboy/src/core/core.cpp @@ -295,6 +295,7 @@ void ArduboyCore::i2c_sendByte(uint8_t byte) " brne 1b \n" // initial set carry will be shifted out after 8 loops setting Z flag " \n" " out %[port],%[sda0] \n" // clear SDA for ACK + " nop \n" // extra delay " sbi %[port], %[sclb] \n" // set SCL (extends ACK bit by 1 cycle) " cbi %[port], %[sclb] \n" // clear SCL (extends SCL high by 1 cycle) :[byte] "+r" (byte) @@ -448,8 +449,8 @@ void ArduboyCore::paintScreen(unsigned char image[]) #if defined (OLED_SSD1306_I2C) //bitbanging I2C ~2Mbps (8 cycles per bit / 78 cycles per byte) asm volatile ( - "1: \n" " ld r0, %a[ptr]+ \n" // fetch display byte from buffer + "1: \n" " sec \n" // set carry for 8 shift counts " rol r0 \n" // shift a bit out and count at the same time "2: \n" @@ -464,6 +465,7 @@ void ArduboyCore::paintScreen(unsigned char image[]) " \n" " out %[port], %[sda0] \n" // clear SDA for ACK " subi %A[len], 1 \n" // len-- part1 (moved here for 1 cycle delay) + " ld r0, %a[ptr]+ \n" // fetch display byte from buffer (and delay) " out %[pin], %[scl] \n" // set SCL (2 cycles required) " sbci %B[len], 0 \n" // len-- part2 (moved here for 1 cycle delay) " out %[pin], %[scl] \n" // clear SCL (2 cycles required)