[processor-sdk/pdk.git] / packages / ti / transport / ndk / nimu / example / CCLink / src / cclink_evmAM335x.c
1 /*
2 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
3 *
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
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
35 /* ========================================================================== */
36 /* Include Files */
37 /* ========================================================================== */
39 #include <stdio.h>
40 #include <string.h>
41 #include <stdlib.h>
42 #include <xdc/std.h>
43 #include <xdc/runtime/Error.h>
44 #include <xdc/runtime/System.h>
45 #include <ti/sysbios/BIOS.h>
46 #include <ti/sysbios/knl/Task.h>
47 #include <ti/sysbios/family/arm/a8/Mmu.h>
49 #include <ti/ndk/inc/stkmain.h>
51 #include <ti/drv/emac/emac_drv.h>
52 #include <ti/drv/emac/src/v4/emac_drv_v4.h>
54 #include <ti/starterware/include/types.h>
55 #include <ti/starterware/include/hw/hw_types.h>
56 #include <ti/starterware/include/hw/hw_control_am335x.h>
57 #include <ti/starterware/include/hw/soc_am335x.h>
58 #include <ti/starterware/include/ethernet.h>
59 #include <ti/starterware/include/soc_control.h>
61 #include <ti/board/board.h>
63 /* UART Header files */
64 #include <ti/drv/uart/UART.h>
65 #include <ti/drv/uart/UART_stdio.h>
67 extern void cclink_thread (UArg a0, UArg a1);
69 extern char *LocalIPAddr;
71 /* Enable the below macro to have prints on the IO Console */
72 //#define IO_CONSOLE
74 #ifndef IO_CONSOLE
75 #define NIMU_log UART_printf
76 #else
77 #define NIMU_log printf
78 #endif
80 /* ========================================================================== */
81 /* Macros */
82 /* ========================================================================== */
84 /**Phy address of the CPSW port 1*/
85 #define CPSW_PORT0_PHY_ADDR_EVM 0
86 /**Phy address of the CPSW port 1*/
87 #define CPSW_PORT1_PHY_ADDR_EVM 1
90 #define MAX_TABLE_ENTRIES 3
92 /* ========================================================================== */
93 /* Global Variables */
94 /* ========================================================================== */
97 /**Task handle for EIP*/
98 Task_Handle main_task;
100 static int nimu_device_index = 0U;
102 NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[MAX_TABLE_ENTRIES];
104 void TaskFxn(UArg a0, UArg a1);
105 extern int CpswEmacInit (STKEVENT_Handle hEvent);
108 /**
109 * \name main
110 * \brief Main Function
111 * \param none
112 * \return none
113 *
114 */
115 int main()
116 {
117 /* Call board init functions */
118 Board_initCfg boardCfg;
119 Task_Params taskParams;
121 boardCfg = BOARD_INIT_PINMUX_CONFIG |
122 BOARD_INIT_MODULE_CLOCK | BOARD_INIT_UART_STDIO;
123 Board_init(boardCfg);
125 /* Chip configuration MII/RMII selection */
126 SOCCtrlCpswPortMacModeSelect(1, ETHERNET_MAC_TYPE_RGMII);
127 SOCCtrlCpswPortMacModeSelect(2, ETHERNET_MAC_TYPE_RGMII);
131 Task_Params_init(&taskParams);
132 taskParams.priority = 1;
133 taskParams.stackSize = 0x1400;
134 main_task = Task_create (cclink_thread, &taskParams, NULL);
136 NIMUDeviceTable[nimu_device_index++].init = &CpswEmacInit ;
137 NIMUDeviceTable[nimu_device_index].init = NULL ;
139 BIOS_start();
141 return -1;
142 }