-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipwm.c
executable file
·93 lines (87 loc) · 1.46 KB
/
ipwm.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "MQ6812.h"
#include "iApp.h"
#include "FlashFunction.h"
#include "protocol.h"
#include "ipwm.h"
#include "battery_detect.h"
#include "led.h"
char dev_start_dchg_flag =0;
char dev_start_chg_flag = 0;
char ipwm_temp = 0;
char ipwm_val = 0;
char led_blink_f = 0;
extern uchar bat_quan ;
uchar dev_discharging_f =0;
uchar dev_charging_f =0;
void PB_Ipwm_Discharge_Control(void)
{
if(dev_start_dchg_flag==0) // not in discharge mode
{
CE = 0;
delay_times(t_1ms, 1);
DIR=1;
PPG00_INIT(50, 100);
CE=1;
dev_start_dchg_flag=1;
dev_start_chg_flag=0;
dev_discharging_f =1;
dev_charging_f = 0;
}
//Get_Battery_Quantity();
D1 = 1;
D2 = 1;
}
void PB_Ipwm_Charge_Control(void)
{
if(dev_start_chg_flag==0)
{
CE = 0;
delay_times(t_1ms, 1);
DIR=0;
PPG00_INIT(20, 100);
CE=1;
dev_start_chg_flag=1;
dev_start_dchg_flag =0;
dev_discharging_f =0;
dev_charging_f = 1;
}
else
{
if(flag_1s==1)
{
pb_ipwm_dynamic_control();
flag_1s=0;
}
}
}
void pb_ipwm_dynamic_control(void)
{
// if(ipwm_temp<30)
// {
// ipwm_temp++;
// }
// PPG00_INIT(ipwm_temp, 100);
PPG00_INIT(15, 100);
D1 = 1;
D2 = 1;
D3 = 1;
if(led_blink_f)
{
D4= 1;
led_blink_f=0;
}
else
{
D4 = 0;
led_blink_f=1;
}
}
void PB_Stay(void)
{
delay_times(t_1ms, 1);
DIR=0;
PPG00_INIT(0, 100);
dev_start_dchg_flag=0;
dev_start_chg_flag=0;
CE=0;
}