From fd5478a52159ac37a78b61efbe0ad9ae793fd458 Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 26 Apr 2023 15:06:03 +0200 Subject: [PATCH] Firmware integration fixes --- sdcl-firmware/Core/Src/main.c | 25 ++++++++++++++----------- sdcl-firmware/sdcl-firmware.ioc | 6 ++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/sdcl-firmware/Core/Src/main.c b/sdcl-firmware/Core/Src/main.c index 0d1210f..517ef24 100644 --- a/sdcl-firmware/Core/Src/main.c +++ b/sdcl-firmware/Core/Src/main.c @@ -190,7 +190,6 @@ int main(void) Error_Handler(); // TODO: Use Filter - /* CAN_FilterTypeDef canfilterconfig; canfilterconfig.FilterActivation = CAN_FILTER_ENABLE; @@ -207,7 +206,6 @@ int main(void) if (HAL_CAN_ConfigFilter(&hcan, &canfilterconfig) != HAL_OK) { Error_Handler(); } - */ if (HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK) Error_Handler(); @@ -232,19 +230,21 @@ int main(void) bool pAMC = false; mission_t new_mission = mission; // By default, don't change mission + HAL_Delay(1000); + while (true) { - bool TS_activate_MUXed = HAL_GPIO_ReadPin(TS_activate_MUXed_GPIO_Port, TS_activate_MUXed_Pin) == GPIO_PIN_SET; - bool ASMS = HAL_GPIO_ReadPin(ASMS_GPIO_Port, ASMS_Pin) == GPIO_PIN_SET; - bool WD_OK = HAL_GPIO_ReadPin(WD_OK_GPIO_Port, WD_OK_Pin) == GPIO_PIN_SET; + bool TS_activate_MUXed = HAL_GPIO_ReadPin(TS_activate_MUXed_GPIO_Port, TS_activate_MUXed_Pin) == GPIO_PIN_RESET; + bool ASMS = HAL_GPIO_ReadPin(ASMS_GPIO_Port, ASMS_Pin) == GPIO_PIN_RESET; + //bool WD_OK = HAL_GPIO_ReadPin(WD_OK_GPIO_Port, WD_OK_Pin) == GPIO_PIN_RESET; bool SDC_is_ready = HAL_GPIO_ReadPin(SDC_is_ready_GPIO_Port, SDC_is_ready_Pin) == GPIO_PIN_SET; bool SDC_in_3V3 = HAL_GPIO_ReadPin(SDC_in_3V3_GPIO_Port, SDC_in_3V3_Pin) == GPIO_PIN_SET; bool LV_SENSE_1 = HAL_GPIO_ReadPin(LV_SENSE_1_GPIO_Port, LV_SENSE_1_Pin) == GPIO_PIN_SET; bool LV_SENSE_2 = HAL_GPIO_ReadPin(LV_SENSE_2_GPIO_Port, LV_SENSE_2_Pin) == GPIO_PIN_SET; - bool INITIAL_OPEN = HAL_GPIO_ReadPin(INITIAL_OPEN_GPIO_Port, INITIAL_OPEN_Pin) == GPIO_PIN_SET; - bool CLOSED = HAL_GPIO_ReadPin(CLOSED_GPIO_Port, CLOSED_Pin) == GPIO_PIN_SET; - bool REOPENED = HAL_GPIO_ReadPin(REOPENED_GPIO_Port, REOPENED_Pin) == GPIO_PIN_SET; + bool INITIAL_OPEN = HAL_GPIO_ReadPin(INITIAL_OPEN_GPIO_Port, INITIAL_OPEN_Pin) == GPIO_PIN_RESET; + bool CLOSED = HAL_GPIO_ReadPin(CLOSED_GPIO_Port, CLOSED_Pin) == GPIO_PIN_RESET; + bool REOPENED = HAL_GPIO_ReadPin(REOPENED_GPIO_Port, REOPENED_Pin) == GPIO_PIN_RESET; bool AMC = HAL_GPIO_ReadPin(AMC_GPIO_Port, AMC_Pin) == GPIO_PIN_SET; // On signal edge. Debouncing usually not needed at these polling rates (10Hz) @@ -258,7 +258,10 @@ int main(void) } - tx_data_t txData = { + // TODO: Depends on STM watchdog + bool WD_OK = true; + + txData = (tx_data_t) { .signals = { .asms_state = ASMS, .sdc_state_1 = LV_SENSE_1, @@ -347,8 +350,8 @@ static void MX_CAN_Init(void) hcan.Init.TimeSeg1 = CAN_BS1_13TQ; hcan.Init.TimeSeg2 = CAN_BS2_2TQ; hcan.Init.TimeTriggeredMode = DISABLE; - hcan.Init.AutoBusOff = DISABLE; - hcan.Init.AutoWakeUp = DISABLE; + hcan.Init.AutoBusOff = ENABLE; + hcan.Init.AutoWakeUp = ENABLE; hcan.Init.AutoRetransmission = ENABLE; hcan.Init.ReceiveFifoLocked = DISABLE; hcan.Init.TransmitFifoPriority = DISABLE; diff --git a/sdcl-firmware/sdcl-firmware.ioc b/sdcl-firmware/sdcl-firmware.ioc index 2e4a1e1..a7969ba 100644 --- a/sdcl-firmware/sdcl-firmware.ioc +++ b/sdcl-firmware/sdcl-firmware.ioc @@ -1,10 +1,12 @@ #MicroXplorer Configuration settings - do not modify +CAN.ABOM=ENABLE +CAN.AWUM=ENABLE CAN.BS1=CAN_BS1_13TQ CAN.BS2=CAN_BS2_2TQ CAN.CalculateBaudRate=500000 CAN.CalculateTimeBit=2000 CAN.CalculateTimeQuantum=125.0 -CAN.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1,BS2,SJW,NART +CAN.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1,BS2,SJW,NART,ABOM,AWUM CAN.NART=ENABLE CAN.Prescaler=1 CAN.SJW=CAN_SJW_1TQ @@ -257,7 +259,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=true -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_CAN_Init-CAN-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_CAN_Init-CAN-false-HAL-true RCC.ADC12outputFreq_Value=16000000 RCC.AHBFreq_Value=8000000 RCC.APB1Freq_Value=8000000