11#ifndef MOTOR_CONTROL_H
12#define MOTOR_CONTROL_H
14#include "pico/stdlib.h"
15#include "pico/types.h"
28#define MOTOR_PWM_CLKDIV 100
30#define MOTOR_PWM_WRAP 62500
32#define MOTOR_LEFT_PIN_CLKWISE 16
34#define MOTOR_LEFT_PIN_ANTICLKWISE 17
36#define MOTOR_RIGHT_PIN_CLKWISE 15
38#define MOTOR_RIGHT_PIN_ANTICLKWISE 14
40#define MOTOR_PWM_PIN_LEFT 10
42#define MOTOR_PWM_PIN_RIGHT 11
44#define MOTOR_DEFAULT_DIFF_RATIO 1.05f
69void motor_start(uint clkwise_gpio, uint anti_clkwise_gpio, uint pwm_gpio);
72 uint anti_clkwise_gpio,
void motor_reverse(void)
A function to reverse the car.
Definition: motor_control.c:134
void motor_turn_left(bool reverse_turn)
A function to turn the car left.
Definition: motor_control.c:156
void motor_update_ratio(float new_ratio)
Update the ratio of the left motor's duty cycle to the right motor's duty cycle.
Definition: motor_control.c:218
struct motor_pins motor_pins_t
Contains the GPIO pins for the motor.
void motor_update_pwm(uint pwm_gpio, uint pwm_wrap, float duty_cycle)
A function to update the PWM duty cycle and wrap value.
Definition: motor_control.c:56
void motor_update_direction(uint clkwise_gpio, uint anti_clkwise_gpio, uint clkwise, uint anti_clkwise)
A function to update the direction of the motor's rotation.
Definition: motor_control.c:85
void motor_stop(void)
A function to stop the car.
Definition: motor_control.c:120
void motor_turn_right(bool reverse_turn)
A function to turn the car right.
Definition: motor_control.c:189
void motor_start(uint clkwise_gpio, uint anti_clkwise_gpio, uint pwm_gpio)
Default initialization of a single motor.
Definition: motor_control.c:31
void motor_move_forward(void)
A function to move the car forward.
Definition: motor_control.c:102
Contains the GPIO pins for the motor.
Definition: motor_control.h:56
uint pwm_gpio_a
GPIO pin for PWM A.
Definition: motor_control.h:57
uint left_anticlkwise
GPIO pin for left motor anti-clockwise.
Definition: motor_control.h:60
uint right_anticlkwise
GPIO pin for right motor anti-clockwise.
Definition: motor_control.h:62
uint right_clkwise
GPIO pin for right motor clockwise.
Definition: motor_control.h:61
uint pwm_gpio_b
GPIO pin for PWM B.
Definition: motor_control.h:58
uint left_clkwise
GPIO pin for left motor clockwise.
Definition: motor_control.h:59