Port of TI's CC3100 Websock camera demo. Using FreeRTOS, mbedTLS, also parts of Arducam for cams ov5642 and 0v2640. Can also use MT9D111. Work in progress. Be warned some parts maybe a bit flacky. This is for Seeed Arch max only, for an M3, see the demo for CM3 using the 0v5642 aducam mini.
Diff: camera_app/camera_app.cpp
- Revision:
- 21:38c6b11aa348
- Parent:
- 18:3f1b52616d00
- Child:
- 22:f9b5e0b80bf2
--- a/camera_app/camera_app.cpp Sat Sep 12 22:38:40 2015 +0000 +++ b/camera_app/camera_app.cpp Tue Sep 15 15:39:38 2015 +0000 @@ -74,7 +74,6 @@ // Macros //***************************************************************************** #define USER_FILE_NAME "www/images/cc3200_camera_capture.jpg" -//#define TOTAL_DMA_ELEMENTS 64 #define AP_SSID_LEN_MAX (33) #define ROLE_INVALID (-5) //***************************************************************************** @@ -108,8 +107,8 @@ #ifdef ENABLE_JPEG char g_header[SMTP_BUF_LEN] /*= {'\0'}*/; #endif -// uint32_t g_image_buffer[NUM_OF_4B_CHUNKS];//60Kb 15360, 50Kb 12800 - uint32_t g_image_buffer[((IMAGE_BUF_SIZE)/(sizeof(unsigned int)))];//51Kb + uint32_t g_image_buffer[((IMAGE_BUF_SIZE)/(sizeof(unsigned int)))];//25Kb + uint8_t sec_image_buffer[26 * 1024]; }; ImageBuffer g_image; @@ -347,7 +346,9 @@ { uint32_t g_header_length = 0; + uint32_t image_size = 0; uint32_t *pbuffer = &(g_image.g_image_buffer[0]); + uint8_t *sec_pbuffer = &(g_image.sec_image_buffer[0]); // int32_t lRetVal= -1; int32_t err = 0; #ifdef MT9D111_CAM @@ -356,10 +357,11 @@ picLoop++; DMAConfig(); - wait(1); +// wait(1); #ifdef MT9D111_CAM /* Send cam capture request, value in frames */ Start_still_capture(1);// Switch to context b + wait(1); #endif // // DCMI Perform Image Capture @@ -381,7 +383,7 @@ err = HAL_DMA_GetState(&phdma_dcmi); HttpDebug("\r\nDMA error! 0x%x\r\n",err); HttpDebug("\r\nDMA error! 0x%x\r\n",phdma_dcmi.ErrorCode); - HttpDebug("g_frame_size_in_bytes = 0x%x\n\r",g_frame_size_in_bytes); + HttpDebug("g_frame_size_in_bytes = 0x%x\r\n",g_frame_size_in_bytes); HttpDebug("\r\nFailed to capture data, check camera connections!\r\n"); HAL_DMA_Abort(&phdma_dcmi); #ifdef MT9D111_CAM @@ -399,29 +401,28 @@ #ifdef MT9D111_CAM memcpy(Image + g_frame_size_in_bytes, jpeg_end, 2); g_frame_size_in_bytes += 2; -#endif +#endif + // // Create JPEG Header // #ifdef MT9D111_CAM #ifdef ENABLE_JPEG memset(g_image.g_header, '\0', sizeof(g_image.g_header)); - g_header_length = CreateJpegHeader((char *)&(g_image.g_header[0]), PIXELS_IN_X_AXIS, PIXELS_IN_Y_AXIS, 0, 0x0020, 9); + g_header_length = CreateJpegHeader((char *)&(g_image.g_header[0]), PIXELS_IN_X_AXIS, PIXELS_IN_Y_AXIS, 0, 0x0020, 8); - // This pushes the header to the start of the array so that the entire picture can be contiguous in memory - memcpy(Image + g_header_length, Image, g_frame_size_in_bytes); - memcpy(Image, g_image.g_header, g_header_length); - - // This pushes the header to the end of the array so that the entire picture can be contiguous in memory -// memcpy((Image + g_frame_size_in_bytes ), g_image.g_header, g_header_length); - wait_ms(100); - HttpDebug("Capture Image %d\n\r",picLoop); + // This pushes the header to the start of the array so that the entire picture can be contiguous in memory + memcpy(sec_pbuffer + g_header_length, Image, g_frame_size_in_bytes); + memcpy(sec_pbuffer, g_image.g_header, g_header_length); + + image_size = g_header_length + g_frame_size_in_bytes; + HttpDebug("\r\nCapture Image %d size 0x%x\r\n",picLoop, image_size); #endif//ENABLE_JPEG - *WriteBuffer = (char*)Image; + *WriteBuffer = (char*)g_image.sec_image_buffer; return(g_header_length += g_frame_size_in_bytes); #endif//MT9D111_CAM - HttpDebug("\r\nCapture Image %d\r\n",picLoop); - *WriteBuffer = (char*)Image; + HttpDebug("\r\nCapture Image %d size 0x%x\r\n",picLoop, image_size); + *WriteBuffer = (char*)g_image.sec_image_buffer; return(g_frame_size_in_bytes); } @@ -452,7 +453,7 @@ phdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;//Data clocked out on rising edge // phdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING;//Data clocked out on falling edge phdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW;//Active high - phdcmi.Init.HSPolarity = DCMI_HSPOLARITY_HIGH;//Active high + phdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;//Active high #endif phdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME; phdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;//8 bit data