5 Commits

3 changed files with 29 additions and 9 deletions

View File

@ -144,6 +144,7 @@ mission_t mission = M_NONE;
#ifdef WATCHDOG_STM
bool pHeartbeat = false;
bool WD_OK = false;
bool WD_initialized = false;
#endif
/* USER CODE END PV */
@ -190,13 +191,20 @@ int main(void)
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
MX_GPIO_Init();
MX_CAN_Init();
#if false
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CAN_Init();
MX_IWDG_Init();
/* USER CODE BEGIN 2 */
#endif
// Freeze WDG when debugging
__HAL_DBGMCU_FREEZE_IWDG();
// Ensure we start with SDC disabled
HAL_GPIO_WritePin(Watchdog_GPIO_Port, Watchdog_Pin, GPIO_PIN_RESET);
@ -209,7 +217,7 @@ int main(void)
canfilterconfig.FilterActivation = CAN_FILTER_ENABLE;
canfilterconfig.FilterBank = 0;
canfilterconfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
canfilterconfig.FilterIdHigh = 0 << (16 - 11);
canfilterconfig.FilterIdHigh = CAN_ID_RX << (16 - 11);
canfilterconfig.FilterIdLow = 0;
canfilterconfig.FilterMaskIdHigh = 0x7FF << (16 - 11);
canfilterconfig.FilterMaskIdLow = 0;
@ -244,8 +252,19 @@ int main(void)
bool pAMC = false;
mission_t new_mission = mission; // By default, don't change mission
// Important to prevent bus error state while ABX is starting up
HAL_Delay(1000);
// Wait 1s to prevent bus error state while ABX is starting up
// During that time, show loading animation to show LEDs work
setMissionLED(M_MANUAL, GPIO_PIN_SET);
HAL_Delay(150);
setMissionLED(M_MANUAL, GPIO_PIN_RESET);
for (mission_t m = M_ACCEL; m != M_MANUAL; m = mission2next[m]) {
setMissionLED(m, GPIO_PIN_SET);
HAL_Delay(150);
setMissionLED(m, GPIO_PIN_RESET);
}
MX_IWDG_Init();
WD_initialized = true;
while (true) {
@ -485,7 +504,8 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
#ifdef WATCHDOG_STM
if (rxData.signals.heartbeat != pHeartbeat) {
HAL_IWDG_Refresh(&hiwdg);
if (WD_initialized)
HAL_IWDG_Refresh(&hiwdg);
WD_OK = true;
HAL_GPIO_WritePin(Watchdog_GPIO_Port, Watchdog_Pin, GPIO_PIN_SET);
}

View File

@ -38,7 +38,7 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]}}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>

View File

@ -911,7 +911,7 @@
)
(symbol (lib_id "Device:R") (at 142.24 88.9 180) (unit 1)
(in_bom yes) (on_board yes) (dnp no)
(in_bom yes) (on_board yes) (dnp yes)
(uuid 86666e00-6522-42d9-8c50-ddbe3c590e94)
(property "Reference" "R3" (at 140.462 90.0684 0)
(effects (font (size 1.27 1.27)) (justify left))
@ -989,7 +989,7 @@
)
(symbol (lib_id "Device:C") (at 148.59 93.98 90) (unit 1)
(in_bom yes) (on_board yes) (dnp no)
(in_bom yes) (on_board yes) (dnp yes)
(uuid e0f15250-bd20-4545-ac0d-527fe10e2cdb)
(property "Reference" "C17" (at 147.4216 91.059 0)
(effects (font (size 1.27 1.27)) (justify left))
@ -1042,7 +1042,7 @@
)
(symbol (lib_id "Device:R") (at 142.24 99.06 180) (unit 1)
(in_bom yes) (on_board yes) (dnp no)
(in_bom yes) (on_board yes) (dnp yes)
(uuid fe93d30d-de39-4ca8-8ec8-dbd2cc54f863)
(property "Reference" "R7" (at 140.462 100.2284 0)
(effects (font (size 1.27 1.27)) (justify left))