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:
@@ -20,6 +20,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
|
#include "stm32h7xx_hal_tim.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
@@ -108,6 +109,24 @@ void camHandler(void *argument);
|
|||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* 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 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
@@ -420,7 +439,8 @@ void crankHandler(void *argument)
|
|||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
osDelay(1);
|
osThreadFlagsWait(0x01,osFlagsWaitAny,osWaitForever);
|
||||||
|
//TODO Handle the call
|
||||||
}
|
}
|
||||||
/* USER CODE END crankHandler */
|
/* USER CODE END crankHandler */
|
||||||
}
|
}
|
||||||
@@ -438,7 +458,8 @@ void camHandler(void *argument)
|
|||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
osDelay(1);
|
osThreadFlagsWait(0x01,osFlagsWaitAny,osWaitForever);
|
||||||
|
//TODO Handle the call
|
||||||
}
|
}
|
||||||
/* USER CODE END camHandler */
|
/* USER CODE END camHandler */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user