Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/adv7511/vc707/main.c

raw symbols SCIP
1 /***************************************************************************//**
2 * @file main.c
3 ********************************************************************************
4 * Copyright 2013(c) Analog Devices, Inc.
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * - Neither the name of Analog Devices, Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 * - The use of this software may or may not infringe the patent rights
20 * of one or more patent holders. This license does not release you
21 * from the requirement that you obtain separate licenses from these
22 * patent holders to use this software.
23 * - Use of the software either in source or binary form, must be run
24 * on or directly connected to an Analog Devices Inc. component.
25 *
26 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
28 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 ********************************************************************************
38 * SVN Revision: $WCREV$
39 *******************************************************************************/
40
41 /******************************************************************************/
42 /***************************** Include Files **********************************/
43 /******************************************************************************/
44 #include <stdio.h>
45 #include "xil_cache.h"
46 #include "xbasic_types.h"
47 #include "xil_io.h"
48 #include "cf_hdmi.h"
49 #include "atv_platform.h"
50 #include "transmitter.h"
51 #include "xil_exception.h"
52 #include "xuartlite_l.h"
53
54 extern void delay_ms(u32 ms_count);
55 extern char inbyte(void);
56
57 /******************************************************************************/
58 /************************** Macros Definitions ********************************/
59 /******************************************************************************/
60 #define HDMI_CALL_INTERVAL_MS 10 /* Interval between two */
61 /* iterations of the main loop */
62 #define DBG_MSG xil_printf
63
64 /******************************************************************************/
65 /************************ Variables Definitions *******************************/
66 /******************************************************************************/
67 static UCHAR MajorRev; /* Major Release Number */
68 static UCHAR MinorRev; /* Usually used for code-drops */
69 static UCHAR RcRev; /* Release Candidate Number */
70 static BOOL DriverEnable;
71 static BOOL LastEnable;
72
73 /***************************************************************************//**
74 * @brief Enables the driver.
75 *
76 * @return Returns ATVERR_OK.
77 *******************************************************************************/
78 void APP_EnableDriver (BOOL Enable)
79 {
80 DriverEnable = Enable;
81 }
82
83 /***************************************************************************//**
84 * @brief Returns the driver enable status.
85 *
86 * @return Returns the driver enable status.
87 *******************************************************************************/
88 static BOOL APP_DriverEnabled (void)
89 {
90 if ((DriverEnable && HAL_GetMBSwitchState()) != LastEnable)
91 {
92 LastEnable = DriverEnable && HAL_GetMBSwitchState();
93 DBG_MSG ("APP: Driver %s\n\r", LastEnable? "Enabled": "Disabled");
94 }
95 return (LastEnable);
96 }
97
98 /***************************************************************************//**
99 * @brief Displays the application version and the chip revision.
100 *
101 * @return None.
102 *******************************************************************************/
103 static void APP_PrintRevisions (void)
104 {
105 UINT16 TxRev;
106
107 ADIAPI_TxGetChipRevision(&TxRev);
108
109 DBG_MSG("\n\r********************************************************************\r\n");
110 DBG_MSG(" ADI HDMI Trasmitter Application Ver R%d.%d.%d\n\r", MajorRev, MinorRev, RcRev);
111 DBG_MSG(" HDMI-TX: ADV7511 Rev 0x%x\r\n", TxRev);
112 DBG_MSG(" Created: %s At %s\n\r", __DATE__, __TIME__);
113 DBG_MSG("********************************************************************\r\n\n\r");
114 }
115
116 /***************************************************************************//**
117 * @brief Changes the video resolution.
118 *
119 * @return None.
120 *******************************************************************************/
121 static void APP_ChangeResolution (void)
122 {
123 char *resolutions[7] = {"640x480", "800x600", "1024x768", "1280x720", "1360x768", "1600x900", "1920x1080"};
124 char receivedChar = 0;
125
126 if(!XUartLite_IsReceiveEmpty(UART_BASEADDR))
127 {
128 receivedChar = inbyte();
129 if((receivedChar >= 0x30) && (receivedChar <= 0x36))
130 {
131 SetVideoResolution(receivedChar - 0x30);
132 DBG_MSG("Resolution was changed to %s \r\n", resolutions[receivedChar - 0x30]);
133 }
134 else
135 {
136 if((receivedChar != 0x0A) && (receivedChar != 0x0D))
137 {
138 SetVideoResolution(RESOLUTION_640x480);
139 DBG_MSG("Resolution was changed to %s \r\n", resolutions[0]);
140 }
141 }
142 }
143 }
144
145 /***************************************************************************//**
146 * @brief Main function.
147 *
148 * @return Returns 0.
149 *******************************************************************************/
150 int main()
151 {
152 UINT32 StartCount;
153
154 MajorRev = 1;
155 MinorRev = 1;
156 RcRev = 1;
157 DriverEnable = TRUE;
158 LastEnable = FALSE;
159
160 Xil_ICacheEnable();
161 Xil_DCacheEnable();
162
163 #ifdef XPAR_AXI_IIC_0_BASEADDR
164 HAL_PlatformInit(XPAR_AXI_IIC_0_BASEADDR, /* Perform any required platform init */
165 XPAR_AXI_TIMER_0_BASEADDR, /* including hardware reset to HDMI devices */
166 XPAR_AXI_TIMER_0_INTERRUPT_MASK,
167 XPAR_AXI_INTC_0_BASEADDR);
168 #else
169 HAL_PlatformInit(XPAR_AXI_IIC_MAIN_BASEADDR, /* Perform any required platform init */
170 XPAR_AXI_TIMER_BASEADDR, /* including hardware reset to HDMI devices */
171 XPAR_AXI_TIMER_INTERRUPT_MASK,
172 XPAR_INTC_0_BASEADDR);
173 #endif
174
175 Xil_ExceptionEnable();
176
177 SetVideoResolution(RESOLUTION_640x480);
178 InitHdmiAudioPcore();
179
180 APP_PrintRevisions(); /* Display S/W and H/W revisions */
181
182 ADIAPI_TransmitterInit(); /* Initialize ADI repeater software and h/w */
183
184 ADIAPI_TransmitterSetPowerMode(REP_POWER_UP);
185
186 StartCount = HAL_GetCurrentMsCount();
187
188 while(1)
189 {
190 if (ATV_GetElapsedMs (StartCount, NULL) >= HDMI_CALL_INTERVAL_MS)
191 {
192 StartCount = HAL_GetCurrentMsCount();
193 if (APP_DriverEnabled())
194 {
195 ADIAPI_TransmitterMain();
196 }
197 }
198 APP_ChangeResolution();
199 }
200
201 Xil_DCacheDisable();
202 Xil_ICacheDisable();
203
204 return(0);
205 }