add encoders, to be tested on real hw, do not break immediately

This commit is contained in:
2026-10-11 19:43:50 +03:00
parent aad79e95c3
commit 33e4fb34a1
9 changed files with 387 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
#include "drvEncoder.h"
extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim4;
void drvEncoder_Init(void) {
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;
}
}