-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.c
More file actions
90 lines (69 loc) · 2.34 KB
/
main.c
File metadata and controls
90 lines (69 loc) · 2.34 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <ti/sysbios/BIOS.h>
#include <xdc/cfg/global.h>
#include <ti/uia/sysbios/LoggerIdle.h>
/*
* Use the long names for ti/sysbios/family/arm/m3/Hwi.h, so we don't
* have name collisions with ti/sysbios/hal/Hwi.h, which is included
* by UART.h.
*/
#define ti_sysbios_family_arm_m3_Hwi__nolocalnames
#include <ti/sysbios/family/arm/m3/Hwi.h>
/* TI-RTOS Header files */
#include <stdint.h> /* assumed by ti.drivers headers (?) */
#include <ti/drivers/GPIO.h>
/* Example/Board Header files */
#include "Board.h"
#include "event_logger.h"
#include "uart_iface.h"
#include "delay.h"
/* Application entry function declaration */
Int app(Int argc, Char* argv[]);
/* Log events and console output go to this UART port */
UART_Iface_Port uartPort = NULL;
/* Called back by both system console and event logger */
Void outputToUART(Char *buf, Int size) {
UART_Iface_write(uartPort, buf, size);
}
Void outputToNull(Char *buf, Int size) {
}
/*
* ======== myExceptionHook ========
* User exception hook function. This function will be run on the ISR
* stack, so it must run to completion. This function is called without
* any Task or Swi scheduling protection, so it cannot call any functions
* that may cause a scheduling operation (eg, Swi_post(), Semaphore_post()).
*/
Void onException(ti_sysbios_family_arm_m3_Hwi_ExcContext *excp)
{
System_printf("Exception context = 0x%x\n", excp);
LoggerIdle_flush();
}
Int main(Int argc, Char* argv[])
{
/* Core configuration parameters (e.g. system clock) are specified in
* xdctools:ti.platforms.{stellaris,tiva}.Platform and maybe also see
* xdctools:ti.catalog.arm.cortexm4.tiva.ce.Boot */
Board_initGPIO();
#ifndef NO_UART
Board_initUART();
if (!(uartPort = UART_Iface_openHandle(Board_UART, FALSE)))
System_abort("Failed to open UART\n");
EventLogger_registerOutputFunc(&outputToUART);
#else
EventLogger_registerOutputFunc(&outputToNull);
#endif
GPIO_write(Board_LED, Board_LED_ON);
shortDelay();
GPIO_write(Board_LED, Board_LED_OFF);
System_printf("Running application...\n");
System_flush();
if (app(argc, argv))
System_abort("Application failed\n");
System_printf("Starting BIOS...\n");
System_flush();
BIOS_start();
return 0;
}