Пример #1
0
int main()
{
	uint32_t *fbase, *imageaddr, *graybuffer;
	uint32_t i, j, k;
	float time, fps;
	clock_t t1, t2;

	cp_en(); /* Enable the coprocessor */
	fbase = svga_enable(); /* Configure and enable the svga controller */
	imageaddr = (uint32_t*)STARTADDR; /* Set the address of the first image */

	t1 = clock(); /* Get the start time */

    for (i = 0; i < NFRAMES-1; i++)
    {
    	switch(MODE)
    	{
    		default:
    		case 1: /* Copy images to framebuffer */
    			mode1(fbase, imageaddr);
    			break;
    		case 2: /* Floating point grayscale conversion in software */
    			mode2(fbase, imageaddr);
    			break;
    		/* Add more cases for new modes */
    		case 3: /* Fixed point grayscale conversion in software */
    			mode3(fbase, imageaddr);
    			break;
    		case 4: /* Mode to use the fixed point grayscale coprocessor */
    			mode4(fbase, imageaddr);
    			break;
    		case 5: /* Mode to do the Laplacian edge detection in software  */
    			mode5(fbase, imageaddr);
    			break;
            case 6:
                mode6(fbase, imageaddr);
    		// case 7: /* "Hack" the screen! */
    		// 	hackmode(fbase, imageaddr);
    		// 	break;
    	}

    	imageaddr += f->hactive_video*f->vactive_video/2; /* Move to the next image */
    }

    /* Report the time to process the frames */
    t2 = clock();
    time = (t2 - t1) / CLOCKS_PER_SEC;
    fps = NFRAMES / time;
    printf("FPS: %f\n", fps);
    t1 = t2;


	return 0;
}
Пример #2
0
void main()
{
    OLED_Init();           //初始化oled
    qd=1;
    ftm_pwm_init(FTM0,FTM_CH3,10000,0);
    ftm_pwm_init(FTM0,FTM_CH4,10000,0);
    ftm_pwm_init(FTM2,FTM_CH0,10000,0);
    ftm_pwm_init(FTM2,FTM_CH1,10000,0);
    adc_init (ADC1_SE10);
    adc_init (ADC1_SE11);
    adc_init (ADC1_SE12);
    adc_init (ADC1_SE13);                               //按键初始化
    gpio_init (PTA13, GPI,HIGH);//拨码开关初始化
    gpio_init (PTA19, GPI,HIGH);
    gpio_init (PTA24, GPI,HIGH);
    gpio_init (PTA25, GPI,HIGH);
    gpio_init (PTA26, GPI,HIGH);
    gpio_init (PTA27, GPI,HIGH);
    gpio_init (PTA28, GPI,HIGH);
    gpio_init (PTA29, GPI,HIGH);

    led_init (LED0);
    mpu6050_init();

    lptmr_delay_ms(1000);

    gyro_zero=ad_ave(100);

    gyro_zero1=ad_ave1(100);

    mpu6050_read();

    accel_accel=(accel_x-accel_zero)/16384.0;
    if(accel_accel>1)   accel_accel=1;
    if(accel_accel<-1)  accel_accel=-1;
    angle_fuse=180/pi*(asin(accel_accel));

    accel_accel1=(accel_y-accel_zero1)/16384.0;
    if(accel_accel1>1)   accel_accel1=1;
    if(accel_accel1<-1)  accel_accel1=-1;
    angle_fuse1=180/3.1415926*(asin(accel_accel1));

    pit_init_ms(PIT0, 5);                                //初始化PIT0,定时时间为: 5ms
    set_vector_handler(PIT0_VECTORn ,PIT0_IRQHandler);      //设置PIT0的中断服务函数为 PIT0_IRQHandler
    enable_irq (PIT0_IRQn);                                 //使能PIT0中断

    uart_init(UART3, 115200);
    while(aa<200);   //初始化 1秒


    DIP_switch();
    while(1)
    {


        //display[0]=angle_fuse;
        //display[1]=angle_fuse1;
        display[0]=angle_fuse3;



        oledplay();


        if(flag==1)
            mode1();
        else if (flag==2)
            mode2();
        else if (flag==3)
            mode3();
        else if (flag==4)
            mode4();



        vcan_sendware((unsigned char *)display, 20);

    }
}