stm32f407驱动山外鹰眼二值化摄像头,使用山外的多功能调试助手显示,特此分享
stm32f407芯片主程序:
- #include "main.h"
- uint8_t pic[OV7725_DATASIZE];
- bool busy = false;
- void ov7725_isr(void)
- {
- uint8_t *ptr = (uint8_t*)&pic[0];
- if(!busy)
- {
- OV7725_GetImg(ptr);
- busy = true;
- }
- }
- int main(void)
- {
- uint16_t i;
-
- GPIO_InitTypeDef GPIO_InitStruct;
- USART_InitTypeDef USART_InitStruct;
-
- //GPIO initialize
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- //USART1 initialize
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
- USART_InitStruct.USART_BaudRate = 256000UL;
- USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
- USART_InitStruct.USART_Mode = USART_Mode_Tx;
- USART_InitStruct.USART_Parity = USART_Parity_No;
- USART_InitStruct.USART_StopBits = USART_StopBits_1;
- USART_InitStruct.USART_WordLength = USART_WordLength_8b;
- USART_Init(USART1, &USART_InitStruct);
- USART_Cmd(USART1, ENABLE);
-
- printf("Hello, world!\r\n");
-
- if(OV7725_Init())
- printf("Camera init failed\r\n");
- else
- {
- OV7725_Callback_Install(ov7725_isr);
- //OV7725_Cmd(ENABLE);
- printf("Done!\r\n");
- }
-
- while(1)
- {
- if(busy)
- {
- putchar(0x01);
- putchar(0xFE);
- for(i = 0; i < OV7725_DATASIZE; i++)
- putchar(pic[i]);
- putchar(0xFE);
- putchar(0x01);
- busy = false;
- }
- }
- }
复制代码
全部资料下载地址(源码):
STM32F407-OV7725.zip
(815.37 KB, 下载次数: 294)
|