ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
Loading...
Searching...
No Matches
motor_driver.h
Go to the documentation of this file.
1/*
2 * motor_driver.h
3 *
4 * Created on: Apr 17, 2025
5 * Author: jacka
6 */
7
8#ifndef INC_MOTOR_DRIVER_H_
9#define INC_MOTOR_DRIVER_H_
10
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#include <stdio.h>
23#include <stdint.h>
24#include <stm32f4xx_hal.h> // Include HAL functions
25
31typedef struct {
32 int32_t duty;
33 TIM_HandleTypeDef* htim;
34 uint32_t ch_A;
35 uint32_t ch_B;
36} motor_t;
37
43void motor_set_duty(motor_t* p_mot, int32_t duty);
44
49void motor_enable(motor_t* p_mot);
50
55void motor_disable(motor_t* p_mot);
56
57#ifdef __cplusplus
58}
59#endif
60
61#endif /* INC_MOTOR_DRIVER_H_ */
void motor_disable(motor_t *p_mot)
Disables PWM output to the motor.
Definition motor_driver.c:28
void motor_set_duty(motor_t *p_mot, int32_t duty)
Sets the PWM duty cycle to control motor speed and direction.
Definition motor_driver.c:41
void motor_enable(motor_t *p_mot)
Enables PWM output to the motor by starting both channels.
Definition motor_driver.c:18
Struct representing a DC motor controlled by two PWM channels.
Definition motor_driver.h:31
TIM_HandleTypeDef * htim
Definition motor_driver.h:33
uint32_t ch_B
Definition motor_driver.h:35
uint32_t ch_A
Definition motor_driver.h:34
int32_t duty
Definition motor_driver.h:32