From 7b19a012040185a28474b6782da206c46a53c614 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sat, 15 Jun 2019 18:39:34 +0200 Subject: betterer I2C --- src/DSi_I2C.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/DSi_I2C.cpp b/src/DSi_I2C.cpp index 4a4f1e7..b7b7022 100644 --- a/src/DSi_I2C.cpp +++ b/src/DSi_I2C.cpp @@ -39,7 +39,7 @@ void DeInit() void Reset() { - CurPos = 0; + CurPos = -1; memset(Registers, 0x5A, 0x100); Registers[0x00] = 0x33; // TODO: support others?? @@ -72,16 +72,36 @@ void Reset() void Start() { - CurPos = 0; + printf("BPTWL: start\n"); } u8 Read(bool last) { + if (last) + { + CurPos = -1; + return 0; + } + + printf("BPTWL: read %02X -> %02X\n", CurPos, Registers[CurPos]); return Registers[CurPos++]; } void Write(u8 val, bool last) { + if (last) + { + CurPos = -1; + return; + } + + if (CurPos == -1) + { + CurPos = val; + printf("BPTWL: reg=%02X\n", val); + return; + } + if (CurPos == 0x11 || CurPos == 0x12 || CurPos == 0x21 || CurPos == 0x30 || CurPos == 0x31 || @@ -93,7 +113,8 @@ void Write(u8 val, bool last) Registers[CurPos] = val; } - CurPos++; + printf("BPTWL: write %02X -> %02X\n", CurPos, val); + CurPos++; // CHECKME } } -- cgit v1.2.3