SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.15
Simplifies the implementation of Internet connectivity
nonos.c
1 /*
2  * Copyright (C) 2016 Texas Instruments Incorporated
3  *
4  * All rights reserved. Property of Texas Instruments Incorporated.
5  * Restricted rights to use, duplicate or disclose this code are
6  * granted through contract.
7  *
8  * The program may not be used without the written permission of
9  * Texas Instruments Incorporated or against the terms and conditions
10  * stipulated in the agreement under which this program has been supplied,
11  * and under no circumstances can it be used with non-TI connectivity device.
12  *
13  */
14 
15 /*****************************************************************************/
16 /* Include files */
17 /*****************************************************************************/
18 #include <ti/drivers/net/wifi/simplelink.h>
19 #include <ti/drivers/net/wifi/source/protocol.h>
20 #include <ti/drivers/net/wifi/source/driver.h>
21 
22 #ifndef SL_PLATFORM_MULTI_THREADED
23 
24 #include "nonos.h"
25 
26 _SlNonOsCB_t g__SlNonOsCB;
27 
28 
29 _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags)
30 {
31  _i8 i = 0;
32 
33  /* The parameter is currently not in use */
34  (void)flags;
35 
36 #ifndef SL_TINY
37  for (i=0 ; i<NONOS_MAX_SPAWN_ENTRIES ; i++)
38 #endif
39  {
40  _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
41 
42  if (pE->IsAllocated == FALSE)
43  {
44  pE->pValue = pValue;
45  pE->pEntry = pEntry;
46  pE->IsAllocated = TRUE;
47 #ifndef SL_TINY
48  break;
49 #endif
50  }
51  }
52 
53  return NONOS_RET_OK;
54 }
55 
56 
57 _SlNonOsRetVal_t _SlNonOsHandleSpawnTask(void)
58 {
59  _i8 i=0;
60  void* pValue;
61 
62 #ifndef SL_TINY
63  for (i=0 ; i<NONOS_MAX_SPAWN_ENTRIES ; i++)
64 #endif
65  {
66  _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
67 
68  if (pE->IsAllocated == TRUE)
69  {
70  _SlSpawnEntryFunc_t pF = pE->pEntry;
71  pValue = pE->pValue;
72 
73  /* Clear the entry */
74  pE->pEntry = NULL;
75  pE->pValue = NULL;
76  pE->IsAllocated = FALSE;
77 
78  /* execute the spawn function */
79  pF(pValue);
80  }
81  }
82  return NONOS_RET_OK;
83 }
84 
85 
86 void tiDriverSpawnCallback(void)
87 {
88  /* If we are in cmd context and waiting for its cmd response
89  * do not handle async events from spawn, as the global lock was already taken when sending the command,
90  * and the Async event would be handled in read cmd context, so we do nothing.
91  */
92  if (FALSE == g_pCB->WaitForCmdResp)
93  {
94  (void)_SlNonOsHandleSpawnTask();
95  }
96 }
97 
98 #endif
99 
Definition: nonos.h:45