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.
Revision 8:529a12812c53, committed 2015-07-06
- Comitter:
- dflet
- Date:
- Mon Jul 06 11:03:14 2015 +0000
- Parent:
- 7:a069c1750fbc
- Child:
- 9:b7c6e7303df5
- Commit message:
- WIP commit 9
Changed in this revision
--- a/camera_app/camera_app.cpp Sun Jul 05 22:18:04 2015 +0000
+++ b/camera_app/camera_app.cpp Mon Jul 06 11:03:14 2015 +0000
@@ -339,29 +339,21 @@
//
// Perform Image Capture
//
-// Uart_Write((uint8_t*)"CaptureImage Start\n\r");
-// HAL_DCMI_Start_DMA(&phdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)p_buffer, sizeof(g_image.g_image_buffer));
-// wait(1);
- HAL_DCMI_Start_DMA(&phdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)p_buffer, FRAME_SIZE_IN_BYTES);
+
+ HAL_DCMI_Start_DMA(&phdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)p_buffer, FRAME_SIZE_IN_BYTES/4);
g_frame_end = 1;
-
-// Uart_Write((uint8_t*)"\n\rCaptureImage Complete\n\r");
/* Read the number of data items transferred */
g_frame_size_in_bytes = (FRAME_SIZE_IN_BYTES - (hdma_dcmi.Instance->NDTR*4));
-// p_buffer += image_size;
-// image_size = hdma_dcmi.Instance->NDTR *4;
-// HttpDebug("hdma_dcmi.Instance->NDTR = %i\r\n",hdma_dcmi.Instance->NDTR *4);
-// image_size = (sizeof(g_image.g_image_buffer) - (hdma_dcmi.Instance->NDTR * 4));
-// HttpDebug("image_size = %i\r\n",image_size);
g_dma_txn_done = 1;
-// g_frame_size_in_bytes = image_size;
g_total_dma_intrpts = 1;
-// int i;
-// for(i = 0;i<10;i++){
-// HttpDebug("%x ",g_image.g_image_buffer[0]);
- // }
+ uint8_t* Image_Array = reinterpret_cast<uint8_t*>(&g_image.g_image_buffer);
+#if 0
+ for(int i =0;i< 100;i++){
+ HttpDebug("0x%x ",Image_Array[i]);
+ }
+#endif//if 0
//
// Create JPEG Header
//
@@ -370,23 +362,19 @@
g_header_length = CreateJpegHeader((char *)&(g_image.g_header[0]), PIXELS_IN_X_AXIS,
PIXELS_IN_Y_AXIS, 0, 0x0020, 9);
- // This loop pushes the header to the end of the array so that the entire picture can be contiguous in memory
- unsigned short shift;
- HttpDebug("p_buffer = 0x%x \n\r",p_buffer);
- memcpy(p_buffer + (g_frame_size_in_bytes/4),g_image.g_header,g_header_length);
- HttpDebug("\n\rCaptureImage Complete\n\r");
-// for(shift=1; shift <= g_header_length; shift++)
-// {
-// g_image.g_image_buffer[(g_frame_size_in_bytes + g_header_length) - shift] = g_image.g_header[g_header_length - shift];
-// g_image.g_header[SMTP_BUF_LEN - shift] = g_image.g_header[g_header_length - shift];
+ // This pushes the header to the start of the array so that the entire picture can be contiguous in memory
+ memcpy(Image_Array + g_header_length,Image_Array,g_frame_size_in_bytes);
+ memcpy(Image_Array,g_image.g_header,g_header_length);
+#if 0
+ for(int i =625;i< 725;i++){
+ HttpDebug("0x%x ",Image_Array[i]);
+ }
+#endif//if 0
-// }
-#endif
- HttpDebug("\n\rCaptureImage Complete\n\r");
- *WriteBuffer = (char*)p_buffer;//(char*)&(g_image.g_image_buffer[0]);
- HttpDebug("Data Len = 0x%x \n\r",WriteBuffer);
-// *WriteBuffer = &(g_image.g_header[SMTP_BUF_LEN - g_header_length]);
-//#endif
+#endif//ENABLE_JPEG
+
+ *WriteBuffer = (char*)Image_Array;
+
return(g_header_length + g_frame_size_in_bytes);
}
//*****************************************************************************
--- a/camera_app/httpserverapp/httpserverapp.cpp Sun Jul 05 22:18:04 2015 +0000
+++ b/camera_app/httpserverapp/httpserverapp.cpp Mon Jul 06 11:03:14 2015 +0000
@@ -108,7 +108,7 @@
if(g_close == 0)
{
Write.uLength = StartCamera((char **)&Write.pData);
- HttpDebug("Data Len = 0x%x \n\r",Write.pData);
+// HttpDebug("Data Len = 0x%x \n\r",Write.pData);
if(!sl_WebSocketSend(g_uConnection, Write, Opcode))
{
Uart_Write((uint8_t*)"sl_WebSocketSend failed.\n\r");
--- a/http/server/WebSockHandler.cpp Sun Jul 05 22:18:04 2015 +0000
+++ b/http/server/WebSockHandler.cpp Mon Jul 06 11:03:14 2015 +0000
@@ -290,7 +290,7 @@
*/
int WSCore_DataSend(UINT16 uConnection, struct HttpBlob PayLoad, UINT8 Opcode)
{
- Uart_Write((uint8_t*)"WSCore_DataSend\n\r");
+// Uart_Write((uint8_t*)"WSCore_DataSend\n\r");
UINT16 usTotalLength;
UINT8 usNextBlock;
UINT16 usPayloadLen; // The heap cannot support beyond 65kb