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

Revision:
4:c27adffcfec2
Parent:
3:7643714ec664
Child:
5:75fcfdb7cae7
--- a/main.cpp	Fri Jun 26 22:53:54 2015 +0000
+++ b/main.cpp	Tue Jun 30 22:51:05 2015 +0000
@@ -51,8 +51,8 @@
 
 #include "httpserverapp.h"
 
-#include "stm32f4xx_hal.h"
-#include "stm32f4xx_hal_rcc.h"
+//#include "stm32f4xx_hal.h"
+//#include "stm32f4xx_hal_rcc.h"
 
 /* Free-RTOS includes */
 #include "osi.h"
@@ -66,6 +66,9 @@
 static void SystemClock_Config(void);
 static void MX_DMA_Init(void);
 static void MX_DCMI_Init(void);
+
+void DCMI_IRQHandler(void);
+void DMA2_Stream1_IRQHandler(void);
  
  /**
   * Initializes the Global MSP.
@@ -95,6 +98,8 @@
 static void SystemClock_Config(void)
 {
   
+  SystemCoreClockUpdate();
+  
   RCC_OscInitTypeDef RCC_OscInitStruct;
   RCC_ClkInitTypeDef RCC_ClkInitStruct;
 //  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;//Used for ov7670 test
@@ -130,15 +135,25 @@
   /* 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_5);
+//  HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4);
+
+  /* RCC_MCODIV_1 8MHz mco output on pin PC_9 (cam xclk) */  
+  HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_HSE, RCC_MCODIV_4);
+
   //Used for ov7670 test
   /* RCC_MCODIV_4 24MHz mco output on pin PC_9 (cam xclk) */
 //  HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_PLLI2SCLK, RCC_MCODIV_4);
 
   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
   
-  //Used for ov7670 test
-//  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
+  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
+
+/* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported  */
+//  if (HAL_GetREVID() == 0x1001)
+//  {
+    /* Enable the Flash prefetch */
+//    __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
+//  }
   
 }
  
@@ -156,7 +171,9 @@
   hdcmi.Init.JPEGMode = DCMI_JPEG_ENABLE;
 #else
   hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
-#endif    
+#endif
+
+  HAL_DCMI_MspInit(&hdcmi);  
   HAL_DCMI_Init(&hdcmi);
 
 }
@@ -170,7 +187,7 @@
    __DMA2_CLK_ENABLE();
 
   /* DMA interrupt init */
-  HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0);
+  HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 5);
 //  HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
 
 }
@@ -251,6 +268,8 @@
 
    int rv = 0;
    
+   HAL_Init();
+   
    SystemClock_Config();
    
    //
@@ -263,7 +282,7 @@
    MX_DCMI_Init();
    initLEDs();
 
-   toggleLed(1);
+//   toggleLed(1);
 //#ifndef NOTERM
 
 	//
@@ -314,6 +333,128 @@
 	return 0;
 }
 
+/**
+  * @brief  This function handles Hard Fault exception.
+  * @param  None
+  * @retval None
+  */
+extern "C" void HardFault_Handler(void)
+{
+  /* Go to infinite loop when Hard Fault exception occurs */
+  Uart_Write((uint8_t*)"HardFault_Handler \n\r");
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles Memory Manage exception.
+  * @param  None
+  * @retval None
+  */
+extern "C" void MemManage_Handler(void)
+{
+  Uart_Write((uint8_t*)"MemManage_Handler \n\r");
+  /* Go to infinite loop when Memory Manage exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles Bus Fault exception.
+  * @param  None
+  * @retval None
+  */
+extern "C" void BusFault_Handler(void)
+{
+  Uart_Write((uint8_t*)"BusFault_Handler \n\r");
+  /* Go to infinite loop when Bus Fault exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles Usage Fault exception.
+  * @param  None
+  * @retval None
+  */
+extern "C" void UsageFault_Handler(void)
+{
+  Uart_Write((uint8_t*)"UsageFault_Handler \n\r");
+  /* Go to infinite loop when Usage Fault exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles SVCall exception.
+  * @param  None
+  * @retval None
+  */
+/*  
+extern "C" void SVC_Handler(void)
+{
+	Uart_Write((uint8_t*)"SVC_Handler \n\r");
+}
+*/
+/**
+  * @brief  This function handles Debug Monitor exception.
+  * @param  None
+  * @retval None
+  */
+extern "C" void DebugMon_Handler(void)
+{
+	Uart_Write((uint8_t*)"DebugMon_Handler \n\r");
+}
+
+/**
+  * @brief  This function handles PendSVC exception.
+  * @param  None
+  * @retval None
+  */
+/*  
+extern "C" void PendSV_Handler(void)
+{
+	Uart_Write((uint8_t*)"PendSV_Handler \n\r");
+}
+*/
+/**
+  * @brief  This function handles SysTick Handler.
+  * @param  None
+  * @retval None
+  */
+/*  
+extern "C" void SysTick_Handler(void)
+{
+  Uart_Write((uint8_t*)"SysTick_Handler \n\r");
+  HAL_IncTick();
+}
+*/
+/**
+  * @brief  DMA interrupt handler.
+  * @param  None
+  * @retval None
+  */
+void DMA2_Stream1_IRQHandler(void)
+{
+  Uart_Write((uint8_t*)"DMA2_Stream1_IRQHandler \n\r");
+  HAL_DMA_IRQHandler(&hdma_dcmi);  
+}
+
+/**
+  * @brief  DCMI interrupt handler.
+  * @param  None
+  * @retval None
+  */
+void DCMI_IRQHandler(void)
+{
+  Uart_Write((uint8_t*)"DCMI_IRQHandler \n\r");
+  HAL_DCMI_IRQHandler(&hdcmi);
+}
+
 //*****************************************************************************
 //
 // Close the Doxygen group.