ganz hässliche code zwischen speicher

This commit is contained in:
2025-07-12 02:38:13 +02:00
parent 9c4b60fd18
commit fb3eba0a09
12 changed files with 88 additions and 66 deletions

View File

@ -63,8 +63,9 @@ PCD_HandleTypeDef hpcd_USB_OTG_FS;
SDRAM_HandleTypeDef hsdram1;
/* USER CODE BEGIN PV */
extern TSStateHandle ts_state;
int can_ams_last_tick = 0;
GPIO_PinState TSON = 0;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@ -134,7 +135,9 @@ int main(void)
error_led_init();
sdc_init();
led_init(&htim3);
can_init(&hfdcan1);
while (can_init(&hfdcan1)){
led_blink(&htim3, 0x00FFFF00, 0);
}
/* USER CODE END 2 */
/* Infinite loop */
@ -147,9 +150,18 @@ int main(void)
if (HAL_GetTick() - can_ams_last_tick > AMS_TIMEOUT) {
error_led_init();
led_blink(&htim3, COLOR_ERROR, 0);
} else {
led_blink(&htim3, COLOR_HEARTBEAT, 1000);
}
led_blink(&htim3, COLOR_HEARTBEAT, 1000);
// SHOW_STATE(check_sdc_state());
// SHOW_STATE(can_update_state());
TSON = HAL_GPIO_ReadPin(TS_ON_GPIO_Port, TS_ON_Pin);
if (TSON == 1){
change_ts_state(TS_ACTIVE);
}
check_sdc_state();
can_update_state();
}
/* USER CODE END 3 */
}
@ -273,9 +285,9 @@ static void MX_FDCAN1_Init(void)
hfdcan1.Init.AutoRetransmission = DISABLE;
hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = 16;
hfdcan1.Init.NominalPrescaler = 5;
hfdcan1.Init.NominalSyncJumpWidth = 1;
hfdcan1.Init.NominalTimeSeg1 = 1;
hfdcan1.Init.NominalTimeSeg1 = 8;
hfdcan1.Init.NominalTimeSeg2 = 1;
hfdcan1.Init.DataPrescaler = 1;
hfdcan1.Init.DataSyncJumpWidth = 1;
@ -284,7 +296,7 @@ static void MX_FDCAN1_Init(void)
hfdcan1.Init.MessageRAMOffset = 0;
hfdcan1.Init.StdFiltersNbr = 32;
hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.RxFifo0ElmtsNbr = 0;
hfdcan1.Init.RxFifo0ElmtsNbr = 16;
hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxFifo1ElmtsNbr = 0;
hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
@ -292,7 +304,7 @@ static void MX_FDCAN1_Init(void)
hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.TxEventsNbr = 0;
hfdcan1.Init.TxBuffersNbr = 0;
hfdcan1.Init.TxFifoQueueElmtsNbr = 0;
hfdcan1.Init.TxFifoQueueElmtsNbr = 32;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
@ -709,17 +721,11 @@ static void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOI, AMS_ERROR_Pin|IMD_ERROR_Pin, GPIO_PIN_SET);
/*Configure GPIO pin : TS_ON_Pin */
GPIO_InitStruct.Pin = TS_ON_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(TS_ON_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : SDC_ON_Pin */
GPIO_InitStruct.Pin = SDC_ON_Pin;
/*Configure GPIO pins : TS_ON_Pin SDC_ON_Pin */
GPIO_InitStruct.Pin = TS_ON_Pin|SDC_ON_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(SDC_ON_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
/*Configure GPIO pin : SDC_ENABLE_Pin */
GPIO_InitStruct.Pin = SDC_ENABLE_Pin;
@ -748,9 +754,6 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(TS_ON_EXTI_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TS_ON_EXTI_IRQn);
HAL_NVIC_SetPriority(ENC_PUSH_ON_EXTI_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(ENC_PUSH_ON_EXTI_IRQn);