From 4270a2dfa5d6ce2947d1d1832e1e1e2a5591e239 Mon Sep 17 00:00:00 2001 From: Tobias Diedrich Date: Sat, 22 Jan 2022 23:50:42 +0100 Subject: [PATCH] Check for slave clock stretching This indeed fixes the values read back: 80000000ff No buttons, no movement 80010000ff Left button 80050000ff Left+right buttons 80070000ff All buttons 800012fdff Force applied 80000fffff force applied --- main.s | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.s b/main.s index 9436f1c..d350272 100644 --- a/main.s +++ b/main.s @@ -1512,7 +1512,9 @@ _i2c_sda0: _i2c_scl1: B0BCLR tpSCLM ; Set SCL to input - JMP $+1 +@@: + B0BTS1 tpSCL ; Wait until SCL high + JMP @B NOP RET @@ -1524,7 +1526,7 @@ _i2c_scl0: _i2c_start: CALL _i2c_sda1 ; 8 cycles - CALL _i2c_scl1 ; 8 cycles + CALL _i2c_scl1 ; 8+N cycles CALL _i2c_sda0 ; 8 cycles CALL _i2c_scl0 ; 8 cycles RET