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.
cc3100_nonos.h
00001 /* 00002 * nonos.h - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 #ifndef NONOS_H_ 00038 #define NONOS_H_ 00039 00040 #include "cc3100_simplelink.h" 00041 00042 /*****************************************************************************/ 00043 /* Macro declarations */ 00044 /*****************************************************************************/ 00045 00046 //#ifndef SL_PLATFORM_MULTI_THREADED 00047 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN)) 00048 00049 namespace mbed_cc3100 { 00050 00051 /* This function call the user defined function, if defined, from the sync wait loop */ 00052 /* The use case of this function is to allow nonos system to call a user function to put the device into sleep */ 00053 /* The wake up should be activated after getting an interrupt from the device to Host */ 00054 /* The user function must return without blocking to prevent a delay on the event handling */ 00055 /* 00056 #define _SlSyncWaitLoopCallback UserSleepFunction 00057 */ 00058 00059 const uint8_t NONOS_WAIT_FOREVER = 0xFF; 00060 const uint8_t NONOS_NO_WAIT = 0x00; 00061 00062 const uint8_t NONOS_RET_OK = 0; 00063 const int8_t NONOS_RET_ERR = 0xFF; 00064 //const uint8_t OSI_OK = 0; 00065 00066 const uint8_t NON_OS_SYNC_OBJ_CLEAR_VALUE = 0x11; 00067 const uint8_t NON_OS_SYNC_OBJ_SIGNAL_VALUE = 0x22; 00068 const uint8_t NON_OS_LOCK_OBJ_UNLOCK_VALUE = 0x33; 00069 const uint8_t NON_OS_LOCK_OBJ_LOCK_VALUE = 0x44; 00070 00071 #define _SlTime_t _SlNonOsTime_t 00072 00073 #define _SlSyncObj_t _SlNonOsSemObj_t 00074 00075 #define _SlLockObj_t _SlNonOsSemObj_t 00076 00077 const uint8_t SL_OS_WAIT_FOREVER = NONOS_WAIT_FOREVER; 00078 00079 const uint8_t SL_OS_RET_CODE_OK = NONOS_RET_OK; 00080 00081 const uint8_t SL_OS_NO_WAIT = NONOS_NO_WAIT; 00082 00083 00084 /*****************************************************************************/ 00085 /* Function prototypes */ 00086 /*****************************************************************************/ 00087 00088 /*! 00089 \brief This function creates a sync object 00090 00091 The sync object is used for synchronization between different thread or ISR and 00092 a thread. 00093 00094 \param pSyncObj - pointer to the sync object control block 00095 00096 \return upon successful creation the function return 0 00097 Otherwise, a negative value indicating the error code shall be returned 00098 \note 00099 \warning 00100 */ 00101 #define _SlNonOsSyncObjCreate(pSyncObj) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_CLEAR_VALUE) 00102 00103 /*! 00104 \brief This function deletes a sync object 00105 00106 \param pSyncObj - pointer to the sync object control block 00107 00108 \return upon successful deletion the function should return 0 00109 Otherwise, a negative value indicating the error code shall be returned 00110 \note 00111 \warning 00112 */ 00113 #define _SlNonOsSyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0)// 00114 00115 /*! 00116 \brief This function generates a sync signal for the object. 00117 00118 All suspended threads waiting on this sync object are resumed 00119 00120 \param pSyncObj - pointer to the sync object control block 00121 00122 \return upon successful signaling the function should return 0 00123 Otherwise, a negative value indicating the error code shall be returned 00124 \note the function could be called from ISR context 00125 \warning 00126 */ 00127 #define _SlNonOsSyncObjSignal(pSyncObj) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_SIGNAL_VALUE)// 00128 00129 /*! 00130 \brief This function waits for a sync signal of the specific sync object 00131 00132 \param pSyncObj - pointer to the sync object control block 00133 \param Timeout - numeric value specifies the maximum number of mSec to 00134 stay suspended while waiting for the sync signal 00135 Currently, the simple link driver uses only two values: 00136 - NONOS_WAIT_FOREVER 00137 - NONOS_NO_WAIT 00138 00139 \return upon successful reception of the signal within the timeout window return 0 00140 Otherwise, a negative value indicating the error code shall be returned 00141 \note 00142 \warning 00143 */ 00144 #define _SlNonOsSyncObjWait(pSyncObj,Timeout) _SlNonOsSemGet(pSyncObj,NON_OS_SYNC_OBJ_SIGNAL_VALUE,NON_OS_SYNC_OBJ_CLEAR_VALUE,Timeout)// 00145 00146 /*! 00147 \brief This function clears a sync object 00148 00149 \param pSyncObj - pointer to the sync object control block 00150 00151 \return upon successful clearing the function should return 0 00152 Otherwise, a negative value indicating the error code shall be returned 00153 \note 00154 \warning 00155 */ 00156 #define _SlNonOsSyncObjClear(pSyncObj) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_CLEAR_VALUE)// 00157 00158 /*! 00159 \brief This function creates a locking object. 00160 00161 The locking object is used for protecting a shared resources between different 00162 threads. 00163 00164 \param pLockObj - pointer to the locking object control block 00165 00166 \return upon successful creation the function should return 0 00167 Otherwise, a negative value indicating the error code shall be returned 00168 \note 00169 \warning 00170 */ 00171 #define _SlNonOsLockObjCreate(pLockObj) _SlNonOsSemSet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE) 00172 00173 /*! 00174 \brief This function deletes a locking object. 00175 00176 \param pLockObj - pointer to the locking object control block 00177 00178 \return upon successful deletion the function should return 0 00179 Otherwise, a negative value indicating the error code shall be returned 00180 \note 00181 \warning 00182 */ 00183 #define _SlNonOsLockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0)// 00184 00185 /*! 00186 \brief This function locks a locking object. 00187 00188 All other threads that call this function before this thread calls 00189 the _SlNonOsLockObjUnlock would be suspended 00190 00191 \param pLockObj - pointer to the locking object control block 00192 \param Timeout - numeric value specifies the maximum number of mSec to 00193 stay suspended while waiting for the locking object 00194 Currently, the simple link driver uses only two values: 00195 - NONOS_WAIT_FOREVER 00196 - NONOS_NO_WAIT 00197 00198 00199 \return upon successful reception of the locking object the function should return 0 00200 Otherwise, a negative value indicating the error code shall be returned 00201 \note 00202 \warning 00203 */ 00204 #define _SlNonOsLockObjLock(pLockObj,Timeout) _SlNonOsSemGet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE,NON_OS_LOCK_OBJ_LOCK_VALUE,Timeout)// 00205 00206 /*! 00207 \brief This function unlock a locking object. 00208 00209 \param pLockObj - pointer to the locking object control block 00210 00211 \return upon successful unlocking the function should return 0 00212 Otherwise, a negative value indicating the error code shall be returned 00213 \note 00214 \warning 00215 */ 00216 #define _SlNonOsLockObjUnlock(pLockObj) _SlNonOsSemSet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE)// 00217 00218 /***************************************************************************** 00219 00220 Overwrite SimpleLink driver OS adaptation functions 00221 00222 00223 *****************************************************************************/ 00224 00225 //class cc3100_nonos _nonos; 00226 00227 #undef sl_SyncObjCreate 00228 #define sl_SyncObjCreate(pSyncObj,pName) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_CLEAR_VALUE) 00229 00230 #undef sl_SyncObjDelete 00231 #define sl_SyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0) 00232 00233 #undef sl_SyncObjSignal 00234 #define sl_SyncObjSignal(pSyncObj) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_SIGNAL_VALUE) 00235 00236 #undef sl_SyncObjSignalFromIRQ 00237 #define sl_SyncObjSignalFromIRQ(pSyncObj) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_SIGNAL_VALUE) 00238 00239 #undef sl_SyncObjWait 00240 #define sl_SyncObjWait(pSyncObj,Timeout) _SlNonOsSemGet(pSyncObj,NON_OS_SYNC_OBJ_SIGNAL_VALUE,NON_OS_SYNC_OBJ_CLEAR_VALUE,Timeout) 00241 00242 #undef sl_LockObjCreate 00243 #define sl_LockObjCreate(pLockObj,pName) _SlNonOsSemSet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE) 00244 00245 #undef sl_LockObjDelete 00246 #define sl_LockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0) 00247 00248 #undef sl_LockObjLock 00249 #define sl_LockObjLock(pLockObj,Timeout) _SlNonOsSemGet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE,NON_OS_LOCK_OBJ_LOCK_VALUE,Timeout) 00250 00251 #undef sl_LockObjUnlock 00252 #define sl_LockObjUnlock(pLockObj) _SlNonOsSemSet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE) 00253 /* 00254 #undef sl_Spawn 00255 #define sl_Spawn(pEntry,pValue,flags) _nonos._SlNonOsSpawn(pEntry,pValue,flags) 00256 00257 #undef _SlTaskEntry 00258 #define _SlTaskEntry _nonos._SlNonOsMainLoopTask 00259 */ 00260 /*! 00261 \brief type definition for the return values of this adaptation layer 00262 */ 00263 typedef int8_t _SlNonOsRetVal_t; 00264 00265 /*! 00266 \brief type definition for a time value 00267 */ 00268 typedef uint8_t _SlNonOsTime_t; 00269 00270 /*! 00271 \brief type definition for a sync object container 00272 00273 Sync object is object used to synchronize between two threads or thread and interrupt handler. 00274 One thread is waiting on the object and the other thread send a signal, which then 00275 release the waiting thread. 00276 The signal must be able to be sent from interrupt context. 00277 This object is generally implemented by binary semaphore or events. 00278 */ 00279 typedef uint8_t _SlNonOsSemObj_t; 00280 00281 class cc3100_driver; 00282 00283 class cc3100_nonos 00284 { 00285 00286 public: 00287 00288 cc3100_nonos(cc3100_driver &driver); 00289 00290 ~cc3100_nonos(); 00291 00292 /*! 00293 \brief This function call the pEntry callback from a different context 00294 00295 \param pEntry - pointer to the entry callback function 00296 00297 \param pValue - pointer to any type of memory structure that would be 00298 passed to pEntry callback from the execution thread. 00299 00300 \param flags - execution flags - reserved for future usage 00301 00302 \return upon successful registration of the spawn the function return 0 00303 (the function is not blocked till the end of the execution of the function 00304 and could be returned before the execution is actually completed) 00305 Otherwise, a negative value indicating the error code shall be returned 00306 \note 00307 \warning 00308 */ 00309 _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , uint32_t flags); 00310 00311 00312 /*! 00313 \brief This function must be called from the main loop in non-os paltforms 00314 00315 \param None 00316 00317 \return 0 - No more activities 00318 1 - Activity still in progress 00319 \note 00320 \warning 00321 */ 00322 _SlNonOsRetVal_t _SlNonOsMainLoopTask(void); 00323 00324 _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout); 00325 _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value); 00326 00327 00328 #if (defined(_SlSyncWaitLoopCallback)) 00329 void _SlSyncWaitLoopCallback(void); 00330 #endif 00331 00332 private: 00333 00334 cc3100_driver &_driver; 00335 00336 };//class 00337 00338 //extern _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , uint32_t flags); 00339 00340 }//namespace mbed_cc3100 00341 00342 #endif /* !SL_PLATFORM_MULTI_THREADED */ 00343 00344 00345 00346 #endif 00347
Generated on Tue Jul 12 2022 22:22:38 by 1.7.2