-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotor.c
54 lines (48 loc) · 1.16 KB
/
motor.c
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
45
46
47
48
49
50
51
52
53
54
/*
* src_motor.c
*
* Created on: Sep 16, 2017
* Author: sdev
*/
#include "motor.h"
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "driverlib/systick.h"
#include "utils/uartstdio.h"
#include "driverlib/pwm.h"
void MotorController(int32_t spd_l, int32_t spd_r) {
if (spd_l < 0) {
spd_l *= -1;
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, 2*spd_l+3);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_5, 3);
}
else
{
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, 3);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_5, 2*spd_l+3);
}
if (spd_r < 0){
spd_r *= -1;
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, 3);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_7, 2*spd_r+3);
}
else
{
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, 2*spd_r+3);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_7, 3);
}
}
void MotorInit()
{
}