-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.c
102 lines (86 loc) · 1.57 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
97
98
99
100
101
102
#include "common.h"
#include "sleep.h"
#include "serial.h"
#include "power.h"
#include "gpio.h"
#include "adc.h"
#include "led.h"
#include "pmh4.h"
#include "irqs.h"
#include "test.h"
void power_board() {
/* !mainoff */
P2DR |= (1 << 4);
/* -KBRC */
/* FAN On */
/* -batlow */
P4DR |= (1 << 0) | (1 << 4) | (1 << 3);
/* -pwrsw_h8s */
P9DR |= (1 << 5);
sleep(2);
P9DR &= ~(1 << 5);
sleep(2);
P9DR |= (1 << 5);
}
int main() {
P2DDR = 0xf0; /* -MAINOFF -LEDNUMPAD -BAYLED -LEDCAPSLOCK */
P4DDR = ((1 << 0) | (1 << 3) | 1 << 4); /* -KBRC -BATLOW FANON */
P9DDR = (1 << 5);
P8DDR = (1 << 1) | (1 << 4); /* TXD1 output */
led_caps(0);
led_num(0);
for(int i=0; i<3; i++) {
led_caps(1);
sleep(1);
led_caps(0);
sleep(1);
}
int ret = setup_serial(B9600, 0);
while(ret) {
led_num(1);
}
print_size_u8();
print_size_u16();
print_size_u32();
print_size_int();
print_size_pointer();
dump_memory((void *)0xffe080, 3*32);
led_num(0);
led_caps(0);
enable_dac(0, 1);
enable_dac(1, 1);
set_dac(0, 120);
set_dac(1, 120);
uart_print_rx_ringbuffer();
uart_puts("TX\n");
uart_print_tx_ringbuffer();
test_ringbuffer();
for(int i=0; i<5; i++) {
led_num(1);
sleep(1);
led_num(0);
sleep(1);
}
power_board();
uart_enable_rx();
enable_irqs();
while(1) {
uart_puts("\r\nyip\r\n");
while (uart_readable()) {
char c;
uart_puts("rd:");
if (uart_getc(&c))
break;
uart_putc(c);
}
debug_irq();
led_caps(1);
sleep(1);
led_caps(0);
sleep(1);
}
uart_puts("NEVER");
uart_puts("NEVER");
uart_puts("NEVER");
uart_puts("NEVER");
}