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.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dflet
Date:
Fri Jun 26 16:49:04 2015 +0000
Parent:
1:1a80c1529aa3
Child:
3:7643714ec664
Commit message:
WIP commit 2

Changed in this revision

camera_app/camera_app.cpp Show annotated file Show diff for this revision Revisions of this file
camera_app/httpserverapp/httpserverapp.cpp Show annotated file Show diff for this revision Revisions of this file
camera_app/mt9d111/mt9d111.cpp Show annotated file Show diff for this revision Revisions of this file
http/server/WebSockHandler.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
utils/app_config.h Show annotated file Show diff for this revision Revisions of this file
--- a/camera_app/camera_app.cpp	Thu Jun 25 18:37:49 2015 +0000
+++ b/camera_app/camera_app.cpp	Fri Jun 26 16:49:04 2015 +0000
@@ -349,35 +349,31 @@
     Uart_Write((uint8_t*)"CaptureImage \n\r");
     DCMI_HandleTypeDef hdcmi;
     DMA_HandleTypeDef hdma_dcmi;
-    //
-    // Configure DMA in ping-pong mode
-    //
+    memset(g_image.g_image_buffer,0xF80F,sizeof(g_image.g_image_buffer));
+    p_buffer = &(g_image.g_image_buffer[0]);
 
     DMAConfig();
     
-    HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)&WriteBuffer, FRAME_SIZE_IN_BYTES); 
-    
- 
-/* Wait for frame */
-while ((DCMI->CR & DCMI_CR_CAPTURE) != 0) {
- 
-}
- 
-/* The frame is finished, but DMA still waiting
-   for data because we set max frame size
-   so we need to abort the DMA transfer here */
-HAL_DMA_Abort(&hdma_dcmi);
- 
-/* Read the number of data items transferred */
-//image->size = (FRAME_SIZE_IN_BYTES - hdma_dcmi.Instance->NDTR)*4;      
-    
     //
     // Perform Image Capture 
     //
-//    MAP_CameraCaptureStart(CAMERA_BASE);
-    while(g_frame_end == 0)
-        ;
-//    MAP_CameraCaptureStop(CAMERA_BASE, true);
+    Uart_Write((uint8_t*)"CaptureImage Start\n\r");
+    HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t)p_buffer, sizeof(g_image.g_image_buffer)); 
+    
+    /* Wait for frame */
+    while ((DCMI->CR & DCMI_CR_CAPTURE) != 0) {
+ 
+    }
+    g_frame_end = 1;
+    
+    Uart_Write((uint8_t*)"CaptureImage Complete\n\r");
+    /* The frame is finished, but DMA still waiting
+       for data because we set max frame size
+       so we need to abort the DMA transfer here */
+    HAL_DMA_Abort(&hdma_dcmi);//need this???
+ 
+    /* Read the number of data items transferred */
+    uint16_t image_size = (FRAME_SIZE_IN_BYTES - hdma_dcmi.Instance->NDTR)*4;      
 
     //
     // Create JPEG Header
@@ -412,8 +408,8 @@
 static void DMAConfig()
 {
     Uart_Write((uint8_t*)"DMAConfig \n\r");
-    memset(g_image.g_image_buffer,0xF80F,sizeof(g_image.g_image_buffer));
-    p_buffer = &(g_image.g_image_buffer[0]);
+//    memset(g_image.g_image_buffer,0xF80F,sizeof(g_image.g_image_buffer));
+//    p_buffer = &(g_image.g_image_buffer[0]);
     //
     // Initilalize DMA 
     //
@@ -427,14 +423,14 @@
     //
     //  Pong Buffer
     // 
-    p_buffer += TOTAL_DMA_ELEMENTS; 
+//    p_buffer += TOTAL_DMA_ELEMENTS; 
 //    UDMASetupTransfer(UDMA_CH22_CAMERA|UDMA_ALT_SELECT,UDMA_MODE_PINGPONG,TOTAL_DMA_ELEMENTS,
 //                     UDMA_SIZE_32, UDMA_ARB_8,(void *)CAM_BUFFER_ADDR,
 //                     UDMA_SRC_INC_32, (void *)p_buffer, UDMA_DST_INC_32);
     //
     //  Ping Buffer
     // 
-    p_buffer += TOTAL_DMA_ELEMENTS; 
+//    p_buffer += TOTAL_DMA_ELEMENTS; 
 
     g_dma_txn_done = 0;
     g_frame_size_in_bytes = 0;
--- a/camera_app/httpserverapp/httpserverapp.cpp	Thu Jun 25 18:37:49 2015 +0000
+++ b/camera_app/httpserverapp/httpserverapp.cpp	Fri Jun 26 16:49:04 2015 +0000
@@ -107,6 +107,7 @@
 
 			if(!sl_WebSocketSend(g_uConnection, Write, Opcode))
 			{
+				Uart_Write((uint8_t*)"sl_WebSocketSend fsiled.\n\r");
 				while(1);
 			}
 		}
