Skip to content

Commit

Permalink
trailing ack was causing STOP not to go through!
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Nov 9, 2023
1 parent 46a3305 commit e565e3c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gateware/drivers/pmod_i2c_master.sv
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ always_ff @(posedge clk) begin
I2C_JACK1: begin
i2c_state <= I2C_JACK2;
i2c_config_pos <= 0;
stb <= 1'b0;
end
I2C_JACK2: begin
case (i2c_config_pos)
Expand Down Expand Up @@ -449,6 +450,7 @@ always_ff @(posedge clk) begin
I2C_TOUCH5: begin
i2c_state <= I2C_TOUCH6;
i2c_config_pos <= 0;
stb <= 1'b0;
end
I2C_TOUCH6: begin
case (i2c_config_pos)
Expand All @@ -461,7 +463,7 @@ always_ff @(posedge clk) begin
// Sensor 0 difference counts
2: begin
if (ack_out == 1'b1) begin
i2c_state <= I2C_TOUCH5;
i2c_state <= I2C_LED1;
cmd <= I2CMASTER_STOP;
end else begin
case (nsensor)
Expand All @@ -486,11 +488,11 @@ always_ff @(posedge clk) begin
end
6: begin
if (ack_out == 1'b1) begin
i2c_state <= I2C_TOUCH5;
i2c_state <= I2C_LED1;
cmd <= I2CMASTER_STOP;
end else begin
cmd <= I2CMASTER_READ;
ack_in <= 1'b0;
ack_in <= 1'b1;
end
end
7: begin
Expand All @@ -504,7 +506,6 @@ always_ff @(posedge clk) begin
6: touch6 <= data_out;
7: touch7 <= data_out;
endcase
ack_in <= 1'b1;
cmd <= I2CMASTER_STOP;
i2c_state <= I2C_LED1;
nsensor <= nsensor + 1;
Expand Down

0 comments on commit e565e3c

Please sign in to comment.