From acf718dd379f9b96258c7e00661ed42440978b98 Mon Sep 17 00:00:00 2001 From: Sebastian Holzapfel Date: Mon, 23 Oct 2023 18:58:10 +0200 Subject: [PATCH] add ACK check on LED1 and JACK2, doesn't fix vanilla flickering? --- gateware/drivers/pmod_i2c_master.sv | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gateware/drivers/pmod_i2c_master.sv b/gateware/drivers/pmod_i2c_master.sv index 7e3915b..e67b689 100644 --- a/gateware/drivers/pmod_i2c_master.sv +++ b/gateware/drivers/pmod_i2c_master.sv @@ -189,6 +189,17 @@ always_ff @(posedge clk) begin end I2C_LED2: begin case (i2c_config_pos) + 1: begin + // On first iteration after I2C address sent, ony + // continue if the device actually ACK'd our TX. + if (ack_out) begin + cmd <= I2CMASTER_STOP; + i2c_state <= I2C_JACK1; + end else begin + data_in <= led_config[5'(i2c_config_pos)]; + cmd <= I2CMASTER_WRITE; + end + end LED_CFG_BYTES: begin cmd <= I2CMASTER_STOP; i2c_state <= I2C_JACK1; @@ -249,7 +260,14 @@ always_ff @(posedge clk) begin data_in <= 8'h31; cmd <= I2CMASTER_WRITE; end - 9: cmd <= I2CMASTER_READ; + 9: begin + if (ack_out) begin + i2c_state <= I2C_LED1; + cmd <= I2CMASTER_STOP; + end else begin + cmd <= I2CMASTER_READ; + end + end // 4) Save the result. 10: begin