-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmotor.h
44 lines (37 loc) · 796 Bytes
/
motor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
*
* Generic H-bridge motor controller driver
*
* motor.h
*
* Created on: Feb 24, 2012
* Author: aah9038
*/
#ifndef MOTOR_H_
#define MOTOR_H_
#include <stdint.h>
#include "pwm.h"
#include "iodefs.h"
#include <math.h>
typedef enum {
freewheel = 0b00,
forward = 0b01,
backward = 0b10,
brake = 0b11
}motor_mode;
typedef struct{
uintptr_t cnt_port; //motor control ouput port
char input_1_pin;
char input_2_pin;
motor_mode current_mode;
pwm_args pwm;
}motor_t;
void motor_setSpeed(motor_t* motor, double speed);
/**
* Set the motor mode
*
* mode=freewheel,forward,backward,brake
*/
void motor_setMode(motor_t* motor, motor_mode mode);
void init_motor(motor_t* motor, uintptr_t port, char input_1_pin, char input_2_pin, char pwmPin);
#endif /* MOTOR_H_ */