c9ab1c385eadcd9bbe12a2fb7fa97880a066aca6
2 /*
3 Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37 * ======== main.c ========
38 */
40 #include <xdc/std.h>
41 #include <xdc/cfg/global.h>
42 #include <xdc/runtime/Log.h>
43 #include <xdc/runtime/System.h>
44 #include <ti/sysbios/BIOS.h>
45 #include <ti/ipc/Ipc.h>
46 #include <ti/sysbios/hal/Cache.h>
48 #include <board.h>
49 #include "evmc66x_i2c.h"
50 #include <aud.h>
51 #include <aud_audio.h>
52 #include "audio_dc_cfg.h"
53 #include "edma_cfg.h"
55 #include "components/clk.h" /* PFP testing */
56 #include "pfp/pfp.h"
57 #include "pfp_app.h" /* contains all PFP ID's */
59 #include "ioConfig.h" //TODO: remove this header
60 extern Void initDev2(Void);
61 extern void evmI2CInit(uint8_t i2cportnumber); // missing in evmc66x_i2c.h
63 #ifdef IO_LOOPBACK_TEST
64 extern void McaspDevice_init();
65 extern void D10_init();
66 extern Aud_STATUS mcaspAudioConfig();
67 extern void audioIoCreate(void);
68 extern void ioSemaphoreCreate(void);
69 #endif
71 /*
72 * ======== main ========
73 */
74 Int main()
75 {
76 Int status;
77 Aud_STATUS AudStatus;
78 Int k;
79 Board_initCfg cfg;
81 Log_info0("Enter main()");
83 /* Setup Profile Points (PFP) */
84 Log_info0("enter PFP Setup");
85 pfpCreate();
86 pfpCalibrate(1000, 1);
87 #if 0 // enabled in System Stream
88 for (k = 0; k <= PFP_ID_LAST; k++)
89 {
90 pfpEnable(k); /* Enable profile point #k */
91 }
92 #endif
93 for (k = 1; k <= PFP_ID_LAST; k++)
94 {
95 pfpSetAlpha(k, PFP_DEF_ALPHA); /* Set default exp. avg. time const. */
96 }
97 #if 0 // debug: dummy load
98 pfpEnable(0); /* Enable profile point #0 */
99 for (k = 0; k < 1000; k++)
100 {
101 pfpBegin(PFP_ID_MAIN,0);
102 clkWorkDelay(CLK_WORKCNT_PER_MS); /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
103 pfpEnd(PFP_ID_MAIN,0);
104 }
105 pfpDisable(0); /* Disable profile point #0 */
106 #endif
108 /* initialize board */
109 cfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_MODULE_CLOCK;
110 Board_init(cfg);
111 evmI2CInit(I2C_PORT_0);
112 evmI2CInit(I2C_PORT_1);
113 evmI2CInit(I2C_PORT_2);
115 Log_info0("exit Board init");
117 Log_info0("Configure EDMA");
118 /* Configure eDMA module */
119 AudStatus = eDmaConfig();
120 if(AudStatus != Aud_EOK)
121 {
122 //System_printf("eDMA Configuration Failed!\n");
123 Log_info0("eDMA Configuration Failed!");
124 //testRet(1);
125 }
127 #ifdef PASDK_SIO_DEV
128 Log_info0("initDev2");
129 initDev2();
130 #endif
132 #ifdef IO_LOOPBACK_TEST
133 /* Initialize McASP HW details */
134 McaspDevice_init();
136 D10_init();
138 #ifdef INPUT_SPDIF
139 // Input is DIR
140 AudStatus = aud_AudioSelectClkSrc(AUD_AUDIO_CLK_SRC_DIR);
141 #else
142 // Input is HDMI
143 AudStatus = aud_AudioSelectClkSrc(AUD_AUDIO_CLK_SRC_I2S);
144 #endif
145 if(AudStatus != Aud_EOK)
146 {
147 Log_info0("aud_AudioSelectClkSrc Failed!\n");
148 }
149 aud_delay(50000); // Without delay between these 2 calls system aborts.
151 /* Initialize McASP module */
152 status = mcaspAudioConfig();
153 if(status != Aud_EOK)
154 {
155 Log_info0("McASP Configuration Failed!\n");
156 }
158 ioSemaphoreCreate();
160 audioIoCreate();
162 Task_setPri(TaskAfp, -1);
163 Task_setPri(TaskAip, -1);
164 Task_setPri(TaskSysInit, -1);
165 Task_setPri(TaskAsip, 5);
166 Task_setPri(TaskAsop, 5);
167 #endif
169 Log_info0("McASP device init");
170 /* Initialize McASP SOC level configuration */
171 McaspDevice_init();
173 Log_info0("IPC start");
174 /* Initialize IPC */
175 status = Ipc_start();
176 if (status < 0)
177 {
178 System_abort("Ipc_start failed\n");
179 }
181 BIOS_start(); /* does not return */
182 return(0);
183 }