Files
proj2/KPI_Rover/Encoders/drvEncoder.c
T

29 lines
673 B
C
Raw Normal View History

#include "drvEncoder.h"
2026-10-11 19:53:19 +03:00
#include "hwTIM.c"
extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim4;
void drvEncoder_Init(void) {
2026-10-11 19:53:19 +03:00
HW_TIM_Init();
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL);
HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL);
HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL);
HAL_TIM_Encoder_Start(&htim4, TIM_CHANNEL_ALL);
}
uint32_t drvEncoder_Read(uint8_t channel) {
switch (channel) {
case 0: return TIM1->CNT;
case 1: return TIM2->CNT;
case 2: return TIM3->CNT;
case 3: return TIM4->CNT;
default: return 0;
}
}