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; }
int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //Configure System Clock //SSD SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); //Enable Port D SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Enable Port B GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,0x0F); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,0xFF); //S1 and S2 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //Enable Port F //Mode 1 SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //Enable ADC0 Module SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //Enable Port E GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1); //Select ADC Function of PE 1 ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0); //Configure ADC0 Sequencer ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END); //Configure the step of the sequencer //Mode 2 SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); //Enable TIMER1 Module GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4); //Set PF4 as Input GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); //Configuring the PF4 GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_BOTH_EDGES); //Setting Interrupt to trigger on both edges TimerConfigure(TIMER1_BASE,TIMER_CFG_PERIODIC); //Configure TIMER1 into a Continuous Mode TimerIntRegister(TIMER1_BASE, TIMER_A, fast); //Register interrupt if PF4 pressed for more than 1s //Mode 3 SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4); //Enable TIMER4 Module SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0); //Enable WTIMER0 Module SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); //Enable Port C GPIOPinConfigure(GPIO_PC4_WT0CCP0); GPIOPinTypeTimer(GPIO_PORTC_BASE,GPIO_PIN_4); //Set PC4 as a Timer Capture pin TimerIntRegister(TIMER4_BASE,TIMER_A,freqfind); //Register a timer interrupt for TIMER4 TimerConfigure(TIMER4_BASE,TIMER_CFG_PERIODIC); //Configure Timer4 in continuous mode TimerConfigure(WTIMER0_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_COUNT); TimerControlEvent(WTIMER0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE); //Configure WTIMER0 for Positive Edge Capture IntMasterEnable(); GPIOPinWrite(GPIO_PORTB_BASE,0xFF,0x00); //Initialize SSD to 0x00 GPIOPinWrite(GPIO_PORTD_BASE, 0x0F, 0x00); //Turn off all the digits of the SSD SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); //Enable TIMER0 Module TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC); //Configure TIMER0 into a Continuous Mode TimerIntRegister(TIMER0_BASE, TIMER_A, ssdmux); //Register ISR for TIMER0 Interrupt to update SSD TimerLoadSet(TIMER0_BASE, TIMER_A,SysCtlClockGet()/3000); //Set the refresh rate of the SSD IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT); //Enable the timer interrupt TimerEnable(TIMER0_BASE,TIMER_A); //Start the timer HWREG(GPIO_PORTF_BASE|GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTF_BASE|GPIO_O_CR) = GPIO_PIN_0; //Unlock PF0 from the NMI mode HWREG(GPIO_PORTF_BASE|GPIO_O_LOCK) = 0; ssdset(0); mode1set(); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0); //Setting PF0 to Input GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); //Configuring the pins GPIOIntRegister(GPIO_PORTF_BASE, modeselect); //Register Interrupt for Port F with ISR modeselect() GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_0); //Clear any existing interrupts GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE); //Setting Interrupt to trigger on falling edges GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0); //Enable the GPIO Interrupts on Port F IntEnable(INT_GPIOF); //Enable Interrupts on Port F while(1){ switch(mode) //Select operation according to mode { case 1: mode1(); break; case 2: ssdsetHex(hex_count); if(fast_flag) { mode2(); SysCtlDelay(SysCtlClockGet()/300); } break; case 3: mode3(); break; case 4: mode1(); break; case 5: ssdsetHex(hex_count); if(fast_flag) { mode2(); SysCtlDelay(SysCtlClockGet()/300); } break; } SysCtlDelay(SysCtlClockGet()/3000); } return 0; }
//================================================ void filter() { mode1(); }
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); } }