Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic gate driver support for Telsa Model 3 inverter #49

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CFLAGS = -Os -ggdb3 -Wall -Wextra -Iinclude/ -Ilibopeninv/include -Ilibopencm3/
-DCONTROL=CTRL_$(CONTROL) -DCTRL_SINE=0 -DCTRL_FOC=1 \
-mcpu=cortex-m3 -mthumb -std=gnu99 -ffunction-sections -fdata-sections
CPPFLAGS = -Os -ggdb3 -Wall -Wextra -Iinclude/ -Ilibopeninv/include -Ilibopencm3/include \
-fno-common -std=c++11 -pedantic -DSTM32F1 -DT_DEBUG=$(TERMINAL_DEBUG) \
-fno-common -std=c++14 -pedantic -DSTM32F1 -DT_DEBUG=$(TERMINAL_DEBUG) \
-DCONTROL=CTRL_$(CONTROL) -DCTRL_SINE=0 -DCTRL_FOC=1 \
-ffunction-sections -fdata-sections -fno-builtin -fno-rtti -fno-exceptions -fno-unwind-tables -mcpu=cortex-m3 -mthumb

Expand All @@ -51,7 +51,7 @@ OBJSL = stm32_sine.o hwinit.o stm32scheduler.o params.o terminal.o terminal_prj
my_string.o digio.o sine_core.o my_fp.o fu.o inc_encoder.o printf.o anain.o \
temp_meas.o param_save.o throttle.o errormessage.o pwmgeneration.o \
picontroller.o terminalcommands.o vehiclecontrol.o \
stm32_can.o canmap.o canhardware.o cansdo.o GD31xxOI.o
stm32_can.o canmap.o canhardware.o cansdo.o GD31xxOI.o crc8.o teslamodel3.o

ifeq ($(CONTROL), SINE)
OBJSL += pwmgeneration-sine.o
Expand Down
25 changes: 25 additions & 0 deletions include/digio_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
DIG_IO_ENTRY(v5_ctrl,,,) \
DIG_IO_ENTRY(intb_in,,,) \
DIG_IO_ENTRY(inta_in,,,) \
DIG_IO_ENTRY(gate_cs_hi,,,) \
DIG_IO_ENTRY(gate_sd_hi,,,) \

//...Then we assign the physical GPIOs per variant

Expand Down Expand Up @@ -91,6 +93,29 @@
DIG_IO_ENTRY(intb_in, GPIOE, GPIO8, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(inta_in, GPIOE, GPIO9, PinMode::INPUT_FLT) \

#define DIG_IO_LIST_TESLAM3 \
DIG_IO_ENTRY(cruise_in, GPIOB, GPIO2, PinMode::INPUT_PD) \
DIG_IO_ENTRY(start_in, GPIOD, GPIO7, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(brake_in, GPIOE, GPIO4, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(mprot_in, GPIOE, GPIO5, PinMode::INPUT_PU) \
DIG_IO_ENTRY(fwd_in, GPIOA, GPIO4, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(rev_in, GPIOA, GPIO3, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(emcystop_in, GPIOC, GPIO7, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(bk_in, GPIOB, GPIO12, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(bms_in, GPIOC, GPIO8, PinMode::INPUT_PD) \
DIG_IO_ENTRY(ocur_in, GPIOE, GPIO2, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(desat_in, GPIOC, GPIO9, PinMode::INPUT_FLT) \
DIG_IO_ENTRY(dcsw_out, GPIOC, GPIO10, PinMode::OUTPUT) \
DIG_IO_ENTRY(fan_out, GPIOC, GPIO15, PinMode::OUTPUT) /* map to unused pin by default */ \
DIG_IO_ENTRY(vtg_out, GPIOC, GPIO14, PinMode::OUTPUT) \
DIG_IO_ENTRY(prec_out, GPIOD, GPIO15, PinMode::OUTPUT) \
DIG_IO_ENTRY(led_out, GPIOC, GPIO12, PinMode::OUTPUT) \
DIG_IO_ENTRY(err_out, GPIOD, GPIO14, PinMode::OUTPUT) \
DIG_IO_ENTRY(temp0_out, GPIOD, GPIO13, PinMode::OUTPUT) \
DIG_IO_ENTRY(speed_out, GPIOD, GPIO12, PinMode::OUTPUT) \
DIG_IO_ENTRY(brk_out, GPIOD, GPIO11, PinMode::OUTPUT) \
DIG_IO_ENTRY(gate_cs_hi, GPIOE, GPIO10, PinMode::OUTPUT) \
DIG_IO_ENTRY(gate_sd_hi, GPIOE, GPIO11, PinMode::OUTPUT) \

#define DIG_IO_BLUEPILL \
DIG_IO_ENTRY(brake_in, GPIOB, GPIO9, PinMode::INPUT_FLT) \
Expand Down
2 changes: 2 additions & 0 deletions include/errormessage_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
ERROR_MESSAGE_ENTRY(TMPMMAX, ERROR_DERATE) \
ERROR_MESSAGE_ENTRY(CANCRC, ERROR_STOP) \
ERROR_MESSAGE_ENTRY(CANCOUNTER, ERROR_STOP) \
ERROR_MESSAGE_ENTRY(GATEDRIVEINITFAIL, ERROR_STOP) \
ERROR_MESSAGE_ENTRY(GATEDRIVEFAULT, ERROR_STOP) \

#endif // ERRORMESSAGE_PRJ_H_INCLUDED
Loading
Loading