Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
motor_driver.h
Go to the documentation of this file.
1
8
9#ifndef INC_MOTOR_DRIVER_H_
10#define INC_MOTOR_DRIVER_H_
11
12#include <stdlib.h>
13#include <stdio.h>
14#include <stdint.h>
15#include "stm32f4xx_hal.h"
16
22typedef struct {
23 TIM_HandleTypeDef *tim;
24 uint32_t chan1;
25 uint32_t chan2;
26} motor_t;
27
34void set_duty(motor_t *p_mot, int32_t duty);
35
41void enable(motor_t *p_mot);
42
48void disable(motor_t *p_mot);
49
58void go_to(motor_t *p_mot, int k_p, int where, int from);
59
60#endif /* INC_MOTOR_DRIVER_H_ */
void go_to(motor_t *p_mot, int k_p, int where, int from)
Uses proportional control to move motor to a target.
Definition motor_driver.c:65
void disable(motor_t *p_mot)
Disables the motor by setting both channels to zero.
Definition motor_driver.c:40
void enable(motor_t *p_mot)
Enables the motor by setting both channels to maximum.
Definition motor_driver.c:51
void set_duty(motor_t *p_mot, int32_t duty)
Sets the duty cycle and direction of the motor.
Definition motor_driver.c:23
Motor object data structure.
Definition motor_driver.h:22
uint32_t chan2
Definition motor_driver.h:25
uint32_t chan1
Definition motor_driver.h:24
TIM_HandleTypeDef * tim
Definition motor_driver.h:23