-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
30 lines (28 loc) · 759 Bytes
/
main.c
File metadata and controls
30 lines (28 loc) · 759 Bytes
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
#include "uart.h"
#include "gpio.h"
int main() {
GPIO->DIRSET = ((1 << 16) - (1 << 4));
GPIO->OUTCLR = ((1 << 16) - (1 << 4));
GPIO->PIN_CNF[17] = 0;
GPIO->PIN_CNF[26] = 0;
int sleep = 0;
uartInit();
while(uartRead() == '\0');
GPIO->OUTSET = (1 << 15);
while(1) {
if (UART->ERRORSRC & (1 << 2)) {
GPIO->OUTCLR = (1 << 16) - (1 << 13);
GPIO->OUTSET = (1 << 15);
}
if (!(GPIO->IN & (1 << 17))) {
uartSend('A');
GPIO->OUTSET = (1 << 16) - (1 << 13);
} else if (!(GPIO->IN & (1 << 26))) {
uartSend('B');
GPIO->OUTCLR = (1 << 16) - (1 << 13);
}
sleep = 10000;
while(--sleep);
}
return 0;
}