From 0d8e3160f86f285904fbdefe96eede4b6dbae1e7 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 8 Jul 2018 21:55:50 +0200 Subject: [PATCH] chg: i2c - adjustments --- common/i2c.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common/i2c.c b/common/i2c.c index e7ed219ba..db1d2951e 100644 --- a/common/i2c.c +++ b/common/i2c.c @@ -174,12 +174,9 @@ void I2C_Stop(void) { SCL_L; I2C_DELAY_2CLK; SDA_L; I2C_DELAY_2CLK; SCL_H; I2C_DELAY_2CLK; - WaitSCL_H(); + if (!WaitSCL_H()) return; SDA_H; - I2C_DELAY_2CLK; - I2C_DELAY_2CLK; - I2C_DELAY_2CLK; - I2C_DELAY_2CLK; + I2C_DELAY_XCLK(8); } // Send i2c ACK void I2C_Ack(void) { @@ -533,10 +530,10 @@ void I2C_print_status(void) { I2C_Reset_EnterMainProgram(); uint8_t len = I2C_BufferRead(resp, sizeof(resp), I2C_DEVICE_CMD_GETVERSION, I2C_DEVICE_ADDRESS_MAIN); if ( len > 0 ) { - Dbprintf(" FW version..............v%x.%02x", resp[0], resp[1]); + Dbprintf(" version.................v%x.%02x", resp[0], resp[1]); LogTrace(resp, len, 0, 0, NULL, false); } else { - DbpString(" FW version..............FAILED"); + DbpString(" version.................FAILED"); } } @@ -588,6 +585,8 @@ void SmartCardRaw( uint64_t arg0, uint64_t arg1, uint8_t *data ) { clear_trace(); set_tracing(true); + //uint64_t flags = arg0; + #define ISO7618_MAX_FRAME 255 I2C_Reset_EnterMainProgram(); @@ -617,7 +616,9 @@ void SmartCardRaw( uint64_t arg0, uint64_t arg1, uint8_t *data ) { // start [C0 03 start C1 len aa bb cc stop] len = I2C_BufferRead(resp, ISO7618_MAX_FRAME, I2C_DEVICE_CMD_READ, I2C_DEVICE_ADDRESS_MAIN); - + if ( len == 0) + isOK = false; + if ( MF_DBGLEVEL > 3 ) Dbprintf("counter %d", len); out: