Basic code to handle the interupts for cam&crank

using osThreads to call the respective handler
TODO add the ring buffers to be able to process the timestamps
This commit is contained in:
2026-06-02 16:34:35 +02:00
parent b0152e2751
commit 5e904177de

View File

@@ -20,6 +20,7 @@
#include "main.h"
#include "FreeRTOS.h"
#include "cmsis_os2.h"
#include "stm32h7xx_hal_tim.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
@@ -108,6 +109,24 @@ void camHandler(void *argument);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
if (htim->Instance == TIM2) {
switch (htim->Channel) {
//HAL_TIM_ACTIVE_CHANNEL_2 is the channel used for cam interupts
case HAL_TIM_ACTIVE_CHANNEL_2:
// TODO push timestamp to the cam ring buffer
osThreadFlagsSet(camTaskHandle,0x01);
break;
//HAL_TIM_ACTIVE_CHANNEL_1 is the channel used for crank interupts
case HAL_TIM_ACTIVE_CHANNEL_1:
// TODO push timestamp to the crank ring buffer
osThreadFlagsSet(crankTaskHandle,0x01);
break;
default:
break;
}
}
}
/* USER CODE END 0 */
@@ -420,7 +439,8 @@ void crankHandler(void *argument)
/* Infinite loop */
for(;;)
{
osDelay(1);
osThreadFlagsWait(0x01,osFlagsWaitAny,osWaitForever);
//TODO Handle the call
}
/* USER CODE END crankHandler */
}
@@ -438,7 +458,8 @@ void camHandler(void *argument)
/* Infinite loop */
for(;;)
{
osDelay(1);
osThreadFlagsWait(0x01,osFlagsWaitAny,osWaitForever);
//TODO Handle the call
}
/* USER CODE END camHandler */
}