forked from fongwh1/quadrotor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwm.c
71 lines (50 loc) · 1.07 KB
/
pwm.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "module_motor.h"
#include "stm32f4xx.h"
#include "stm32f4_delay.h"
#include "string-util.h"
void PWM_Config( void ){
Motor_Config();
}
void PWM_print()
{
printf("1: %d 2: %d 3: %d 4: %d\n",PWM_Motor1,PWM_Motor2,PWM_Motor3,PWM_Motor4);
}
void PWM_test(void){
u16 PWM_pulse = PWM_MOTOR_MIN;
u8 count;
while( 1 ){
while(PWM_pulse < PWM_MOTOR_MAX - 200)
{
PWM_pulse += 10 ;
PWM_Motor1 = PWM_pulse;
PWM_Motor2 = PWM_pulse;
PWM_Motor3 = PWM_pulse;
PWM_Motor4 = PWM_pulse;
if ((PWM_pulse % 100) == 0 )
{
PWM_print();
}
Delay_100ms(1);
}
while(PWM_pulse > PWM_MOTOR_MIN)
{
PWM_pulse -= 10;
PWM_Motor1 = PWM_pulse;
PWM_Motor2 = PWM_pulse;
PWM_Motor3 = PWM_pulse;
PWM_Motor4 = PWM_pulse;
if ((PWM_pulse % 100) == 0 )
{
PWM_print();
}
Delay_100ms(1);
}
}
}
void PWM_task(void * pvParameters)
{
PWM_test();
while(1)
{
}
}