Peripherals/I2C_driver: Uncommented code to check for device acknowledgment
This commit is contained in:
parent
94bc6eba39
commit
65dfd21ef0
2
Makefile
2
Makefile
@ -62,7 +62,7 @@ upload: boot_code/bios.stxt
|
|||||||
fpga_sim: boot_code/bios.stxt
|
fpga_sim: boot_code/bios.stxt
|
||||||
${Q}make ${MAKEOPTS} PRINT_PATH_PREFIX=system/ -C system fpga_sim
|
${Q}make ${MAKEOPTS} PRINT_PATH_PREFIX=system/ -C system fpga_sim
|
||||||
|
|
||||||
.PHONY: fpga
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@echo 'Simulation targets:'
|
@echo 'Simulation targets:'
|
||||||
@echo ' - No target will start a simulation with the default'
|
@echo ' - No target will start a simulation with the default'
|
||||||
|
@ -32,6 +32,7 @@ int main(int argc, char** argv) {
|
|||||||
contextp->commandArgs(argc, argv);
|
contextp->commandArgs(argc, argv);
|
||||||
system_state = new Vfpga_top{contextp};
|
system_state = new Vfpga_top{contextp};
|
||||||
system_state->user_button=1;
|
system_state->user_button=1;
|
||||||
|
system_state->i2c_sda_in=0;
|
||||||
|
|
||||||
//system_state->reset=1;
|
//system_state->reset=1;
|
||||||
tick();
|
tick();
|
||||||
|
@ -19,9 +19,7 @@
|
|||||||
|
|
||||||
module I2C_driver (
|
module I2C_driver (
|
||||||
input wire clock,
|
input wire clock,
|
||||||
/* verilator lint_off UNUSEDSIGNAL */
|
|
||||||
input wire SDA_input,
|
input wire SDA_input,
|
||||||
/* verilator lint_on UNUSEDSIGNAL */
|
|
||||||
output wire SDA_output,
|
output wire SDA_output,
|
||||||
output reg SDA_direction, //1:output 0:input
|
output reg SDA_direction, //1:output 0:input
|
||||||
output reg SCL,
|
output reg SCL,
|
||||||
@ -119,13 +117,12 @@ always @(posedge clock) begin
|
|||||||
end
|
end
|
||||||
6'b001110:begin
|
6'b001110:begin
|
||||||
SCL<=1;
|
SCL<=1;
|
||||||
// if (SDA==1)begin
|
if (SDA_input==1)begin
|
||||||
// led<=1;
|
i2c_state<=6'b111111; //TODO: Don't freeze the entire driver if a single error occurs!! (here and on the second ack as well)
|
||||||
// i2c_state<=6'b011111;
|
end else begin
|
||||||
// end else begin
|
|
||||||
i2c_state<=6'b001111;
|
i2c_state<=6'b001111;
|
||||||
data_bit_counter<=0;
|
data_bit_counter<=0;
|
||||||
// end
|
end
|
||||||
end
|
end
|
||||||
/****** separator ********/
|
/****** separator ********/
|
||||||
6'b001111:begin
|
6'b001111:begin
|
||||||
@ -192,13 +189,12 @@ always @(posedge clock) begin
|
|||||||
end
|
end
|
||||||
6'b011011:begin
|
6'b011011:begin
|
||||||
SCL<=1;
|
SCL<=1;
|
||||||
// if (SDA==1)begin
|
if (SDA_input==1)begin
|
||||||
// led<=1;
|
i2c_state<=6'b111111;
|
||||||
// i2c_state<=6'b011111;
|
end else begin
|
||||||
// end else begin
|
|
||||||
i2c_state<=6'b011100;
|
i2c_state<=6'b011100;
|
||||||
SDA_direction<=1;
|
SDA_direction<=1;
|
||||||
// end
|
end
|
||||||
end
|
end
|
||||||
/****** separator ********/
|
/****** separator ********/
|
||||||
6'b011100:begin
|
6'b011100:begin
|
||||||
|
Loading…
Reference in New Issue
Block a user