Skip to content

Commit 36c0e9b

Browse files
committed
Add explicit I2C stop command
1 parent c229dcb commit 36c0e9b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

rtl/i2c_init.v

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Commands:
9797
00 0000011 : start write to current address
9898
00 0001000 : start address block
9999
00 0001001 : start data block
100+
00 1000001 : send I2C stop
100101
01 aaaaaaa : start write to address
101102
1 dddddddd : write 8-bit data
102103
@@ -266,6 +267,16 @@ always @* begin
266267

267268
address_next = address_reg + 1;
268269

270+
state_next = STATE_RUN;
271+
end else if (init_data_reg == 9'b001000001) begin
272+
// send stop
273+
cmd_write_next = 1'b0;
274+
cmd_start_next = 1'b0;
275+
cmd_stop_next = 1'b1;
276+
cmd_valid_next = 1'b1;
277+
278+
address_next = address_reg + 1;
279+
269280
state_next = STATE_RUN;
270281
end else if (init_data_reg == 9'b000001001) begin
271282
// data table start
@@ -377,6 +388,16 @@ always @* begin
377388

378389
address_next = address_reg + 1;
379390

391+
state_next = STATE_TABLE_3;
392+
end else if (init_data_reg == 9'b001000001) begin
393+
// send stop
394+
cmd_write_next = 1'b0;
395+
cmd_start_next = 1'b0;
396+
cmd_stop_next = 1'b1;
397+
cmd_valid_next = 1'b1;
398+
399+
address_next = address_reg + 1;
400+
380401
state_next = STATE_TABLE_3;
381402
end else if (init_data_reg == 9'b000001001) begin
382403
// data table start

0 commit comments

Comments
 (0)