From 2285b3a1e805e0988f219b4c8deee980b46972b1 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:44:14 +0800 Subject: [PATCH 1/3] Update hardware.c --- src/hardware.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 5693eca..2994218 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -442,10 +442,9 @@ void GetVtxParameter() { // last_SA_lock #if defined USE_SMARTAUDIO_SW || defined USE_SMARTAUDIO_HW last_SA_lock = I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_SA_LOCK); - WAIT(10); if (last_SA_lock == 0xff) { last_SA_lock = 0; - I2C_Write8(ADDR_EEPROM, EEP_ADDR_SA_LOCK, last_SA_lock); + I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_SA_LOCK, last_SA_lock); } #ifdef _DEBUG_MODE debugf("\r\nlast_SA_lock %x", (uint16_t)last_SA_lock); @@ -1577,7 +1576,7 @@ void RF_Delay_Init() { if (SA_saved == 0) { if (seconds >= WAIT_SA_CONFIG) { - I2C_Write8(ADDR_EEPROM, EEP_ADDR_SA_LOCK, SA_lock); + I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_SA_LOCK, SA_lock); SA_saved = 1; #ifdef _DEBUG_MODE debugf("\r\nSave SA_lock(%x) to EEPROM", (uint16_t)SA_lock); From d7e2e95435c41d47a65cc86342ea13bca4956187 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:25:12 +0800 Subject: [PATCH 2/3] write() then wait(ms+2) --- src/i2c.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/i2c.c b/src/i2c.c index fb0c477..f05e9e0 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -121,9 +121,10 @@ uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { } uint8_t I2C_Write8_Wait(uint16_t ms, uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { - WAIT(ms); - // debugf("\r\nEEP:0x%04x, 0x%04x", reg_addr, (uint16_t)val); - return I2C_Write8(slave_addr, reg_addr, val); + uint8_t ret; + ret = I2C_Write8(slave_addr, reg_addr, val); + WAIT(ms + 2); + return } uint8_t I2C_Write16(uint8_t slave_addr, uint16_t reg_addr, uint16_t val) { From 4194beccd8a3f7273b9db7404dee7b0e586e2c0a Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:49:16 +0800 Subject: [PATCH 3/3] Update i2c.c --- src/i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i2c.c b/src/i2c.c index f05e9e0..2f165e5 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -124,7 +124,7 @@ uint8_t I2C_Write8_Wait(uint16_t ms, uint8_t slave_addr, uint8_t reg_addr, uint8 uint8_t ret; ret = I2C_Write8(slave_addr, reg_addr, val); WAIT(ms + 2); - return + return ret; } uint8_t I2C_Write16(uint8_t slave_addr, uint16_t reg_addr, uint16_t val) {