1 /*
2 * ======== empty_min.c ========
3 */
4 /* XDCtools Header files */
5 #include <xdc/std.h>
6 #include <xdc/runtime/System.h>
8 /* BIOS Header files */
9 #include <ti/sysbios/BIOS.h>
10 #include <ti/sysbios/knl/Task.h>
11 #include <ti/sysbios/knl/Clock.h>
13 /* TI-RTOS Header files */
14 #include <ti/drivers/I2C.h>
15 #include <ti/drivers/PIN.h>
16 // #include <ti/drivers/SPI.h>
17 #include <ti/drivers/UART.h>
18 // #include <ti/drivers/Watchdog.h>
20 /* Board Header files */
21 #include "Board.h"
23 #define TASKSTACKSIZE 512
25 Task_Struct task0Struct;
26 Char task0Stack[TASKSTACKSIZE];
28 Task_Struct task1Struct;
29 Char task1Stack[TASKSTACKSIZE];
32 /* Pin driver handle */
33 static PIN_Handle ledPinHandle;
34 static PIN_State ledPinState;
36 /*
37 * Application LED pin configuration table:
38 * - All LEDs board LEDs are off.
39 */
40 PIN_Config ledPinTable[] = {
41 Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
42 Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
43 PIN_TERMINATE
44 };
46 Void taskFxn(UArg arg0, UArg arg1)
47 {
48 char input;
49 UART_Handle uart;
50 UART_Params uartParams;
52 /* Create a UART with data processing off. */
53 UART_Params_init(&uartParams);
54 uartParams.writeDataMode = UART_DATA_BINARY;
55 uartParams.readDataMode = UART_DATA_BINARY;
56 uartParams.readReturnMode = UART_RETURN_FULL;
57 uartParams.readEcho = UART_ECHO_OFF;
58 //uartParams.baudRate = 9600;
59 uartParams.baudRate = 115200;
60 uart = UART_open(Board_UART0, &uartParams);
62 if (uart == NULL) {
63 System_abort("Error opening the UART");
64 }
66 /* Loop forever echoing */
67 while (1) {
68 /* Blocking Read */
69 UART_read(uart, &input, 1);
70 /* Echo */
71 UART_write(uart, &input, 1);
72 }
74 }
76 /*
77 * ======== heartBeatFxn ========
78 * Toggle the Board_LED0. The Task_sleep is determined by arg0 which
79 * is configured for the heartBeat Task instance.
80 */
81 Void heartBeatFxn(UArg arg0, UArg arg1)
82 {
83 while (1) {
84 Task_sleep((UInt)arg0);
85 //PIN_setOutputValue(ledPinHandle, Board_LEDR,!PIN_getOutputValue(Board_LED0));
86 PIN_setOutputValue(ledPinHandle, Board_LEDG,!PIN_getOutputValue(Board_LED1));
87 }
88 }
90 /*
91 * ======== main ========
92 */
93 int main(void)
94 {
95 Task_Params taskParams;
97 /* Call board init functions */
98 Board_initGeneral();
99 Board_initUART();
100 // Board_initI2C();
101 // Board_initSPI();
102 // Board_initWatchdog();
104 /* Construct heartBeat Task thread */
105 Task_Params_init(&taskParams);
106 taskParams.arg0 = 1000000 / Clock_tickPeriod;
107 taskParams.stackSize = TASKSTACKSIZE;
108 taskParams.stack = &task0Stack;
109 Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
111 /* UART */
112 Task_Params_init(&taskParams);
113 taskParams.stackSize = TASKSTACKSIZE;
114 taskParams.stack = &task1Stack;
115 Task_construct(&task1Struct, (Task_FuncPtr)taskFxn, &taskParams, NULL);
117 /* Open LED pins */
118 ledPinHandle = PIN_open(&ledPinState, ledPinTable);
119 if(!ledPinHandle) {
120 System_abort("Error initializing board LED pins\n");
121 }
123 PIN_setOutputValue(ledPinHandle, Board_LED0, 0);
124 PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
126 /* Start BIOS */
127 BIOS_start();
129 return (0);
130 }