]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/application/main.c
PASDK-577:Add JX updates for autodet restart, plug into ASIT FSM
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / application / main.c
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>
47 #include <ti/xdais/xdas.h>
49 #include <board.h>
50 #include "evmc66x_i2c.h"
51 #include <aud.h>
52 #include <aud_audio.h>
53 #include "audio_dc_cfg.h"
54 #include "edma_cfg.h"
55 #include <soc/mcasp_soc.h>
57 #include "components/clk.h" /* PFP testing */
58 #include "pfp/pfp.h"
59 #include "pfp_app.h"        /* contains all PFP ID's */
61 #include "ioConfig.h"    //TODO: remove this header
62 extern Void initDev2(Void);
63 extern void evmI2CInit(uint8_t i2cportnumber); // missing in evmc66x_i2c.h
65 #ifdef IO_LOOPBACK_TEST
66 extern void McaspDevice_init();
67 extern void D10_init();
68 extern Aud_STATUS mcaspAudioConfig();
69 extern void audioIoCreate(void);
70 extern void ioSemaphoreCreate(void);
71 #endif
73 // avoid including sap_d10.h, which would cause symbol redefinition
74 // warning (MCASP_PFUNC_XXX)
75 extern XDAS_Int32 D10_init(void);
77 /*
78  *  ======== main ========
79  */
80 Int main()
81 {
82     Int status;
83     Aud_STATUS AudStatus;
84     Int k;
85     //Board_initCfg cfg;
87     Log_info0("Enter main()");
88     
89     /* Setup Profile Points (PFP) */
90     Log_info0("enter PFP Setup");
91     pfpCreate();
92     pfpCalibrate(1000, 1);
93 #if 0 // enabled in System Stream
94     for (k = 0; k <= PFP_ID_LAST; k++) 
95     {
96         pfpEnable(k);   /* Enable profile point #k */
97     }
98 #endif
99     for (k = 1; k <= PFP_ID_LAST; k++)
100     {
101         pfpSetAlpha(k, PFP_DEF_ALPHA);  /* Set default exp. avg. time const. */
102     }
103 #if 0 // debug: dummy load
104     pfpEnable(0);   /* Enable profile point #0 */
105     for (k = 0; k < 1000; k++) 
106     {
107         pfpBegin(PFP_ID_MAIN,0);
108         clkWorkDelay(CLK_WORKCNT_PER_MS);     /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
109         pfpEnd(PFP_ID_MAIN,0);
110     }    
111     pfpDisable(0);   /* Disable profile point #0 */
112 #endif    
114     /* initialize board */
115     // board init is handled by GEL files or SBL
116     //cfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_MODULE_CLOCK;
117     //Board_init(cfg);
118     evmI2CInit(I2C_PORT_0);
119     evmI2CInit(I2C_PORT_1);
120     evmI2CInit(I2C_PORT_2);
122     Log_info0("exit Board init");
124     Log_info0("Configure EDMA");
125     /* Configure eDMA module */
126     AudStatus = eDmaConfig();
127     if(AudStatus != Aud_EOK)
128     {
129         //System_printf("eDMA Configuration Failed!\n");
130         Log_info0("eDMA Configuration Failed!");
131         //testRet(1);
132     }
134 #ifdef PASDK_SIO_DEV
135     Log_info0("initDev2");
136     initDev2();
137 #endif
139 #ifdef IO_LOOPBACK_TEST
140     /* Initialize McASP HW details */
141     McaspDevice_init();
143     D10_init();
145 #ifdef INPUT_SPDIF
146     // Input is DIR
147     AudStatus = aud_AudioSelectClkSrc(AUD_AUDIO_CLK_SRC_DIR);
148 #else
149     // Input is HDMI
150     AudStatus = aud_AudioSelectClkSrc(AUD_AUDIO_CLK_SRC_I2S);
151 #endif
152     if(AudStatus != Aud_EOK)
153     {
154         Log_info0("aud_AudioSelectClkSrc Failed!\n");
155     }
156     aud_delay(50000); // Without delay between these 2 calls system aborts.
158     /* Initialize McASP module */
159     status = mcaspAudioConfig();
160     if(status != Aud_EOK)
161     {
162         Log_info0("McASP Configuration Failed!\n");
163     }
165     ioSemaphoreCreate();
167     audioIoCreate();
169     Task_setPri(TaskAfp, -1);
170     Task_setPri(TaskAip, -1);
171     Task_setPri(TaskSysInit, -1);
172     Task_setPri(TaskAsip, 5);
173     Task_setPri(TaskAsop, 5);
174 #endif
176     Log_info0("McASP device init");
177     /* Initialize McASP SOC level configuration */
178     McaspDevice_init();
180     Log_info0("D10 init");
181     /* Initialize audio hardware */
182     D10_init();
184     Log_info0("IPC start");
185     /* Initialize IPC */
186     status = Ipc_start();
187     if (status < 0) 
188     {
189         System_abort("Ipc_start failed\n");
190     }
191     
192     BIOS_start();    /* does not return */
193     return(0);