summaryrefslogtreecommitdiff
path: root/firmware/src/os/main.c
blob: 4b7a7a2237d367bc520b3f1c859b8b51b55b7022 (plain)
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
#include <errno.h>
#include <string.h>
#include <include/lib_AT91SAM7.h>
#include <os/dbgu.h>
#include <os/led.h>
#include <os/dfu.h>
#include <os/main.h>
#include <os/power.h>
#include <os/pcd_enumerate.h>
#include "../openpcd.h"

int main(void)
{
	/* initialize LED and debug unit */
	led_init();
	AT91F_DBGU_Init();

	AT91F_PIOA_CfgPMC();
	/* call application specific init function */
	_init_func();

	/* initialize USB */
	udp_init();
	udp_open();

	// Enable User Reset and set its minimal assertion to 960 us
	AT91C_BASE_RSTC->RSTC_RMR =
	    AT91C_RSTC_URSTEN | (0x4 << 8) | (unsigned int)(0xA5 << 24);

#ifdef DEBUG_CLOCK_PA6
	AT91F_PMC_EnablePCK(AT91C_BASE_PMC, 0, AT91C_PMC_CSS_PLL_CLK);
	AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, 0, AT91C_PA6_PCK0);
#endif

	/* switch on first led */
	led_switch(2, 1);

	DEBUGPCRF("entering main (idle) loop");
	while (1) {
		/* Call application specific main idle function */
		_main_func();
		dbgu_rb_flush();
#ifdef CONFIG_IDLE
		//cpu_idle();
#endif
	}
}
personal git repositories of Harald Welte. Your mileage may vary