黄 {MOD}:pclk(周期约28ns) 蓝 {MOD}:hs 红 {MOD}:href
部分程式:
主函数:
[mw_shl_code=c,true]int main(void)
{
HAL_Init();
/* Configure the system clock to 168 Mhz */
SystemClock_Config();
UartHandle.Instance = USARTx;
UartHandle.Init.BaudRate = 115200;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle.Init.StopBits = UART_STOPBITS_1;
UartHandle.Init.Parity = UART_PARITY_NONE;
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle.Init.Mode = UART_MODE_TX_RX;
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Enable the GPIO_LED clock */
__GPIOD_CLK_ENABLE();
__GPIOG_CLK_ENABLE();
/* Configure the Reset pin */
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/* Configure the PWDN pin */
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_9, GPIO_PIN_RESET); //PWDN ON
HAL_Delay(10);//10ms
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_RESET); //Reset active
HAL_Delay(10);//10ms
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_SET); //Reset off
/* Initialize the Camera */
BSP_CAMERA_Init(RESOLUTION_R1600x1200);
OV2640_JPEG_Mode(CAMERA_I2C_ADDRESS);
OV2640_OutSize_Set(CAMERA_I2C_ADDRESS,jpeg_img_size_tbl[size][0],jpeg_img_size_tbl[size][1]);//set output size
// *jpeg_buf = BSP_CAMERA_Receive();
/* Start the Camera Capture */
BSP_CAMERA_ContinuousStart((uint8_t *)&jpeg_buf,jpeg_buf_size);
while (1)
{
if(jpeg_data_ok == 1)
{
p = (uint8_t *)jpeg_buf;
if(HAL_UART_Transmit(&UartHandle, p, jpeg_data_len*4, 5000)!= HAL_OK)
{
Error_Handler();
}
jpeg_data_ok = 2;
}
}
}[/mw_shl_code]
DMA FRAME中断函数:
[mw_shl_code=c,true]void BSP_CAMERA_FrameEventCallback(void)
{
jpeg_data_process();
}
void jpeg_data_process(void)
{
if(jpeg_data_ok == 0)
{
//get data
BSP_CAMERA_Suspend();
jpeg_data_len = jpeg_buf_size - BSP_CAMERA_RemainData();
jpeg_data_ok=1;
}
if(jpeg_data_ok == 2)
{
BSP_CAMERA_Resume();
jpeg_data_ok=0;
}
}[/mw_shl_code]
不知道从何下手找问题,有经验的朋友指导一下我,谢谢。
一周热门 更多>