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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers osi_freertos.c Source File

osi_freertos.c

00001 //*****************************************************************************
00002 // osi_freertos.c
00003 //
00004 // Interface APIs for free-rtos function 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 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 #include <stdio.h>
00041 #include <stdlib.h>
00042 #include <string.h>
00043 #include "FreeRTOS.h"
00044 #include "task.h"
00045 #include "semphr.h"
00046 #include "portmacro.h"
00047 #include <osi.h>
00048 
00049 
00050 
00051 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
00052 //Local function definition
00053 static void vSimpleLinkSpawnTask( void *pvParameters );
00054 //Queue Handler
00055 xQueueHandle xSimpleLinkSpawnQueue = NULL;
00056 xTaskHandle xSimpleLinkSpawnTaskHndl = NULL;
00057 // Queue size 
00058 #define slQUEUE_SIZE                ( 3 )
00059 
00060 
00061 
00062 
00063 
00064 /*!
00065     \brief  This function creates a sync object
00066 
00067     The sync object is used for synchronization between different thread or ISR and
00068     a thread.
00069 
00070     \param  pSyncObj    -   pointer to the sync object control block
00071 
00072     \return upon successful creation the function should return 0
00073             Otherwise, a negative value indicating the error code shall be returned
00074     \note
00075     \warning
00076 */
00077 OsiReturnVal_e osi_SyncObjCreate(OsiSyncObj_t* pSyncObj)
00078 {
00079     //Check for NULL
00080     if(NULL == pSyncObj)
00081     {
00082         return OSI_INVALID_PARAMS;
00083     }
00084     xSemaphoreHandle *pl_SyncObj = (xSemaphoreHandle *)pSyncObj;
00085 
00086     *pl_SyncObj = xSemaphoreCreateBinary();
00087 
00088     if((xSemaphoreHandle)(*pSyncObj) != NULL)
00089     {
00090         return OSI_OK; 
00091     }
00092     else
00093     {
00094         return OSI_OPERATION_FAILED;
00095     }
00096 }
00097 
00098 /*!
00099     \brief  This function deletes a sync object
00100 
00101     \param  pSyncObj    -   pointer to the sync object control block
00102 
00103     \return upon successful deletion the function should return 0
00104             Otherwise, a negative value indicating the error code shall be returned
00105     \note
00106     \warning
00107 */
00108 OsiReturnVal_e osi_SyncObjDelete(OsiSyncObj_t* pSyncObj)
00109 {
00110     //Check for NULL
00111     if(NULL == pSyncObj)
00112     {
00113         return OSI_INVALID_PARAMS;
00114     }
00115     vSemaphoreDelete(*pSyncObj );
00116     return OSI_OK;
00117 }
00118 
00119 /*!
00120     \brief      This function generates a sync signal for the object.
00121 
00122     All suspended threads waiting on this sync object are resumed
00123 
00124     \param      pSyncObj    -   pointer to the sync object control block
00125 
00126     \return     upon successful signaling the function should return 0
00127                 Otherwise, a negative value indicating the error code shall be returned
00128     \note       the function could be called from ISR context
00129     \warning
00130 */
00131 OsiReturnVal_e osi_SyncObjSignal(OsiSyncObj_t* pSyncObj)
00132 {
00133     //Check for NULL
00134     if(NULL == pSyncObj)
00135     {
00136         return OSI_INVALID_PARAMS;
00137     }
00138 
00139     if(pdTRUE != xSemaphoreGive( *pSyncObj ))
00140     {
00141         //In case of Semaphore, you are expected to get this if multiple sem
00142         // give is called before sem take
00143         return OSI_OK;
00144     }
00145     
00146     return OSI_OK;
00147 }
00148 /*!
00149     \brief      This function generates a sync signal for the object
00150                 from ISR context.
00151 
00152     All suspended threads waiting on this sync object are resumed
00153 
00154     \param      pSyncObj    -   pointer to the sync object control block
00155 
00156     \return     upon successful signalling the function should return 0
00157                 Otherwise, a negative value indicating the error code shall be returned
00158     \note       the function is called from ISR context
00159     \warning
00160 */
00161 OsiReturnVal_e osi_SyncObjSignalFromISR(OsiSyncObj_t* pSyncObj)
00162 {
00163     //Check for NULL
00164     if(NULL == pSyncObj)
00165     {
00166         return OSI_INVALID_PARAMS;
00167     }
00168     xHigherPriorityTaskWoken = pdFALSE;
00169     if(pdTRUE == xSemaphoreGiveFromISR( *pSyncObj, &xHigherPriorityTaskWoken ))
00170     {
00171         if( xHigherPriorityTaskWoken )
00172         {
00173             taskYIELD ();
00174         }
00175         return OSI_OK;
00176     }
00177     else
00178     {
00179         //In case of Semaphore, you are expected to get this if multiple sem
00180         // give is called before sem take
00181         return OSI_OK;
00182     }
00183 }
00184 
00185 /*!
00186     \brief  This function waits for a sync signal of the specific sync object
00187 
00188     \param  pSyncObj    -   pointer to the sync object control block
00189     \param  Timeout     -   numeric value specifies the maximum number of mSec to
00190                             stay suspended while waiting for the sync signal
00191                             Currently, the simple link driver uses only two values:
00192                                 - OSI_WAIT_FOREVER
00193                                 - OSI_NO_WAIT
00194 
00195     \return upon successful reception of the signal within the timeout window return 0
00196             Otherwise, a negative value indicating the error code shall be returned
00197     \note
00198     \warning
00199 */
00200 OsiReturnVal_e osi_SyncObjWait(OsiSyncObj_t* pSyncObj , OsiTime_t Timeout)
00201 {
00202     //Check for NULL
00203     if(NULL == pSyncObj)
00204     {
00205         return OSI_INVALID_PARAMS;
00206     }
00207     if(pdTRUE == xSemaphoreTake( (xSemaphoreHandle)*pSyncObj, ( portTickType )(Timeout/portTICK_RATE_MS) ))
00208     {
00209         return OSI_OK;
00210     }
00211     else
00212     {
00213         return OSI_OPERATION_FAILED;
00214     }
00215 }
00216 
00217 /*!
00218     \brief  This function clears a sync object
00219 
00220     \param  pSyncObj    -   pointer to the sync object control block
00221 
00222     \return upon successful clearing the function should return 0
00223             Otherwise, a negative value indicating the error code shall be returned
00224     \note
00225     \warning
00226 */
00227 OsiReturnVal_e osi_SyncObjClear(OsiSyncObj_t* pSyncObj)
00228 {
00229     //Check for NULL
00230     if(NULL == pSyncObj)
00231     {
00232         return OSI_INVALID_PARAMS;
00233     }
00234 
00235     if (OSI_OK == osi_SyncObjWait(pSyncObj,0) )
00236     {
00237         return OSI_OK;
00238     }
00239     else
00240     {
00241         return OSI_OPERATION_FAILED;
00242     }
00243 }
00244 
00245 /*!
00246     \brief  This function creates a locking object.
00247 
00248     The locking object is used for protecting a shared resources between different
00249     threads.
00250 
00251     \param  pLockObj    -   pointer to the locking object control block
00252 
00253     \return upon successful creation the function should return 0
00254             Otherwise, a negative value indicating the error code shall be returned
00255     \note
00256     \warning
00257 */
00258 OsiReturnVal_e osi_LockObjCreate(OsiLockObj_t* pLockObj)
00259 {
00260     //Check for NULL
00261     if(NULL == pLockObj)
00262     {
00263             return OSI_INVALID_PARAMS;
00264     }
00265     *pLockObj = (OsiLockObj_t)xSemaphoreCreateMutex();
00266     if(pLockObj != NULL)
00267     {  
00268         return OSI_OK;
00269     }
00270     else
00271     {
00272         return OSI_OPERATION_FAILED;
00273     }
00274 }
00275 
00276 /*!
00277     \brief  This function creates a Task.
00278 
00279     Creates a new Task and add it to the last of tasks that are ready to run
00280 
00281     \param  pEntry  -   pointer to the Task Function
00282     \param  pcName  -   Task Name String
00283     \param  usStackDepth    -   Stack Size in bytes
00284     \param  pvParameters    -   pointer to structure to be passed to the Task Function
00285     \param  uxPriority  -   Task Priority
00286 
00287     \return upon successful creation the function should return 0
00288             Otherwise, a negative value indicating the error code shall be returned
00289     \note
00290     \warning
00291 */
00292 OsiReturnVal_e osi_TaskCreate(P_OSI_TASK_ENTRY pEntry,const signed char * const pcName,
00293                               unsigned short usStackDepth, void *pvParameters,
00294                               uint32_t uxPriority,OsiTaskHandle* pTaskHandle)
00295 {
00296     if(pdPASS == xTaskCreate( pEntry, (const char *)pcName,
00297                                 (usStackDepth/(sizeof( portSTACK_TYPE ))), 
00298                                 pvParameters,(unsigned portBASE_TYPE)uxPriority,
00299                                 (xTaskHandle*)pTaskHandle ))
00300     {
00301         return OSI_OK;
00302     }
00303 
00304     return OSI_OPERATION_FAILED;    
00305 }
00306 
00307 
00308 /*!
00309     \brief  This function Deletes a Task.
00310 
00311     Deletes a  Task and remove it from list of running task
00312 
00313     \param  pTaskHandle -   Task Handle
00314 
00315     \note
00316     \warning
00317 */
00318 void osi_TaskDelete(OsiTaskHandle* pTaskHandle)
00319 {
00320     vTaskDelete((xTaskHandle)*pTaskHandle);
00321 }
00322 
00323 
00324 
00325 /*!
00326     \brief  This function deletes a locking object.
00327 
00328     \param  pLockObj    -   pointer to the locking object control block
00329 
00330     \return upon successful deletion the function should return 0
00331             Otherwise, a negative value indicating the error code shall be returned
00332     \note
00333     \warning
00334 */
00335 OsiReturnVal_e osi_LockObjDelete(OsiLockObj_t* pLockObj)
00336 {
00337     vSemaphoreDelete((xSemaphoreHandle)*pLockObj );
00338     return OSI_OK;
00339 }
00340 
00341 /*!
00342     \brief  This function locks a locking object.
00343 
00344     All other threads that call this function before this thread calls
00345     the osi_LockObjUnlock would be suspended
00346 
00347     \param  pLockObj    -   pointer to the locking object control block
00348     \param  Timeout     -   numeric value specifies the maximum number of mSec to
00349                             stay suspended while waiting for the locking object
00350                             Currently, the simple link driver uses only two values:
00351                                 - OSI_WAIT_FOREVER
00352                                 - OSI_NO_WAIT
00353 
00354 
00355     \return upon successful reception of the locking object the function should return 0
00356             Otherwise, a negative value indicating the error code shall be returned
00357     \note
00358     \warning
00359 */
00360 OsiReturnVal_e osi_LockObjLock(OsiLockObj_t* pLockObj , OsiTime_t Timeout)
00361 {
00362     //Check for NULL
00363     if(NULL == pLockObj)
00364     {
00365             return OSI_INVALID_PARAMS;
00366     }
00367     //Take Semaphore
00368     if(pdTRUE == xSemaphoreTake( *pLockObj, ( portTickType ) (Timeout/portTICK_RATE_MS) ))
00369     {
00370         return OSI_OK;
00371     }
00372     else
00373     {
00374         return OSI_OPERATION_FAILED;
00375     }
00376 }
00377 
00378 /*!
00379     \brief  This function unlock a locking object.
00380 
00381     \param  pLockObj    -   pointer to the locking object control block
00382 
00383     \return upon successful unlocking the function should return 0
00384             Otherwise, a negative value indicating the error code shall be returned
00385     \note
00386     \warning
00387 */
00388 OsiReturnVal_e osi_LockObjUnlock(OsiLockObj_t* pLockObj)
00389 {
00390     //Check for NULL
00391     if(NULL == pLockObj)
00392     {
00393         return OSI_INVALID_PARAMS;
00394     }
00395     //Release Semaphore
00396     if(pdTRUE == xSemaphoreGive( *pLockObj ))
00397     {
00398         return OSI_OK;
00399     }
00400     else
00401     {
00402         return OSI_OPERATION_FAILED;
00403     }
00404 }
00405 
00406 
00407 /*!
00408     \brief  This function call the pEntry callback from a different context
00409 
00410     \param  pEntry      -   pointer to the entry callback function
00411 
00412     \param  pValue      -   pointer to any type of memory structure that would be
00413                             passed to pEntry callback from the execution thread.
00414 
00415     \param  flags       -   execution flags - reserved for future usage
00416 
00417     \return upon successful registration of the spawn the function should return 0
00418             (the function is not blocked till the end of the execution of the function
00419             and could be returned before the execution is actually completed)
00420             Otherwise, a negative value indicating the error code shall be returned
00421     \note
00422     \warning
00423 */
00424 
00425 OsiReturnVal_e osi_Spawn(P_OSI_SPAWN_ENTRY pEntry , void* pValue , uint32_t flags)
00426 {
00427 
00428     tSimpleLinkSpawnMsg Msg;
00429     Msg.pEntry = pEntry;
00430     Msg.pValue = pValue;
00431     xHigherPriorityTaskWoken = pdFALSE;
00432 
00433     if(pdTRUE == xQueueSendFromISR( xSimpleLinkSpawnQueue, &Msg, &xHigherPriorityTaskWoken ))
00434     {
00435         if( xHigherPriorityTaskWoken )
00436         {
00437             taskYIELD ();
00438         }
00439 
00440         return OSI_OK;
00441     }
00442     return OSI_OPERATION_FAILED;
00443 }
00444 
00445 
00446 /*!
00447     \brief  This is the simplelink spawn task to call SL callback from a different context 
00448 
00449     \param  pvParameters        -   pointer to the task parameter
00450 
00451     \return void
00452     \note
00453     \warning
00454 */
00455 void vSimpleLinkSpawnTask(void *pvParameters)
00456 {
00457     tSimpleLinkSpawnMsg Msg;
00458     portBASE_TYPE ret=pdFAIL;
00459 
00460     for(;;)
00461     {
00462         ret = xQueueReceive( xSimpleLinkSpawnQueue, &Msg, portMAX_DELAY );
00463         if(ret == pdPASS)
00464         {
00465                 Msg.pEntry(Msg.pValue);
00466         }
00467     }
00468 }
00469 
00470 /*!
00471     \brief  This is the API to create SL spawn task and create the SL queue
00472 
00473     \param  uxPriority      -   task priority
00474 
00475     \return void
00476     \note
00477     \warning
00478 */
00479 OsiReturnVal_e VStartSimpleLinkSpawnTask(unsigned portBASE_TYPE uxPriority)
00480 {
00481     xSimpleLinkSpawnQueue = xQueueCreate( slQUEUE_SIZE, sizeof( tSimpleLinkSpawnMsg ) );
00482     if(0 == xSimpleLinkSpawnQueue)
00483     {
00484         return OSI_OPERATION_FAILED;
00485     }
00486     if(pdPASS == xTaskCreate( vSimpleLinkSpawnTask, /*( portCHAR * )*/ "SLSPAWN",\
00487                          (512/sizeof( portSTACK_TYPE )), NULL, uxPriority, &xSimpleLinkSpawnTaskHndl ))
00488     {
00489         return OSI_OK;
00490     }
00491 
00492     return OSI_OPERATION_FAILED;
00493 }
00494 
00495 /*!
00496     \brief  This is the API to delete SL spawn task and delete the SL queue
00497 
00498     \param  none
00499 
00500     \return void
00501     \note
00502     \warning
00503 */
00504 void VDeleteSimpleLinkSpawnTask( void )
00505 {
00506     if(0 != xSimpleLinkSpawnTaskHndl)
00507     {
00508         vTaskDelete( xSimpleLinkSpawnTaskHndl );
00509         xSimpleLinkSpawnTaskHndl = 0;
00510     }
00511 
00512     if(0 !=xSimpleLinkSpawnQueue)
00513     {
00514         vQueueDelete( xSimpleLinkSpawnQueue );
00515         xSimpleLinkSpawnQueue = 0;
00516     }
00517 }
00518 
00519 /*!
00520     \brief  This function is used to create the MsgQ
00521 
00522     \param  pMsgQ   -   pointer to the message queue
00523     \param  pMsgQName   -   msg queue name
00524     \param  MsgSize -   size of message on the queue
00525     \param  MaxMsgs -   max. number of msgs that the queue can hold
00526 
00527     \return - OsiReturnVal_e
00528     \note
00529     \warning
00530 */
00531 OsiReturnVal_e osi_MsgQCreate(OsiMsgQ_t*        pMsgQ , 
00532                   char*         pMsgQName,
00533                   uint32_t      MsgSize,
00534                   uint32_t      MaxMsgs)
00535 {
00536     //Check for NULL
00537     if(NULL == pMsgQ)
00538     {
00539         return OSI_INVALID_PARAMS;
00540     }
00541 
00542     xQueueHandle handle =0;
00543 
00544     //Create Queue
00545     handle = xQueueCreate( MaxMsgs, MsgSize );
00546     if (handle==0)
00547     {
00548         return OSI_OPERATION_FAILED;
00549     }
00550 
00551     *pMsgQ = (OsiMsgQ_t)handle;
00552     return OSI_OK;
00553 }
00554 /*!
00555     \brief  This function is used to delete the MsgQ
00556 
00557     \param  pMsgQ   -   pointer to the message queue
00558 
00559     \return - OsiReturnVal_e
00560     \note
00561     \warning
00562 */
00563 OsiReturnVal_e osi_MsgQDelete(OsiMsgQ_t* pMsgQ)
00564 {
00565     //Check for NULL
00566     if(NULL == pMsgQ)
00567     {
00568         return OSI_INVALID_PARAMS;
00569     }
00570     vQueueDelete((xQueueHandle) *pMsgQ );
00571     return OSI_OK;
00572 }
00573 /*!
00574     \brief  This function is used to write data to the MsgQ
00575 
00576     \param  pMsgQ   -   pointer to the message queue
00577     \param  pMsg    -   pointer to the Msg strut to read into
00578     \param  Timeout -   timeout to wait for the Msg to be available
00579 
00580     \return - OsiReturnVal_e
00581     \note
00582     \warning
00583 */
00584 
00585 OsiReturnVal_e osi_MsgQWrite(OsiMsgQ_t* pMsgQ, void* pMsg , OsiTime_t Timeout)
00586 {
00587     //Check for NULL
00588     if(NULL == pMsgQ)
00589     {
00590         return OSI_INVALID_PARAMS;
00591     }
00592 
00593     if(pdPASS == xQueueSendFromISR((xQueueHandle) *pMsgQ, pMsg, &xHigherPriorityTaskWoken ))
00594     {
00595         taskYIELD ();
00596         return OSI_OK;
00597     }
00598     else
00599     {
00600         return OSI_OPERATION_FAILED;
00601     }
00602 }
00603 /*!
00604     \brief  This function is used to read data from the MsgQ
00605 
00606     \param  pMsgQ   -   pointer to the message queue
00607     \param  pMsg    -   pointer to the Msg strut to read into
00608     \param  Timeout -   timeout to wait for the Msg to be available
00609 
00610     \return - OsiReturnVal_e
00611     \note
00612     \warning
00613 */
00614 
00615 OsiReturnVal_e osi_MsgQRead(OsiMsgQ_t* pMsgQ, void* pMsg , OsiTime_t Timeout)
00616 {
00617     //Check for NULL
00618     if(NULL == pMsgQ)   
00619     {
00620         printf("OSI_INVALID_PARAMS\r\n");
00621         return OSI_INVALID_PARAMS;
00622     }
00623 
00624     if ( Timeout == (OsiTime_t) OSI_WAIT_FOREVER )
00625     {
00626         Timeout = portMAX_DELAY ;
00627     }
00628 
00629     //Receive Item from Queue
00630     if( pdTRUE  == xQueueReceive((xQueueHandle)*pMsgQ,pMsg,Timeout) )
00631     {
00632         return OSI_OK;
00633     }
00634     else
00635     {
00636         return OSI_OPERATION_FAILED;
00637     }
00638 }
00639 
00640 /*!
00641     \brief  This function to call the memory de-allocation function of the FREERTOS
00642 
00643     \param  Size    -   size of memory to alloc in bytes
00644 
00645     \return - void *
00646     \note
00647     \warning
00648 */
00649 
00650 void * mem_Malloc(uint32_t Size)
00651 {
00652   
00653     return ( void * ) pvPortMalloc( (size_t)Size );
00654 }
00655 
00656 /*!
00657     \brief  This function to call the memory de-allocation function of the FREERTOS
00658 
00659     \param  pMem        -   pointer to the memory which needs to be freed
00660     
00661     \return - void 
00662     \note
00663     \warning
00664 */
00665 void mem_Free(void *pMem)
00666 {
00667     vPortFree( pMem );
00668 }
00669 
00670 /*!
00671     \brief  This function call the memset function
00672     \param  pBuf         -   pointer to the memory to be fill
00673         \param  Val          -   Value to be fill
00674         \param  Size         -   Size of the memory which needs to be fill
00675     \return - void 
00676     \note
00677     \warning
00678 */
00679 
00680 void  mem_set(void *pBuf,int Val,size_t Size)
00681 {
00682     memset( pBuf,Val,Size);
00683   
00684 }
00685 
00686 /*!
00687       \brief    This function call the memcopy function
00688       \param    pDst    -   pointer to the destination
00689       \param pSrc     -   pointer to the source
00690       \param Size     -   Size of the memory which needs to be copy
00691       
00692       \return - void 
00693       \note
00694       \warning
00695 */
00696 void  mem_copy(void *pDst, void *pSrc,size_t Size)
00697 {
00698     memcpy(pDst,pSrc,Size);
00699 }
00700 
00701 
00702 /*!
00703     \brief  This function use to entering into critical section
00704     \param  void        
00705     \return - void 
00706     \note
00707     \warning
00708 */
00709 
00710 uint32_t osi_EnterCritical(void)
00711 {
00712     portENTER_CRITICAL();
00713     return 0;
00714 }
00715 
00716 /*!
00717     \brief  This function use to exit critical section
00718     \param  void        
00719     \return - void 
00720     \note
00721     \warning
00722 */
00723 
00724 void osi_ExitCritical(uint32_t ulKey)
00725 {
00726     portENTER_CRITICAL();
00727 }
00728 /*!
00729     \brief  This function used to start the scheduler
00730     \param  void
00731     \return - void
00732     \note
00733     \warning
00734 */
00735 void osi_start()
00736 {
00737     vTaskStartScheduler();
00738 }
00739 /*!
00740     \brief  This function used to suspend the task for the specified number of milli secs
00741     \param  MilliSecs   -   Time in millisecs to suspend the task
00742     \return - void
00743     \note
00744     \warning
00745 */
00746 void osi_Sleep(unsigned int MilliSecs)
00747 {
00748     portTickType xDelay = MilliSecs / portTICK_RATE_MS;
00749     vTaskDelay(xDelay);
00750 }
00751 
00752 
00753 /*!
00754     \brief  This function used to disable the tasks
00755     \param  - void
00756     \return - Key with the suspended tasks
00757     \note
00758     \warning
00759 */
00760 uint32_t osi_TaskDisable(void)
00761 {
00762    vTaskSuspendAll();
00763 
00764    return OSI_OK;
00765 }
00766 
00767 
00768 /*!
00769     \brief  This function used to resume all the tasks
00770     \param  key -   returned from suspend tasks
00771     \return - void
00772     \note
00773     \warning
00774 */
00775 void osi_TaskEnable(uint32_t key)
00776 {
00777    xTaskResumeAll();
00778 }
00779 
00780 /*!
00781     \brief  This function used to save the OS context before sleep
00782     \param  void
00783     \return - void
00784     \note
00785     \warning
00786 */
00787 void osi_ContextSave()
00788 {
00789 
00790 }
00791 /*!
00792     \brief  This function used to restore the OS context after sleep
00793     \param  void
00794     \return - void
00795     \note
00796     \warning
00797 */
00798 void osi_ContextRestore()
00799 {
00800 
00801 }
00802