inline void TestDemo_Init() { Demo_Init(); Demo_AddScreen(Screen1_Create()); Demo_AddScreen(Screen2_Create()); }
int main(void) { static unsigned long TimerCnt = 0; static unsigned int temp7670 = 0; u16 value,val,val1,val2; Demo_Init(); ili9320_Initializtion(); ili9320_Clear(0xffff); delay_ms(100); ili9320_SetCursor(0,0); LCD_WriteReg(0x0050, 0); LCD_WriteReg(0x0052, 0); LCD_WriteReg(0x0051, 239); LCD_WriteReg(0x0053, 319); LCD_WriteRAM_Prepare(); // ©╙от╢Ф //delay_ms(10); while(1!=OV7670_init()); while(1) { TimerCnt = 0; temp7670 = 0; CLK_init_ON(); // OV7670 XCLK ©╙ while(value & 0x0800) value = GPIOC->IDR; // Vsync=H while((~value) & 0x0800) value = GPIOC->IDR; // Vhync=L CLK_init_OFF(); //OV7670 XCLK ╧ь while(TimerCnt < 76800) { XCLK_L; XCLK_H; value = GPIOC->IDR; temp7670 ++; if(value & 0x0100) // HREF = H ||(LCD_PCLK_STATE) { //value = GPIOC->IDR; //display[TimerCnt]=value; if((temp7670 == 1))// ╦ъвж╫з||(value & 0x0200) ||(LCD_PCLK_STATE) { val1=value& 0x00ff; } else // ╣мвж╫з if((temp7670 != 1)||(LCD_PCLK_STATE)) { val2= value<<8 ; // val =ili9320_BGR2RGB(val1 |val2); temp7670 = 0; LCD_WriteRAM(val); //TFT GRAM йЩ╬щ TimerCnt ++; } } } } }
/******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { /* Initialize the Demo */ Demo_Init(); while (1) { /* If SEL pushbutton is pressed */ if(SELStatus == 1) { /* External Interrupt Disable */ IntExtOnOffConfig(DISABLE); /* Execute Sel Function */ SelFunc(); /* External Interrupt Enable */ IntExtOnOffConfig(ENABLE); /* Reset SELStatus value */ SELStatus = 0; } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s) before to branch to application main. */ /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); /* Initialize LEDs mounted on EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDOn(LED1); /* Initialize the LCD */ LCD_Init(); LCD_Clear(Black); LCD_SetTextColor(White); LCD_LOG_SetHeader((uint8_t*)"STM32 Camera Demo"); LCD_LOG_SetFooter ((uint8_t*)" Copyright (c) STMicroelectronics" ); /* ADC configuration */ ADC_Config(); /* Initializes the DCMI interface (I2C and GPIO) used to configure the camera */ OV2640_HW_Init(); /* Read the OV9655/OV2640 Manufacturer identifier */ OV9655_ReadID(&OV9655_Camera_ID); OV2640_ReadID(&OV2640_Camera_ID); if(OV9655_Camera_ID.PID == 0x96) { Camera = OV9655_CAMERA; sprintf((char*)abuffer, "OV9655 Camera ID 0x%x", OV9655_Camera_ID.PID); ValueMax = 2; } else if(OV2640_Camera_ID.PIDH == 0x26) { Camera = OV2640_CAMERA; sprintf((char*)abuffer, "OV2640 Camera ID 0x%x", OV2640_Camera_ID.PIDH); ValueMax = 2; } else { LCD_SetTextColor(LCD_COLOR_RED); LCD_DisplayStringLine(LINE(4), (uint8_t*)"Check the Camera HW and try again"); while(1); } LCD_SetTextColor(LCD_COLOR_YELLOW); LCD_DisplayStringLine(LINE(4), (uint8_t*)abuffer); LCD_SetTextColor(LCD_COLOR_WHITE); Delay(200); /* Initialize demo */ ImageFormat = (ImageFormat_TypeDef)Demo_Init(); /* Configure the Camera module mounted on STM324xG-EVAL/STM324x7I-EVAL boards */ Demo_LCD_Clear(); LCD_DisplayStringLine(LINE(4), (uint8_t*)"Camera Init.. "); Camera_Config(); sprintf((char*)abuffer, " Image selected: %s", ImageForematArray[ImageFormat]); LCD_DisplayStringLine(LINE(4),(uint8_t*)abuffer); /* Enable DMA2 stream 1 and DCMI interface then start image capture */ DMA_Cmd(DMA2_Stream1, ENABLE); DCMI_Cmd(ENABLE); /* Insert 100ms delay: wait 100ms */ Delay(200); DCMI_CaptureCmd(ENABLE); LCD_ClearLine(LINE(4)); Demo_LCD_Clear(); if(ImageFormat == BMP_QQVGA) { /* LCD Display window */ LCD_SetDisplayWindow(179, 239, 120, 160); LCD_WriteReg(LCD_REG_3, 0x1038); LCD_WriteRAM_Prepare(); } else if(ImageFormat == BMP_QVGA) { /* LCD Display window */ LCD_SetDisplayWindow(239, 319, 240, 320); LCD_WriteReg(LCD_REG_3, 0x1038); LCD_WriteRAM_Prepare(); } while(1) { /* Blink LD1, LED2 and LED4 */ STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED3); STM_EVAL_LEDToggle(LED4); /* Insert 100ms delay */ Delay(10); /* Get the last ADC3 conversion result data */ uhADCVal = ADC_GetConversionValue(ADC3); /* Change the Brightness of camera using "Brightness Adjustment" register: For OV9655 camera Brightness can be positively (0x01 ~ 0x7F) and negatively (0x80 ~ 0xFF) adjusted For OV2640 camera Brightness can be positively (0x20 ~ 0x40) and negatively (0 ~ 0x20) adjusted */ if(Camera == OV9655_CAMERA) { OV9655_BrightnessConfig(uhADCVal); } if(Camera == OV2640_CAMERA) { OV2640_BrightnessConfig(uhADCVal/2); } } }