-
Notifications
You must be signed in to change notification settings - Fork 65
/
demo.c
executable file
·56 lines (48 loc) · 1.58 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
52
53
54
55
56
//
// demo.c -- Simple demonstration program
//
// Copyright (c) 2012-2013 Andrew Payne <andy@payne.org>
//
#include <stdio.h>
#include "freedom.h"
#include "common.h"
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();
// Blink the green LED to indicate booting
unsigned int pattern = 0b1100110011001100;
while(pattern) {
RGB_LED(0, pattern & 1 ? 100 : 0, 0); // Set GREEN led based on LSB
pattern >>= 1;
delay(25);
}
// Welcome banner
iprintf("\r\n\r\n====== Freescale Freedom FRDM-KL25Z\r\n");
iprintf("Built: %s %s\r\n\r\n", __DATE__, __TIME__);
heap_end = _sbrk(0);
iprintf("Reset code: 0x%02x 0x%02x\r\n", RCM_SRS0, RCM_SRS1);
iprintf("Heap: %p to %p (%d bytes used)\r\n", __heap_start, heap_end,
heap_end - (char *)__heap_start);
iprintf("Stack: %p to %p (%d bytes used)\r\n", &i, __StackTop,
(char *)__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();
}
}