From 41435806b8436365e3bed20579fa650b6bb48ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 19 Aug 2022 16:04:42 +0200 Subject: [PATCH] =?UTF-8?q?use=20I=C2=B2C=20NAK=20to=20indicate=20programm?= =?UTF-8?q?ing=20is=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 582d583..9ba3b9d 100644 --- a/main.c +++ b/main.c @@ -503,6 +503,7 @@ level pulse on the Hot Plug Detect pin. This pulse shall be at least 100 msec. if (i2c_prog) { // received data over i2c to be programmed if (EDID_PORT->IDR.reg & EDID_PIN) { // EDID switched off puts("I²C prog disabled\r\n"); + I2C_CR2 &= I2C_CR2_ACK; // NACK next received byte to indicate programming it disabled } else { // EDID programming allowed /* puts("I²C prog "); @@ -525,7 +526,7 @@ level pulse on the Hot Plug Detect pin. This pulse shall be at least 100 msec. if (!(FLASH_IAPSR & FLASH_IAPSR_EOP)) { FLASH_IAPSR &= ~FLASH_IAPSR_DUL; // re-enable write protection LED_PORT->ODR.reg &= ~LED_PIN; // switch LED on to indicate programming failed - //I2C_CR2 &= I2C_CR2_ACK; // NACK next received byte + I2C_CR2 &= I2C_CR2_ACK; // NACK next received byte to indicate programming error puts("EEPROM byte prog failed\r\n"); } FLASH_IAPSR &= ~FLASH_IAPSR_DUL; // re-enable write protection @@ -564,6 +565,9 @@ void i2c(void) __interrupt(IRQ_I2C) // auto wakeup } else { // received data byte i2c_prog = true; // notify main loop data needs to be programmed } + if (EDID_PORT->IDR.reg & EDID_PIN) { // EDID programming is not enabled + I2C_CR2 &= I2C_CR2_ACK; // NACK next received byte to indicate programming it disabled + } } if (sr1 & I2C_SR1_STOPF) { // stop received I2C_CR2 |= I2C_CR2_ACK; // this is just to clear the flag