1 /*
2 * Copyright (c) 2015-2016, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /*
34 * ======== empty_min.c ========
35 */
36 /* XDCtools Header files */
37 #include <xdc/std.h>
38 #include <xdc/runtime/System.h>
40 /* BIOS Header files */
41 #include <ti/sysbios/BIOS.h>
42 #include <ti/sysbios/knl/Task.h>
43 #include <ti/sysbios/knl/Clock.h>
45 /* TI-RTOS Header files */
46 #include <ti/drivers/PIN.h>
47 // #include <ti/drivers/I2C.h>
48 // #include <ti/drivers/SPI.h>
49 //#include <ti/drivers/UART.h>
50 // #include <ti/drivers/Watchdog.h>
52 /* Board Header files */
53 #include "Board.h"
55 #define TASKSTACKSIZE 512
57 Task_Struct task0Struct;
58 Char task0Stack[TASKSTACKSIZE];
60 /* Pin driver handle */
61 static PIN_Handle ledPinHandle;
62 static PIN_State ledPinState;
64 /*
65 * Application LED pin configuration table:
66 * - All LEDs board LEDs are off.
67 */
68 PIN_Config ledPinTable[] = {
69 Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
70 Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
71 PIN_TERMINATE
72 };
74 /*
75 * ======== heartBeatFxn ========
76 * Toggle the Board_LED0. The Task_sleep is determined by arg0 which
77 * is configured for the heartBeat Task instance.
78 */
79 Void heartBeatFxn(UArg arg0, UArg arg1)
80 {
81 while (1) {
82 Task_sleep((UInt)arg0);
83 PIN_setOutputValue(ledPinHandle, Board_LEDG,!PIN_getOutputValue(Board_LED1));
84 PIN_setOutputValue(ledPinHandle, Board_LEDR,!PIN_getOutputValue(Board_LED0));
85 //System_printf(".\n");
86 //System_flush();
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_initI2C();
100 // Board_initSPI();
101 // Board_initUART();
102 // Board_initWatchdog();
104 /* Construct heartBeat Task thread */
105 Task_Params_init(&taskParams);
106 taskParams.arg0 = 500000 / Clock_tickPeriod;
107 taskParams.stackSize = TASKSTACKSIZE;
108 taskParams.stack = &task0Stack;
109 Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
111 /* Open LED pins */
112 ledPinHandle = PIN_open(&ledPinState, ledPinTable);
113 if(!ledPinHandle) {
114 System_abort("Error initializing board LED pins\n");
115 }
117 PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
118 PIN_setOutputValue(ledPinHandle, Board_LED0, 0);
120 /* Start BIOS */
121 BIOS_start();
123 return (0);
124 }