diff --git a/Makefile b/Makefile
index dd03313..1088272 100644
--- a/Makefile
+++ b/Makefile
@@ -31,20 +31,20 @@ OBJDUMP = $(PREFIX)-objdump
MKDIR_P = mkdir -p
TERMINAL_DEBUG ?= 0
CFLAGS = -Os -ggdb3 -Wall -Wextra -Iinclude/ -Ilibopeninv/include -Ilibopencm3/include \
- -fno-common -fno-builtin -pedantic -DSTM32F1 -DT_DEBUG=$(TERMINAL_DEBUG) \
- -DCONTROL=CTRL_$(CONTROL) -DCTRL_SINE=0 -DCTRL_FOC=1 \
- -mcpu=cortex-m3 -mthumb -std=gnu99 -ffunction-sections -fdata-sections
+ -fno-common -fno-builtin -pedantic -DSTM32F1 -DT_DEBUG=$(TERMINAL_DEBUG) \
+ -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) \
- -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
+ -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
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 \
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
+ stm32_can.o canmap.o canhardware.o cansdo.o
ifeq ($(CONTROL), SINE)
OBJSL += pwmgeneration-sine.o
diff --git a/include/param_prj.h b/include/param_prj.h
index ae73d16..195c298 100644
--- a/include/param_prj.h
+++ b/include/param_prj.h
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#define VER 5.29.R
+#define VER 5.32.R
/* Entries should be ordered as follows:
1. Saveable parameters
diff --git a/libopeninv b/libopeninv
index 2546170..3e70495 160000
--- a/libopeninv
+++ b/libopeninv
@@ -1 +1 @@
-Subproject commit 2546170a6eedb049505e1dc4305982803ce12f3c
+Subproject commit 3e704952f9ee74d790ee01abcc66e46642787dc0
diff --git a/sinus.cbp b/sinus.cbp
index 792d55d..62c95c7 100644
--- a/sinus.cbp
+++ b/sinus.cbp
@@ -77,6 +77,7 @@
+
@@ -100,6 +101,7 @@
+
diff --git a/src/stm32_sine.cpp b/src/stm32_sine.cpp
index a8c296b..8d309f7 100644
--- a/src/stm32_sine.cpp
+++ b/src/stm32_sine.cpp
@@ -45,6 +45,7 @@
#include "vehiclecontrol.h"
#include "stm32_can.h"
#include "canmap.h"
+#include "cansdo.h"
#define PRINT_JSON 0
@@ -53,6 +54,7 @@ HWREV hwRev; //Hardware variant of board we are running on
static Stm32Scheduler* scheduler;
static CanHardware* can;
static CanMap* canMap;
+static CanSdo* canSdo;
static Terminal* terminal;
static bool seenBrakePedal = false;
@@ -289,7 +291,7 @@ void Param::Change(Param::PARAM_NUM paramNum)
Throttle::brkmax = Param::GetFloat(Param::offthrotregen);
break;
case Param::nodeid:
- canMap->SetNodeId(Param::GetInt(Param::nodeid));
+ canSdo->SetNodeId(Param::GetInt(Param::nodeid));
//terminal->SetNodeId(Param::GetInt(Param::nodeid));
break;
default:
@@ -397,8 +399,10 @@ extern "C" int main(void)
scheduler = &s;
Stm32Can c(CAN1, (CanHardware::baudrates)Param::GetInt(Param::canspeed));
CanMap cm(&c);
+ CanSdo sdo(&c, &cm);
can = &c;
canMap = &cm;
+ canSdo = &sdo;
VehicleControl::SetCan(can);
TerminalCommands::SetCanMap(canMap);
@@ -423,10 +427,10 @@ extern "C" int main(void)
{
char c = 0;
t.Run();
- if (canMap->GetPrintRequest() == PRINT_JSON)
+ if (canSdo->GetPrintRequest() == PRINT_JSON)
{
- TerminalCommands::PrintParamsJson(canMap, &c);
- canMap->SignalPrintComplete();
+ TerminalCommands::PrintParamsJson(canSdo, &c);
+ canSdo->SignalPrintComplete();
}
}
diff --git a/src/vehiclecontrol.cpp b/src/vehiclecontrol.cpp
index b7ceecf..fe571d7 100644
--- a/src/vehiclecontrol.cpp
+++ b/src/vehiclecontrol.cpp
@@ -58,7 +58,7 @@ void VehicleControl::SetCan(CanHardware* canHw)
seqCounter = 0; //Mainly useful for unit tests
canErrors = 0;
can = canHw;
- can->AddReceiveCallback(&callback);
+ can->AddCallback(&callback);
CanClear();
}
@@ -116,7 +116,7 @@ bool VehicleControl::CanReceive(uint32_t canId, uint32_t data[2])
lastCanRxTime = rtc_get_counter_val();
Param::SetInt(Param::canio, canio);
- Param::SetInt(Param::regenpreset, regenpreset);
+ Param::SetInt(Param::regenpreset, MIN(100, regenpreset));
if ((Param::GetInt(Param::potmode) & POTMODE_CAN) > 0)
{
@@ -315,11 +315,11 @@ float VehicleControl::ProcessThrottle()
else //inconsistency here: in slip control negative always means regen
finalSpnt *= Param::GetInt(Param::dir);
- //At 110% fmax start derating field weakening current just in case it has a torque producing current
+ //At 110% fmax start derating field weakening current just in case it has a torque producing component
Throttle::fmax = Param::GetFloat(Param::fmax) * 1.1f;
float fwPercent = 100;
Throttle::FrequencyLimitCommand(fwPercent, fstat);
- PwmGeneration::SetFwCurMax(fwPercent * Param::GetFloat(Param::fwcurmax));
+ PwmGeneration::SetFwCurMax(fwPercent * Param::GetFloat(Param::fwcurmax) / 100.0f);
#endif // CONTROL
}