diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvoptx b/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvoptx
index 864f58607f..085cfd003c 100644
--- a/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvoptx
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvoptx
@@ -259,244 +259,6 @@
-
- appl-can-ulpro
- 0x4
- ARM-ADS
-
- 12000000
-
- 1
- 1
- 0
- 1
- 0
-
-
- 1
- 65535
- 0
- 0
- 0
-
-
- 79
- 66
- 8
- .\lst\
-
-
- 1
- 1
- 1
- 0
- 1
- 1
- 0
- 1
- 0
- 0
- 0
- 0
-
-
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 0
-
-
- 1
- 0
- 1
-
- 18
-
- 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 1
- 1
- 1
- 1
- 0
- 0
- 1
- 0
- 0
- 6
-
-
-
-
-
-
-
-
-
-
- STLink\ST-LINKIII-KEIL_SWO.dll
-
-
-
- 0
- ULP2CM3
- -UP0948199 -O206 -S8 -C0 -P00000003 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO65554 -TC200000000 -TT10000000 -TP18 -TDX0 -TDD0 -TDS8000 -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
-
-
- 0
- UL2CM3
- UL2CM3(-S0 -C0 -P0 ) -FN1 -FC8000 -FD10000000 -FF0STM32H7x_2048 -FL0200000 -FS08000000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
-
-
- 0
- ST-LINKIII-KEIL_SWO
- -U005700373137510539383538 -O462 -SF24000 -C0 -A3 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO19 -TC200000000 -TT400000000 -TP21 -TDS8021 -TDT0 -TDC1F -TIE80000000 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
-
-
- 0
- ARMRTXEVENTFLAGS
- -L200 -Z14 -C0 -M1 -T1
-
-
- 0
- DLGTARM
- (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)
-
-
- 0
- ARMDBGFLAGS
-
-
-
- 0
- DLGUARM
- (105=-1,-1,-1,-1,0)
-
-
-
-
-
- 0
- 1
- signalled
-
-
- 1
- 1
- TXreceivedback
-
-
- 2
- 1
- tde.str
-
-
- 3
- 1
- tout,0x0A
-
-
- 4
- 1
- replyinfo
-
-
- 5
- 1
- dd
-
-
-
-
- 0
- 2
- osRtxInfo
-
-
-
-
- 1
- 0
- 0x5C004000
- 0
-
-
-
- 0
-
-
- 0
- 1
- 0
- 0
- 0
- 0
- 0
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 1
- 1
- 0
- 0
- 0
-
-
-
- 0
- 0
- 0
-
-
-
-
-
-
-
-
-
-
- OS Support\Event Viewer
- 35905
-
-
-
- 0
- 0
- 0
- 2
- 10000000
-
-
-
-
appl-can-ulpro
0x4
@@ -596,7 +358,7 @@
0
ULP2CM3
- -UP0948193 -O462 -S12 -C0 -P00000003 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO32787 -TC200000000 -TT400000000 -TP18 -TDX0 -TDD0 -TDS8001 -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
+ -UP1123199 -O462 -S12 -C0 -P00000003 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO32819 -TC200000000 -TT400000000 -TP18 -TDX0 -TDD0 -TDS8001 -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
0
@@ -606,12 +368,12 @@
0
ST-LINKIII-KEIL_SWO
- -U005700373137510539383538 -O206 -SF10000 -C0 -A3 -I2 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO19 -TC200000000 -TT64000000 -TP21 -TDS8005 -TDT0 -TDC1F -TIE80000003 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
+ -U005700373137510539383538 -O462 -SF24000 -C0 -A3 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO19 -TC200000000 -TT400000000 -TP21 -TDS8021 -TDT0 -TDC1F -TIE80000000 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
0
ARMRTXEVENTFLAGS
- -L200 -Z23 -C0 -M1 -T1
+ -L200 -Z11 -C0 -M1 -T1
0
@@ -634,22 +396,12 @@
0
1
- signalled
+ PPP
1
1
- TXreceivedback
-
-
- 2
- 1
- tde.str
-
-
- 3
- 1
- tout,0x0A
+ activated
@@ -709,12 +461,6 @@
-
-
- OS Support\Event Viewer
- 35905
-
-
0
0
@@ -732,10 +478,10 @@
12000000
- 1
+ 0
1
- 0
- 1
+ 1
+ 0
0
@@ -777,14 +523,14 @@
0
- 1
+ 0
0
0
18
- 0
- 1
+ 1
+ 0
1
1
1
@@ -793,7 +539,7 @@
1
1
1
- 1
+ 0
1
1
1
@@ -807,91 +553,32 @@
1
0
0
- 6
+ -1
-
-
-
-
- STLink\ST-LINKIII-KEIL_SWO.dll
-
-
-
- 0
- ULP2CM3
- -UP0948199 -O206 -S8 -C0 -P00000003 -N00("ARM CoreSight SW-DP") -D00(6BA02477) -L00(0) -TO65555 -TC200000000 -TT10000000 -TP18 -TDX0 -TDD0 -TDS8000 -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
-
-
- 0
- UL2CM3
- UL2CM3(-S0 -C0 -P0 ) -FN1 -FC8000 -FD10000000 -FF0STM32H7x_2048 -FL0200000 -FS08000000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
-
-
- 0
- ST-LINKIII-KEIL_SWO
- -U002E00303137510A39383538 -O206 -SF10000 -C0 -A3 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(6BA02477) -L00(0) -TO131091 -TC200000000 -TT10000000 -TP21 -TDS8010 -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD10000000 -FC8000 -FN1 -FF0STM32H7x_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32H745IIKx$CMSIS\Flash\STM32H7x_2048.FLM)
-
-
- 0
- ARMRTXEVENTFLAGS
- -L200 -Z20 -C0 -M1 -T1
-
-
- 0
- DLGTARM
- (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)
-
-
- 0
- ARMDBGFLAGS
-
-
-
- 0
- DLGUARM
- (105=-1,-1,-1,-1,0)
-
-
+
+
+
+
+
+
-
-
- 0
- 1
- abs_pos,0x0A
-
-
-
-
- 0
- 2
- osRtxInfo
-
-
-
-
- 1
- 0
- 0x20003134
- 0
-
-
0
0
- 1
- 1
+ 0
+ 0
0
0
0
0
- 1
+ 0
0
0
0
@@ -903,7 +590,7 @@
0
0
0
- 1
+ 0
0
0
0
@@ -922,13 +609,6 @@
-
- 1
- 0
- 0
- 2
- 10000000
-
@@ -954,7 +634,7 @@
embot::app::board::amc2c
- 0
+ 1
0
0
0
@@ -1010,7 +690,7 @@
theMBD
- 1
+ 0
0
0
0
@@ -1490,7 +1170,7 @@
embot::hw::bsp
- 0
+ 1
0
0
0
@@ -1581,7 +1261,7 @@
- embot::os
+ motorhal
0
0
0
@@ -1593,8 +1273,8 @@
0
0
0
- ..\..\..\..\embot\os\embot_os.cpp
- embot_os.cpp
+ ..\..\bsp\motorhal\motorhal.cpp
+ motorhal.cpp
0
0
@@ -1605,8 +1285,8 @@
0
0
0
- ..\..\..\..\embot\os\embot_os_Action.cpp
- embot_os_Action.cpp
+ ..\..\bsp\motorhal\motorhal_config.c
+ motorhal_config.c
0
0
@@ -1617,8 +1297,8 @@
0
0
0
- ..\..\..\..\embot\os\embot_os_theCallbackManager.cpp
- embot_os_theCallbackManager.cpp
+ ..\..\bsp\motorhal\adcm.c
+ adcm.c
0
0
@@ -1629,8 +1309,8 @@
0
0
0
- ..\..\..\..\embot\os\embot_os_theScheduler.cpp
- embot_os_theScheduler.cpp
+ ..\..\bsp\motorhal\enc.c
+ enc.c
0
0
@@ -1641,8 +1321,8 @@
0
0
0
- ..\..\..\..\embot\os\embot_os_theTimerManager.cpp
- embot_os_theTimerManager.cpp
+ ..\..\bsp\motorhal\hall.c
+ hall.c
0
0
@@ -1653,8 +1333,8 @@
0
0
0
- ..\..\..\..\embot\os\embot_os_Thread.cpp
- embot_os_Thread.cpp
+ ..\..\bsp\motorhal\pwm.c
+ pwm.c
0
0
@@ -1665,31 +1345,31 @@
0
0
0
- ..\..\..\..\embot\os\embot_os_Timer.cpp
- embot_os_Timer.cpp
+ ..\..\bsp\motorhal\motorhal_faults.c
+ motorhal_faults.c
0
0
+
+
+
+ embot::os
+ 0
+ 0
+ 0
+ 0
- 13
+ 14
54
8
0
0
0
- ..\..\..\..\embot\os\embot_os_rtos.cpp
- embot_os_rtos.cpp
+ ..\..\..\..\embot\os\embot_os.cpp
+ embot_os.cpp
0
0
-
-
-
- embot::prot::can
- 0
- 0
- 0
- 0
14
55
@@ -1697,8 +1377,8 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can.cpp
- embot_prot_can.cpp
+ ..\..\..\..\embot\os\embot_os_Action.cpp
+ embot_os_Action.cpp
0
0
@@ -1709,8 +1389,8 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_analog_periodic.cpp
- embot_prot_can_analog_periodic.cpp
+ ..\..\..\..\embot\os\embot_os_theCallbackManager.cpp
+ embot_os_theCallbackManager.cpp
0
0
@@ -1721,8 +1401,8 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_analog_polling.cpp
- embot_prot_can_analog_polling.cpp
+ ..\..\..\..\embot\os\embot_os_theScheduler.cpp
+ embot_os_theScheduler.cpp
0
0
@@ -1733,8 +1413,8 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_bootloader.cpp
- embot_prot_can_bootloader.cpp
+ ..\..\..\..\embot\os\embot_os_theTimerManager.cpp
+ embot_os_theTimerManager.cpp
0
0
@@ -1745,8 +1425,8 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_inertial_periodic.cpp
- embot_prot_can_inertial_periodic.cpp
+ ..\..\..\..\embot\os\embot_os_Thread.cpp
+ embot_os_Thread.cpp
0
0
@@ -1757,8 +1437,8 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_motor_periodic.cpp
- embot_prot_can_motor_periodic.cpp
+ ..\..\..\..\embot\os\embot_os_Timer.cpp
+ embot_os_Timer.cpp
0
0
@@ -1769,120 +1449,132 @@
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_motor_polling.cpp
- embot_prot_can_motor_polling.cpp
+ ..\..\..\..\embot\os\embot_os_rtos.cpp
+ embot_os_rtos.cpp
0
0
+
+
+
+ embot::prot::can
+ 0
+ 0
+ 0
+ 0
- 14
+ 15
62
8
0
0
0
- ..\..\..\..\embot\prot\can\embot_prot_can_skin_periodic.cpp
- embot_prot_can_skin_periodic.cpp
+ ..\..\..\..\embot\prot\can\embot_prot_can.cpp
+ embot_prot_can.cpp
0
0
-
-
-
- others-cmsis-math
- 0
- 0
- 0
- 0
15
63
- 4
+ 8
0
0
0
- ..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Lib\ARM\arm_cortexM4lf_math.lib
- arm_cortexM4lf_math.lib
+ ..\..\..\..\embot\prot\can\embot_prot_can_analog_periodic.cpp
+ embot_prot_can_analog_periodic.cpp
0
0
-
-
-
- others::motorhal
- 0
- 0
- 0
- 0
- 16
+ 15
64
8
0
0
0
- ..\..\bsp\motorhal\motorhal.cpp
- motorhal.cpp
+ ..\..\..\..\embot\prot\can\embot_prot_can_analog_polling.cpp
+ embot_prot_can_analog_polling.cpp
0
0
- 16
+ 15
65
8
0
0
0
- ..\..\bsp\motorhal\motorhal_config.c
- motorhal_config.c
+ ..\..\..\..\embot\prot\can\embot_prot_can_bootloader.cpp
+ embot_prot_can_bootloader.cpp
0
0
- 16
+ 15
66
8
0
0
0
- ..\..\bsp\motorhal\adcm.c
- adcm.c
+ ..\..\..\..\embot\prot\can\embot_prot_can_inertial_periodic.cpp
+ embot_prot_can_inertial_periodic.cpp
0
0
- 16
+ 15
67
8
0
0
0
- ..\..\bsp\motorhal\enc.c
- enc.c
+ ..\..\..\..\embot\prot\can\embot_prot_can_motor_periodic.cpp
+ embot_prot_can_motor_periodic.cpp
0
0
- 16
+ 15
68
8
0
0
0
- ..\..\bsp\motorhal\hall.c
- hall.c
+ ..\..\..\..\embot\prot\can\embot_prot_can_motor_polling.cpp
+ embot_prot_can_motor_polling.cpp
0
0
- 16
+ 15
69
8
0
0
0
- ..\..\bsp\motorhal\pwm.c
- pwm.c
+ ..\..\..\..\embot\prot\can\embot_prot_can_skin_periodic.cpp
+ embot_prot_can_skin_periodic.cpp
+ 0
+ 0
+
+
+
+
+ others-cmsis-math
+ 0
+ 0
+ 0
+ 0
+
+ 16
+ 70
+ 4
+ 0
+ 0
+ 0
+ ..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Lib\ARM\arm_cortexM4lf_math.lib
+ arm_cortexM4lf_math.lib
0
0
@@ -1896,120 +1588,120 @@
0
17
- 70
+ 71
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\const_params.cpp
+ ..\src\model-based-design\sharedutils\const_params.cpp
const_params.cpp
0
0
17
- 71
+ 72
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
rt_hypotf_snf.cpp
0
0
17
- 72
+ 73
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_nonfinite.cpp
+ ..\src\model-based-design\sharedutils\rt_nonfinite.cpp
rt_nonfinite.cpp
0
0
17
- 73
+ 74
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_roundd_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_roundd_snf.cpp
rt_roundd_snf.cpp
0
0
17
- 74
+ 75
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetInf.cpp
+ ..\src\model-based-design\sharedutils\rtGetInf.cpp
rtGetInf.cpp
0
0
17
- 75
+ 76
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetNaN.cpp
+ ..\src\model-based-design\sharedutils\rtGetNaN.cpp
rtGetNaN.cpp
0
0
17
- 76
+ 77
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWord2Double.cpp
+ ..\src\model-based-design\sharedutils\uMultiWord2Double.cpp
uMultiWord2Double.cpp
0
0
17
- 77
+ 78
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWordShl.cpp
+ ..\src\model-based-design\sharedutils\uMultiWordShl.cpp
uMultiWordShl.cpp
0
0
17
- 78
+ 79
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
+ ..\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
rtw_enable_disable_motors.c
0
0
17
- 79
+ 80
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_motor_config.c
+ ..\src\model-based-design\sharedutils\rtw_motor_config.c
rtw_motor_config.c
0
0
@@ -2024,12 +1716,12 @@
0
18
- 80
+ 81
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\can-encoder\can_encoder.cpp
+ ..\src\model-based-design\can-encoder\can_encoder.cpp
can_encoder.cpp
0
0
@@ -2044,12 +1736,12 @@
0
19
- 81
+ 82
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\can-decoder\can_decoder.cpp
+ ..\src\model-based-design\can-decoder\can_decoder.cpp
can_decoder.cpp
0
0
@@ -2064,24 +1756,24 @@
0
20
- 82
+ 83
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
SupervisorFSM_RX.cpp
0
0
20
- 83
+ 84
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
SupervisorFSM_RX_data.cpp
0
0
@@ -2096,12 +1788,12 @@
0
21
- 84
+ 85
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
+ ..\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
SupervisorFSM_TX.cpp
0
0
@@ -2116,12 +1808,12 @@
0
22
- 85
+ 86
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\control-outer\control_outer.cpp
+ ..\src\model-based-design\control-outer\control_outer.cpp
control_outer.cpp
0
0
@@ -2136,36 +1828,36 @@
0
23
- 86
+ 87
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc.cpp
+ ..\src\model-based-design\control-foc\control_foc.cpp
control_foc.cpp
0
0
23
- 87
+ 88
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc_data.cpp
+ ..\src\model-based-design\control-foc\control_foc_data.cpp
control_foc_data.cpp
0
0
23
- 88
+ 89
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\FOCInnerLoop.cpp
+ ..\src\model-based-design\control-foc\FOCInnerLoop.cpp
FOCInnerLoop.cpp
0
0
@@ -2180,12 +1872,12 @@
0
24
- 89
+ 90
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\estimator\estimation_velocity.cpp
+ ..\src\model-based-design\estimator\estimation_velocity.cpp
estimation_velocity.cpp
0
0
@@ -2200,12 +1892,12 @@
0
25
- 90
+ 91
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\filter-current\filter_current.cpp
+ ..\src\model-based-design\filter-current\filter_current.cpp
filter_current.cpp
0
0
@@ -2220,12 +1912,12 @@
0
26
- 91
+ 92
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\amc-bldc\AMC_BLDC.cpp
+ ..\src\model-based-design\amc-bldc\AMC_BLDC.cpp
AMC_BLDC.cpp
0
0
@@ -2240,12 +1932,12 @@
0
27
- 92
+ 93
8
0
0
0
- ..\..\..\amcbldc\application\src\model-based-design\thermal-model\thermal_model.cpp
+ ..\src\model-based-design\thermal-model\thermal_model.cpp
thermal_model.cpp
0
0
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvprojx b/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvprojx
index d788552c2d..736b350e2d 100644
--- a/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvprojx
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/proj/amc2c-appl-can.uvprojx
@@ -340,7 +340,7 @@
-Wno-pragma-pack -Wno-deprecated-register -DEMBOT_USE_rtos_osal
USE_STM32HAL STM32HAL_BOARD_AMC2C STM32HAL_DRIVER_V1A0
- ..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot\app;..\..\..\..\embot\app;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\highlevel\services\embenv\api;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\bsp;..\..\..\..\embot\app\eth;..\..\..\..\embot\app\bldc;..\src\app-board-amc2c;..\..\..\amcbldc\application\src\model-based-design\sharedutils;..\..\..\amcbldc\application\src\model-based-design\can-decoder;..\..\..\amcbldc\application\src\model-based-design\can-encoder;..\..\..\amcbldc\application\src\model-based-design\supervisor-rx;..\..\..\amcbldc\application\src\model-based-design\supervisor-tx;..\..\..\amcbldc\application\src\model-based-design\control-outer;..\..\..\amcbldc\application\src\model-based-design\control-foc;..\..\..\amcbldc\application\src\model-based-design\estimator;..\..\..\amcbldc\application\src\model-based-design\amc-bldc;..\..\..\amcbldc\application\src\model-based-design\filter-current;..\..\..\amcbldc\application\src\model-based-design\thermal-model;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\bsp\motorhal
+ ..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot\app;..\..\..\..\embot\app;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\highlevel\services\embenv\api;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\bsp;..\..\..\..\embot\app\eth;..\..\..\..\embot\app\bldc;..\src\app-board-amc2c;..\src\model-based-design\sharedutils;..\src\model-based-design\can-decoder;..\src\model-based-design\can-encoder;..\src\model-based-design\supervisor-rx;..\src\model-based-design\supervisor-tx;..\src\model-based-design\control-outer;..\src\model-based-design\control-foc;..\src\model-based-design\estimator;..\src\model-based-design\amc-bldc;..\src\model-based-design\filter-current;..\src\model-based-design\thermal-model;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\bsp\motorhal
@@ -893,6 +893,46 @@
+
+ motorhal
+
+
+ motorhal.cpp
+ 8
+ ..\..\bsp\motorhal\motorhal.cpp
+
+
+ motorhal_config.c
+ 8
+ ..\..\bsp\motorhal\motorhal_config.c
+
+
+ adcm.c
+ 8
+ ..\..\bsp\motorhal\adcm.c
+
+
+ enc.c
+ 8
+ ..\..\bsp\motorhal\enc.c
+
+
+ hall.c
+ 8
+ ..\..\bsp\motorhal\hall.c
+
+
+ pwm.c
+ 8
+ ..\..\bsp\motorhal\pwm.c
+
+
+ motorhal_faults.c
+ 8
+ ..\..\bsp\motorhal\motorhal_faults.c
+
+
+
embot::os
@@ -993,93 +1033,58 @@
-
- others::motorhal
-
-
- motorhal.cpp
- 8
- ..\..\bsp\motorhal\motorhal.cpp
-
-
- motorhal_config.c
- 8
- ..\..\bsp\motorhal\motorhal_config.c
-
-
- adcm.c
- 8
- ..\..\bsp\motorhal\adcm.c
-
-
- enc.c
- 8
- ..\..\bsp\motorhal\enc.c
-
-
- hall.c
- 8
- ..\..\bsp\motorhal\hall.c
-
-
- pwm.c
- 8
- ..\..\bsp\motorhal\pwm.c
-
-
-
mbd
const_params.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\const_params.cpp
+ ..\src\model-based-design\sharedutils\const_params.cpp
rt_hypotf_snf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
rt_nonfinite.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_nonfinite.cpp
+ ..\src\model-based-design\sharedutils\rt_nonfinite.cpp
rt_roundd_snf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_roundd_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_roundd_snf.cpp
rtGetInf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetInf.cpp
+ ..\src\model-based-design\sharedutils\rtGetInf.cpp
rtGetNaN.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetNaN.cpp
+ ..\src\model-based-design\sharedutils\rtGetNaN.cpp
uMultiWord2Double.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWord2Double.cpp
+ ..\src\model-based-design\sharedutils\uMultiWord2Double.cpp
uMultiWordShl.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWordShl.cpp
+ ..\src\model-based-design\sharedutils\uMultiWordShl.cpp
rtw_enable_disable_motors.c
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
+ ..\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
rtw_motor_config.c
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_motor_config.c
+ ..\src\model-based-design\sharedutils\rtw_motor_config.c
@@ -1089,7 +1094,7 @@
can_encoder.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\can-encoder\can_encoder.cpp
+ ..\src\model-based-design\can-encoder\can_encoder.cpp
@@ -1099,7 +1104,7 @@
can_decoder.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\can-decoder\can_decoder.cpp
+ ..\src\model-based-design\can-decoder\can_decoder.cpp
@@ -1109,12 +1114,12 @@
SupervisorFSM_RX.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
SupervisorFSM_RX_data.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
@@ -1124,7 +1129,7 @@
SupervisorFSM_TX.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
+ ..\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
@@ -1134,7 +1139,7 @@
control_outer.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-outer\control_outer.cpp
+ ..\src\model-based-design\control-outer\control_outer.cpp
@@ -1144,17 +1149,17 @@
control_foc.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc.cpp
+ ..\src\model-based-design\control-foc\control_foc.cpp
control_foc_data.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc_data.cpp
+ ..\src\model-based-design\control-foc\control_foc_data.cpp
FOCInnerLoop.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\FOCInnerLoop.cpp
+ ..\src\model-based-design\control-foc\FOCInnerLoop.cpp
@@ -1164,7 +1169,7 @@
estimation_velocity.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\estimator\estimation_velocity.cpp
+ ..\src\model-based-design\estimator\estimation_velocity.cpp
@@ -1174,7 +1179,7 @@
filter_current.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\filter-current\filter_current.cpp
+ ..\src\model-based-design\filter-current\filter_current.cpp
@@ -1184,7 +1189,7 @@
AMC_BLDC.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\amc-bldc\AMC_BLDC.cpp
+ ..\src\model-based-design\amc-bldc\AMC_BLDC.cpp
@@ -1194,7 +1199,7 @@
thermal_model.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\thermal-model\thermal_model.cpp
+ ..\src\model-based-design\thermal-model\thermal_model.cpp
@@ -1243,7 +1248,7 @@
1
.\obj\
- amc2c
+ amc2c_can
1
0
1
@@ -1274,9 +1279,9 @@
0
- 0
+ 1
0
-
+ cmd.exe /C copy .\obj\amc2c_can.hex ..\bin\amc2c.can.hex
0
0
@@ -1508,7 +1513,7 @@
1
- 5
+ 6
0
0
1
@@ -1534,7 +1539,7 @@
-Wno-pragma-pack -Wno-deprecated-register -DEMBOT_USE_rtos_osal
USE_STM32HAL STM32HAL_BOARD_AMC2C STM32HAL_DRIVER_V1A0
- ..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot\app;..\..\..\..\embot\app;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\highlevel\services\embenv\api;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\bsp;..\..\..\..\embot\app\eth;..\..\..\..\embot\app\bldc;..\src\app-board-amc2c;..\..\..\amcbldc\application\src\model-based-design\sharedutils;..\..\..\amcbldc\application\src\model-based-design\can-decoder;..\..\..\amcbldc\application\src\model-based-design\can-encoder;..\..\..\amcbldc\application\src\model-based-design\supervisor-rx;..\..\..\amcbldc\application\src\model-based-design\supervisor-tx;..\..\..\amcbldc\application\src\model-based-design\control-outer;..\..\..\amcbldc\application\src\model-based-design\control-foc;..\..\..\amcbldc\application\src\model-based-design\estimator;..\..\..\amcbldc\application\src\model-based-design\amc-bldc;..\..\..\amcbldc\application\src\model-based-design\filter-current;..\..\..\amcbldc\application\src\model-based-design\thermal-model;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\bsp\motorhal
+ ..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot\app;..\..\..\..\embot\app;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\highlevel\services\embenv\api;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\bsp;..\..\..\..\embot\app\eth;..\..\..\..\embot\app\bldc;..\src\app-board-amc2c;..\src\model-based-design\sharedutils;..\src\model-based-design\can-decoder;..\src\model-based-design\can-encoder;..\src\model-based-design\supervisor-rx;..\src\model-based-design\supervisor-tx;..\src\model-based-design\control-outer;..\src\model-based-design\control-foc;..\src\model-based-design\estimator;..\src\model-based-design\amc-bldc;..\src\model-based-design\filter-current;..\src\model-based-design\thermal-model;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\bsp\motorhal
@@ -2087,6 +2092,46 @@
+
+ motorhal
+
+
+ motorhal.cpp
+ 8
+ ..\..\bsp\motorhal\motorhal.cpp
+
+
+ motorhal_config.c
+ 8
+ ..\..\bsp\motorhal\motorhal_config.c
+
+
+ adcm.c
+ 8
+ ..\..\bsp\motorhal\adcm.c
+
+
+ enc.c
+ 8
+ ..\..\bsp\motorhal\enc.c
+
+
+ hall.c
+ 8
+ ..\..\bsp\motorhal\hall.c
+
+
+ pwm.c
+ 8
+ ..\..\bsp\motorhal\pwm.c
+
+
+ motorhal_faults.c
+ 8
+ ..\..\bsp\motorhal\motorhal_faults.c
+
+
+
embot::os
@@ -2187,93 +2232,58 @@
-
- others::motorhal
-
-
- motorhal.cpp
- 8
- ..\..\bsp\motorhal\motorhal.cpp
-
-
- motorhal_config.c
- 8
- ..\..\bsp\motorhal\motorhal_config.c
-
-
- adcm.c
- 8
- ..\..\bsp\motorhal\adcm.c
-
-
- enc.c
- 8
- ..\..\bsp\motorhal\enc.c
-
-
- hall.c
- 8
- ..\..\bsp\motorhal\hall.c
-
-
- pwm.c
- 8
- ..\..\bsp\motorhal\pwm.c
-
-
-
mbd
const_params.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\const_params.cpp
+ ..\src\model-based-design\sharedutils\const_params.cpp
rt_hypotf_snf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
rt_nonfinite.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_nonfinite.cpp
+ ..\src\model-based-design\sharedutils\rt_nonfinite.cpp
rt_roundd_snf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_roundd_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_roundd_snf.cpp
rtGetInf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetInf.cpp
+ ..\src\model-based-design\sharedutils\rtGetInf.cpp
rtGetNaN.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetNaN.cpp
+ ..\src\model-based-design\sharedutils\rtGetNaN.cpp
uMultiWord2Double.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWord2Double.cpp
+ ..\src\model-based-design\sharedutils\uMultiWord2Double.cpp
uMultiWordShl.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWordShl.cpp
+ ..\src\model-based-design\sharedutils\uMultiWordShl.cpp
rtw_enable_disable_motors.c
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
+ ..\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
rtw_motor_config.c
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_motor_config.c
+ ..\src\model-based-design\sharedutils\rtw_motor_config.c
@@ -2283,7 +2293,7 @@
can_encoder.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\can-encoder\can_encoder.cpp
+ ..\src\model-based-design\can-encoder\can_encoder.cpp
@@ -2293,7 +2303,7 @@
can_decoder.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\can-decoder\can_decoder.cpp
+ ..\src\model-based-design\can-decoder\can_decoder.cpp
@@ -2303,12 +2313,12 @@
SupervisorFSM_RX.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
SupervisorFSM_RX_data.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
@@ -2318,7 +2328,7 @@
SupervisorFSM_TX.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
+ ..\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
@@ -2328,7 +2338,7 @@
control_outer.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-outer\control_outer.cpp
+ ..\src\model-based-design\control-outer\control_outer.cpp
@@ -2338,17 +2348,17 @@
control_foc.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc.cpp
+ ..\src\model-based-design\control-foc\control_foc.cpp
control_foc_data.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc_data.cpp
+ ..\src\model-based-design\control-foc\control_foc_data.cpp
FOCInnerLoop.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\FOCInnerLoop.cpp
+ ..\src\model-based-design\control-foc\FOCInnerLoop.cpp
@@ -2358,7 +2368,7 @@
estimation_velocity.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\estimator\estimation_velocity.cpp
+ ..\src\model-based-design\estimator\estimation_velocity.cpp
@@ -2368,7 +2378,7 @@
filter_current.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\filter-current\filter_current.cpp
+ ..\src\model-based-design\filter-current\filter_current.cpp
@@ -2378,7 +2388,7 @@
AMC_BLDC.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\amc-bldc\AMC_BLDC.cpp
+ ..\src\model-based-design\amc-bldc\AMC_BLDC.cpp
@@ -2388,7 +2398,7 @@
thermal_model.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\thermal-model\thermal_model.cpp
+ ..\src\model-based-design\thermal-model\thermal_model.cpp
@@ -2728,7 +2738,7 @@
-Wno-pragma-pack -Wno-deprecated-register -DEMBOT_USE_rtos_osal
USE_STM32HAL STM32HAL_BOARD_AMC2C STM32HAL_DRIVER_V1A0 MOTORHALCONFIG_enabletests
- ..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot\app;..\..\..\..\embot\app;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\highlevel\services\embenv\api;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\bsp;..\..\..\..\embot\app\eth;..\..\..\..\embot\app\bldc;..\src\app-board-amc2c;..\..\..\amcbldc\application\src\model-based-design\sharedutils;..\..\..\amcbldc\application\src\model-based-design\can-decoder;..\..\..\amcbldc\application\src\model-based-design\can-encoder;..\..\..\amcbldc\application\src\model-based-design\supervisor-rx;..\..\..\amcbldc\application\src\model-based-design\supervisor-tx;..\..\..\amcbldc\application\src\model-based-design\control-outer;..\..\..\amcbldc\application\src\model-based-design\control-foc;..\..\..\amcbldc\application\src\model-based-design\estimator;..\..\..\amcbldc\application\src\model-based-design\amc-bldc;..\..\..\amcbldc\application\src\model-based-design\filter-current;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\bsp\motorhal
+ ..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot\app;..\..\..\..\embot\app;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\highlevel\services\embenv\api;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\bsp;..\..\..\..\embot\app\eth;..\..\..\..\embot\app\bldc;..\src\app-board-amc2c;..\src\model-based-design\sharedutils;..\src\model-based-design\can-decoder;..\src\model-based-design\can-encoder;..\src\model-based-design\supervisor-rx;..\src\model-based-design\supervisor-tx;..\src\model-based-design\control-outer;..\src\model-based-design\control-foc;..\src\model-based-design\estimator;..\src\model-based-design\amc-bldc;..\src\model-based-design\filter-current;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\bsp\motorhal
@@ -3230,6 +3240,46 @@
+
+ motorhal
+
+
+ motorhal.cpp
+ 8
+ ..\..\bsp\motorhal\motorhal.cpp
+
+
+ motorhal_config.c
+ 8
+ ..\..\bsp\motorhal\motorhal_config.c
+
+
+ adcm.c
+ 8
+ ..\..\bsp\motorhal\adcm.c
+
+
+ enc.c
+ 8
+ ..\..\bsp\motorhal\enc.c
+
+
+ hall.c
+ 8
+ ..\..\bsp\motorhal\hall.c
+
+
+ pwm.c
+ 8
+ ..\..\bsp\motorhal\pwm.c
+
+
+ motorhal_faults.c
+ 8
+ ..\..\bsp\motorhal\motorhal_faults.c
+
+
+
embot::os
@@ -3330,93 +3380,58 @@
-
- others::motorhal
-
-
- motorhal.cpp
- 8
- ..\..\bsp\motorhal\motorhal.cpp
-
-
- motorhal_config.c
- 8
- ..\..\bsp\motorhal\motorhal_config.c
-
-
- adcm.c
- 8
- ..\..\bsp\motorhal\adcm.c
-
-
- enc.c
- 8
- ..\..\bsp\motorhal\enc.c
-
-
- hall.c
- 8
- ..\..\bsp\motorhal\hall.c
-
-
- pwm.c
- 8
- ..\..\bsp\motorhal\pwm.c
-
-
-
mbd
const_params.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\const_params.cpp
+ ..\src\model-based-design\sharedutils\const_params.cpp
rt_hypotf_snf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_hypotf_snf.cpp
rt_nonfinite.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_nonfinite.cpp
+ ..\src\model-based-design\sharedutils\rt_nonfinite.cpp
rt_roundd_snf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rt_roundd_snf.cpp
+ ..\src\model-based-design\sharedutils\rt_roundd_snf.cpp
rtGetInf.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetInf.cpp
+ ..\src\model-based-design\sharedutils\rtGetInf.cpp
rtGetNaN.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtGetNaN.cpp
+ ..\src\model-based-design\sharedutils\rtGetNaN.cpp
uMultiWord2Double.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWord2Double.cpp
+ ..\src\model-based-design\sharedutils\uMultiWord2Double.cpp
uMultiWordShl.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\uMultiWordShl.cpp
+ ..\src\model-based-design\sharedutils\uMultiWordShl.cpp
rtw_enable_disable_motors.c
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
+ ..\src\model-based-design\sharedutils\rtw_enable_disable_motors.c
rtw_motor_config.c
8
- ..\..\..\amcbldc\application\src\model-based-design\sharedutils\rtw_motor_config.c
+ ..\src\model-based-design\sharedutils\rtw_motor_config.c
@@ -3426,7 +3441,7 @@
can_encoder.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\can-encoder\can_encoder.cpp
+ ..\src\model-based-design\can-encoder\can_encoder.cpp
@@ -3436,7 +3451,7 @@
can_decoder.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\can-decoder\can_decoder.cpp
+ ..\src\model-based-design\can-decoder\can_decoder.cpp
@@ -3446,12 +3461,12 @@
SupervisorFSM_RX.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX.cpp
SupervisorFSM_RX_data.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
+ ..\src\model-based-design\supervisor-rx\SupervisorFSM_RX_data.cpp
@@ -3461,7 +3476,7 @@
SupervisorFSM_TX.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
+ ..\src\model-based-design\supervisor-tx\SupervisorFSM_TX.cpp
@@ -3471,7 +3486,7 @@
control_outer.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-outer\control_outer.cpp
+ ..\src\model-based-design\control-outer\control_outer.cpp
@@ -3481,17 +3496,17 @@
control_foc.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc.cpp
+ ..\src\model-based-design\control-foc\control_foc.cpp
control_foc_data.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\control_foc_data.cpp
+ ..\src\model-based-design\control-foc\control_foc_data.cpp
FOCInnerLoop.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\control-foc\FOCInnerLoop.cpp
+ ..\src\model-based-design\control-foc\FOCInnerLoop.cpp
@@ -3501,7 +3516,7 @@
estimation_velocity.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\estimator\estimation_velocity.cpp
+ ..\src\model-based-design\estimator\estimation_velocity.cpp
@@ -3511,7 +3526,7 @@
filter_current.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\filter-current\filter_current.cpp
+ ..\src\model-based-design\filter-current\filter_current.cpp
@@ -3521,7 +3536,7 @@
AMC_BLDC.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\amc-bldc\AMC_BLDC.cpp
+ ..\src\model-based-design\amc-bldc\AMC_BLDC.cpp
@@ -3531,7 +3546,7 @@
thermal_model.cpp
8
- ..\..\..\amcbldc\application\src\model-based-design\thermal-model\thermal_model.cpp
+ ..\src\model-based-design\thermal-model\thermal_model.cpp
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_info.cpp b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_info.cpp
index d991f7f39b..47f694e186 100644
--- a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_info.cpp
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_info.cpp
@@ -28,13 +28,13 @@ namespace embot::app::board::amc2c::info {
constexpr embot::prot::can::applicationInfo applInfo
{
- embot::prot::can::versionOfAPPLICATION {100, 100, 0},
+ embot::prot::can::versionOfAPPLICATION {2, 0, 4},
embot::prot::can::versionOfCANPROTOCOL {2, 0}
};
constexpr embot::app::eth::Date date
{
- 2023, embot::app::eth::Month::Apr, embot::app::eth::Day::fourteen, 16, 54
+ 2023, embot::app::eth::Month::Oct, embot::app::eth::Day::sixteen, 15, 51
};
constexpr embot::hw::FLASHpartitionID codePartition
@@ -46,10 +46,19 @@ namespace embot::app::board::amc2c::info {
{
embot::hw::CAN::two
};
+
+ constexpr uint8_t canaddress {3};
+
+ // marco.accame: i use the macro INFO32 just because ... i want to init eEmoduleExtendedInfo_t::userdefined with the same string
+ // and i dont know how to fit it inside otherwise
+
+ // 0123456789abcde0123456789abcde
+ #define INFO32 "hi, i am an amc2c on CAN2:3"
- static const char *info32
+ constexpr const char *info32
{ // 0123456789abcde0123456789abcde
- "hi, i am an amc2c can"
+ //"hi, i am an amc2c CAN2:3"
+ INFO32
};
} // embot::app::board::amc2c::info {
@@ -74,7 +83,7 @@ namespace embot::app::board::amc2c::info {
if(!initted)
{
force_placement_of_moduleinfo();
- embot::app::board::amc2c::theCANagentCORE::getInstance().initialise({applInfo, canBus, info32});
+ embot::app::board::amc2c::theCANagentCORE::getInstance().initialise({applInfo, canBus, canaddress, info32});
initted = true;
}
return &embot::app::board::amc2c::theCANagentCORE::getInstance();
@@ -139,22 +148,23 @@ constexpr eEmoduleExtendedInfo_t s_cm4app_info_extended __attribute__((section(E
.size = 0,
.addr = 0
},
- .communication = ee_commtype_none,
+ .communication = ee_commtype_can2,
.name = "eOther01"
},
.protocols =
{
.udpprotversion = { .major = 0, .minor = 0},
.can1protversion = { .major = 0, .minor = 0},
- .can2protversion = { .major = 0, .minor = 0},
+ .can2protversion = { .major = 2, .minor = 0},
.gtwprotversion = { .major = 0, .minor = 0}
},
.extra = {"EXT"}
},
.compilationdatetime = __DATE__ " " __TIME__,
- .userdefined = {0}
+ .userdefined = {INFO32}
};
+
#include
eEmoduleExtendedInfo_t ss {};
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.cpp b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.cpp
index 2de3a5ce8d..d2636bc7cd 100644
--- a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.cpp
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.cpp
@@ -85,8 +85,10 @@ bool embot::app::board::amc2c::theCANagentCORE::Impl::initialise(const Config &c
std::memmove(_storedinfo.info32, _config.boardinfo, sizeof(_storedinfo.info32));
+ _storedinfo.canaddress = _config.canaddress;
+
_board = static_cast(_storedinfo.boardtype);
-// _address = _storedinfo.canaddress;
+
_applicationinfo.version.major = _storedinfo.applicationVmajor;
_applicationinfo.version.minor = _storedinfo.applicationVminor;
_applicationinfo.version.build = _storedinfo.applicationVbuild;
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.h b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.h
index d7696fa7aa..017c164148 100644
--- a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.h
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theCANagentCORE.h
@@ -28,10 +28,11 @@ namespace embot::app::board::amc2c {
{
embot::prot::can::applicationInfo applicationinfo {{0,0,1}, {2,0}};
embot::hw::CAN canbus {embot::hw::CAN::one};
+ uint8_t canaddress {3};
const char *boardinfo {"hello, i am an amc2c"};
constexpr Config() = default;
- constexpr Config(const embot::prot::can::applicationInfo& ai, embot::hw::CAN b, const char *bi)
- : applicationinfo(ai), canbus(b), boardinfo(bi) {}
+ constexpr Config(const embot::prot::can::applicationInfo& ai, embot::hw::CAN b, uint8_t ca, const char *bi)
+ : applicationinfo(ai), canbus(b), canaddress(ca), boardinfo(bi) {}
};
bool initialise(const Config &config);
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theMBD.cpp b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theMBD.cpp
index d19ddc3316..cc4154355a 100644
--- a/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theMBD.cpp
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/app-board-amc2c/embot_app_board_amc2c_theMBD.cpp
@@ -520,23 +520,17 @@ dbgFOCvalues dbgFOC {};
void embot::app::board::amc2c::theMBD::Impl::onCurrents_FOC_innerloop(void *owner, const embot::hw::motor::Currents * const currents)
{
- embot::hw::testpoint::on(tp2);
-
- //embot::hw::testpoint::on(tp2);
Impl * impl = reinterpret_cast(owner);
if((nullptr == impl) || (nullptr == currents))
{
return;
}
- impl->measureFOC->start();
+// impl->measureFOC->start();
// 1. copy currents straight away, so that we can use them
embot::hw::motor::Currents currs = *currents;
-#if defined(TEST_DURATION_FOC)
- embot::hw::sys::delay(25);
-#else
// remember to manage impl->EXTFAULTisPRESSED ............
@@ -568,78 +562,24 @@ void embot::app::board::amc2c::theMBD::Impl::onCurrents_FOC_innerloop(void *owne
AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[2] = 0.001f*currs.w;
// -----------------------------------------------------------------------------
- // FOC Step Function (~26.6 KHz)
+ // FOC Step Function (~16.6 KHz)
// -----------------------------------------------------------------------------
- AMC_BLDC_step_FOC();
+ AMC_BLDC_step1();
// -----------------------------------------------------------------------------
AMC_BLDC_U.SensorsData_p.jointpositions.position = static_cast(position) * 0.0054931640625f; // iCubDegree -> deg
- //constexpr float coneversion2pwmvalue (163.83F);
- constexpr float coneversion2pwmvalue (12.19F);
-
- // Set the voltages
- int32_T Vabc0 = static_cast(AMC_BLDC_Y.ControlOutputs_p.Vabc[0] * coneversion2pwmvalue);
- int32_T Vabc1 = static_cast(AMC_BLDC_Y.ControlOutputs_p.Vabc[1] * coneversion2pwmvalue);
- int32_T Vabc2 = static_cast(AMC_BLDC_Y.ControlOutputs_p.Vabc[2] * coneversion2pwmvalue);
-
-#if defined(TEST_FOC_logvalues)
- dbgFOC.currents = currs;
- dbgFOC.hall = hall;
- dbgFOC.electricalangle = electricalAngle;
- dbgFOC.position = position;
- dbgFOC.jointangle = static_cast(position) * 0.0054931640625f;
- dbgFOC.pwms = {Vabc0, Vabc1, Vabc2};
-
-#endif
- // TODO: Remove, used only for debug
- // 0% PWM value on phase Vabc2 = 0,0,0
- // 10% PWM value on phase Vabc2 = 0,0,122
- // 20% PWM value on phase Vabc2 = 0,0,244
- // 30% PWM value on phase Vabc2 = 0,0,366
-
- embot::hw::motor::setpwm(embot::hw::MOTOR::one, 0, 0, 122);
-
-
-//#define DEBUG_PARAMS
-#ifdef DEBUG_PARAMS
-
- static char msg2[64];
- static uint32_t counter;
- if(counter % 10 == 0)
+ embot::hw::motor::PWMperc pwmperc
{
- sprintf(msg2, "%d,%d,%d,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f", \
- Vabc0, \
- Vabc1, \
- Vabc2, \
- AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[0], \
- AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[1], \
- AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[2], \
- AMC_BLDC_U.SensorsData_p.motorsensors.angle, \
- AMC_BLDC_Y.EstimatedData_p.jointvelocities.velocity, \
- AMC_BLDC_B.Targets_n.motorcurrent.current, \
- AMC_BLDC_Y.ControlOutputs_p.Iq_fbk.current, \
- AMC_BLDC_Y.ControlOutputs_p.Vq);
-
-// sprintf(msg2, "%d,%d,%d,%.3f,%.3f,%.3f", \
-// Vabc0, \
-// Vabc1, \
-// Vabc2, \
-// AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[0], \
-// AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[1], \
-// AMC_BLDC_U.SensorsData_p.motorsensors.Iabc[2]);
- embot::core::print(msg2);
- counter = 0;
- }
- counter++;
-#endif
+ AMC_BLDC_Y.ControlOutputs_p.Vabc[0], AMC_BLDC_Y.ControlOutputs_p.Vabc[1], AMC_BLDC_Y.ControlOutputs_p.Vabc[2]
+ };
+ embot::hw::motor::setPWM(embot::hw::MOTOR::one, pwmperc);
+
-#endif // #if defined(TEST_DURATION_FOC)
- impl->measureFOC->stop();
- embot::hw::testpoint::off(tp2);
+// impl->measureFOC->stop();
}
#ifdef PRINT_HISTO_DEBUG
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC.cpp b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC.cpp
new file mode 100644
index 0000000000..aab5dce281
--- /dev/null
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC.cpp
@@ -0,0 +1,922 @@
+//
+// Non-Degree Granting Education License -- for use at non-degree
+// granting, nonprofit, education, and research organizations only. Not
+// for commercial or industrial use.
+//
+// File: AMC_BLDC.cpp
+//
+// Code generated for Simulink model 'AMC_BLDC'.
+//
+// Model version : 6.18
+// Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
+// C/C++ source code generated on : Mon Oct 16 10:09:05 2023
+//
+// Target selection: ert.tlc
+// Embedded hardware selection: ARM Compatible->ARM Cortex-M
+// Code generation objectives: Unspecified
+// Validation result: Not run
+//
+#include "AMC_BLDC.h"
+#include "rtw_mutex.h"
+#include "rtwtypes.h"
+#include "AMC_BLDC_types.h"
+#include "thermal_model.h"
+#include "estimation_velocity.h"
+#include "filter_current.h"
+#include "control_foc.h"
+#include "control_outer.h"
+#define can_decoder_MDLREF_HIDE_CHILD_
+#include "can_decoder.h"
+#define can_encoder_MDLREF_HIDE_CHILD_
+#include "can_encoder.h"
+#define SupervisorFSM_RX_MDLREF_HIDE_CHILD_
+#include "SupervisorFSM_RX.h"
+#define SupervisorFSM_TX_MDLREF_HIDE_CHILD_
+#include "SupervisorFSM_TX.h"
+
+// Exported block parameters
+ConfigurationParameters InitConfParams = {
+ {
+ true,
+ true,
+ false,
+ false,
+ true,
+ false,
+ 16000,
+ 0,
+ 0U,
+ 7U,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 44.0F,
+ 24.0F,
+ 25.9F,
+ 271.0F,
+ 16.0F,
+ 797.5F
+ },
+
+ {
+ EstimationVelocityModes_MovingAverage,
+ 0.9995F
+ },
+
+ {
+ 0.0F,
+ 0.0F,
+ 2.0F,
+ 500.0F,
+ 0.0F,
+ 10.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ },
+
+ {
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ },
+
+ {
+ 0.0F,
+ 0.0F,
+ -3.0e-5F,
+ -3.0e-5F,
+ 0.0F,
+ 10.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ },
+
+ {
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ },
+
+ {
+ 1.0F,
+ 359.0F,
+ 0.0F,
+ 360.0F,
+ 0.0F,
+ 0.0F,
+ 40000.0F,
+ 10U,
+ 2.0F,
+ 5.0F,
+ 10.0F,
+ 32000U,
+ 70.0F
+ },
+ 25.0F
+} ; // Variable: InitConfParams
+ // Referenced by: '/SupervisorFSM_RX'
+
+
+real32_T CAN_ANGLE_DEG2ICUB = 182.044449F;// Variable: CAN_ANGLE_DEG2ICUB
+ // Referenced by: '/CAN_Encoder'
+ // 2^16/360
+
+real32_T CAN_ANGLE_ICUB2DEG = 0.00549316406F;// Variable: CAN_ANGLE_ICUB2DEG
+ // Referenced by: '/CAN_Decoder'
+ // 360/2^16
+
+uint8_T CAN_ID_AMC = 3U; // Variable: CAN_ID_AMC
+ // Referenced by:
+ // '/CAN_Decoder'
+ // '/CAN_Encoder'
+ // 4 bits defining the ID of the AMC_BLDC board.
+
+
+// Block signals (default storage)
+B_AMC_BLDC_T AMC_BLDC_B;
+
+// Block states (default storage)
+DW_AMC_BLDC_T AMC_BLDC_DW;
+
+// External inputs (root inport signals with default storage)
+ExtU_AMC_BLDC_T AMC_BLDC_U;
+
+// External outputs (root outports fed by signals with default storage)
+ExtY_AMC_BLDC_T AMC_BLDC_Y;
+
+// Real-time model
+RT_MODEL_AMC_BLDC_T AMC_BLDC_M_ = RT_MODEL_AMC_BLDC_T();
+RT_MODEL_AMC_BLDC_T *const AMC_BLDC_M = &AMC_BLDC_M_;
+
+// Model step function for TID0
+void AMC_BLDC_step0(void) // Sample time: [2.0E-5s, 0.0s]
+{
+ // (no output/update code required)
+}
+
+// Model step function for TID1
+void AMC_BLDC_step1(void) // Sample time: [6.0E-5s, 0.0s]
+{
+ int8_T wrBufIdx;
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls;
+ rtw_mutex_unlock();
+ AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.flags =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD];
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls;
+ rtw_mutex_unlock();
+ AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.configurationparameters
+ =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD];
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls;
+ rtw_mutex_unlock();
+ AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.estimateddata
+ =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD];
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls;
+ rtw_mutex_unlock();
+ AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.targets =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD];
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls;
+ rtw_mutex_unlock();
+ AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.controlouteroutputs
+ =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD];
+
+ // ModelReference: '/FOC' incorporates:
+ // Inport generated from: '/In Bus Element6'
+ // Outport generated from: '/Out Bus Element'
+
+ control_foc(&AMC_BLDC_U.SensorsData_p,
+ &AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1,
+ &AMC_BLDC_Y.ControlOutputs_p, &(AMC_BLDC_DW.FOC_InstanceData.rtb),
+ &(AMC_BLDC_DW.FOC_InstanceData.rtdw),
+ &(AMC_BLDC_DW.FOC_InstanceData.rtzce));
+
+ // RateTransition generated from: '/Adapter1' incorporates:
+ // Outport generated from: '/Out Bus Element'
+
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ switch (wrBufIdx) {
+ case 0:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf0 =
+ AMC_BLDC_Y.ControlOutputs_p;
+ break;
+
+ case 1:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf1 =
+ AMC_BLDC_Y.ControlOutputs_p;
+ break;
+
+ case 2:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf2 =
+ AMC_BLDC_Y.ControlOutputs_p;
+ break;
+ }
+
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB =
+ wrBufIdx;
+
+ // End of RateTransition generated from: '/Adapter1'
+
+ // RateTransition generated from: '/Adapter3' incorporates:
+ // Inport generated from: '/In Bus Element6'
+
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ switch (wrBufIdx) {
+ case 0:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_e =
+ AMC_BLDC_U.SensorsData_p;
+ break;
+
+ case 1:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_c =
+ AMC_BLDC_U.SensorsData_p;
+ break;
+
+ case 2:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_j =
+ AMC_BLDC_U.SensorsData_p;
+ break;
+ }
+
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB =
+ wrBufIdx;
+
+ // End of RateTransition generated from: '/Adapter3'
+}
+
+// Model step function for TID2
+void AMC_BLDC_step_Time_1ms(void) // Sample time: [0.001s, 0.0s]
+{
+ // local block i/o variables
+ Targets rtb_SupervisorFSM_RX_o2;
+ ControlOuterOutputs rtb_OuterControl;
+ BUS_STATUS_TX rtb_SupervisorFSM_TX_o2;
+ int8_T wrBufIdx;
+
+ // UnitDelay generated from: '/Adapter4'
+ AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0 =
+ AMC_BLDC_DW.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;
+
+ // RateTransition generated from: '/Adapter3'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB;
+ rtw_mutex_unlock();
+ switch
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu) {
+ case 0:
+ // RateTransition generated from: '/Adapter3'
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_e;
+ break;
+
+ case 1:
+ // RateTransition generated from: '/Adapter3'
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_c;
+ break;
+
+ case 2:
+ // RateTransition generated from: '/Adapter3'
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_j;
+ break;
+ }
+
+ // End of RateTransition generated from: '/Adapter3'
+
+ // ModelReference: '/Estimation_Velocity'
+ estimation_velocity
+ (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
+ &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0,
+ &AMC_BLDC_Y.EstimatedData_p.jointvelocities,
+ &(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtdw));
+
+ // RateTransition generated from: '/Adapter1'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB;
+ rtw_mutex_unlock();
+ switch
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu) {
+ case 0:
+ // RateTransition generated from: '/Adapter1'
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf0;
+ break;
+
+ case 1:
+ // RateTransition generated from: '/Adapter1'
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf1;
+ break;
+
+ case 2:
+ // RateTransition generated from: '/Adapter1'
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf2;
+ break;
+ }
+
+ // End of RateTransition generated from: '/Adapter1'
+
+ // ModelReference: '/Filter_Current'
+ filter_current
+ (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0,
+ &AMC_BLDC_Y.EstimatedData_p.Iq_filtered,
+ &(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
+
+ // RateTransition generated from: '/Adapter1'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j;
+ rtw_mutex_unlock();
+ AMC_BLDC_Y.EstimatedData_p.motor_temperature =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a];
+
+ // ModelReference: '/CAN_Decoder' incorporates:
+ // Inport generated from: '/In Bus Element2'
+
+ can_decoder(&AMC_BLDC_U.PacketsRx,
+ &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0,
+ &AMC_BLDC_B.CAN_Decoder_o1, &AMC_BLDC_B.CAN_Decoder_o2,
+ &AMC_BLDC_B.CAN_Decoder_o3);
+
+ // ModelReference: '/SupervisorFSM_RX' incorporates:
+ // Inport generated from: '/In Bus Element'
+ // Outport generated from: '/Out Bus Element3'
+ // Outport generated from: '/Out Bus Element2'
+ // Outport generated from: '/Out Bus Element4'
+
+ SupervisorFSM_RX
+ (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
+ &AMC_BLDC_U.ExternalFlags_p,
+ &AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0,
+ &AMC_BLDC_B.CAN_Decoder_o1, &AMC_BLDC_Y.EstimatedData_p,
+ &AMC_BLDC_B.CAN_Decoder_o2, &AMC_BLDC_B.CAN_Decoder_o3, &AMC_BLDC_Y.Flags_p,
+ &rtb_SupervisorFSM_RX_o2, &AMC_BLDC_Y.ConfigurationParameters_p);
+
+ // ModelReference: '/SupervisorFSM_TX' incorporates:
+ // Outport generated from: '/Out Bus Element3'
+ // Outport generated from: '/Out Bus Element2'
+ // Outport generated from: '/Out Bus Element4'
+
+ SupervisorFSM_TX
+ (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
+ &AMC_BLDC_Y.EstimatedData_p, &AMC_BLDC_Y.Flags_p,
+ &AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0,
+ &AMC_BLDC_B.MessagesTx, &rtb_SupervisorFSM_TX_o2);
+
+ // ModelReference: '/CAN_Encoder' incorporates:
+ // Outport generated from: '/Out Bus Element1'
+
+ can_encoder(&AMC_BLDC_B.MessagesTx, &rtb_SupervisorFSM_TX_o2,
+ &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0,
+ &AMC_BLDC_Y.PacketsTx);
+
+ // ModelReference: '/OuterControl' incorporates:
+ // Outport generated from: '/Out Bus Element3'
+ // Outport generated from: '/Out Bus Element2'
+ // Outport generated from: '/Out Bus Element4'
+
+ control_outer(&AMC_BLDC_Y.Flags_p, &AMC_BLDC_Y.ConfigurationParameters_p,
+ &rtb_SupervisorFSM_RX_o2,
+ &AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
+ &AMC_BLDC_Y.EstimatedData_p, &rtb_OuterControl,
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtb),
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtdw),
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtzce));
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Bu[wrBufIdx]
+ = rtb_OuterControl;
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls =
+ wrBufIdx;
+
+ // RateTransition generated from: '/Adapter2' incorporates:
+ // Outport generated from: '/Out Bus Element4'
+
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Bu[wrBufIdx]
+ = AMC_BLDC_Y.Flags_p;
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls =
+ wrBufIdx;
+
+ // RateTransition generated from: '/Adapter2' incorporates:
+ // Outport generated from: '/Out Bus Element3'
+
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Bu[wrBufIdx]
+ = AMC_BLDC_Y.ConfigurationParameters_p;
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls =
+ wrBufIdx;
+
+ // RateTransition generated from: '/Adapter2'
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Bu[wrBufIdx]
+ = rtb_SupervisorFSM_RX_o2;
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls =
+ wrBufIdx;
+
+ // RateTransition generated from: '/Adapter2' incorporates:
+ // Outport generated from: '/Out Bus Element2'
+
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Bu[wrBufIdx]
+ = AMC_BLDC_Y.EstimatedData_p;
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls =
+ wrBufIdx;
+
+ // RateTransition generated from: '/Adapter3'
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Ls_g +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RD_p)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ switch (wrBufIdx) {
+ case 0:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf0 =
+ AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;
+ break;
+
+ case 1:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf1 =
+ AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;
+ break;
+
+ case 2:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf2 =
+ AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;
+ break;
+ }
+
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Ls_g =
+ wrBufIdx;
+
+ // End of RateTransition generated from: '/Adapter3'
+
+ // RateTransition generated from: '/Adapter'
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_LstBu +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_RDBuf)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ switch (wrBufIdx) {
+ case 0:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf0 =
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0;
+ break;
+
+ case 1:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf1 =
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0;
+ break;
+
+ case 2:
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf2 =
+ AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0;
+ break;
+ }
+
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_LstBu =
+ wrBufIdx;
+
+ // End of RateTransition generated from: '/Adapter'
+
+ // Update for UnitDelay generated from: '/Adapter4' incorporates:
+ // Outport generated from: '/Out Bus Element3'
+
+ AMC_BLDC_DW.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0 =
+ AMC_BLDC_Y.ConfigurationParameters_p;
+}
+
+// Model step function for TID3
+void AMC_BLDC_step_Time_10ms(void) // Sample time: [0.01s, 0.0s]
+{
+ // local block i/o variables
+ MotorTemperature rtb_Estimation_Temperature;
+ ConfigurationParameters
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0;
+ ControlOutputs rtb_RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0;
+ int8_T wrBufIdx;
+
+ // RateTransition generated from: '/Adapter'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_RDBuf =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_LstBu;
+ rtw_mutex_unlock();
+ switch
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_RDBuf) {
+ case 0:
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf0;
+ break;
+
+ case 1:
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf1;
+ break;
+
+ case 2:
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf2;
+ break;
+ }
+
+ // End of RateTransition generated from: '/Adapter'
+
+ // RateTransition generated from: '/Adapter3'
+ rtw_mutex_lock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RD_p =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Ls_g;
+ rtw_mutex_unlock();
+ switch
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RD_p) {
+ case 0:
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf0;
+ break;
+
+ case 1:
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf1;
+ break;
+
+ case 2:
+ rtb_RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf2;
+ break;
+ }
+
+ // End of RateTransition generated from: '/Adapter3'
+
+ // ModelReference: '/Estimation_Temperature'
+ thermal_model(&rtb_RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0,
+ &rtb_RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
+ &rtb_Estimation_Temperature,
+ &(AMC_BLDC_DW.Estimation_Temperature_InstanceData.rtdw));
+
+ // RateTransition generated from: '/Adapter1'
+ rtw_mutex_lock();
+ wrBufIdx = static_cast
+ (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j +
+ 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+
+ if (wrBufIdx ==
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a)
+ {
+ wrBufIdx = static_cast(wrBufIdx + 1);
+ if (wrBufIdx == 3) {
+ wrBufIdx = 0;
+ }
+ }
+
+ rtw_mutex_unlock();
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf[wrBufIdx]
+ = rtb_Estimation_Temperature;
+ AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j =
+ wrBufIdx;
+
+ // End of RateTransition generated from: '/Adapter1'
+}
+
+// Model initialize function
+void AMC_BLDC_initialize(void)
+{
+ // Model Initialize function for ModelReference Block: '/Estimation_Temperature'
+ thermal_model_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.Estimation_Temperature_InstanceData.rtm),
+ &(AMC_BLDC_DW.Estimation_Temperature_InstanceData.rtdw));
+
+ // Model Initialize function for ModelReference Block: '/Estimation_Velocity'
+ estimation_velocity_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtm),
+ &(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtdw));
+
+ // Model Initialize function for ModelReference Block: '/Filter_Current'
+ filter_current_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.Filter_Current_InstanceData.rtm),
+ &(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
+
+ // Model Initialize function for ModelReference Block: '/FOC'
+ control_foc_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.FOC_InstanceData.rtm), &(AMC_BLDC_DW.FOC_InstanceData.rtb),
+ &(AMC_BLDC_DW.FOC_InstanceData.rtdw), &(AMC_BLDC_DW.FOC_InstanceData.rtzce));
+
+ // Model Initialize function for ModelReference Block: '/CAN_Decoder'
+ can_decoder_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+
+ // Model Initialize function for ModelReference Block: '/CAN_Encoder'
+ can_encoder_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+
+ // Model Initialize function for ModelReference Block: '/OuterControl'
+ control_outer_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtm),
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtb),
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtdw),
+ &(AMC_BLDC_DW.OuterControl_InstanceData.rtzce));
+
+ // Model Initialize function for ModelReference Block: '/SupervisorFSM_RX'
+ SupervisorFSM_RX_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+
+ // Model Initialize function for ModelReference Block: '/SupervisorFSM_TX'
+ SupervisorFSM_TX_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+
+ // Start for RateTransition generated from: '/Adapter2'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter2'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter2'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter2'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter2'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter1'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter3'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter1'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter3'
+ rtw_mutex_init();
+
+ // Start for RateTransition generated from: '/Adapter'
+ rtw_mutex_init();
+
+ // SystemInitialize for ModelReference: '/Estimation_Temperature'
+ thermal_model_Init(&(AMC_BLDC_DW.Estimation_Temperature_InstanceData.rtdw));
+
+ // SystemInitialize for ModelReference: '/Estimation_Velocity'
+ estimation_velocity_Init(&(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtdw));
+
+ // SystemInitialize for ModelReference: '/Filter_Current'
+ filter_current_Init(&(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
+
+ // SystemInitialize for ModelReference: '/FOC'
+ control_foc_Init(&(AMC_BLDC_DW.FOC_InstanceData.rtdw));
+
+ // SystemInitialize for ModelReference: '/CAN_Decoder' incorporates:
+ // Inport generated from: '/In Bus Element2'
+
+ can_decoder_Init();
+
+ // SystemInitialize for ModelReference: '/OuterControl'
+ control_outer_Init(&(AMC_BLDC_DW.OuterControl_InstanceData.rtdw));
+
+ // SystemInitialize for ModelReference: '/SupervisorFSM_RX' incorporates:
+ // Inport generated from: '/In Bus Element'
+ // Outport generated from: '/Out Bus Element3'
+ // Outport generated from: '/Out Bus Element4'
+
+ SupervisorFSM_RX_Init(&AMC_BLDC_Y.Flags_p,
+ &AMC_BLDC_Y.ConfigurationParameters_p);
+
+ // SystemInitialize for ModelReference: '/SupervisorFSM_TX' incorporates:
+ // Outport generated from: '/Out Bus Element3'
+ // Outport generated from: '/Out Bus Element4'
+
+ SupervisorFSM_TX_Init(&AMC_BLDC_B.MessagesTx);
+
+ // Enable for ModelReference: '/OuterControl'
+ control_outer_Enable(&(AMC_BLDC_DW.OuterControl_InstanceData.rtdw));
+}
+
+// Model terminate function
+void AMC_BLDC_terminate(void)
+{
+ // Terminate for RateTransition generated from: '/Adapter2'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter2'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter2'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter2'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter2'
+ rtw_mutex_destroy();
+
+ // Terminate for ModelReference: '/FOC'
+ control_foc_Term(&(AMC_BLDC_DW.FOC_InstanceData.rtdw));
+
+ // Terminate for RateTransition generated from: '/Adapter1'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter3'
+ rtw_mutex_destroy();
+
+ // Terminate for ModelReference: '/Filter_Current'
+ filter_current_Term(&(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
+
+ // Terminate for RateTransition generated from: '/Adapter1'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter3'
+ rtw_mutex_destroy();
+
+ // Terminate for RateTransition generated from: '/Adapter'
+ rtw_mutex_destroy();
+}
+
+//
+// File trailer for generated code.
+//
+// [EOF]
+//
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC.h b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC.h
new file mode 100644
index 0000000000..cb2de392c6
--- /dev/null
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC.h
@@ -0,0 +1,295 @@
+//
+// Non-Degree Granting Education License -- for use at non-degree
+// granting, nonprofit, education, and research organizations only. Not
+// for commercial or industrial use.
+//
+// File: AMC_BLDC.h
+//
+// Code generated for Simulink model 'AMC_BLDC'.
+//
+// Model version : 6.18
+// Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
+// C/C++ source code generated on : Mon Oct 16 10:09:05 2023
+//
+// Target selection: ert.tlc
+// Embedded hardware selection: ARM Compatible->ARM Cortex-M
+// Code generation objectives: Unspecified
+// Validation result: Not run
+//
+#ifndef RTW_HEADER_AMC_BLDC_h_
+#define RTW_HEADER_AMC_BLDC_h_
+#include "rtwtypes.h"
+#include "AMC_BLDC_types.h"
+#include "control_foc.h"
+#include "estimation_velocity.h"
+#include "filter_current.h"
+#include "control_outer.h"
+#include "thermal_model.h"
+#include
+#include "zero_crossing_types.h"
+
+// Macros for accessing real-time model data structure
+#ifndef rtmGetErrorStatus
+#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
+#endif
+
+#ifndef rtmSetErrorStatus
+#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
+#endif
+
+#ifndef rtmGetErrorStatusPointer
+#define rtmGetErrorStatusPointer(rtm) ((const char_T **)(&((rtm)->errorStatus)))
+#endif
+
+#ifndef rtmStepTask
+#define rtmStepTask(rtm, idx) ((rtm)->Timing.TaskCounters.TID[(idx)] == 0)
+#endif
+
+#ifndef rtmTaskCounter
+#define rtmTaskCounter(rtm, idx) ((rtm)->Timing.TaskCounters.TID[(idx)])
+#endif
+
+// Block signals (default storage)
+struct B_AMC_BLDC_T {
+ FOCSlowInputs BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1;
+ BUS_MESSAGES_RX_MULTIPLE CAN_Decoder_o1;// '/CAN_Decoder'
+ ConfigurationParameters
+ ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;// '/Adapter4'
+ BUS_MESSAGES_TX MessagesTx; // '/SupervisorFSM_TX'
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0;// '/Adapter1'
+ SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0;// '/Adapter3'
+ BUS_STATUS_RX_MULTIPLE CAN_Decoder_o2;// '/CAN_Decoder'
+ BUS_CAN_RX_ERRORS_MULTIPLE CAN_Decoder_o3;// '/CAN_Decoder'
+};
+
+// Block states (default storage) for system ''
+struct DW_AMC_BLDC_T {
+ ConfigurationParameters
+ ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;// synthesized block
+ ConfigurationParameters
+ RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Bu[3];// synthesized block
+ ConfigurationParameters
+ RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf0;// synthesized block
+ ConfigurationParameters
+ RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf1;// synthesized block
+ ConfigurationParameters
+ RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf2;// synthesized block
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf0;// synthesized block
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf1;// synthesized block
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf2;// synthesized block
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf0;// synthesized block
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf1;// synthesized block
+ ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_Buf2;// synthesized block
+ SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_e;// synthesized block
+ SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_c;// synthesized block
+ SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Bu_j;// synthesized block
+ Targets RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Bu[3];// synthesized block
+ EstimatedData RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Bu[3];// synthesized block
+ ControlOuterOutputs
+ RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Bu[3];// synthesized block
+ Flags RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Bu[3];// synthesized block
+ MotorTemperature RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf[3];// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_SE;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_SE;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_SE;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_SE;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_SE;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_SEMA;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_SEMA;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_SE_l;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_SE_b;// synthesized block
+ void* RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_SEMAP;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Ls_g;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RD_p;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_LstBu;// synthesized block
+ int8_T RTBInsertedForAdapter_InsertedFor_Adapter_at_outport_0_RDBuf;// synthesized block
+ MdlrefDW_control_foc_T FOC_InstanceData;// '/FOC'
+ MdlrefDW_estimation_velocity_T Estimation_Velocity_InstanceData;// '/Estimation_Velocity'
+ MdlrefDW_filter_current_T Filter_Current_InstanceData;// '/Filter_Current'
+ MdlrefDW_control_outer_T OuterControl_InstanceData;// '/OuterControl'
+ MdlrefDW_thermal_model_T Estimation_Temperature_InstanceData;// '/Estimation_Temperature'
+};
+
+// External inputs (root inport signals with default storage)
+struct ExtU_AMC_BLDC_T {
+ SensorsData SensorsData_p; // '/SensorsData'
+ ExternalFlags ExternalFlags_p; // '/ExternalFlags'
+ BUS_CAN_MULTIPLE PacketsRx; // '/PacketsRx'
+};
+
+// External outputs (root outports fed by signals with default storage)
+struct ExtY_AMC_BLDC_T {
+ ControlOutputs ControlOutputs_p; // '/ControlOutputs'
+ ConfigurationParameters ConfigurationParameters_p;// '/ConfigurationParameters'
+ Flags Flags_p; // '/Flags'
+ EstimatedData EstimatedData_p; // '/EstimatedData'
+ BUS_CAN_MULTIPLE PacketsTx; // '/PacketsTx'
+};
+
+// Real-time Model Data Structure
+struct tag_RTM_AMC_BLDC_T {
+ const char_T *errorStatus;
+
+ //
+ // Timing:
+ // The following substructure contains information regarding
+ // the timing information for the model.
+
+ struct {
+ struct {
+ uint32_T TID[4];
+ } TaskCounters;
+ } Timing;
+};
+
+// Block signals (default storage)
+#ifdef __cplusplus
+
+extern "C"
+{
+
+#endif
+
+ extern struct B_AMC_BLDC_T AMC_BLDC_B;
+
+#ifdef __cplusplus
+
+}
+
+#endif
+
+// Block states (default storage)
+extern struct DW_AMC_BLDC_T AMC_BLDC_DW;
+
+#ifdef __cplusplus
+
+extern "C"
+{
+
+#endif
+
+ // External inputs (root inport signals with default storage)
+ extern struct ExtU_AMC_BLDC_T AMC_BLDC_U;
+
+ // External outputs (root outports fed by signals with default storage)
+ extern struct ExtY_AMC_BLDC_T AMC_BLDC_Y;
+
+#ifdef __cplusplus
+
+}
+
+#endif
+
+//
+// Exported Global Parameters
+//
+// Note: Exported global parameters are tunable parameters with an exported
+// global storage class designation. Code generation will declare the memory for
+// these parameters and exports their symbols.
+//
+
+extern ConfigurationParameters InitConfParams;// Variable: InitConfParams
+ // Referenced by: '/SupervisorFSM_RX'
+
+extern real32_T CAN_ANGLE_DEG2ICUB; // Variable: CAN_ANGLE_DEG2ICUB
+ // Referenced by: '/CAN_Encoder'
+ // 2^16/360
+
+extern real32_T CAN_ANGLE_ICUB2DEG; // Variable: CAN_ANGLE_ICUB2DEG
+ // Referenced by: '/CAN_Decoder'
+ // 360/2^16
+
+extern uint8_T CAN_ID_AMC; // Variable: CAN_ID_AMC
+ // Referenced by:
+ // '/CAN_Decoder'
+ // '/CAN_Encoder'
+ // 4 bits defining the ID of the AMC_BLDC board.
+
+
+#ifdef __cplusplus
+
+extern "C"
+{
+
+#endif
+
+ // Model entry point functions
+ extern void AMC_BLDC_initialize(void);
+ extern void AMC_BLDC_step0(void);
+ extern void AMC_BLDC_step1(void);
+ extern void AMC_BLDC_step_Time_1ms(void);
+ extern void AMC_BLDC_step_Time_10ms(void);
+ extern void AMC_BLDC_terminate(void);
+
+#ifdef __cplusplus
+
+}
+
+#endif
+
+// Real-time Model object
+#ifdef __cplusplus
+
+extern "C"
+{
+
+#endif
+
+ extern RT_MODEL_AMC_BLDC_T *const AMC_BLDC_M;
+
+#ifdef __cplusplus
+
+}
+
+#endif
+
+//-
+// The generated code includes comments that allow you to trace directly
+// back to the appropriate location in the model. The basic format
+// is /block_name, where system is the system number (uniquely
+// assigned by Simulink) and block_name is the name of the block.
+//
+// Use the MATLAB hilite_system command to trace the generated code back
+// to the model. For example,
+//
+// hilite_system('') - opens system 3
+// hilite_system('/Kp') - opens and selects block Kp which resides in S3
+//
+// Here is the system hierarchy for this model
+//
+// '' : 'AMC_BLDC'
+// '' : 'AMC_BLDC/Adapter1'
+// '' : 'AMC_BLDC/Adapter2'
+// '' : 'AMC_BLDC/Adapter3'
+// '' : 'AMC_BLDC/Adapter4'
+// '' : 'AMC_BLDC/Estimation'
+// '' : 'AMC_BLDC/Messaging'
+// '' : 'AMC_BLDC/Supervision'
+// '' : 'AMC_BLDC/Estimation/Adapter'
+// '' : 'AMC_BLDC/Estimation/Adapter1'
+// '' : 'AMC_BLDC/Estimation/Adapter3'
+// '' : 'AMC_BLDC/Estimation/Mux'
+
+#endif // RTW_HEADER_AMC_BLDC_h_
+
+//
+// File trailer for generated code.
+//
+// [EOF]
+//
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC_private.h b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC_private.h
new file mode 100644
index 0000000000..7254c864ea
--- /dev/null
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC_private.h
@@ -0,0 +1,30 @@
+//
+// Non-Degree Granting Education License -- for use at non-degree
+// granting, nonprofit, education, and research organizations only. Not
+// for commercial or industrial use.
+//
+// File: AMC_BLDC_private.h
+//
+// Code generated for Simulink model 'AMC_BLDC'.
+//
+// Model version : 6.18
+// Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
+// C/C++ source code generated on : Mon Oct 16 10:09:05 2023
+//
+// Target selection: ert.tlc
+// Embedded hardware selection: ARM Compatible->ARM Cortex-M
+// Code generation objectives: Unspecified
+// Validation result: Not run
+//
+#ifndef RTW_HEADER_AMC_BLDC_private_h_
+#define RTW_HEADER_AMC_BLDC_private_h_
+#include "rtwtypes.h"
+#include "zero_crossing_types.h"
+#include "AMC_BLDC_types.h"
+#endif // RTW_HEADER_AMC_BLDC_private_h_
+
+//
+// File trailer for generated code.
+//
+// [EOF]
+//
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC_types.h b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC_types.h
new file mode 100644
index 0000000000..3fc4f2d93f
--- /dev/null
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/AMC_BLDC_types.h
@@ -0,0 +1,824 @@
+//
+// Non-Degree Granting Education License -- for use at non-degree
+// granting, nonprofit, education, and research organizations only. Not
+// for commercial or industrial use.
+//
+// File: AMC_BLDC_types.h
+//
+// Code generated for Simulink model 'AMC_BLDC'.
+//
+// Model version : 6.18
+// Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
+// C/C++ source code generated on : Mon Oct 16 10:09:05 2023
+//
+// Target selection: ert.tlc
+// Embedded hardware selection: ARM Compatible->ARM Cortex-M
+// Code generation objectives: Unspecified
+// Validation result: Not run
+//
+#ifndef RTW_HEADER_AMC_BLDC_types_h_
+#define RTW_HEADER_AMC_BLDC_types_h_
+#include "rtwtypes.h"
+
+// Includes for objects with custom storage classes
+#include "rtw_defines.h"
+
+//
+// Registered constraints for dimension variants
+
+#if CAN_MAX_NUM_PACKETS <= 0
+# error "The preprocessor definition 'CAN_MAX_NUM_PACKETS' must be greater than '0'"
+#endif
+
+#if CAN_MAX_NUM_PACKETS >= 16
+# error "The preprocessor definition 'CAN_MAX_NUM_PACKETS' must be less than '16'"
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_JointPositions_
+#define DEFINED_TYPEDEF_FOR_JointPositions_
+
+struct JointPositions
+{
+ // joint positions
+ real32_T position;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MotorSensors_
+#define DEFINED_TYPEDEF_FOR_MotorSensors_
+
+struct MotorSensors
+{
+ real32_T Iabc[3];
+
+ // electrical angle = angle * pole_pairs
+ real32_T angle;
+ real32_T temperature;
+ real32_T voltage;
+ real32_T current;
+ uint8_T hallABC;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_SensorsData_
+#define DEFINED_TYPEDEF_FOR_SensorsData_
+
+struct SensorsData
+{
+ // position encoders
+ JointPositions jointpositions;
+ MotorSensors motorsensors;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_ControlModes_
+#define DEFINED_TYPEDEF_FOR_ControlModes_
+
+typedef enum {
+ ControlModes_NotConfigured = 0, // Default value
+ ControlModes_Idle,
+ ControlModes_Position,
+ ControlModes_PositionDirect,
+ ControlModes_Current,
+ ControlModes_Velocity,
+ ControlModes_Voltage,
+ ControlModes_Torque,
+ ControlModes_HwFaultCM
+} ControlModes;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_Flags_
+#define DEFINED_TYPEDEF_FOR_Flags_
+
+struct Flags
+{
+ // control mode
+ ControlModes control_mode;
+ boolean_T enable_sending_msg_status;
+ boolean_T fault_button;
+ boolean_T enable_thermal_protection;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MotorConfig_
+#define DEFINED_TYPEDEF_FOR_MotorConfig_
+
+struct MotorConfig
+{
+ boolean_T has_hall_sens;
+ boolean_T has_quadrature_encoder;
+ boolean_T has_speed_quadrature_encoder;
+ boolean_T has_torque_sens;
+ boolean_T use_index;
+ boolean_T enable_verbosity;
+ int16_T rotor_encoder_resolution;
+ int16_T rotor_index_offset;
+ uint8_T encoder_tolerance;
+ uint8_T pole_pairs;
+ real32_T Kbemf;
+ real32_T Rphase;
+ real32_T Imin;
+ real32_T Imax;
+ real32_T Vcc;
+ real32_T Vmax;
+ real32_T resistance;
+ real32_T inductance;
+ real32_T thermal_resistance;
+ real32_T thermal_time_constant;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_EstimationVelocityModes_
+#define DEFINED_TYPEDEF_FOR_EstimationVelocityModes_
+
+typedef enum {
+ EstimationVelocityModes_Disabled = 0,// Default value
+ EstimationVelocityModes_MovingAverage,
+ EstimationVelocityModes_LeastSquares
+} EstimationVelocityModes;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_EstimationConfig_
+#define DEFINED_TYPEDEF_FOR_EstimationConfig_
+
+struct EstimationConfig
+{
+ EstimationVelocityModes velocity_mode;
+
+ // Forgetting factor in [0, 1] for exponential weighting-based estimation of RMS current value
+ real32_T current_rms_lambda;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_PIDConfig_
+#define DEFINED_TYPEDEF_FOR_PIDConfig_
+
+struct PIDConfig
+{
+ real32_T OutMax;
+ real32_T OutMin;
+ real32_T P;
+ real32_T I;
+ real32_T D;
+ real32_T N;
+ real32_T I0;
+ real32_T D0;
+ uint8_T shift_factor;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_Thresholds_
+#define DEFINED_TYPEDEF_FOR_Thresholds_
+
+struct Thresholds
+{
+ // It shall be greater than hardwareJntPosMin
+ real32_T jntPosMin;
+
+ // It shall be smaller than hardwareJntPosMax
+ real32_T jntPosMax;
+
+ // Imposed by hardware constraint
+ real32_T hardwareJntPosMin;
+
+ // Imposed by hardware constraint
+ real32_T hardwareJntPosMax;
+
+ // If robotMin == rotorMax == 0, there's no check
+ real32_T rotorPosMin;
+
+ // If robotMin == rotorMax == 0, there's no check
+ real32_T rotorPosMax;
+
+ // Can be only non-negative
+ real32_T jntVelMax;
+
+ // Timeout on reception of velocity setpoint
+ // Can be only non-negative
+ uint32_T velocityTimeout;
+
+ // Current that can be kept for an indefinite period of time w/o damaging the motor
+ // Expressed in [A] as all the internal computations are done this way
+ // Can be only non-negative
+ real32_T motorNominalCurrents;
+
+ // Current that can be applied for a short period of time
+ // Expressed in [A] as all the internal computations are done this way
+ // Can be only non-negative
+ real32_T motorPeakCurrents;
+
+ // Currents over this threshold can instantaneously damages the motor
+ // Expressed in [A] as all the internal computations are done this way
+ // Can be only non-negative
+ real32_T motorOverloadCurrents;
+
+ // Expressed in ticks
+ // Max value is 32000
+ // Can be only non-negative
+ uint32_T motorPwmLimit;
+
+ // The critical temperature of the motor that triggers i2t current protection.
+ real32_T motorCriticalTemperature;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_ConfigurationParameters_
+#define DEFINED_TYPEDEF_FOR_ConfigurationParameters_
+
+struct ConfigurationParameters
+{
+ MotorConfig motorconfig;
+ EstimationConfig estimationconfig;
+ PIDConfig CurLoopPID;
+ PIDConfig PosLoopPID;
+ PIDConfig VelLoopPID;
+ PIDConfig DirLoopPID;
+ Thresholds thresholds;
+ real32_T environment_temperature;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_JointVelocities_
+#define DEFINED_TYPEDEF_FOR_JointVelocities_
+
+struct JointVelocities
+{
+ // joint velocities
+ real32_T velocity;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MotorCurrent_
+#define DEFINED_TYPEDEF_FOR_MotorCurrent_
+
+struct MotorCurrent
+{
+ // motor current
+ real32_T current;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MotorTemperature_
+#define DEFINED_TYPEDEF_FOR_MotorTemperature_
+
+struct MotorTemperature
+{
+ // motor temperature
+ real32_T temperature;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_EstimatedData_
+#define DEFINED_TYPEDEF_FOR_EstimatedData_
+
+struct EstimatedData
+{
+ // velocity
+ JointVelocities jointvelocities;
+
+ // filtered motor current
+ MotorCurrent Iq_filtered;
+
+ // motor temperature
+ MotorTemperature motor_temperature;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MotorVoltage_
+#define DEFINED_TYPEDEF_FOR_MotorVoltage_
+
+struct MotorVoltage
+{
+ // motor voltage
+ real32_T voltage;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_Targets_
+#define DEFINED_TYPEDEF_FOR_Targets_
+
+struct Targets
+{
+ JointPositions jointpositions;
+ JointVelocities jointvelocities;
+ MotorCurrent motorcurrent;
+ MotorVoltage motorvoltage;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_ControlOuterOutputs_
+#define DEFINED_TYPEDEF_FOR_ControlOuterOutputs_
+
+struct ControlOuterOutputs
+{
+ boolean_T vel_en;
+ boolean_T cur_en;
+ boolean_T out_en;
+ boolean_T pid_reset;
+ MotorCurrent motorcurrent;
+ real32_T current_limiter;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_FOCSlowInputs_
+#define DEFINED_TYPEDEF_FOR_FOCSlowInputs_
+
+struct FOCSlowInputs
+{
+ Flags flags;
+ ConfigurationParameters configurationparameters;
+ EstimatedData estimateddata;
+ Targets targets;
+ ControlOuterOutputs controlouteroutputs;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_ControlOutputs_
+#define DEFINED_TYPEDEF_FOR_ControlOutputs_
+
+struct ControlOutputs
+{
+ // control effort (quadrature)
+ real32_T Vq;
+
+ // control effort (3-phases)
+ real32_T Vabc[3];
+
+ // quadrature current
+ MotorCurrent Iq_fbk;
+
+ // direct current
+ MotorCurrent Id_fbk;
+
+ // RMS of Iq
+ MotorCurrent Iq_rms;
+
+ // RMS of Id
+ MotorCurrent Id_rms;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_ExternalFlags_
+#define DEFINED_TYPEDEF_FOR_ExternalFlags_
+
+struct ExternalFlags
+{
+ // External Fault Button (1 == pressed)
+ boolean_T fault_button;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MCControlModes_
+#define DEFINED_TYPEDEF_FOR_MCControlModes_
+
+typedef enum {
+ MCControlModes_Idle = 0, // Default value
+ MCControlModes_OpenLoop = 80,
+ MCControlModes_SpeedVoltage = 10,
+ MCControlModes_SpeedCurrent = 11,
+ MCControlModes_Current = 6,
+ MCControlModes_NotConfigured = 176,
+ MCControlModes_HWFault = 160
+} MCControlModes;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_CONTROL_MODE_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_CONTROL_MODE_
+
+// Fields of a CONTROL_MODE message.
+struct BUS_MSG_CONTROL_MODE
+{
+ // Motor selector.
+ boolean_T motor;
+
+ // Control mode.
+ MCControlModes mode;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_CURRENT_LIMIT_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_CURRENT_LIMIT_
+
+// Fields of a CURRENT_LIMIT message.
+struct BUS_MSG_CURRENT_LIMIT
+{
+ // Motor selector.
+ boolean_T motor;
+
+ // Nominal current in A.
+ real32_T nominal;
+
+ // Peak current in A.
+ real32_T peak;
+
+ // Overload current in A.
+ real32_T overload;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_DESIRED_TARGETS_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_DESIRED_TARGETS_
+
+// Fields of a DESIRED_TARGETS message.
+struct BUS_MSG_DESIRED_TARGETS
+{
+ // Target current in A.
+ real32_T current;
+
+ // Target voltage in %.
+ real32_T voltage;
+
+ // Target veocity in deg/s.
+ real32_T velocity;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_PID_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_PID_
+
+// Fields of a CURRENT_PID message.
+struct BUS_MSG_PID
+{
+ // Motor selector.
+ boolean_T motor;
+
+ // Proportional gain.
+ real32_T Kp;
+
+ // Integral gain.
+ real32_T Ki;
+
+ // Derivative gain.
+ real32_T Kd;
+
+ // Shift factor.
+ uint8_T Ks;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_MOTOR_CONFIG_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_MOTOR_CONFIG_
+
+struct BUS_MSG_MOTOR_CONFIG
+{
+ boolean_T has_hall_sens;
+ boolean_T has_quadrature_encoder;
+ boolean_T has_speed_quadrature_encoder;
+ boolean_T has_torque_sens;
+ boolean_T use_index;
+ boolean_T enable_verbosity;
+
+ // Number of polese of the motor.
+ uint8_T number_poles;
+
+ // Encoder tolerance.
+ uint8_T encoder_tolerance;
+
+ // Resolution of rotor encoder.
+ int16_T rotor_encoder_resolution;
+
+ // Offset of the rotor encoder.
+ int16_T rotor_index_offset;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_
+#define DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_
+
+// Aggregate of all CAN received messages.
+struct BUS_MESSAGES_RX
+{
+ BUS_MSG_CONTROL_MODE control_mode;
+ BUS_MSG_CURRENT_LIMIT current_limit;
+ BUS_MSG_DESIRED_TARGETS desired_targets;
+ BUS_MSG_PID pid;
+ BUS_MSG_MOTOR_CONFIG motor_config;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_MULTIPLE_
+#define DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_MULTIPLE_
+
+struct BUS_MESSAGES_RX_MULTIPLE
+{
+ BUS_MESSAGES_RX messages[CAN_MAX_NUM_PACKETS];
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_
+#define DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_
+
+// Aggregate of all events specifying types of received messages.
+struct BUS_STATUS_RX
+{
+ boolean_T control_mode;
+ boolean_T current_limit;
+ boolean_T desired_targets;
+ boolean_T current_pid;
+ boolean_T velocity_pid;
+ boolean_T motor_config;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_MULTIPLE_
+#define DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_MULTIPLE_
+
+struct BUS_STATUS_RX_MULTIPLE
+{
+ BUS_STATUS_RX status[CAN_MAX_NUM_PACKETS];
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_CANErrorTypes_
+#define DEFINED_TYPEDEF_FOR_CANErrorTypes_
+
+typedef enum {
+ CANErrorTypes_No_Error = 0, // Default value
+ CANErrorTypes_Packet_Not4Us,
+ CANErrorTypes_Packet_Unrecognized,
+ CANErrorTypes_Packet_Malformed,
+ CANErrorTypes_Packet_MultiFunctionsDetected,
+ CANErrorTypes_Mode_Unrecognized
+} CANErrorTypes;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_
+
+// Specifies the CAN error types.
+struct BUS_CAN_RX_ERRORS
+{
+ // True if an error has been detected.
+ boolean_T event;
+ CANErrorTypes type;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_MULTIPLE_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_MULTIPLE_
+
+struct BUS_CAN_RX_ERRORS_MULTIPLE
+{
+ BUS_CAN_RX_ERRORS errors[CAN_MAX_NUM_PACKETS];
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_FOC_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_FOC_
+
+// Fields of a FOC message.
+struct BUS_MSG_FOC
+{
+ // Current feedback in A.
+ real32_T current;
+
+ // Position feedback in deg.
+ real32_T position;
+
+ // Velocity feedback in deg/s.
+ real32_T velocity;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_FLAGS_TX_
+#define DEFINED_TYPEDEF_FOR_BUS_FLAGS_TX_
+
+struct BUS_FLAGS_TX
+{
+ boolean_T dirty;
+ boolean_T stuck;
+ boolean_T index_broken;
+ boolean_T phase_broken;
+ real32_T not_calibrated;
+ boolean_T ExternalFaultAsserted;
+ boolean_T UnderVoltageFailure;
+ boolean_T OverVoltageFailure;
+ boolean_T OverCurrentFailure;
+ boolean_T DHESInvalidValue;
+ boolean_T AS5045CSumError;
+ boolean_T DHESInvalidSequence;
+ boolean_T CANInvalidProtocol;
+ boolean_T CAN_BufferOverRun;
+ boolean_T SetpointExpired;
+ boolean_T CAN_TXIsPasv;
+ boolean_T CAN_RXIsPasv;
+ boolean_T CAN_IsWarnTX;
+ boolean_T CAN_IsWarnRX;
+ boolean_T OverHeating;
+ boolean_T ADCCalFailure;
+ boolean_T I2TFailure;
+ boolean_T EMUROMFault;
+ boolean_T EMUROMCRCFault;
+ boolean_T EncoderFault;
+ boolean_T FirmwareSPITimingError;
+ boolean_T AS5045CalcError;
+ boolean_T FirmwarePWMFatalError;
+ boolean_T CAN_TXWasPasv;
+ boolean_T CAN_RXWasPasv;
+ boolean_T CAN_RTRFlagActive;
+ boolean_T CAN_WasWarn;
+ boolean_T CAN_DLCError;
+ boolean_T SiliconRevisionFault;
+ boolean_T PositionLimitUpper;
+ boolean_T PositionLimitLower;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_STATUS_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_STATUS_
+
+struct BUS_MSG_STATUS
+{
+ MCControlModes control_mode;
+
+ // control effort (quadrature)
+ real32_T pwm_fbk;
+ BUS_FLAGS_TX flags;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MESSAGES_TX_
+#define DEFINED_TYPEDEF_FOR_BUS_MESSAGES_TX_
+
+// Aggregate of all CAN transmitted messages.
+struct BUS_MESSAGES_TX
+{
+ BUS_MSG_FOC foc;
+ BUS_MSG_STATUS status;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_STATUS_TX_
+#define DEFINED_TYPEDEF_FOR_BUS_STATUS_TX_
+
+// Aggregate of all events specifying types of transmitted messages.
+struct BUS_STATUS_TX
+{
+ boolean_T foc;
+ boolean_T status;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_PACKET_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_PACKET_
+
+// Fields of a transmitted CAN packet.
+struct BUS_CAN_PACKET
+{
+ // ID of the CAN packet.
+ uint16_T ID;
+
+ // PAYLOAD of the CAN packet.
+ uint8_T PAYLOAD[8];
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_
+
+struct BUS_CAN
+{
+ // If true, the packet is available to be processed.
+ boolean_T available;
+ uint8_T length;
+ BUS_CAN_PACKET packet;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_MULTIPLE_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_MULTIPLE_
+
+struct BUS_CAN_MULTIPLE
+{
+ BUS_CAN packets[CAN_MAX_NUM_PACKETS];
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_CANClassTypes_
+#define DEFINED_TYPEDEF_FOR_CANClassTypes_
+
+typedef enum {
+ CANClassTypes_Motor_Control_Command = 0,// Default value
+ CANClassTypes_Motor_Control_Streaming = 1,
+ CANClassTypes_Analog_Sensors_Command = 2,
+ CANClassTypes_Skin_Sensor_Streaming = 4,
+ CANClassTypes_Inertial_Sensor_Streaming = 5,
+ CANClassTypes_Future_Use = 6,
+ CANClassTypes_Management_Bootloader = 7
+} CANClassTypes;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_ID_RX_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_ID_RX_
+
+struct BUS_CAN_ID_RX
+{
+ // 3 bits defining the message class type.
+ CANClassTypes CLS;
+
+ // 4 bits defining the source ID.
+ uint8_T SRC;
+
+ // 4 bits definint the destination ID or the message sub-type.
+ uint8_T DST_TYP;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_CMD_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_CMD_
+
+struct BUS_CAN_CMD
+{
+ // 1 bits for motor selector.
+ boolean_T M;
+
+ // 7 bits defining the operational code of the command.
+ uint8_T OPC;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_PAYLOAD_RX_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_PAYLOAD_RX_
+
+struct BUS_CAN_PAYLOAD_RX
+{
+ // Actual length of the total PAYLOAD field.
+ uint8_T LEN;
+ BUS_CAN_CMD CMD;
+
+ // 8 bytes for the command argument in order to account also message of type streaming.
+ uint8_T ARG[8];
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_PACKET_RX_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_PACKET_RX_
+
+// Fields of a received CAN packet.
+struct BUS_CAN_PACKET_RX
+{
+ // ID of the CAN packet.
+ BUS_CAN_ID_RX ID;
+
+ // PAYLOAD of the CAN packet.
+ BUS_CAN_PAYLOAD_RX PAYLOAD;
+};
+
+#endif
+
+// Forward declaration for rtModel
+typedef struct tag_RTM_AMC_BLDC_T RT_MODEL_AMC_BLDC_T;
+
+#endif // RTW_HEADER_AMC_BLDC_types_h_
+
+//
+// File trailer for generated code.
+//
+// [EOF]
+//
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/ert_main.cpp b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/ert_main.cpp
new file mode 100644
index 0000000000..3b2a8a6add
--- /dev/null
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/amc-bldc/ert_main.cpp
@@ -0,0 +1,293 @@
+//
+// Non-Degree Granting Education License -- for use at non-degree
+// granting, nonprofit, education, and research organizations only. Not
+// for commercial or industrial use.
+//
+// File: ert_main.cpp
+//
+// Code generated for Simulink model 'AMC_BLDC'.
+//
+// Model version : 5.1
+// Simulink Coder version : 9.8 (R2022b) 13-May-2022
+// C/C++ source code generated on : Wed Sep 28 09:23:48 2022
+//
+// Target selection: ert.tlc
+// Embedded hardware selection: ARM Compatible->ARM Cortex-M
+// Code generation objectives: Unspecified
+// Validation result: Not run
+//
+#include
+#include
+#include
+#include // This example main program uses printf/fflush
+#include "AMC_BLDC.h" // Model header file
+#define CHECK_STATUS(status,fcn) if (status != 0) {fprintf(stderr, "Call to %s returned error status (%d).\n", (fcn),(status)); perror((fcn)); fflush(stderr); exit(EXIT_FAILURE);}
+
+struct ThreadInfo {
+ HANDLE threadHandle;
+ unsigned threadID;
+ int_T index;
+ HANDLE startEvent;
+ HANDLE stopEvent;
+ LONG exitFlag;
+};
+
+ThreadInfo periodicThread[3];
+ThreadInfo periodicTriggerThread[1];
+int threadPriority[4] = { THREAD_PRIORITY_ABOVE_NORMAL,
+ THREAD_PRIORITY_NORMAL,
+ THREAD_PRIORITY_BELOW_NORMAL,
+ THREAD_PRIORITY_LOWEST };
+
+HANDLE quitEvent = NULL;
+BOOL OnCtrlHandler(DWORD ctrl)
+{
+ // Unused argument
+ (void)(ctrl);
+ SetEvent(quitEvent);
+ return true;
+}
+
+// Model wrapper function
+void AMC_BLDC_step(int_T tid)
+{
+ switch (tid) {
+ case 0 :
+ AMC_BLDC_step0();
+ break;
+
+ case 1 :
+ AMC_BLDC_step_FOC();
+ break;
+
+ case 2 :
+ AMC_BLDC_step_Time();
+ break;
+
+ default :
+ // do nothing
+ break;
+ }
+}
+
+unsigned __stdcall baseRateTaskScheduler(void *arg)
+{
+ volatile boolean_T noErr;
+ DWORD waitResult;
+ HANDLE orTimer;
+ LARGE_INTEGER orDueTime;
+ int_T i;
+
+ // Unused argument
+ (void)(arg);
+ int_T taskCounters[3] = { 0, 0, 0 };
+
+ int_T taskTicks[3] = { 1, 32, 875 };
+
+ int_T taskId[3] = { 0, 1, 2 };
+
+ noErr = (rtmGetErrorStatus(AMC_BLDC_M) == (NULL));
+ orTimer = CreateWaitableTimer((NULL), false, (NULL));
+ orDueTime.QuadPart = (LONGLONG)(1.1428571428571438E-6 * 1e7 * -1);
+ while (noErr) {
+ // Check for Ctrl+C event
+ waitResult = WaitForSingleObject(quitEvent, 0);
+ if ((waitResult == WAIT_OBJECT_0) || (waitResult == WAIT_FAILED)) {
+ // The quitEvent is set or the wait failed
+ noErr = false;
+ continue;
+ }
+
+ CHECK_STATUS(SetWaitableTimer(orTimer, &orDueTime, 0, (NULL), (NULL), false)
+ == false, "SetWaitableTimer");
+ for (i = 0; i < 3; i++) {
+ if (taskCounters[i] == 0) {
+ waitResult = WaitForSingleObject(periodicThread[taskId[i]].stopEvent, 0);
+ if (waitResult == WAIT_TIMEOUT) {
+ printf("Overrun - rate for periodic task %d too fast.\n", taskId[i]);
+ WaitForSingleObject(periodicThread[taskId[i]].stopEvent, INFINITE);
+ }
+ }
+ }
+
+ noErr = (rtmGetErrorStatus(AMC_BLDC_M) == (NULL));
+ if (noErr) {
+ for (i = 0; i <3; i++) {
+ if (taskCounters[i] == 0) {
+ SetEvent(periodicThread[taskId[i]].startEvent);
+ }
+ }
+
+ for (i = 0; i <3; i++) {
+ taskCounters[i]++;
+ if (taskCounters[i] > (taskTicks[i]-1)) {
+ taskCounters[i] = 0;
+ }
+ }
+ } else {
+ for (i = 0; i < 3; i++) {
+ if (taskCounters[i] != 0) {
+ WaitForSingleObject(periodicThread[taskId[i]].stopEvent,INFINITE);
+ }
+ }
+ }
+
+ if (WaitForSingleObject(orTimer, 0) == WAIT_OBJECT_0) {
+ printf("Overrun - periodic trigger 0 base rate too fast.\n");
+ }
+ } // while
+
+ for (i = 0; i < 3; i++) {
+ InterlockedIncrement(&periodicThread[taskId[i]].exitFlag);
+ SetEvent(periodicThread[taskId[i]].startEvent);
+ }
+
+ _endthreadex(0);
+ return 0;
+}
+
+unsigned __stdcall periodicTask(void *arg)
+{
+ DWORD waitResult;
+ ThreadInfo* info = (ThreadInfo*)arg;
+ volatile boolean_T noErr = true;
+ while (noErr) {
+ waitResult = WaitForSingleObject(info->startEvent,INFINITE);
+ if ((waitResult != WAIT_OBJECT_0) || info->exitFlag) {
+ // Wait failed or exitFlag is set
+ noErr = false;
+ continue;
+ }
+
+ AMC_BLDC_step(info->index);
+
+ // Get model outputs here
+ SetEvent(info->stopEvent);
+ }
+
+ _endthreadex(0);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ int priority[3];
+
+ // Unused arguments
+ (void)(argc);
+ (void)(argv);
+ priority[0] = threadPriority[0];
+ priority[1] = threadPriority[1];
+ priority[2] = threadPriority[2];
+ CHECK_STATUS(SetConsoleCtrlHandler((PHANDLER_ROUTINE)OnCtrlHandler, true) ==
+ false, "SetConsoleCtrlHandler");
+ printf("**starting the model**\n");
+ fflush(stdout);
+
+ // Initialize model
+ AMC_BLDC_initialize();
+ rtmSetErrorStatus(AMC_BLDC_M, 0);
+
+ // Set the priority of the main thread
+ CHECK_STATUS(SetThreadPriority(GetCurrentThread(),
+ THREAD_PRIORITY_TIME_CRITICAL) == false, "SetThreadPriority");
+
+ // Create & initialize events used for thread synchronization
+ quitEvent = CreateEvent((NULL), true, false, (NULL));
+ CHECK_STATUS(quitEvent == (NULL),"CreateEvent");
+
+ // Create periodic threads
+ for (i = 0; i < 3; i++) {
+ periodicThread[i].index = (int_T) i;
+ periodicThread[i].exitFlag = 0;
+
+ // Create the events that will be used by the thread
+ periodicThread[i].startEvent = CreateEvent((NULL), false, false, (NULL));
+ CHECK_STATUS(periodicThread[i].startEvent == (NULL), "CreateEvent");
+ periodicThread[i].stopEvent = CreateEvent((NULL), false, true, (NULL));
+ CHECK_STATUS(periodicThread[i].stopEvent == (NULL), "CreateStopEventEvent");
+
+ // Create the thread in suspended mode
+ periodicThread[i].threadHandle = (HANDLE)_beginthreadex((NULL), 0,
+ &periodicTask, &periodicThread[i], CREATE_SUSPENDED, &periodicThread[i].
+ threadID);
+ CHECK_STATUS(periodicThread[i].threadID == 0,"_beginthreadex");
+
+ // Set the thread priority
+ CHECK_STATUS(SetThreadPriority(periodicThread[i].threadHandle, priority[i]) ==
+ false, "SetThreadPriority");
+
+ // Start the thread
+ CHECK_STATUS(ResumeThread(periodicThread[i].threadHandle) == -1,
+ "ResumeThread");
+ }
+
+ // Create periodic trigger threads
+ {
+ periodicTriggerThread[0].index = 0;
+ periodicTriggerThread[0].exitFlag = 0;
+ periodicTriggerThread[0].startEvent = (NULL);
+ periodicTriggerThread[0].stopEvent = (NULL);
+
+ // Create the thread in suspended mode
+ periodicTriggerThread[0].threadHandle = (HANDLE)_beginthreadex((NULL), 0,
+ &baseRateTaskScheduler, (NULL), CREATE_SUSPENDED, &periodicTriggerThread[0]
+ .threadID);
+ CHECK_STATUS(periodicTriggerThread[0].threadHandle == 0,"_beginthreadex");
+
+ // Set the periodic trigger thread priority
+ CHECK_STATUS(SetThreadPriority(periodicTriggerThread[0].threadHandle,
+ THREAD_PRIORITY_HIGHEST) == false, "SetThreadPriority");
+
+ // Start the periodic trigger thread
+ CHECK_STATUS(ResumeThread(periodicTriggerThread[0].threadHandle) == -1,
+ "ResumeThread");
+ }
+
+ // Wait for a stopping condition.
+ for (i = 0; i < 1; i++) {
+ WaitForSingleObject(periodicTriggerThread[i].threadHandle, INFINITE);
+ }
+
+ // Clean up
+ for (i = 0; i< 1; i++) {
+ if (periodicTriggerThread[i].threadHandle != (NULL)) {
+ CloseHandle(periodicTriggerThread[i].threadHandle);
+ }
+ }
+
+ if (quitEvent != (NULL)) {
+ CloseHandle(quitEvent);
+ }
+
+ for (i = 0; i < 3; i++) {
+ if (periodicThread[i].startEvent != (NULL)) {
+ CloseHandle(periodicThread[i].startEvent);
+ }
+
+ if (periodicThread[i].stopEvent != (NULL)) {
+ CloseHandle(periodicThread[i].stopEvent);
+ }
+
+ if (periodicThread[i].threadHandle != (NULL)) {
+ CloseHandle(periodicThread[i].threadHandle);
+ }
+ }
+
+ printf("**stopping the model**\n");
+ fflush(stdout);
+ if (rtmGetErrorStatus(AMC_BLDC_M) != (NULL)) {
+ fprintf(stderr, "\n**%s**\n", rtmGetErrorStatus(AMC_BLDC_M));
+ }
+
+ // Terminate model
+ AMC_BLDC_terminate();
+ return 0;
+}
+
+//
+// File trailer for generated code.
+//
+// [EOF]
+//
diff --git a/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/can-decoder/can_decoder.cpp b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/can-decoder/can_decoder.cpp
new file mode 100644
index 0000000000..cf5bcf5eaf
--- /dev/null
+++ b/emBODY/eBcode/arch-arm/board/amc2c/application/src/model-based-design/can-decoder/can_decoder.cpp
@@ -0,0 +1,844 @@
+//
+// Non-Degree Granting Education License -- for use at non-degree
+// granting, nonprofit, education, and research organizations only. Not
+// for commercial or industrial use.
+//
+// File: can_decoder.cpp
+//
+// Code generated for Simulink model 'can_decoder'.
+//
+// Model version : 5.0
+// Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
+// C/C++ source code generated on : Mon Oct 16 10:07:44 2023
+//
+// Target selection: ert.tlc
+// Embedded hardware selection: ARM Compatible->ARM Cortex-M
+// Code generation objectives: Unspecified
+// Validation result: Not run
+//
+#include "can_decoder.h"
+#include "rtwtypes.h"
+#include "can_decoder_types.h"
+#include
+#include
+#include "can_decoder_private.h"
+#include "rtw_defines.h"
+
+// Named constants for Chart: '/Decoding Logic'
+const int32_T can_decoder_CALL_EVENT = -1;
+const uint8_T can_decoder_IN_Event_Error = 1U;
+const uint8_T can_decoder_IN_Home = 1U;
+const uint8_T can_decoder_IN_Home_k = 2U;
+const int32_T can_decoder_event_ev_error_mode_unrecognized = 0;
+const int32_T can_decoder_event_ev_error_pck_malformed = 1;
+const int32_T can_decoder_event_ev_error_pck_not4us = 2;
+MdlrefDW_can_decoder_T can_decoder_MdlrefDW;
+
+// Block signals (default storage)
+B_can_decoder_c_T can_decoder_B;
+
+// Block states (default storage)
+DW_can_decoder_f_T can_decoder_DW;
+
+// Forward declaration for local functions
+static int32_T can_decoder_safe_cast_to_MCStreaming(int32_T input);
+static void can_decoder_ERROR_HANDLING(boolean_T rtu_pck_available,
+ B_DecodingLogic_can_decoder_T *localB, DW_DecodingLogic_can_decoder_T *localDW);
+static int16_T can_decoder_merge_2bytes_signed(uint16_T bl, uint16_T bh);
+static boolean_T can_decoder_is_controlmode_recognized(int32_T mode);
+static int32_T can_decoder_safe_cast_to_MCControlModes(int32_T input);
+static uint16_T can_decoder_merge_2bytes_unsigned(uint16_T bl, uint16_T bh);
+
+// Forward declaration for local functions
+static CANClassTypes can_decoder_convert_to_enum_CANClassTypes(int32_T input);
+static int32_T can_decoder_safe_cast_to_MCStreaming(int32_T input)
+{
+ int32_T output;
+
+ // Initialize output value to default value for MCStreaming (Desired_Targets)
+ output = 15;
+ if ((input == 0) || (input == 15)) {
+ // Set output value to input value if it is a member of MCStreaming
+ output = input;
+ }
+
+ return output;
+}
+
+// Function for Chart: '/Decoding Logic'
+static void can_decoder_ERROR_HANDLING(boolean_T rtu_pck_available,
+ B_DecodingLogic_can_decoder_T *localB, DW_DecodingLogic_can_decoder_T *localDW)
+{
+ boolean_T guard1;
+ guard1 = false;
+ switch (localDW->is_ERROR_HANDLING) {
+ case can_decoder_IN_Event_Error:
+ localDW->is_ERROR_HANDLING = can_decoder_IN_Home_k;
+ localDW->cmd_processed = 0U;
+ break;
+
+ case can_decoder_IN_Home_k:
+ if (localDW->sfEvent == can_decoder_event_ev_error_pck_not4us) {
+ localB->error_type = CANErrorTypes_Packet_Not4Us;
+ localDW->ev_errorEventCounter++;
+ guard1 = true;
+ } else if (localDW->sfEvent == can_decoder_event_ev_error_pck_malformed) {
+ localB->error_type = CANErrorTypes_Packet_Malformed;
+ localDW->ev_errorEventCounter++;
+ guard1 = true;
+ } else if (localDW->sfEvent == can_decoder_event_ev_error_mode_unrecognized)
+ {
+ localB->error_type = CANErrorTypes_Mode_Unrecognized;
+ localDW->ev_errorEventCounter++;
+ guard1 = true;
+ } else {
+ if (!localDW->ev_async) {
+ if (rtu_pck_available && (localDW->cmd_processed == 0)) {
+ localB->error_type = CANErrorTypes_Packet_Unrecognized;
+ localDW->ev_errorEventCounter++;
+ } else if (localDW->cmd_processed > 1) {
+ localB->error_type = CANErrorTypes_Packet_MultiFunctionsDetected;
+ localDW->ev_errorEventCounter++;
+ } else {
+ localB->error_type = CANErrorTypes_No_Error;
+ }
+ }
+
+ localDW->ev_async = false;
+ localDW->is_ERROR_HANDLING = can_decoder_IN_Home_k;
+ localDW->cmd_processed = 0U;
+ }
+ break;
+ }
+
+ if (guard1) {
+ localDW->is_ERROR_HANDLING = can_decoder_IN_Event_Error;
+ localDW->ev_async = true;
+ }
+}
+
+// Function for Chart: '/Decoding Logic'
+static int16_T can_decoder_merge_2bytes_signed(uint16_T bl, uint16_T bh)
+{
+ int16_T sw;
+ uint16_T x;
+ x = static_cast(static_cast(bh << 8) | bl);
+ std::memcpy((void *)&sw, (void *)&x, (size_t)1 * sizeof(int16_T));
+ return sw;
+}
+
+// Function for Chart: '/Decoding Logic'
+static boolean_T can_decoder_is_controlmode_recognized(int32_T mode)
+{
+ return (mode == static_cast(MCControlModes_Idle)) || (mode ==
+ static_cast(MCControlModes_OpenLoop)) || (mode ==
+ static_cast(MCControlModes_SpeedVoltage)) || (mode ==
+ static_cast(MCControlModes_Current));
+}
+
+static int32_T can_decoder_safe_cast_to_MCControlModes(int32_T input)
+{
+ int32_T output;
+
+ // Initialize output value to default value for MCControlModes (Idle)
+ output = 0;
+ if ((input == 0) || (input == 6) || ((input >= 10) && (input <= 11)) || (input
+ == 80) || (input == 160) || (input == 176)) {
+ // Set output value to input value if it is a member of MCControlModes
+ output = input;
+ }
+
+ return output;
+}
+
+// Function for Chart: '/Decoding Logic'
+static uint16_T can_decoder_merge_2bytes_unsigned(uint16_T bl, uint16_T bh)
+{
+ return static_cast(static_cast(bh << 8) | bl);
+}
+
+// System initialize for atomic system: '/Decoding Logic'
+void can_decoder_DecodingLogic_Init(B_DecodingLogic_can_decoder_T *localB,
+ DW_DecodingLogic_can_decoder_T *localDW)
+{
+ localDW->sfEvent = can_decoder_CALL_EVENT;
+ localB->msg_set_control_mode.motor = false;
+ localB->msg_set_control_mode.mode = MCControlModes_Idle;
+ localB->msg_set_current_limit.motor = false;
+ localB->msg_set_current_limit.nominal = 0.0F;
+ localB->msg_set_current_limit.peak = 0.0F;
+ localB->msg_set_current_limit.overload = 0.0F;
+ localB->msg_desired_targets.current = 0.0F;
+ localB->msg_desired_targets.voltage = 0.0F;
+ localB->msg_desired_targets.velocity = 0.0F;
+ localB->msg_set_pid.motor = false;
+ localB->msg_set_pid.Kp = 0.0F;
+ localB->msg_set_pid.Ki = 0.0F;
+ localB->msg_set_pid.Kd = 0.0F;
+ localB->msg_set_pid.Ks = 0U;
+ localB->msg_set_motor_config.has_hall_sens = false;
+ localB->msg_set_motor_config.has_quadrature_encoder = false;
+ localB->msg_set_motor_config.has_speed_quadrature_encoder = false;
+ localB->msg_set_motor_config.has_torque_sens = false;
+ localB->msg_set_motor_config.use_index = false;
+ localB->msg_set_motor_config.enable_verbosity = false;
+ localB->msg_set_motor_config.number_poles = 0U;
+ localB->msg_set_motor_config.encoder_tolerance = 0U;
+ localB->msg_set_motor_config.rotor_encoder_resolution = 0;
+ localB->msg_set_motor_config.rotor_index_offset = 0;
+}
+
+// Output and update for atomic system: '/Decoding Logic'
+void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
+ BUS_CAN_PACKET_RX *rtu_pck_input, const ConfigurationParameters
+ *rtu_ConfigurationParameters, uint8_T rtu_CAN_ID_DST, uint8_T
+ rtu_CAN_VOLT_REF_SHIFT, real32_T rtu_CAN_VOLT_REF_GAIN,
+ B_DecodingLogic_can_decoder_T *localB, DW_DecodingLogic_can_decoder_T *localDW)
+{
+ real32_T c;
+ int16_T tmp_merged;
+ uint8_T idx;
+ boolean_T guard1;
+ boolean_T tmp;
+ boolean_T tmp_0;
+ localDW->sfEvent = can_decoder_CALL_EVENT;
+
+ // Chart: '/Decoding Logic'
+ // This state chart is responsible for decoding incoming CAN packets.
+ if (localDW->is_active_c3_can_decoder == 0U) {
+ localDW->is_active_c3_can_decoder = 1U;
+ localDW->is_active_SET_CONTROL_MODE = 1U;
+ localDW->is_SET_CONTROL_MODE = can_decoder_IN_Home;
+ localDW->is_active_DESIRED_TARGETS = 1U;
+ localDW->is_DESIRED_TARGETS = can_decoder_IN_Home;
+ localDW->is_active_SET_OPTIONS = 1U;
+ localDW->is_SET_OPTIONS = can_decoder_IN_Home;
+ localDW->is_active_SET_MOTOR_CONFIG = 1U;
+ localDW->is_SET_MOTOR_CONFIG = can_decoder_IN_Home;
+ localDW->is_active_ERROR_HANDLING = 1U;
+ localDW->ev_async = false;
+ localDW->is_ERROR_HANDLING = can_decoder_IN_Home_k;
+ localDW->cmd_processed = 0U;
+ } else {
+ tmp = !rtu_pck_available;
+ tmp_0 = (tmp || (rtu_pck_input->ID.CLS !=
+ CANClassTypes_Motor_Control_Command));
+ if ((localDW->is_active_SET_CONTROL_MODE != 0U) &&
+ (localDW->is_SET_CONTROL_MODE == can_decoder_IN_Home) && (!tmp_0)) {
+ if (rtu_pck_input->ID.DST_TYP == rtu_CAN_ID_DST) {
+ if (rtu_pck_input->PAYLOAD.LEN >= 1) {
+ if (rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
+ (MCOPC_Set_Control_Mode)) {
+ if (rtu_pck_input->PAYLOAD.LEN >= 2) {
+ if (can_decoder_is_controlmode_recognized(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[1]))) {
+ localB->msg_set_control_mode.motor =
+ rtu_pck_input->PAYLOAD.CMD.M;
+ localB->msg_set_control_mode.mode = static_cast
+ (can_decoder_safe_cast_to_MCControlModes
+ (rtu_pck_input->PAYLOAD.ARG[1]));
+ localDW->cmd_processed = static_cast
+ (localDW->cmd_processed + 1);
+ localDW->ev_set_control_modeEventCounter++;
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_mode_unrecognized;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_CONTROL_MODE = can_decoder_IN_Home;
+ }
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_malformed;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_CONTROL_MODE = can_decoder_IN_Home;
+ }
+ }
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_malformed;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_CONTROL_MODE = can_decoder_IN_Home;
+ }
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_not4us;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_CONTROL_MODE = can_decoder_IN_Home;
+ }
+ }
+
+ if ((localDW->is_active_DESIRED_TARGETS != 0U) &&
+ (localDW->is_DESIRED_TARGETS == can_decoder_IN_Home) && ((!tmp) &&
+ (rtu_pck_input->ID.CLS == CANClassTypes_Motor_Control_Streaming) &&
+ (can_decoder_safe_cast_to_MCStreaming(rtu_pck_input->ID.DST_TYP) ==
+ static_cast(MCStreaming_Desired_Targets)))) {
+ if ((rtu_pck_input->PAYLOAD.LEN == 8) && (rtu_CAN_ID_DST <= 4)) {
+ idx = static_cast((rtu_CAN_ID_DST - 1) << 1);
+ tmp_merged = can_decoder_merge_2bytes_signed(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[idx]), static_cast
+ (rtu_pck_input->PAYLOAD.ARG[idx + 1]));
+ localB->msg_desired_targets.current = 0.001F * static_cast
+ (tmp_merged);
+ localB->msg_desired_targets.voltage = static_cast
+ (static_cast(tmp_merged >> (rtu_CAN_VOLT_REF_SHIFT -
+ rtu_ConfigurationParameters->CurLoopPID.shift_factor))) /
+ rtu_CAN_VOLT_REF_GAIN;
+ localB->msg_desired_targets.velocity = 1000.0F * static_cast
+ (tmp_merged) * CAN_ANGLE_ICUB2DEG;
+ localDW->cmd_processed = static_cast(localDW->cmd_processed +
+ 1);
+ localDW->ev_desired_targetsEventCounter++;
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_malformed;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_DESIRED_TARGETS = can_decoder_IN_Home;
+ }
+ }
+
+ if ((localDW->is_active_SET_OPTIONS != 0U) && (localDW->is_SET_OPTIONS ==
+ can_decoder_IN_Home) && (!tmp_0)) {
+ if (rtu_pck_input->ID.DST_TYP == rtu_CAN_ID_DST) {
+ if (rtu_pck_input->PAYLOAD.LEN >= 1) {
+ guard1 = false;
+ if (rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
+ (MCOPC_Set_Current_Limit)) {
+ if (rtu_pck_input->PAYLOAD.LEN == 8) {
+ localB->msg_set_current_limit.motor = rtu_pck_input->PAYLOAD.CMD.M;
+ localB->msg_set_current_limit.nominal = 0.001F *
+ static_cast(can_decoder_merge_2bytes_signed(
+ static_cast(rtu_pck_input->PAYLOAD.ARG[2]),
+ static_cast(rtu_pck_input->PAYLOAD.ARG[3])));
+ localB->msg_set_current_limit.peak = 0.001F * static_cast
+ (can_decoder_merge_2bytes_unsigned(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[4]), static_cast
+ (rtu_pck_input->PAYLOAD.ARG[5])));
+ localB->msg_set_current_limit.overload = 0.001F *
+ static_cast(can_decoder_merge_2bytes_unsigned(
+ static_cast(rtu_pck_input->PAYLOAD.ARG[6]),
+ static_cast(rtu_pck_input->PAYLOAD.ARG[7])));
+ localDW->cmd_processed = static_cast
+ (localDW->cmd_processed + 1);
+ localDW->ev_set_current_limitEventCounter++;
+ } else {
+ guard1 = true;
+ }
+ } else if ((rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
+ (MCOPC_Set_Current_PID)) ||
+ (rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
+ (MCOPC_Set_Velocity_PID))) {
+ if (rtu_pck_input->PAYLOAD.LEN == 8) {
+ localB->msg_set_pid.motor = rtu_pck_input->PAYLOAD.CMD.M;
+ localB->msg_set_pid.Ks = rtu_pck_input->PAYLOAD.ARG[7];
+ c = static_cast(0x01 << (15 - localB->msg_set_pid.Ks)) /
+ 32768.0F;
+ localB->msg_set_pid.Kp = c * static_cast
+ (can_decoder_merge_2bytes_signed(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[1]), static_cast
+ (rtu_pck_input->PAYLOAD.ARG[2])));
+ localB->msg_set_pid.Ki = c * static_cast
+ (can_decoder_merge_2bytes_signed(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[3]), static_cast
+ (rtu_pck_input->PAYLOAD.ARG[4])));
+ localB->msg_set_pid.Kd = c * static_cast
+ (can_decoder_merge_2bytes_signed(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[5]), static_cast
+ (rtu_pck_input->PAYLOAD.ARG[6])));
+ localDW->cmd_processed = static_cast
+ (localDW->cmd_processed + 1);
+ if (rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
+ (MCOPC_Set_Current_PID)) {
+ localDW->ev_set_current_pidEventCounter++;
+ } else {
+ localB->msg_set_pid.Kp *= 0.001F;
+ localB->msg_set_pid.Ki *= 0.001F;
+ localB->msg_set_pid.Kd *= 0.001F;
+ localDW->ev_set_velocity_pidEventCounter++;
+ }
+ } else {
+ guard1 = true;
+ }
+ }
+
+ if (guard1) {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_malformed;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_OPTIONS = can_decoder_IN_Home;
+ }
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_malformed;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_OPTIONS = can_decoder_IN_Home;
+ }
+ } else {
+ localDW->sfEvent = can_decoder_event_ev_error_pck_not4us;
+ if (localDW->is_active_ERROR_HANDLING != 0U) {
+ can_decoder_ERROR_HANDLING(true, localB, localDW);
+ }
+
+ localDW->sfEvent = -1;
+ localDW->is_SET_OPTIONS = can_decoder_IN_Home;
+ }
+ }
+
+ if ((localDW->is_active_SET_MOTOR_CONFIG != 0U) &&
+ (localDW->is_SET_MOTOR_CONFIG == can_decoder_IN_Home) && (!tmp_0)) {
+ if (rtu_pck_input->ID.DST_TYP == rtu_CAN_ID_DST) {
+ if (rtu_pck_input->PAYLOAD.LEN >= 1) {
+ if (rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
+ (MCOPC_Set_Motor_Config)) {
+ if (rtu_pck_input->PAYLOAD.LEN == 8) {
+ localB->msg_set_motor_config.has_quadrature_encoder =
+ ((rtu_pck_input->PAYLOAD.ARG[1] & 1U) != 0U);
+ localB->msg_set_motor_config.has_hall_sens =
+ ((rtu_pck_input->PAYLOAD.ARG[1] & 2U) != 0U);
+ localB->msg_set_motor_config.has_torque_sens =
+ ((rtu_pck_input->PAYLOAD.ARG[1] & 4U) != 0U);
+ localB->msg_set_motor_config.use_index =
+ ((rtu_pck_input->PAYLOAD.ARG[1] & 8U) != 0U);
+ localB->msg_set_motor_config.has_speed_quadrature_encoder =
+ ((rtu_pck_input->PAYLOAD.ARG[1] & 16U) != 0U);
+ localB->msg_set_motor_config.enable_verbosity =
+ ((rtu_pck_input->PAYLOAD.ARG[1] & 32U) != 0U);
+ localB->msg_set_motor_config.rotor_encoder_resolution =
+ can_decoder_merge_2bytes_signed(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[2]), static_cast
+ (rtu_pck_input->PAYLOAD.ARG[3]));
+ localB->msg_set_motor_config.rotor_index_offset =
+ can_decoder_merge_2bytes_signed(static_cast
+ (rtu_pck_input->PAYLOAD.ARG[4]), static_cast