PYNQ-Z2_demos/hdmi-out-test/hdmi-out-test.vitis/hdmi-out-test.files/src/main.c

86 lines
1.9 KiB
C

#include <stdio.h>
//#include "platform.h"
#include "xil_printf.h"
#include "xv_tpg.h"
#include "xvtc.h"
int main()
{
//init_platform();
int Status;
XV_tpg tpg_inst; // Instance of the TPG core
XVtc VtcInst; // Instance of the VTC core
print("--- hdmi-out-test ---\n\r");
//--( TPG Initialization
print("TPG Initialization\n\r");
Status = XV_tpg_Initialize(&tpg_inst, XPAR_XV_TPG_0_DEVICE_ID);
if(Status!= XST_SUCCESS)
{
xil_printf("TPG configuration failed\r\n");
return(XST_FAILURE);
}
// Set Resolution to 1280x720
XV_tpg_Set_height(&tpg_inst, 720);
XV_tpg_Set_width(&tpg_inst, 1280);
// Set Color Space to RGB
XV_tpg_Set_colorFormat(&tpg_inst, 0x0);
//Set pattern to color bar
XV_tpg_Set_bckgndId(&tpg_inst, XTPG_BKGND_COLOR_BARS);
//Start the TPG
XV_tpg_EnableAutoRestart(&tpg_inst);
XV_tpg_Start(&tpg_inst);
xil_printf("TPG started!\r\n");
//--)
//--( VTC Initialization
print("VTC Initialization\n\r");
XVtc_Config *Config;
XVtc_Timing ti;
XVtc_Signal si;
XVtc_HoriOffsets ho;
XVtc_Polarity po;
//Initialize the VTC driver so that it's ready to use look up
//configuration in the config table, then initialize it.
Config = XVtc_LookupConfig(XPAR_VTC_0_DEVICE_ID);
if (NULL == Config) {
return (XST_FAILURE);
}
//Initialize the VTC core
Status = XVtc_CfgInitialize(&VtcInst, Config, Config->BaseAddress);
if (Status != (XST_SUCCESS)) {
return (XST_FAILURE);
}
//Perform a self-test
Status = XVtc_SelfTest(&VtcInst);
if (Status != (XST_SUCCESS)) {
return (XST_FAILURE);
}
//Set our configuration as 1280x720
XVtc_ConvVideoMode2Timing(&VtcInst, XVTC_VMODE_720P, &ti);
XVtc_ConvTiming2Signal(&VtcInst, &ti, &si, &ho, &po);
XVtc_SetGenerator(&VtcInst, &si);
//Enable the vtc
XVtc_Enable(&VtcInst);
xil_printf("VTC enabled!\r\n");
//--)
while(1){
}
cleanup_platform();
return 0;
}