--- a/camera_app/mt9d111/mt9d111.cpp	Thu Jun 25 18:37:49 2015 +0000
+++ b/camera_app/mt9d111/mt9d111.cpp	Fri Jun 26 16:49:04 2015 +0000
@@ -340,7 +340,7 @@
 //*****************************************************************************
 int StartSensorInJpegMode(int width, int height)
 {
-    Uart_Write((uint8_t*)"StartSensorInJpegMode \n\r");
+    Uart_Write((uint8_t*)"\n\rStartSensorInJpegMode \n\r");
 #ifdef ENABLE_JPEG
     int lRetVal = -1;
 
@@ -413,7 +413,7 @@
 //*****************************************************************************
 static int RegLstWrite(s_RegList *pRegLst, unsigned int ulNofItems)
 {
-    Uart_Write((uint8_t*)"RegLstWrite \n\r");
+    Uart_Write((uint8_t*)"\n\rRegLstWrite \n\r");
     unsigned int       ulNdx;
     unsigned short      usTemp;
     unsigned char       i;
@@ -431,7 +431,7 @@
         if(pRegLst->ucPageAddr == 100)
         {
             // PageAddr == 100, insret a delay equal to reg value 
-            wait_us(pRegLst->usValue * 80000/3);
+            wait_us(pRegLst->usValue);// * 80000/3);
         }
         else if(pRegLst->ucPageAddr == 111)
         {
@@ -448,6 +448,7 @@
 
                 usTemp = ucBuffer[0] << 8;
                 usTemp |= ucBuffer[1];
+                usTemp = pRegLst->usValue;//Temp debug
             }while(usTemp != pRegLst->usValue);
         }
         else
--- a/http/server/WebSockHandler.cpp	Thu Jun 25 18:37:49 2015 +0000
+++ b/http/server/WebSockHandler.cpp	Fri Jun 26 16:49:04 2015 +0000
@@ -290,6 +290,7 @@
  */
 int WSCore_DataSend(UINT16 uConnection, struct HttpBlob PayLoad, UINT8 Opcode)
 {
+	Uart_Write((uint8_t*)"WSCore_DataSend.\n\r");
 	UINT16 usTotalLength;
 	UINT8 usNextBlock;
 	UINT16 usPayloadLen;	// The heap cannot support beyond 65kb
--- a/main.cpp	Thu Jun 25 18:37:49 2015 +0000
+++ b/main.cpp	Fri Jun 26 16:49:04 2015 +0000
@@ -123,7 +123,7 @@
   /* RCC_MCODIV_5 33.6MHz mco output on pin PC_9 (cam xclk) */
   /* RCC_MCODIV_4 42MHz mco output on pin PC_9 (cam xclk) */
   /* RCC_MCODIV_3 56MHz mco output on pin PC_9 (cam xclk) */
-  HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_3);
+  HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_5);
 
   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
 
@@ -248,7 +248,6 @@
 /* Initialize all configured peripherals */
    MX_DMA_Init();
    MX_DCMI_Init();
-//   Uart_Write((uint8_t*)"Initialize all configured peripherals complete \n\r");
    initLEDs();
 
    toggleLed(1);
--- a/utils/app_config.h	Thu Jun 25 18:37:49 2015 +0000
+++ b/utils/app_config.h	Fri Jun 26 16:49:04 2015 +0000
@@ -3,7 +3,7 @@
 #define app_config_H
 
 
-#define SPAWN_TASK_PRIORITY            9//9
+#define SPAWN_TASK_PRIORITY            7//9
 #define HTTP_SERVER_APP_TASK_PRIORITY  1//1
 #define CAMERA_SERVICE_PRIORITY        1
 #define OSI_STACK_SIZE                 2048