условно работающий первый канал, не вычисляется только duration

This commit is contained in:
2025-04-01 14:42:19 +03:00
parent b577be4b82
commit 40fca38a75
5 changed files with 78 additions and 16 deletions

View File

@@ -22,6 +22,7 @@
#include "stm32f4xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "recorder_buffer.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -252,9 +253,28 @@ void TIM1_TRG_COM_TIM11_IRQHandler(void)
void TIM2_IRQHandler(void)
{
/* USER CODE BEGIN TIM2_IRQn 0 */
static uint32_t overflows = 0;
const uint16_t sr = TIM2->SR;
TIM2->SR = 0;
if (sr & TIM_SR_UIF) {
overflows++;
}
if (sr & (TIM_SR_CC1OF | TIM_SR_CC2OF)) {
// overrun, skip processing
buffer_ch1.overruns = buffer_ch1.overruns + 1;
} else if (sr & TIM_SR_CC2IF) {
BufferItem_t b;
b.duration = TIM2->CCR1;
b.timepoint = TIM2->CCR2;
b.duration = b.duration - b.timepoint;
b.timepoint |= (uint64_t)(overflows) << 32;
ChannelBuffer_push(&buffer_ch1, &b);
}
/* USER CODE END TIM2_IRQn 0 */
HAL_TIM_IRQHandler(&htim2);
//HAL_TIM_IRQHandler(&htim2);
/* USER CODE BEGIN TIM2_IRQn 1 */
/* USER CODE END TIM2_IRQn 1 */