Skip to content

Commit

Permalink
On Prius inverters ignore break signal when ocurlim==-1
Browse files Browse the repository at this point in the history
New version semantics
  • Loading branch information
jsphuebner committed May 3, 2024
1 parent 0d1fb5a commit 3037f14
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ CPPFLAGS = -Os -ggdb3 -Wall -Wextra -Iinclude/ -Ilibopeninv/include -Ilibopen
-fno-common -std=c++11 -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

# Check if the variable GITHUB_RUN_NUMBER exists. When running on the github actions running, this
# variable is automatically available.
# Create a compiler define with the content of the variable. Or, if it does not exist, use replacement value 99999.
EXTRACOMPILERFLAGS = $(shell \
if [ -z "$$GITHUB_RUN_NUMBER" ]; then echo "-DGITHUB_RUN_NUMBER=0"; else echo "-DGITHUB_RUN_NUMBER=$$GITHUB_RUN_NUMBER"; fi )

LDSCRIPT = stm32_sine.ld
LDFLAGS = -Llibopencm3/lib -ggdb3 -T$(LDSCRIPT) -march=armv7 -nostartfiles -Wl,--gc-sections,-Map,linker.map
OBJSL = stm32_sine.o hwinit.o stm32scheduler.o params.o terminal.o terminal_prj.o \
Expand Down Expand Up @@ -116,7 +123,7 @@ $(OUT_DIR)/%.o: %.c Makefile

$(OUT_DIR)/%.o: %.cpp Makefile
@printf " CPP $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CPP) $(CPPFLAGS) -MMD -MP -o $@ -c $<
$(Q)$(CPP) $(CPPFLAGS) $(EXTRACOMPILERFLAGS) -MMD -MP -o $@ -c $<

clean:
@printf " CLEAN ${OUT_DIR}\n"
Expand Down
16 changes: 13 additions & 3 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define VER 5.33.R
#define VERSION 5.34

/* Entries should be ordered as follows:
1. Saveable parameters
Expand Down Expand Up @@ -295,10 +295,20 @@
#define CAN_PERIOD_100MS 0
#define CAN_PERIOD_10MS 1

#define PARAM_ID_SUM_START_OFFSET GITHUB_RUN_NUMBER

#if GITHUB_RUN_NUMBER == 0 //local build
#define VER(G) VERSION.R
#else //github runner build
#define VER(G) VERSION.##G.B
#endif

#define VER2(G) VER(G)

#if CONTROL == CTRL_SINE
#define VERSTR STRINGIFY(4=VER-sine)
#define VERSTR STRINGIFY(4=VER2(GITHUB_RUN_NUMBER)-sine)
#elif CONTROL == CTRL_FOC
#define VERSTR STRINGIFY(4=VER-foc)
#define VERSTR STRINGIFY(4=VER2(GITHUB_RUN_NUMBER)-foc)
#endif // CONTROL

enum cruisemodes
Expand Down
2 changes: 1 addition & 1 deletion libopeninv
4 changes: 4 additions & 0 deletions src/pwmgeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ uint16_t PwmGeneration::TimerSetup(uint16_t deadtime, bool activeLow)
timer_set_break_polarity_high(PWM_TIMER);

timer_enable_break(PWM_TIMER);

if (hwRev == HW_PRIUS && Param::GetInt(Param::ocurlim) == -1)
timer_disable_break(PWM_TIMER);

timer_set_enabled_off_state_in_run_mode(PWM_TIMER);
timer_set_enabled_off_state_in_idle_mode(PWM_TIMER);
timer_set_deadtime(PWM_TIMER, deadtime);
Expand Down

0 comments on commit 3037f14

Please sign in to comment.