David Fletcher
/
cc3100_Test_Demo
TI's CC3100. A test demo with very little testing done!
Embed:
(wiki syntax)
Show/hide line numbers
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 namespace mbed_cc3100 { 00043 00044 /*****************************************************************************/ 00045 /* Macro declarations */ 00046 /*****************************************************************************/ 00047 00048 00049 #ifndef SL_PLATFORM_MULTI_THREADED 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 = NONOS_RET_OK; 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 #undef sl_SyncObjCreate 00226 #define sl_SyncObjCreate(pSyncObj,pName) _SlNonOsSemSet(pSyncObj,NON_OS_SYNC_OBJ_CLEAR_VALUE) 00227 00228 #undef sl_LockObjCreate 00229 #define sl_LockObjCreate(pLockObj,pName) _SlNonOsSemSet(pLockObj,NON_OS_LOCK_OBJ_UNLOCK_VALUE) 00230 00231 /*! 00232 \brief type definition for the return values of this adaptation layer 00233 */ 00234 typedef int8_t _SlNonOsRetVal_t; 00235 00236 /*! 00237 \brief type definition for a time value 00238 */ 00239 typedef uint8_t _SlNonOsTime_t; 00240 00241 /*! 00242 \brief type definition for a sync object container 00243 00244 Sync object is object used to synchronize between two threads or thread and interrupt handler. 00245 One thread is waiting on the object and the other thread send a signal, which then 00246 release the waiting thread. 00247 The signal must be able to be sent from interrupt context. 00248 This object is generally implemented by binary semaphore or events. 00249 */ 00250 typedef uint8_t _SlNonOsSemObj_t; 00251 00252 class cc3100_driver; 00253 00254 class cc3100_nonos 00255 { 00256 00257 public: 00258 00259 cc3100_nonos(cc3100_driver &driver); 00260 00261 ~cc3100_nonos(); 00262 00263 /*! 00264 \brief This function call the pEntry callback from a different context 00265 00266 \param pEntry - pointer to the entry callback function 00267 00268 \param pValue - pointer to any type of memory structure that would be 00269 passed to pEntry callback from the execution thread. 00270 00271 \param flags - execution flags - reserved for future usage 00272 00273 \return upon successful registration of the spawn the function return 0 00274 (the function is not blocked till the end of the execution of the function 00275 and could be returned before the execution is actually completed) 00276 Otherwise, a negative value indicating the error code shall be returned 00277 \note 00278 \warning 00279 */ 00280 _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , uint32_t flags); 00281 00282 00283 /*! 00284 \brief This function must be called from the main loop in non-os paltforms 00285 00286 \param None 00287 00288 \return 0 - No more activities 00289 1 - Activity still in progress 00290 \note 00291 \warning 00292 */ 00293 _SlNonOsRetVal_t _SlNonOsMainLoopTask(void); 00294 00295 _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout); 00296 _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value); 00297 // _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , uint32_t flags); 00298 // _SlNonOsRetVal_t sl_SyncObjCreate(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t NON_OS_SYNC_OBJ_CLEAR_VALUE); 00299 _SlNonOsRetVal_t sl_SyncObjDelete(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t ); 00300 _SlNonOsRetVal_t sl_SyncObjSignal(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t NON_OS_SYNC_OBJ_SIGNAL_VALUE); 00301 _SlNonOsRetVal_t sl_SyncObjSignalFromIRQ(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t NON_OS_SYNC_OBJ_SIGNAL_VALUE); 00302 // _SlNonOsRetVal_t sl_LockObjCreate(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t NON_OS_LOCK_OBJ_UNLOCK_VALUE); 00303 _SlNonOsRetVal_t sl_LockObjDelete(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t ); 00304 _SlNonOsRetVal_t sl_LockObjUnlock(_SlNonOsSemObj_t* pSemObj, _SlNonOsSemObj_t NON_OS_LOCK_OBJ_UNLOCK_VALUE); 00305 _SlNonOsRetVal_t sl_SyncObjWait(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t NON_OS_SYNC_OBJ_SIGNAL_VALUE, _SlNonOsSemObj_t NON_OS_SYNC_OBJ_CLEAR_VALUE, _SlNonOsTime_t Timeout); 00306 _SlNonOsRetVal_t sl_LockObjLock(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t NON_OS_LOCK_OBJ_UNLOCK_VALUE, _SlNonOsSemObj_t NON_OS_LOCK_OBJ_LOCK_VALUE, _SlNonOsTime_t Timeout); 00307 00308 00309 #if (defined(_SlSyncWaitLoopCallback)) 00310 void _SlSyncWaitLoopCallback(void); 00311 #endif 00312 00313 private: 00314 00315 cc3100_driver &_driver; 00316 00317 };//class 00318 00319 }//namespace mbed_cc3100 00320 00321 #endif /* !SL_PLATFORM_MULTI_THREADED */ 00322 00323 00324 00325 #endif 00326
Generated on Sun Jul 17 2022 07:25:50 by 1.7.2