+motors, not crashing, ADC needs DMA fix to stop messing up other DMAs

This commit is contained in:
2026-10-11 19:29:03 +03:00
parent 844f53a12b
commit aad79e95c3
25 changed files with 1715 additions and 198 deletions
+47
View File
@@ -0,0 +1,47 @@
#ifndef MOTORS_DRIVER_H
#define MOTORS_DRIVER_H
#include "stm32f4xx_hal.h"
#include <stdbool.h>
typedef enum {
PWM_SRC_TIM,
PWM_SRC_PCA9685
} pwm_source_t;
typedef struct {
GPIO_TypeDef* IN1_port;
uint16_t IN1_pin;
GPIO_TypeDef* IN2_port;
uint16_t IN2_pin;
pwm_source_t pwm_src;
uint8_t in1_pca_channel;
uint8_t in2_pca_channel;
bool last_forward;
union {
struct {
TIM_HandleTypeDef* htim;
uint32_t channel;
} tim;
struct {
uint8_t channel;
} pca;
} pwm;
bool enabled;
} drvMotor_t;
void DriverMotor_Init(drvMotor_t* motor);
void DriverMotor_Enable(drvMotor_t* motor);
void DriverMotor_Disable(drvMotor_t* motor);
void DriverMotor_setDirection(drvMotor_t* motor, bool forward);
void DriverMotor_setPwm(drvMotor_t* motor, uint16_t pwm);
#endif