📄 image_s_m.c
字号:
}
#else
/*------------------------------------------------
get image_buffer1 from LED1 image
------------------------------------------------*/
void pre_process100(){
if((line_counter>=IMAGE_L_ST0*line_m*Led_M) &&
line_counter < (IMAGE_L_ST0+IMAGE_HIGHT0)*line_m*Led_M &&
line_counter == (line_counter/line_m/Led_M)*line_m*Led_M )
{
inbuff0 = line_buffer+IMAGE_W_ST0*pixel_m;
for ( x=0; x<IMAGE_WIDTH0;x++)
{
*pixel_p0++ = *inbuff0;
inbuff0=inbuff0+pixel_m;
}
inbuff0=pixel_p0-IMAGE_WIDTH0;
CACHE_wbInvL2(inbuff0, (IMAGE_WIDTH0+1), CACHE_WAIT);
}
inbuff0 = line_buffer;
CACHE_clean(CACHE_L2,inbuff0,(IMAGE_WIDTH+1));
}
int Image_ln;
void pre_process101(){
Image_ln=line_counter - (line_counter/line_m01/Led_M )*line_m01*Led_M;
if(line_counter >= IMAGE_L_ST1 *line_m *Led_M &&
line_counter < (IMAGE_L_ST1 *line_m + IMAGE_HIGHT1*line_m01)*Led_M )
{
if ( Image_ln == 1 ){
inbuff0 = line_buffer+( IMAGE_W_ST1 + IMAGE_W_ST0 ) * pixel_m;
for ( x=0; x<IMAGE_WIDTH1;x++)
{
*pixel_p1++ = *inbuff0;
inbuff0 = inbuff0 + pixel_m01;
}
}
}
inbuff0=pixel_p1-IMAGE_WIDTH1;
CACHE_wbInvL2(inbuff0, (IMAGE_WIDTH1+1), CACHE_WAIT);
inbuff0 = line_buffer;
CACHE_clean(CACHE_L2,inbuff0,(IMAGE_WIDTH+1));
}
/*------------------------------------------------
get image_buffer2 from LED2 image
------------------------------------------------*/
void pre_process102(){
int Image_ln;
Image_ln=line_counter - (line_counter/line_m02/Led_M )*line_m02*Led_M;
if(line_counter >= IMAGE_L_ST2 *line_m *Led_M &&
line_counter < (IMAGE_L_ST2 *line_m + IMAGE_HIGHT2*line_m02)*Led_M )
{
if ( Image_ln == 2 ){
inbuff0 = line_buffer+( IMAGE_W_ST2 + IMAGE_W_ST0 ) * pixel_m;
for ( x=0; x<IMAGE_WIDTH2;x++)
{
*pixel_p2++ = *inbuff0;
inbuff0 = inbuff0 + pixel_m02;
}
}
}
inbuff0=pixel_p2-IMAGE_WIDTH2;
CACHE_wbInvL2(inbuff0, (IMAGE_WIDTH2+1), CACHE_WAIT);
inbuff0 = line_buffer;
CACHE_clean(CACHE_L2,inbuff0,(IMAGE_WIDTH+1));
}
#endif
/****************************************************
frame_process
----------------------------------------------------*/
void frame_process(){
/* add prog. to processing image */
{
}
}
/**************************************************/
void setupInterrupts(void)
{
IRQ_setVecs(vectors); /* point to the IRQ vector table */
IRQ_nmiEnable();
IRQ_globalEnable();
IRQ_map(IRQ_EVT_EXTINT7, 5);
IRQ_map(IRQ_EVT_EDMAINT, 8);
IRQ_reset(IRQ_EVT_EXTINT7);
IRQ_reset(IRQ_EVT_EDMAINT);
IRQ_enable(IRQ_EVT_EXTINT7);
}
/*********************************************/
interrupt void
c_int08(void)
{
#ifdef Led_M
int Image_n;
#endif
/* Clear the pending interrupt from the EDMA interrupt pending register */
EDMA_intClear(TCCINTNUM);
#ifdef Led_M
// Image_n = line_counter % nn;
Image_n = line_counter -(line_counter/ Led_M)*Led_M;
if( Image_n == 0) pre_process100();
if( Image_n == 1) pre_process101();
#ifdef Led_M3
if( Image_n == 2) pre_process102();
#endif
#ifdef Led_M4
if( Image_n == 2) pre_process102();
// if( Image_n == 3) pre_process103();
#endif
#endif
#ifndef Led_M
pre_process00(); /* from LRS image*/
pre_process01(); /* from HRS image*/
pre_process02(); /* from HRS image*/
#endif
// printf("\n %2d - %2d ",line_counter,frame_sam_end);
line_counter++;
if (line_counter >= IMAGE_HIGHT){
frame_sam_end=1;
stopEdma();
}
return;
}
//----------------------------------------------------
void stopEdma(void) {
/*Disable interrupts, close EDMA channel before exit of the program*/
IRQ_disable(IRQ_EVT_EDMAINT);
EDMA_RSET(CCER,0x00000000);
EDMA_disableChannel(hEdma);
EDMA_intDisable(TCCINTNUM);
EDMA_intClear(TCCINTNUM);
EDMA_close(hEdma);
EDMA_resetAll();
EDMA_RSET(CIPR,0xFFFFFFFF);
EDMA_RSET(ECR,0xFFFFFFFF);
}
void init_emif( void )
{
*(int *)EMIF_GCTL = 0x00000078;
*(int *)EMIF_CE0 = 0xffffff93; /* CE0 SDRAM */
*(int *)EMIF_CE1 = 0xffffff13; /* CE1 asyn Flash 16-bit */
*(int *)EMIF_CE2 = 0x00608102; // 0x02208802; /* CE2 PSD RAM 8-bit */
*(int *)EMIF_CE3 = 0x02208802; /* CE3 I/O 8-bit */
// *(int *)EMIF_SDRAMCTL = 0x53115000; /* SDRAM control */
// *(int *)EMIF_SDRAMTIM = 0x00000578; /* SDRAM timing (refresh) */
// *(int *)EMIF_SDRAMEXT = 0x000a8529; /* SDRAM Extension register */
}
void init_pll( void )
{
*(int *)PLL_CSR &= ~CSR_PLLEN;
*(int *)PLL_CSR |= CSR_PLLRST;
*(int *)PLL_DIV0 = DIV_ENABLE + 0;
// *(int *)PLL_MULT = 2; // CPU_CLK 50MHz
// *(int *)PLL_MULT = 4; // CPU_CLK 100MHz
*(int *)PLL_MULT = 6; // CPU_CLK 150MHz
// *(int *)PLL_MULT = 8; // CPU_CLK 200MHz
*(int *)PLL_OSCDIV1 = DIV_ENABLE + 3;
*(int *)PLL_DIV3 = DIV_ENABLE + 2;
*(int *)PLL_DIV2 = DIV_ENABLE + 1;
*(int *)PLL_DIV1 = DIV_ENABLE + 1; //CUP clk = pll out
*(int *)PLL_CSR &= ~CSR_PLLRST;
*(int *)PLL_CSR |= CSR_PLLEN;
// while(*(int *)PLL_CSR &0x00000040==0x0) {}
}
void interrupt time( void );
void initInterrupt(void);
void save_image0(){
char fname[20],frame[5];
strcpy(fname,"D:\\");
sprintf(frame, "%d", frame_counter+1);
strcat(fname,frame);
if((file=fopen(fname,"wb"))==NULL)
return;
fwrite(ImageBuffer0,1,IMAGE_WIDTH0*IMAGE_HIGHT0,file);
fclose(file);
return;
}
void save_image1(){
char fname[20],frame[5];
strcpy(fname,"D:\\");
sprintf(frame, "%d", frame_counter+101);
strcat(fname,frame);
if((file=fopen(fname,"wb"))==NULL)
return;
fwrite(ImageBuffer1,1,IMAGE_WIDTH1*IMAGE_HIGHT1,file);
fclose(file);
return;
}
void save_image2(){
char fname[20],frame[5];
strcpy(fname,"D:\\");
sprintf(frame, "%d", frame_counter+201);
strcat(fname,frame);
if((file=fopen(fname,"wb"))==NULL)
return;
fwrite(ImageBuffer2 , 1 ,IMAGE_WIDTH2*IMAGE_HIGHT2 , file);
fclose(file);
return;
}
unsigned char *p00; //for test mem
unsigned char tmp001; //for test mem
void test(void)
{
tmp001=0x80; //for test mem
p00=test_;
for(i=0;i<0x300000;i++)
{
*p00=tmp001; //write
if(i%2==0)tmp001=0x80;
else tmp001=0x0;
}
for(i=0;i<0x300000;i++)
{
*p00=tmp001; //write
if(i%2==0)tmp001=0x80;
else tmp001=0x80;
}
for(i=0;i<0x300000;i++)
{
*p00=tmp001; //write
if(i%2==0)tmp001=0x80;
else tmp001=0x0;
}
for(i=0;i<0x300000;i++)
{
*p00=tmp001; //write
if(i%2==0)tmp001=0x80;
else tmp001=0x80;
}
for(i=0;i<0x300000;i++)
{
*p00=tmp001; //write
if(i%2==0)tmp001=0x80;
else tmp001=0x0;
}
}
void mem_test(void)
{
unsigned short *p00; //for test mem
short tmp001; //for test mem
tmp001=0xaaaa; //for test mem
while(1)
{
p00=(unsigned short *)0x90000000;
for(i=0;i<0x80000;i++)
{
// tmp001=*p00; //read
p00++;
*p00=tmp001; //write
tmp001++;
}
}
}
/****************************************************/
// uart func.
void rs232_out(){
int con;
L0: s_p00=(unsigned char *) com_add1;
for(con=0;con<0x40; con++)
{
s_state = *s_p00; //read rs232 port status
if((s_state & 0x80) != 0) break;
s_p00++;
}
if((s_state & 0x80) == 0) goto L0;
s_p00=(unsigned char *)com_add0;
*s_p00=uart232_out; //write
}
unsigned char rs232_in(void){
int con;
unsigned char d_in;
L1: s_p00=(unsigned char *) com_add1;
for(con=0;con<0x40; con++)
{
s_state = *s_p00; //read rs232 port status
if((s_state & 0x40) != 0) break;
s_p00++;
}
if((s_state & 0x40) == 0) goto L1;
s_p00=(unsigned char *)com_add0;
d_in = *s_p00 ; //Read data
return(d_in);
}
void disp(int Num){
int i,n;
char chr;
trans_p = trans_buf+9;
*trans_p-- = 0x0a;
*trans_p-- = 0x0d;
for(i=0;i<5;i++){
n=Num-(Num/10)*10;
Num=Num/10;
*trans_p-- = n+'0';
}
*trans_p-- = Num+0x30;
*trans_p-- = '=';
*trans_p-- = 'f';
trans_p=trans_buf+2;
for(i=0;i<5;i++){
chr = *trans_p;
if(chr == '0') { *trans_p++ = ' '; }
else break;
;
}
trans_counter=10-1;
trans_p=trans_buf;
uart232_out= *trans_p++;
rs232_out(); // send first char
trans_flag=1;
}
//------------------------------------------
// rs232 Isr
interrupt void
c_int07(void){
s_state = *(unsigned char *) com_add1; /* read rs232 port status */
if((s_state & 0x40) != 0) {
// uart232_out= *(unsigned char *) com_add0; //test for rs232 working whith extint 5 see below line
// rs232_out(); // send char for testing rs232 working whith extint 5 see below line
*receive_p++ = *(unsigned char *) com_add0;
if( receive_flag == 0) receive_flag=1;
if (receive_p == receive_buf+tr_lenth ) {
receive_p = receive_buf ;
}
}
if((s_state & 0x80) != 0) {
if ( trans_flag )
{
*(unsigned char *) com_add0 = *trans_p++ ;
trans_counter--;
if (trans_counter == 0 ) {
trans_flag =0 ;
}
}
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -