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

Committer:
dflet
Date:
Tue Sep 15 16:45:04 2015 +0000
Revision:
22:f9b5e0b80bf2
Parent:
19:3dd3e7f30f8b
Removed some debug.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:50cedd586816 1 /*
dflet 0:50cedd586816 2 * nonos.c - CC31xx/CC32xx Host Driver Implementation
dflet 0:50cedd586816 3 *
dflet 0:50cedd586816 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:50cedd586816 5 *
dflet 0:50cedd586816 6 *
dflet 0:50cedd586816 7 * Redistribution and use in source and binary forms, with or without
dflet 0:50cedd586816 8 * modification, are permitted provided that the following conditions
dflet 0:50cedd586816 9 * are met:
dflet 0:50cedd586816 10 *
dflet 0:50cedd586816 11 * Redistributions of source code must retain the above copyright
dflet 0:50cedd586816 12 * notice, this list of conditions and the following disclaimer.
dflet 0:50cedd586816 13 *
dflet 0:50cedd586816 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:50cedd586816 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:50cedd586816 16 * documentation and/or other materials provided with the
dflet 0:50cedd586816 17 * distribution.
dflet 0:50cedd586816 18 *
dflet 0:50cedd586816 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:50cedd586816 20 * its contributors may be used to endorse or promote products derived
dflet 0:50cedd586816 21 * from this software without specific prior written permission.
dflet 0:50cedd586816 22 *
dflet 0:50cedd586816 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:50cedd586816 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:50cedd586816 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:50cedd586816 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:50cedd586816 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:50cedd586816 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:50cedd586816 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:50cedd586816 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:50cedd586816 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:50cedd586816 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:50cedd586816 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:50cedd586816 34 *
dflet 0:50cedd586816 35 */
dflet 0:50cedd586816 36
dflet 0:50cedd586816 37
dflet 0:50cedd586816 38
dflet 0:50cedd586816 39 /*****************************************************************************/
dflet 0:50cedd586816 40 /* Include files */
dflet 0:50cedd586816 41 /*****************************************************************************/
dflet 0:50cedd586816 42
dflet 0:50cedd586816 43 #include "cc3100_simplelink.h"
dflet 0:50cedd586816 44 #include "fPtr_func.h"
dflet 0:50cedd586816 45
dflet 19:3dd3e7f30f8b 46 //#ifndef SL_PLATFORM_MULTI_THREADED
dflet 19:3dd3e7f30f8b 47 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
dflet 0:50cedd586816 48 #include "cc3100_nonos.h"
dflet 0:50cedd586816 49
dflet 0:50cedd586816 50 namespace mbed_cc3100 {
dflet 0:50cedd586816 51
dflet 0:50cedd586816 52 #ifndef SL_TINY_EXT
dflet 0:50cedd586816 53 #define NONOS_MAX_SPAWN_ENTRIES 5
dflet 0:50cedd586816 54 #else
dflet 0:50cedd586816 55 #define NONOS_MAX_SPAWN_ENTRIES 1
dflet 0:50cedd586816 56 #endif
dflet 0:50cedd586816 57
dflet 0:50cedd586816 58 cc3100_nonos::cc3100_nonos(cc3100_driver &driver)
dflet 0:50cedd586816 59 : _driver(driver)
dflet 0:50cedd586816 60 {
dflet 0:50cedd586816 61
dflet 0:50cedd586816 62 }
dflet 0:50cedd586816 63
dflet 0:50cedd586816 64 cc3100_nonos::~cc3100_nonos()
dflet 0:50cedd586816 65 {
dflet 0:50cedd586816 66
dflet 0:50cedd586816 67 }
dflet 0:50cedd586816 68
dflet 0:50cedd586816 69 typedef struct {
dflet 0:50cedd586816 70 _SlSpawnEntryFunc_t pEntry;
dflet 0:50cedd586816 71 void* pValue;
dflet 0:50cedd586816 72 } _SlNonOsSpawnEntry_t;
dflet 0:50cedd586816 73
dflet 0:50cedd586816 74 typedef struct {
dflet 0:50cedd586816 75 _SlNonOsSpawnEntry_t SpawnEntries[NONOS_MAX_SPAWN_ENTRIES];
dflet 0:50cedd586816 76 } _SlNonOsCB_t;
dflet 0:50cedd586816 77
dflet 0:50cedd586816 78 _SlNonOsCB_t g_SlNonOsCB;
dflet 0:50cedd586816 79
dflet 0:50cedd586816 80
dflet 0:50cedd586816 81 _SlNonOsRetVal_t cc3100_nonos::_SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value)
dflet 0:50cedd586816 82 {
dflet 0:50cedd586816 83 *pSemObj = Value;
dflet 0:50cedd586816 84 return NONOS_RET_OK;
dflet 0:50cedd586816 85 }
dflet 0:50cedd586816 86
dflet 0:50cedd586816 87 _SlNonOsRetVal_t cc3100_nonos::_SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout)
dflet 0:50cedd586816 88 {
dflet 0:50cedd586816 89 #ifdef _SlSyncWaitLoopCallback
dflet 0:50cedd586816 90 _SlNonOsTime_t timeOutRequest = Timeout;
dflet 0:50cedd586816 91 #endif
dflet 0:50cedd586816 92
dflet 0:50cedd586816 93 while (Timeout > 0) {
dflet 0:50cedd586816 94 if (WaitValue == *pSyncObj) {
dflet 0:50cedd586816 95 *pSyncObj = SetValue;
dflet 0:50cedd586816 96 break;
dflet 0:50cedd586816 97 }
dflet 0:50cedd586816 98 if (Timeout != NONOS_WAIT_FOREVER) {
dflet 0:50cedd586816 99 Timeout--;
dflet 0:50cedd586816 100 }
dflet 0:50cedd586816 101 _SlNonOsMainLoopTask();
dflet 0:50cedd586816 102
dflet 0:50cedd586816 103 #ifdef _SlSyncWaitLoopCallback
dflet 0:50cedd586816 104 if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) ) {
dflet 0:50cedd586816 105 if (WaitValue == *pSyncObj) {
dflet 0:50cedd586816 106 *pSyncObj = SetValue;
dflet 0:50cedd586816 107 break;
dflet 0:50cedd586816 108 }
dflet 0:50cedd586816 109 _SlSyncWaitLoopCallback();
dflet 0:50cedd586816 110 }
dflet 0:50cedd586816 111 #endif
dflet 0:50cedd586816 112
dflet 0:50cedd586816 113 }
dflet 0:50cedd586816 114
dflet 0:50cedd586816 115 if (0 == Timeout) {
dflet 0:50cedd586816 116 return NONOS_RET_ERR;
dflet 0:50cedd586816 117 } else {
dflet 0:50cedd586816 118 return NONOS_RET_OK;
dflet 0:50cedd586816 119 }
dflet 0:50cedd586816 120 }
dflet 0:50cedd586816 121
dflet 0:50cedd586816 122
dflet 0:50cedd586816 123 _SlNonOsRetVal_t cc3100_nonos::_SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , uint32_t flags)
dflet 0:50cedd586816 124 {
dflet 0:50cedd586816 125 int8_t i = 0;
dflet 0:50cedd586816 126
dflet 0:50cedd586816 127 #ifndef SL_TINY_EXT
dflet 0:50cedd586816 128 for (i=0 ; i<NONOS_MAX_SPAWN_ENTRIES ; i++)
dflet 0:50cedd586816 129 #endif
dflet 0:50cedd586816 130 {
dflet 0:50cedd586816 131 _SlNonOsSpawnEntry_t* pE = &g_SlNonOsCB.SpawnEntries[i];
dflet 0:50cedd586816 132
dflet 0:50cedd586816 133 if (NULL == pE->pEntry)
dflet 0:50cedd586816 134 {
dflet 0:50cedd586816 135 pE->pValue = pValue;
dflet 0:50cedd586816 136 pE->pEntry = pEntry;
dflet 0:50cedd586816 137 #ifndef SL_TINY_EXT
dflet 0:50cedd586816 138 break;
dflet 0:50cedd586816 139 #endif
dflet 0:50cedd586816 140 }
dflet 0:50cedd586816 141 }
dflet 0:50cedd586816 142
dflet 0:50cedd586816 143
dflet 0:50cedd586816 144 return NONOS_RET_OK;
dflet 0:50cedd586816 145 }
dflet 0:50cedd586816 146
dflet 0:50cedd586816 147 _SlNonOsRetVal_t cc3100_nonos::_SlNonOsMainLoopTask(void)
dflet 0:50cedd586816 148 {
dflet 19:3dd3e7f30f8b 149 printf("_SlNonOsMainLoopTask\r\n");
dflet 0:50cedd586816 150 int8_t i = 0;
dflet 0:50cedd586816 151
dflet 0:50cedd586816 152 #ifndef SL_TINY_EXT
dflet 0:50cedd586816 153 for (i=0 ; i<NONOS_MAX_SPAWN_ENTRIES ; i++)
dflet 0:50cedd586816 154 #endif
dflet 0:50cedd586816 155 {
dflet 0:50cedd586816 156 _SlNonOsSpawnEntry_t* pE = &g_SlNonOsCB.SpawnEntries[i];
dflet 0:50cedd586816 157 _SlSpawnEntryFunc_t pF = pE->pEntry;
dflet 0:50cedd586816 158
dflet 0:50cedd586816 159 if (NULL != pF)
dflet 0:50cedd586816 160 {
dflet 0:50cedd586816 161 if(RxIrqCnt != (g_pCB)->RxDoneCnt) {
dflet 0:50cedd586816 162 _SlDrvMsgReadSpawnCtx(0);
dflet 0:50cedd586816 163 //pF(0);/*(pValue);*//*Function pointer*/
dflet 0:50cedd586816 164 }
dflet 0:50cedd586816 165 pE->pEntry = NULL;
dflet 0:50cedd586816 166 pE->pValue = NULL;
dflet 0:50cedd586816 167 }
dflet 0:50cedd586816 168 }
dflet 0:50cedd586816 169
dflet 0:50cedd586816 170 return NONOS_RET_OK;
dflet 0:50cedd586816 171 }
dflet 0:50cedd586816 172
dflet 0:50cedd586816 173 }//namespace mbed_cc3100
dflet 0:50cedd586816 174
dflet 0:50cedd586816 175 #endif /*(SL_PLATFORM != SL_PLATFORM_NON_OS)*/
dflet 0:50cedd586816 176
dflet 0:50cedd586816 177
dflet 0:50cedd586816 178
dflet 0:50cedd586816 179
dflet 0:50cedd586816 180