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 <audk2g.h>
51 #include <audk2g_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 extern Void initDev2(Void);
60 extern void evmI2CInit(uint8_t i2cportnumber); // missing in evmc66x_i2c.h
62 /*
63 * ======== main ========
64 */
65 Int main()
66 {
67 Int status;
68 Audk2g_STATUS AudStatus;
69 Int k;
70 Board_initCfg cfg;
72 Log_info0("Enter main()");
74 /* Setup Profile Points (PFP) */
75 Log_info0("enter PFP Setup");
76 pfpCreate();
77 pfpCalibrate(1000, 1);
78 #if 0 // enabled in System Stream
79 for (k = 0; k <= PFP_ID_LAST; k++)
80 {
81 pfpEnable(k); /* Enable profile point #k */
82 }
83 #endif
84 for (k = 1; k <= PFP_ID_LAST; k++)
85 {
86 pfpSetAlpha(k, PFP_DEF_ALPHA); /* Set default exp. avg. time const. */
87 }
88 #if 0 // debug: dummy load
89 pfpEnable(0); /* Enable profile point #0 */
90 for (k = 0; k < 1000; k++)
91 {
92 pfpBegin(PFP_ID_MAIN,0);
93 clkWorkDelay(CLK_WORKCNT_PER_MS); /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
94 pfpEnd(PFP_ID_MAIN,0);
95 }
96 pfpDisable(0); /* Disable profile point #0 */
97 #endif
99 /* initialize board */
100 cfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_MODULE_CLOCK;
101 Board_init(cfg);
102 evmI2CInit(I2C_PORT_0);
103 evmI2CInit(I2C_PORT_1);
104 evmI2CInit(I2C_PORT_2);
106 Log_info0("exit Platform Setup");
108 Log_info0("Configure EDMA");
109 /* Configure eDMA module */
110 AudStatus = eDmaConfig();
111 if(AudStatus != Audk2g_EOK)
112 {
113 //System_printf("eDMA Configuration Failed!\n");
114 Log_info0("eDMA Configuration Failed!");
115 //testRet(1);
116 }
118 Log_info0("initDev2");
119 initDev2();
121 Log_info0("IPC start");
122 // Initialize IPC
123 status = Ipc_start();
124 if (status < 0)
125 {
126 System_abort("Ipc_start failed\n");
127 }
129 BIOS_start(); /* does not return */
130 return(0);
131 }