main.c 859 Bytes
Newer Older
Rahix's avatar
Rahix committed
1
#include <stdio.h>
Rahix's avatar
Rahix committed
2
#include "card10.h"
Rahix's avatar
Rahix committed
3
#include "uart.h"
4
#include "cdcacm.h"
Rahix's avatar
Rahix committed
5
#include "leds.h"
Rahix's avatar
Rahix committed
6
7
8
9
10
11
12
#include "api/dispatcher.h"

extern mxc_uart_regs_t * ConsoleUart;

void epic_uart_write_str(char*str, intptr_t length)
{
	UART_Write(ConsoleUart, (uint8_t*)str, length);
Rahix's avatar
Rahix committed
13
	cdcacm_write((uint8_t*)str, length);
Rahix's avatar
Rahix committed
14
15
16
17
}

char epic_uart_read_chr(void)
{
Rahix's avatar
Rahix committed
18
19
20
21
22
23
24
25
26
	while(1) {
		if(UART_NumReadAvail(ConsoleUart) > 0) {
			return UART_ReadByte(ConsoleUart);
		}

		if(cdcacm_num_read_avail() > 0) {
			return cdcacm_read();
		}
	}
Rahix's avatar
Rahix committed
27
}
Rahix's avatar
Rahix committed
28

29
30
31
32
33
34
void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)
{
	leds_set(led, r, g, b);
	leds_update();
}

Rahix's avatar
Rahix committed
35
36
37
38
int main(void)
{
	card10_init();
	card10_diag();
Rahix's avatar
Rahix committed
39

Rahix's avatar
Rahix committed
40
	cdcacm_init();
41

Rahix's avatar
Rahix committed
42
43
44
	printf("Initializing dispatcher ...\n");
	api_dispatcher_init();

Rahix's avatar
Rahix committed
45
46
	printf("Staring core1 payload ...\n");
	core1_start();
Rahix's avatar
Rahix committed
47
48
49
50
51

	while(1) {
		__WFE();
		api_dispatcher_poll();
	}
Rahix's avatar
Rahix committed
52
}