📄 main.c
字号:
#include "main.h"
// set up DMA descriptors (one for each frame, then repeat)
// small descriptor model, only start address needs to be fetched
tDMA_descriptor DMA_PPI0_first = {&DMA_PPI0_second, sFrame0};
tDMA_descriptor DMA_PPI0_second = {&DMA_PPI0_third , sFrame1};
tDMA_descriptor DMA_PPI0_third = {&DMA_PPI0_fourth, sFrame2};
tDMA_descriptor DMA_PPI0_fourth = {&DMA_PPI0_first , sFrame3};
extern volatile char p,b;
#define DELAY_SIZE 0x00fffffff
//long sum,t,i;
//int ave,l1=0x60,l2=0x80,lp=0x70;
//int DGC=0x20;
//int AGC=0x00;
volatile int current_in_Frame = -1; // 0, 1, 2 or 3 ... indicates the last frame that was received COMPLETELY
//short c,d1,d2;
bool Set_PACK32 = false;
bool Set_Entire_Field = false;
bool ISPAL=1;
//int *r1,*r2;
// User program
void main() {
// unblock Core B if dual core operation is desired
#ifndef RUN_ON_SINGLE_CORE
*pSICA_SYSCR &= 0xFFDF; // clear bit 5 to unlock
#endif
// set Clocks
Set_PLL( (short)(CORECLK/CLKIN), (short)(CORECLK/SYSCLK)); // sets Core and System Clocks to the values defined in system.h
// initialise SDRAM
InitSDRAM();
*pTC_PER = 0x0770; // set DMA traffic control register to favour unidirectional transfers to SDRAM
// initialise Video Encoder ADV7179
Reset_ADV7171();
if (!Init_ADV7171(ISPAL))
return false;
// initialise Video Decoder ADV7183
Reset_tvp5150();
if (!Init_tvp5150(ISPAL))
return false;
//if (!I2C_Read5150(&r, 0x07)) return false;
// initialise PPI0 and associated DMA channel for Video IN
current_in_Frame = -1; // no frames received yet
semaphore_frames_received = false; // do not start output stream yet
Set_Entire_Field = false;
#ifdef ENTIRE_FIELD_MODE
Set_Entire_Field = true;
#endif
Set_PACK32 = false;
#ifdef PACK_32
Set_PACK32 = true;
#endif
InitPPI0(Set_Entire_Field, Set_PACK32, &DMA_PPI0_first, PIXEL_PER_LINE, LINES_PER_FRAME);
// initialise Interrupts
InitInterrupts_coreA();
// enable transfers
*pDMA1_0_CONFIG |= DMAEN;
ssync();
*pPPI0_CONTROL |= PORT_EN;
ssync();
//p=0;
//b=0;
//I2C_Write3152(0x02,0xA1);
// I2C_Write3152(0x09,0x1A);
// I2C_Write3152(0x3F,0x1B);
//I2C_Write3152(0x06,0x1C);
// I2C_Write3152(0x3F,0x1D);
//I2C_Write3152(0x01,0x38);
// printf("Core #%d Started input stream!\n", &_CORE);
//sum=0;
// main loop, just wait for interrupts
/*for(;;)
{
while(p) {
// do nothing
d1=*sFrame0;
d2=*(sFrame0+1);
for(t=0;t<0x65401;t++)
{
sum=sum+*(sFrame0+t);
}
ave=(sum/0x65401);/// while(1)
p=0x0;
/*if (ave>l2) //图像亮度过高
{
if(ave-lp>2)
{
if(DGC>=0x25)
{DGC=DGC-0x05;}
if(DGC>=0x20)
I2C_Write3152(DGC,0x33);
if(AGC>=0x03)
{AGC=AGC-0x05;}
if(AGC>=0x00)
I2C_Write3152(AGC,0x35);
}
}*/
/*if (ave<l1) //图像亮度过低
{
/* if((lp-ave)>2)
{
if(DGC<=0xFA)
{DGC=DGC+0x05;}
if(DGC<=0xFF)
I2C_Write3152(DGC,0x33);
if(AGC<=0x7C)
{AGC=AGC+0x05;}
if(AGC<=0x7F)
I2C_Write3152(AGC,0x35);
}
I2C_Write3152(0x7f,0x35);
I2C_Write3152(0xff,0x33);
}
if (ave>l2) //图像亮度过高
{
if(ave-lp>2)
{
if(DGC>=0x25)
{DGC=DGC-0x05;}
if(DGC>=0x20)
I2C_Write3152(DGC,0x33);
for(i=0; i<DELAY_SIZE; i++)
{
asm("nop;");
}
if(AGC>=0x03)
{AGC=AGC-0x05;}
if(AGC>=0x00)
I2C_Write3152(AGC,0x35);
for(i=0; i<DELAY_SIZE; i++)
{
asm("nop;");
}
}
}*/
/*sum=0;
InitPPI0(Set_Entire_Field, Set_PACK32, &DMA_PPI0_first, PIXEL_PER_LINE, LINES_PER_FRAME);
*pDMA1_0_CONFIG |= DMAEN;
ssync();
*pPPI0_CONTROL |= PORT_EN;
ssync();
}
}*/
while(1)
{idle();
}
} // main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -