TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //*****************************************************************************
00002 // main.c
00003 //
00004 // Reference code to demonstrate getting the current time using an NTP server.
00005 //
00006 // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
00007 //
00008 //
00009 //  Redistribution and use in source and binary forms, with or without
00010 //  modification, are permitted provided that the following conditions
00011 //  are met:
00012 //
00013 //    Redistributions of source code must retain the above copyright
00014 //    notice, this list of conditions and the following disclaimer.
00015 //
00016 //    Redistributions in binary form must reproduce the above copyright
00017 //    notice, this list of conditions and the following disclaimer in the
00018 //    documentation and/or other materials provided with the
00019 //    distribution.
00020 //
00021 //    Neither the name of Texas Instruments Incorporated nor the names of
00022 //    its contributors may be used to endorse or promote products derived
00023 //    from this software without specific prior written permission.
00024 //
00025 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 //*****************************************************************************
00038 
00039 //****************************************************************************
00040 //
00041 //! \addtogroup main
00042 //! @{
00043 //
00044 //****************************************************************************
00045 
00046 #include "mbed.h"
00047 
00048 // SimpleLink include
00049 #include "cc3100_simplelink.h"
00050 #include "cc3100.h"
00051 
00052 #include "httpserverapp.h"
00053 
00054 /* Free-RTOS includes */
00055 #include "osi.h"
00056 
00057 #include "cli_uart.h"
00058 #include "app_config.h"
00059 #include "myBoardInit.h"
00060 #include "camera_app.h"
00061 
00062 using namespace mbed_cc3100;
00063 
00064 
00065 /* Warning if pin changes are made below then the same changes have to be made in the following files.
00066  * httpserverapp.cpp
00067  * HttpCore.cpp
00068  * HttpSocket.cpp
00069  * HttpStatic.cpp
00070  * fPtr_func.cpp
00071  * cc3100_spawn.cpp
00072  */ 
00073 
00074 /* On board leds */
00075   DigitalOut led1(LED1);
00076   DigitalOut led2(LED2);
00077 
00078 cc3100 _cc3100(NC, NC, p9, p10, p8, SPI(p5, p6, p7));//LPC1768  irq, nHib, cs, mosi, miso, sck
00079 //ArduCAM myCAM(OV5642, p14, SPI(p11, p12, p13), I2C(p28, p27));
00080 
00081 void initLEDs(void);
00082 void toggleLed(int ind);
00083 static void DisplayBanner(char * AppName);
00084 
00085 #define PRINT_BUF_LEN    128
00086 int8_t print_buf[PRINT_BUF_LEN];
00087 
00088 //*****************************************************************************
00089 //                          LOCAL DEFINES
00090 //*****************************************************************************
00091 #define APP_NAME                "WebSocket"
00092 
00093 void initLEDs(void){
00094       
00095     led1 = 1;
00096     led2 = 1;       
00097     
00098 }
00099 
00100 void toggleLed(int ind){
00101     
00102     if(ind == 1){
00103         led1 = !led1;
00104     }
00105     if(ind == 2){
00106         led2 = !led2;
00107     }   
00108     
00109 }   
00110 
00111 //*****************************************************************************
00112 //
00113 //! Application startup display on UART
00114 //!
00115 //! \param  none
00116 //!
00117 //! \return none
00118 //!
00119 //*****************************************************************************
00120 
00121 static void
00122 DisplayBanner(char * AppName)
00123 {
00124 
00125     Report("\n\n\n\r");
00126     Report(" *************************************************\n\r");
00127     Report("      CC3100 %s Application       \n\r", AppName);
00128     Report(" *************************************************\n\r");
00129     Report("\n\n\n\r");
00130 }
00131 
00132 //****************************************************************************
00133 //                          MAIN FUNCTION
00134 //****************************************************************************
00135 int main(void) {
00136 
00137    SCB->SHCSR |= 0x00070000; 
00138    int rv = 0;
00139    
00140    //
00141    // Configuring UART
00142    //
00143    CLI_Configure();
00144    initLEDs();
00145     
00146     memset(print_buf, 0x00, PRINT_BUF_LEN);
00147     sprintf((char*) print_buf, " \r\nSystemCoreClock = %dMHz\r\n ", SystemCoreClock /1000000);
00148     rv = Uart_Write((uint8_t *) print_buf);
00149     if(rv < 0){
00150         while(1){
00151         toggleLed(1);
00152         wait(0.1);
00153         }
00154     }
00155     
00156     //
00157     // Display Application Banner
00158     //
00159     DisplayBanner(APP_NAME);
00160 
00161     //
00162     // Start the SimpleLink Host
00163     //
00164     VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
00165     //
00166     // Start the HttpServer Task
00167     //
00168     //
00169 
00170     osi_TaskCreate(HttpServerAppTask,
00171                     "WebSocketApp",
00172                         OSI_STACK_SIZE,
00173                         NULL,
00174                         HTTP_SERVER_APP_TASK_PRIORITY,
00175                         NULL );
00176 
00177     Uart_Write((uint8_t*)"HttpServerApp Initialized \n\r");
00178 
00179     //
00180     // Start the task scheduler
00181     //
00182     osi_start();
00183 
00184     return 0;
00185 }
00186 
00187 //*****************************************************************************
00188 //
00189 // Close the Doxygen group.
00190 //! @}
00191 //
00192 //*****************************************************************************
00193 
00194 
00195