remove sink presence detection

This commit is contained in:
King Kévin 2022-08-05 15:13:59 +02:00
parent 5d76a67bd3
commit e211a5446a
1 changed files with 6 additions and 14 deletions

20
main.c
View File

@ -35,7 +35,6 @@ static bool eeprom_valid = true; // if the EDID can be read from EEPROM
#define SCL_SNK_PU_PIN PC5
static bool i2c_fwd = false; // if the I²C source lines are connected to sink
static bool sink_present = false; // if he sink is present (tested using sink DDC)
// hot plug detect pull up
#define HPD_PORT GPIO_PC
#define HPD_PIN PC6
@ -249,21 +248,17 @@ void main(void)
SDA_SNK_PORT->ODR.reg |= SDA_SNK_PIN; // release SDA line
SDA_SNK_PORT->CR1.reg &= ~SDA_SNK_PIN; // switch pin to open-drain
SDA_SNK_PORT->DDR.reg |= SDA_SNK_PIN; // switch pin to output
// test I²C forwarding
SCL_SNK_PORT->ODR.reg &= ~SCL_SNK_PIN; // assert SCL line
SDA_SNK_PORT->ODR.reg &= ~SDA_SNK_PIN; // assert SDA line
SDA_SNK_PORT->ODR.reg &= ~SDA_SNK_PIN; // assert SDA line (send start condition)
SCL_SNK_PORT->ODR.reg &= ~SCL_SNK_PIN; // assert SCL line (send start condition)
wait_10us(1); // wait 1 clock cycle
if (0 == (SCL_SRC_PORT->IDR.reg & SCL_SRC_PIN) || 0 == (SDA_SRC_PORT->IDR.reg & SDA_SRC_PIN)) {
i2c_fwd = true; // remember the I²C line(s) are forwarded
puts("I²C lines forwarded\r\n");
}
SCL_SNK_PORT->ODR.reg |= SCL_SNK_PIN; // release SCL line
SDA_SNK_PORT->ODR.reg |= SDA_SNK_PIN; // release SDA line
if (!i2c_fwd) {
wait_10us(5); // let sink 47k pull-up take effect
if ((SCL_SNK_PORT->IDR.reg & SCL_SNK_PIN) && (SDA_SNK_PORT->IDR.reg & SDA_SNK_PIN)) {
sink_present = true;
}
}
SCL_SNK_PORT->ODR.reg |= SCL_SNK_PIN; // release SCL line (send stop condition)
SDA_SNK_PORT->ODR.reg |= SDA_SNK_PIN; // release SDA line (send stop condition)
// configure I²C pull-ups
if (i2c_fwd) { // I²C lines are not pulled up
@ -329,9 +324,6 @@ we will only be able to provide 1 extension block since we can only respond to o
} else if (i2c_fwd) { // we are not the only master on the I²C sink lines
puts("can't read EDID: I²C lines forwarded\r\n");
LED_PORT->ODR.reg &= ~LED_PIN; // switch LED on to indicate error
} else if (!sink_present) {
puts("can't read EDID: sink not present\r\n");
LED_PORT->ODR.reg &= ~LED_PIN; // switch LED on to indicate error
} else {
IWDG_KR = IWDG_KR_KEY_REFRESH; // reset watchdog
puts("reading sink EDID: ");