1 /* 2 * nonos.h - CC31xx/CC32xx Host Driver Implementation 3 * 4 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the 17 * distribution. 18 * 19 * Neither the name of Texas Instruments Incorporated nor the names of 20 * its contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 */ 36 37 #ifndef __NONOS_H__ 38 #define __NONOS_H__ 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #ifndef SL_PLATFORM_MULTI_THREADED 45 46 /* This function call the user defined function, if defined, from the sync wait loop */ 47 /* The use case of this function is to allow nonos system to call a user function to put the device into sleep */ 48 /* The wake up should be activated after getting an interrupt from the device to Host */ 49 /* The user function must return without blocking to prevent a delay on the event handling */ 50 /* 51 #define _SlSyncWaitLoopCallback UserSleepFunction 52 */ 53 54 #define NONOS_MAX_SPAWN_ENTRIES (5) 55 56 #define NONOS_WAIT_FOREVER ~(0UL) 57 #define NONOS_NO_WAIT (0x0) 58 59 #define NONOS_RET_OK (0) 60 #define NONOS_RET_ERR (0xFF) 61 #define OSI_OK (NONOS_RET_OK) 62 63 typedef struct 64 { 65 _SlSpawnEntryFunc_t pEntry; 66 void* pValue; 67 _u8 IsAllocated; 68 }_SlNonOsSpawnEntry_t; 69 70 typedef struct 71 { 72 _SlNonOsSpawnEntry_t SpawnEntries[NONOS_MAX_SPAWN_ENTRIES]; 73 }_SlNonOsCB_t; 74 75 76 /*! 77 \brief type definition for the return values of this adaptation layer 78 */ 79 typedef _u32 _SlNonOsRetVal_t; 80 81 /*! 82 \brief type definition for a time value 83 */ 84 typedef _u32 _SlNonOsTime_t; 85 86 87 #define _SlTime_t _SlNonOsTime_t 88 89 #define SL_OS_WAIT_FOREVER NONOS_WAIT_FOREVER 90 91 #define SL_OS_RET_CODE_OK NONOS_RET_OK 92 93 #define SL_OS_NO_WAIT NONOS_NO_WAIT 94 95 96 /*! 97 \brief This function call the pEntry callback from a different context 98 99 \param pEntry - pointer to the entry callback function 100 101 \param pValue - pointer to any type of memory structure that would be 102 passed to pEntry callback from the execution thread. 103 104 \param flags - execution flags - reserved for future usage 105 106 \return upon successful registration of the spawn the function return 0 107 (the function is not blocked till the end of the execution of the function 108 and could be returned before the execution is actually completed) 109 Otherwise, a negative value indicating the error code shall be returned 110 \note 111 \warning 112 */ 113 _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags); 114 115 116 /*! 117 \brief This function is called form the main context, while waiting on a sync object. 118 119 \param None 120 121 \return None 122 123 \note 124 \warning 125 */ 126 void tiDriverSpawnCallback(void); 127 128 129 /*! 130 \brief This function is called directly the main context, while in main task loop. 131 132 \param None 133 134 \return None 135 136 \note 137 \warning 138 */ 139 _SlNonOsRetVal_t _SlNonOsHandleSpawnTask(void); 140 141 extern _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags); 142 143 /***************************************************************************** 144 145 Overwrite SimpleLink driver OS adaptation functions 146 147 *****************************************************************************/ 148 149 #undef sl_Spawn 150 #define sl_Spawn(pEntry,pValue,flags) _SlNonOsSpawn(pEntry,pValue,flags) 151 152 #undef _SlTaskEntry 153 #define _SlTaskEntry _SlNonOsHandleSpawnTask 154 155 #endif /* !SL_PLATFORM_MULTI_THREADED */ 156 157 #ifdef __cplusplus 158 } 159 #endif /* __cplusplus */ 160 161 #endif 162