forked from payne92/bare-metal-arm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.c
executable file
·51 lines (43 loc) · 1.36 KB
/
demo.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
//
// demo.c -- Simple demonstration program
//
// Copyright (c) 2012-2013 Andrew Payne <[email protected]>
//
#include <stdio.h>
#include "freedom.h"
#include "common.h"
// Defined by linker
extern char __heap_start[];
extern char __StackTop[];
extern char *_sbrk(int len);
// Main program
int main(void)
{
char i;
char *heap_end;
// Initialize all modules
uart_init(115200);
accel_init();
touch_init((1 << 9) | (1 << 10)); // Channels 9 and 10
// usb_init();
setvbuf(stdin, NULL, _IONBF, 0); // No buffering
// Run tests
tests();
delay(500);
RGB_LED(0,100,0); // Green
// Welcome banner
iprintf("\r\n\r\n====== Freescale Freedom FRDM-LK25Z\r\n");
iprintf("Built: %s %s\r\n\r\n", __DATE__, __TIME__);
heap_end = _sbrk(0);
iprintf("Heap: %p to %p (%d bytes used)\r\n", __heap_start, heap_end, heap_end - __heap_start);
iprintf("Stack: %p to %p (%d bytes used)\r\n", &i, __StackTop, __StackTop - &i);
iprintf("%d bytes free\r\n", &i - heap_end);
for(;;) {
iprintf("monitor> ");
getchar();
iprintf("\r\n");
iprintf("Inputs: x=%5d y=%5d z=%5d ", accel_x(), accel_y(), accel_z());
iprintf("touch=(%d,%d)\r\n", touch_data(9), touch_data(10));
// usb_dump();
}
}