TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.
osi.h
00001 //***************************************************************************** 00002 // osi.h 00003 // 00004 // MACRO and Function prototypes for TI-RTOS and Free-RTOS API calls 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 zof 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 #ifndef __OSI_H__ 00040 #define __OSI_H__ 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 #include <string.h> 00047 #include "portable.h" 00048 00049 #define OSI_WAIT_FOREVER (0xFFFFFFFF) 00050 00051 #define OSI_NO_WAIT (0) 00052 00053 #ifndef SPAWN_TASK_STACK 00054 #define STACK_LEN (2048) /*Stack Size*/ 00055 #else 00056 #define STACK_LEN (SPAWN_TASK_STACK) 00057 #endif 00058 00059 typedef enum 00060 { 00061 OSI_OK = 0, 00062 OSI_FAILURE = -1, 00063 OSI_OPERATION_FAILED = -2, 00064 OSI_ABORTED = -3, 00065 OSI_INVALID_PARAMS = -4, 00066 OSI_MEMORY_ALLOCATION_FAILURE = -5, 00067 OSI_TIMEOUT = -6, 00068 OSI_EVENTS_IN_USE = -7, 00069 OSI_EVENT_OPEARTION_FAILURE = -8 00070 }OsiReturnVal_e; 00071 00072 //#define ENTER_CRITICAL_SECTION osi_EnterCritical() 00073 //#define EXIT_CRITICAL_SECTION osi_ExitCritical() 00074 00075 typedef void* OsiMsgQ_t; 00076 00077 /*! 00078 \brief type definition for a time value 00079 00080 \note On each porting or platform the type could be whatever is needed - integer, pointer to structure etc. 00081 */ 00082 typedef uint32_t OsiTime_t; 00083 //typedef unsigned long OsiTime_t; 00084 /*! 00085 \brief type definition for a sync object container 00086 00087 Sync object is object used to synchronize between two threads or thread and interrupt handler. 00088 One thread is waiting on the object and the other thread send a signal, which then 00089 release the waiting thread. 00090 The signal must be able to be sent from interrupt context. 00091 This object is generally implemented by binary semaphore or events. 00092 00093 \note On each porting or platform the type could be whatever is needed - integer, structure etc. 00094 */ 00095 //typedef unsigned int OsiSyncObj_t; 00096 typedef void * OsiSyncObj_t; 00097 00098 /*! 00099 \brief type definition for a locking object container 00100 00101 Locking object are used to protect a resource from mutual accesses of two or more threads. 00102 The locking object should support re-entrant locks by a signal thread. 00103 This object is generally implemented by mutex semaphore 00104 00105 \note On each porting or platform the type could be whatever is needed - integer, structure etc. 00106 */ 00107 //typedef unsigned int OsiLockObj_t; 00108 typedef void * OsiLockObj_t; 00109 00110 /*! 00111 \brief type definition for a spawn entry callback 00112 00113 the spawn mechanism enable to run a function on different context. 00114 This mechanism allow to transfer the execution context from interrupt context to thread context 00115 or changing the context from an unknown user thread to general context. 00116 The implementation of the spawn mechanism depends on the user's system requirements and could varies 00117 from implementation of serialized execution using single thread to creating thread per call 00118 00119 \note The stack size of the execution thread must be at least of TBD bytes! 00120 */ 00121 typedef void (*P_OSI_SPAWN_ENTRY)(void* pValue); 00122 00123 typedef void (*P_OSI_EVENT_HANDLER)(void* pValue); 00124 00125 typedef void (*P_OSI_TASK_ENTRY)(void* pValue); 00126 00127 typedef void (*P_OSI_INTR_ENTRY)(void); 00128 00129 typedef void* OsiTaskHandle; 00130 00131 /*! 00132 \brief This function registers an interrupt in NVIC table 00133 00134 The sync object is used for synchronization between different thread or ISR and 00135 a thread. 00136 00137 \param iIntrNum - Interrupt number to register 00138 \param pEntry - Pointer to the interrupt handler 00139 00140 \return upon successful creation the function should return 0 00141 Otherwise, a negative value indicating the error code shall be returned 00142 \note 00143 \warning 00144 */ 00145 OsiReturnVal_e osi_InterruptRegister(int iIntrNum,P_OSI_INTR_ENTRY pEntry,unsigned char ucPriority); 00146 00147 /*! 00148 \brief This function De-registers an interrupt in NVIC table 00149 00150 \param iIntrNum - Interrupt number to register 00151 \param pEntry - Pointer to the interrupt handler 00152 00153 \return upon successful creation the function should return Positive number 00154 Otherwise, a negative value indicating the error code shall be returned 00155 \note 00156 \warning 00157 */ 00158 void osi_InterruptDeRegister(int iIntrNum); 00159 00160 00161 /*! 00162 \brief This function creates a sync object 00163 00164 The sync object is used for synchronization between different thread or ISR and 00165 a thread. 00166 00167 \param pSyncObj - pointer to the sync object control block 00168 00169 \return upon successful creation the function should return 0 00170 Otherwise, a negative value indicating the error code shall be returned 00171 \note 00172 \warning 00173 */ 00174 OsiReturnVal_e osi_SyncObjCreate(OsiSyncObj_t* pSyncObj); 00175 00176 00177 /*! 00178 \brief This function deletes a sync object 00179 00180 \param pSyncObj - pointer to the sync object control block 00181 00182 \return upon successful deletion the function should return 0 00183 Otherwise, a negative value indicating the error code shall be returned 00184 \note 00185 \warning 00186 */ 00187 OsiReturnVal_e osi_SyncObjDelete(OsiSyncObj_t* pSyncObj); 00188 00189 /*! 00190 \brief This function generates a sync signal for the object. 00191 00192 All suspended threads waiting on this sync object are resumed 00193 00194 \param pSyncObj - pointer to the sync object control block 00195 00196 \return upon successful signalling the function should return 0 00197 Otherwise, a negative value indicating the error code shall be returned 00198 \note the function could be called from ISR context 00199 \warning 00200 */ 00201 OsiReturnVal_e osi_SyncObjSignal(OsiSyncObj_t* pSyncObj); 00202 00203 /*! 00204 \brief This function generates a sync signal for the object. 00205 from ISR context. 00206 00207 All suspended threads waiting on this sync object are resumed 00208 00209 \param pSyncObj - pointer to the sync object control block 00210 00211 \return upon successful signalling the function should return 0 00212 Otherwise, a negative value indicating the error code shall be returned 00213 \note the function is called from ISR context 00214 \warning 00215 */ 00216 OsiReturnVal_e osi_SyncObjSignalFromISR(OsiSyncObj_t* pSyncObj); 00217 00218 /*! 00219 \brief This function waits for a sync signal of the specific sync object 00220 00221 \param pSyncObj - pointer to the sync object control block 00222 \param Timeout - numeric value specifies the maximum number of mSec to 00223 stay suspended while waiting for the sync signal 00224 Currently, the simple link driver uses only two values: 00225 - OSI_WAIT_FOREVER 00226 - OSI_NO_WAIT 00227 00228 \return upon successful reception of the signal within the timeout window return 0 00229 Otherwise, a negative value indicating the error code shall be returned 00230 \note 00231 \warning 00232 */ 00233 OsiReturnVal_e osi_SyncObjWait(OsiSyncObj_t* pSyncObj , OsiTime_t Timeout); 00234 00235 /*! 00236 \brief This function clears a sync object 00237 00238 \param pSyncObj - pointer to the sync object control block 00239 00240 \return upon successful clearing the function should return 0 00241 Otherwise, a negative value indicating the error code shall be returned 00242 \note 00243 \warning 00244 */ 00245 OsiReturnVal_e osi_SyncObjClear(OsiSyncObj_t* pSyncObj); 00246 00247 /*! 00248 \brief This function creates a locking object. 00249 00250 The locking object is used for protecting a shared resources between different 00251 threads. 00252 00253 \param pLockObj - pointer to the locking object control block 00254 00255 \return upon successful creation the function should return 0 00256 Otherwise, a negative value indicating the error code shall be returned 00257 \note 00258 \warning 00259 */ 00260 OsiReturnVal_e osi_LockObjCreate(OsiLockObj_t* pLockObj); 00261 00262 /*! 00263 \brief This function deletes a locking object. 00264 00265 \param pLockObj - pointer to the locking object control block 00266 00267 \return upon successful deletion the function should return 0 00268 Otherwise, a negative value indicating the error code shall be returned 00269 \note 00270 \warning 00271 */ 00272 OsiReturnVal_e osi_LockObjDelete(OsiLockObj_t* pLockObj); 00273 00274 /*! 00275 \brief This function locks a locking object. 00276 00277 All other threads that call this function before this thread calls 00278 the osi_LockObjUnlock would be suspended 00279 00280 \param pLockObj - pointer to the locking object control block 00281 \param Timeout - numeric value specifies the maximum number of mSec to 00282 stay suspended while waiting for the locking object 00283 Currently, the simple link driver uses only two values: 00284 - OSI_WAIT_FOREVER 00285 - OSI_NO_WAIT 00286 00287 00288 \return upon successful reception of the locking object the function should return 0 00289 Otherwise, a negative value indicating the error code shall be returned 00290 \note 00291 \warning 00292 */ 00293 OsiReturnVal_e osi_LockObjLock(OsiLockObj_t* pLockObj , OsiTime_t Timeout); 00294 00295 /*! 00296 \brief This function unlock a locking object. 00297 00298 \param pLockObj - pointer to the locking object control block 00299 00300 \return upon successful unlocking the function should return 0 00301 Otherwise, a negative value indicating the error code shall be returned 00302 \note 00303 \warning 00304 */ 00305 OsiReturnVal_e osi_LockObjUnlock(OsiLockObj_t* pLockObj); 00306 00307 00308 /*! 00309 \brief This function call the pEntry callback from a different context 00310 00311 \param pEntry - pointer to the entry callback function 00312 00313 \param pValue - pointer to any type of memory structure that would be 00314 passed to pEntry callback from the execution thread. 00315 00316 \param flags - execution flags - reserved for future usage 00317 00318 \return upon successful registration of the spawn the function should return 0 00319 (the function is not blocked till the end of the execution of the function 00320 and could be returned before the execution is actually completed) 00321 Otherwise, a negative value indicating the error code shall be returned 00322 \note 00323 \warning 00324 */ 00325 /*! 00326 \brief This function creates a Task. 00327 00328 Creates a new Task and add it to the last of tasks that are ready to run 00329 00330 \param pEntry - pointer to the Task Function 00331 \param pcName - Task Name String 00332 \param usStackDepth - Stack Size Stack Size in 32-bit long words 00333 \param pvParameters - pointer to structure to be passed to the Task Function 00334 \param uxPriority - Task Priority 00335 00336 \return upon successful unlocking the function should return 0 00337 Otherwise, a negative value indicating the error code shall be returned 00338 \note 00339 \warning 00340 */ 00341 OsiReturnVal_e osi_TaskCreate(P_OSI_TASK_ENTRY pEntry,const signed char * const pcName,unsigned short usStackDepth,void *pvParameters,uint32_t uxPriority,OsiTaskHandle *pTaskHandle); 00342 00343 /*! 00344 \brief This function Deletes a Task. 00345 00346 Deletes a Task and remove it from list of running task 00347 00348 \param pTaskHandle - Task Handle 00349 00350 \note 00351 \warning 00352 */ 00353 void osi_TaskDelete(OsiTaskHandle* pTaskHandle); 00354 00355 /*! 00356 \brief This function call the pEntry callback from a different context 00357 00358 \param pEntry - pointer to the entry callback function 00359 00360 \param pValue - pointer to any type of memory structure that would be 00361 passed to pEntry callback from the execution thread. 00362 00363 \param flags - execution flags - reserved for future usage 00364 00365 \return upon successful registration of the spawn the function should return 0 00366 (the function is not blocked till the end of the execution of the function 00367 and could be returned before the execution is actually completed) 00368 Otherwise, a negative value indicating the error code shall be returned 00369 \note 00370 \warning 00371 */ 00372 OsiReturnVal_e osi_Spawn(P_OSI_SPAWN_ENTRY pEntry , void* pValue , uint32_t flags); 00373 00374 00375 /******************************************************************************* 00376 00377 This function creates a message queue that is typically used for inter thread 00378 communication. 00379 00380 Parameters: 00381 00382 pMsgQ - pointer to the message queue control block 00383 pMsgQName - pointer to the name of the message queue 00384 MsgSize - the size of the message. 00385 00386 NOTICE: THE MESSGAE SIZE MUST BE SMALLER THAN 16 00387 00388 MaxMsgs - maximum number of messages. 00389 00390 Please note that this function allocates the entire memory required 00391 for the maximum number of messages (MsgSize * MaxMsgs). 00392 00393 ********************************************************************************/ 00394 OsiReturnVal_e osi_MsgQCreate(OsiMsgQ_t* pMsgQ , 00395 char* pMsgQName, 00396 uint32_t MsgSize, 00397 uint32_t MaxMsgs); 00398 00399 /******************************************************************************* 00400 00401 This function deletes a specific message queue. 00402 All threads suspended waiting for a message from this queue are resumed with 00403 an error return value. 00404 00405 Parameters: 00406 00407 pMsgQ - pointer to the message queue control block 00408 00409 ********************************************************************************/ 00410 OsiReturnVal_e osi_MsgQDelete(OsiMsgQ_t* pMsgQ); 00411 00412 00413 /******************************************************************************* 00414 00415 This function writes a message to a specific message queue. 00416 00417 Notice that the message is copied to the queue from the memory area specified 00418 by pMsg pointer. 00419 00420 -------------------------------------------------------------------------------- 00421 THIS FUNCTION COULD BE CALLED FROM ISR AS LONG AS THE TIMEOUT PARAMETER IS 00422 SET TO "OSI_NO_WAIT" 00423 -------------------------------------------------------------------------------- 00424 00425 Parameters: 00426 00427 pMsgQ - pointer to the message queue control block 00428 pMsg - pointer to the message 00429 Timeout - numeric value specifies the maximum number of mSec to stay 00430 suspended while waiting for available space for the message 00431 00432 ********************************************************************************/ 00433 OsiReturnVal_e osi_MsgQWrite(OsiMsgQ_t* pMsgQ, void* pMsg , OsiTime_t Timeout); 00434 00435 00436 /******************************************************************************* 00437 00438 This function retrieves a message from the specified message queue. The 00439 retrieved message is copied from the queue into the memory area specified by 00440 the pMsg pointer 00441 00442 Parameters: 00443 00444 pMsgQ - pointer to the message queue control block 00445 pMsg - pointer that specify the location where to copy the message 00446 Timeout - numeric value specifies the maximum number of mSec to stay 00447 suspended while waiting for a message to be available 00448 00449 ********************************************************************************/ 00450 OsiReturnVal_e osi_MsgQRead(OsiMsgQ_t* pMsgQ, void* pMsg , OsiTime_t Timeout); 00451 00452 /*! 00453 \brief This function starts the OS Scheduler 00454 \param - void 00455 \return - void 00456 \note 00457 \warning 00458 */ 00459 void osi_start(void); 00460 00461 /*! 00462 \brief Allocates Memory on Heap 00463 \param Size - Size of the Buffer to be allocated 00464 \sa 00465 \note 00466 \warning 00467 */ 00468 void * mem_Malloc(uint32_t Size); 00469 00470 00471 /*! 00472 \brief Deallocates Memory 00473 \param pMem - Pointer to the Buffer to be freed 00474 \return void 00475 \sa 00476 \note 00477 \warning 00478 */ 00479 void mem_Free(void *pMem); 00480 00481 00482 /*! 00483 \brief Set Memory 00484 \param pBuf - Pointer to the Buffer 00485 \param Val - Value to be set 00486 \param Size - Size of the memory to be set 00487 \sa 00488 \note 00489 \warning 00490 */ 00491 void mem_set(void *pBuf,int Val,size_t Size); 00492 00493 /*! 00494 \brief Copy Memory 00495 \param pDst - Pointer to the Destination Buffer 00496 \param pSrc - Pointer to the Source Buffer 00497 \param Size - Size of the memory to be copied 00498 \return void 00499 \note 00500 \warning 00501 */ 00502 void mem_copy(void *pDst, void *pSrc,size_t Size); 00503 00504 /*! 00505 \brief Enter Critical Section 00506 \sa 00507 \note 00508 \warning 00509 */ 00510 uint32_t osi_EnterCritical(void); 00511 00512 /*! 00513 \brief Exit Critical Section 00514 \sa 00515 \note 00516 \warning 00517 */ 00518 void osi_ExitCritical(uint32_t ulKey); 00519 00520 /*! 00521 \brief This function used to save the os context before sleep 00522 \param void 00523 \return void 00524 \note 00525 \warning 00526 */ 00527 void osi_ContextSave(void); 00528 /*! 00529 \brief This function used to retrieve the context after sleep 00530 \param void 00531 \return void 00532 \note 00533 \warning 00534 */ 00535 void osi_ContextRestore(void); 00536 00537 /*! 00538 \brief This function used to suspend the task for the specified number of milli secs 00539 \param MilliSecs - Time in millisecs to suspend the task 00540 \return void 00541 \note 00542 \warning 00543 */ 00544 void osi_Sleep(unsigned int MilliSecs); 00545 00546 /*! 00547 \brief This function used to disable the tasks 00548 \param - void 00549 \return - Key with the suspended tasks 00550 \note 00551 \warning 00552 */ 00553 uint32_t osi_TaskDisable(void); 00554 00555 /*! 00556 \brief This function used to enable all tasks 00557 \param unsigned long 00558 \return - void 00559 \note 00560 \warning 00561 */ 00562 void osi_TaskEnable(uint32_t); 00563 /*! 00564 \brief structure definition for simple link spawn message 00565 00566 \note On each porting or platform the type could be whatever is needed - integer, pointer to structure etc. 00567 */ 00568 00569 typedef struct 00570 { 00571 P_OSI_SPAWN_ENTRY pEntry; 00572 void* pValue; 00573 }tSimpleLinkSpawnMsg; 00574 00575 /* The queue used to send message to simple link spawn task. */ 00576 extern void* xSimpleLinkSpawnQueue; 00577 00578 /* API for SL Task*/ 00579 OsiReturnVal_e VStartSimpleLinkSpawnTask(unsigned portBASE_TYPE uxPriority); 00580 void VDeleteSimpleLinkSpawnTask( void ); 00581 00582 00583 00584 #ifdef __cplusplus 00585 } 00586 #endif // __cplusplus 00587 00588 #endif 00589
Generated on Wed Jul 13 2022 15:58:45 by 1.7.2