⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 ADV7171 在BF553上测试通过 大家开下了
💻 C
字号:
#include "system.h"
#include "system.h"
#include "test.h"
#include "adv7171.h"
#include "video.h"

bool IsPAL = 1;

void Delay(DWORD value)
{
	DWORD i;
	for(i = 0; i < value; i++);
}


void Init_PLL(void)
{
	int iIMASK_Value;
	sysreg_write(reg_SYSCFG, 0x32); //Initialize System Configuration Register

	// set VCO/CCLK = 1, and VCO/SCLK = 7 (take effect immediately)
	*pPLL_DIV = 0x0007;

	// prepare PLL changes (set CLKIN/VCO = 21; takes effect after PLL programming sequence)
	*pPLL_LOCKCNT	= 0x0200; // time for PLL to stabilize
	*pPLL_CTL		= 0x2A00; // set VCO/CLKIN = 21

	// execute PLL programming sequence
	*pSIC_IWR = 0x00000001; // enable only PLL wakeup interrupt
	iIMASK_Value	= cli(); // disable interrupts
	idle(); // wait for PLL wakeup interrupt
	sti(iIMASK_Value);
}

void Init_SDRAM(void)
{
	*pEBIU_SDRRC	= 0x00000817;	//SDRAM Refresh Rate Control Register
	*pEBIU_SDBCTL	= 0x00000013;	//SDRAM Memory Bank Control Register
	*pEBIU_SDGCTL	= 0x0091998d;	//SDRAM Memory Global Control Register
}

void Init_EBIU(void)
{
	*pEBIU_AMBCTL0	= 0x7bb07bb0;
	*pEBIU_AMBCTL1	= 0xa4c77bb0;
	*pEBIU_AMGCTL	= 0x000f;
}

void Close_ADV7181(void)
{
	unsigned short dataIn[10];
	int i;
	*pCtrlSetReg1 = 0x01;
	for(i = 0;i < 1000;i++)
	{;}
	if(!I2C_Init(ADV7181_IDENT_W))
	{
		while(1);
	}
	I2C_Write(0x40,0x03);
	I2C_Read(&dataIn[0],0x03);
}

BOOL VideoOutInit(BOOL IsPAL)
{
	*pCtrlClrReg2 = 0x03; // PPI CLK for ADV7171
	Delay(100);

	ADV7171_ExitReset(); // ADV7171 exit Reset

	// Initialize ADV7171
	if (!Init_ADV7171(IsPAL))
		return FALSE;

	// Initialize frame buffer
	if (IsPAL)
		PalVideoOutFrameBufferInit();
	else
		NtscVideoOutFrameBufferInit();

	// Initialize DMA for ADV7171
	Init_ADV7171_DMA(IsPAL);

	// Initialize PPI for ADV7171
	Init_ADV7171_PPI();

	// Enable DMA
	*pDMA0_CONFIG |= DMAEN;

	asm("ssync;");

	// Enable PPI
	*pPPI_CONTROL |= PORT_EN;

	return TRUE;
}

main()
{
	Init_PLL();
//---------------------------------------------------------
//	If you use an emulator and use Debugger to 	initialize
//  SDRAM,please eliminate the "Init_SDRAM()" function 
//---------------------------------------------------------						
	//Init_SDRAM();
	Init_EBIU();
	Close_ADV7181();
	VideoOutInit(IsPAL);
	while(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -