Do some work with DRC8353 driver

This commit is contained in:
Kelvin Ly 2020-01-25 20:19:05 -05:00
parent 6b8dc6f337
commit f66c03cf2a
5 changed files with 60 additions and 4 deletions

2
rtl/.gitignore vendored
View File

@ -2,4 +2,4 @@
*.bin
*.json
*.rpt
*.log
*.log*

View File

@ -13,7 +13,7 @@ ${FN}.json: ${FN}.v $(shell find library -type f -name '*.v')
./run_yosys.sh ${FN} | tee bldc.log
${FN}.asc: ${FN}.json ${FN}.pcf
nextpnr-ice40 ${NEXTPNR_OPTS} --pcf "${FN}.pcf" --json "${FN}.json" --asc "${FN}.asc"
nextpnr-ice40 ${NEXTPNR_OPTS} --pcf "${FN}.pcf" --json "${FN}.json" --asc "${FN}.asc" --freq 25 | tee bldc.log_pnr
${FN}.rpt: ${FN}.pcf ${FN}.asc
icetime ${ICETIME_OPTS} -p "${FN}.pcf" -mtr "${FN}.rpt" "${FN}.asc"

View File

@ -6,4 +6,12 @@ set_io adc_ss 27
set_io adc_si 26
set_io adc_so 25
set_io drv_fault_n 36
set_io drv_en 43
set_io drv_cs_n 44
set_io drv_sck 45
set_io drv_sdi 46
set_io drv_sdo 47
set_io clk 20

View File

@ -6,8 +6,16 @@ module bldc (
output adc_ss,
output adc_sck,
input adc_so,
output adc_si
);
output adc_si,
input drv_fault_n,
output drv_en,
output drv_cs_n,
output drv_sck,
output drv_sdi,
input drv_sdo
);
reg [7:0] dbg_buf = 0;
reg dbg_buf_vld = 0;
@ -27,6 +35,15 @@ wire [11:0] adc_val;
wire adc_vld;
reg adc_ack = 0;
reg stop = 0;
reg coast_nbrake = 0;
reg clear_fault = 0;
wire drv_rdy;
wire fault_a;
wire fault_b;
wire fault_c;
adc_driver adc0(
.clk(clk),
.rst(1'b0),
@ -41,6 +58,29 @@ adc_driver adc0(
.ack(adc_ack)
);
drv8353r_driver driver0(
.clk(clk),
.rst(1'b0),
.en(1'b1),
.drv_fault_n(drv_fault_n),
.drv_en(drv_en),
.drv_cs_n(drv_cs_n),
.drv_sck(drv_sck),
.drv_sdi(drv_sdi),
.drv_sdo(drv_sdo),
.stop(stop),
.coast_nbrake(coast_nbrake),
.clear_fault(clear_fault),
.rdy(drv_rdy),
.fault_a(fault_a),
.fault_b(fault_b),
.fault_c(fault_c)
);
uart_tx_115200 dbg(
.clk_25mhz(clk),
.rst(1'b0),

View File

@ -138,6 +138,14 @@ assign cur_bit = 15 - count[6:3];
reg [2:0] cur_reg = 0;
reg [2:0] cur_reg_next;
reg fault_a_ff = 0;
reg fault_b_ff = 0;
reg fault_c_ff = 0;
assign fault_a = fault_a_ff;
assign fault_b = fault_b_ff;
assign fault_c = fault_c_ff;
always @* begin
state_next = state;