-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathmain.c
96 lines (75 loc) · 1.62 KB
/
main.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
94
95
96
/*
* This file is part of rad1o
*
*/
#include <unistd.h>
#include <rad1olib/setup.h>
#include <r0ketlib/display.h>
#include <r0ketlib/keyin.h>
#include <r0ketlib/menu.h>
#include <r0ketlib/config.h>
#include <rad1olib/pins.h>
#include <rad1olib/systick.h>
#include <rad1olib/battery.h>
#include <r0ketlib/fs_util.h>
#include "main.gen"
#include "l0ungel1cht.h"
#define EVERY(x,y) if((ctr+y)%(x/SYSTICKSPEED)==0)
void tick_batteryLED(void){
static int ctr;
ctr++;
EVERY(50,0){
if(GLOBAL(chargeled)){
//char iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0;
if(batteryCharging()) {
ON(LED4);
} else {
OFF(LED4);
}
};
if(batteryGetVoltage()<3600){
if( (ctr/(50/SYSTICKSPEED))%10 == 1 ) {
ON(LED4);
} else {
OFF(LED4);
}
};
};
return;
}
void sys_tick_handler(void){
incTimer();
generated_tick();
};
void init_nick(void){
readTextFile("nick.cfg",GLOBAL(nickname),MAXNICK);
readTextFile("font.cfg",GLOBAL(nickfont),FLEN);
readTextFile("l0nick.cfg",GLOBAL(nickl0),FLEN);
}
int main(void) {
cpuClockInit(); /* CPU Clock is now 104 MHz */
systickInit();
// cpu_clock_set(204);
SETUPgout(EN_VDD);
SETUPgout(EN_1V8);
SETUPgout(MIXER_EN);
SETUPgout(MIC_AMP_DIS);
SETUPgout(LED1);
SETUPgout(LED2);
SETUPgout(LED3);
SETUPgout(LED4);
SETUPpin(UART0_TXD);
SETUPpin(UART0_RXD);
inputInit();
lcdInit();
fsInit();
lcdFill(0xff);
readConfig();
batteryInit();
init_nick();
generated_init();
while(1){
l0ungel1cht();
};
return 0;
}