SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.27
Simplifies the implementation of Internet connectivity
Device

Controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status) More...

Functions

_i16 sl_Start (const void *pIfHdl, _i8 *pDevName, const P_INIT_CALLBACK pInitCallBack)
 Start the SimpleLink device. More...
 
_i16 sl_Stop (const _u16 Timeout)
 Stop the SimpleLink device. More...
 
_i16 sl_DeviceSet (const _u8 DeviceSetId, const _u8 Option, const _u16 ConfigLen, const _u8 *pValues)
 Setting device configurations. More...
 
_i16 sl_DeviceGet (const _u8 DeviceGetId, _u8 *pOption, _u16 *pConfigLen, _u8 *pValues)
 Internal function for getting device configurations. More...
 
_i16 sl_DeviceEventMaskSet (const _u8 EventClass, const _u32 Mask)
 Set asynchronous event mask. More...
 
_i16 sl_DeviceEventMaskGet (const _u8 EventClass, _u32 *pMask)
 Get current event mask of the device. More...
 
void * sl_Task (void *pEntry)
 The SimpleLink task entry. More...
 
_i16 sl_DeviceUartSetMode (const SlDeviceUartIfParams_t *pUartParams)
 Setting the internal uart mode. More...
 

Typedefs

typedef struct SlDeviceFatalNoCmdAck_t SlDeviceFatalCmdTimeout_t
 
typedef void(* P_INIT_CALLBACK) (_u32 Status, SlDeviceInitInfo_t *DeviceInitInfo)
 

Enumerations

enum  SlDeviceEventId_e {
  SL_DEVICE_EVENT_FATAL_DEVICE_ABORT = 1,
  SL_DEVICE_EVENT_FATAL_DRIVER_ABORT,
  SL_DEVICE_EVENT_FATAL_SYNC_LOSS,
  SL_DEVICE_EVENT_FATAL_NO_CMD_ACK,
  SL_DEVICE_EVENT_FATAL_CMD_TIMEOUT,
  SL_DEVICE_EVENT_RESET_REQUEST,
  SL_DEVICE_EVENT_ERROR,
  SL_DEVICE_EVENT_MAX
}
 
enum  SlDeviceSource_e {
  SL_DEVICE_SOURCE_OTHER,
  SL_DEVICE_SOURCE_WLAN,
  SL_DEVICE_SOURCE_NETCFG,
  SL_DEVICE_SOURCE_NETAPP,
  SL_DEVICE_SOURCE_SECURITY,
  SL_DEVICE_SOURCE_LAST = 0xFF
}
 
enum  SlDeviceResetRequestCaller_e {
  SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING,
  SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING_EXTERNAL_CONFIGURATION,
  SL_DEVICE_RESET_REQUEST_NUM_OF_CALLERS
}
 

Detailed Description

Controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status)

Function Documentation

§ sl_DeviceEventMaskGet()

_i16 sl_DeviceEventMaskGet ( const _u8  EventClass,
_u32 *  pMask 
)

Get current event mask of the device.

Return the events bit mask from the device. In case event is masked, the device will not send that event.

Parameters
[in]EventClassThe classification groups that the mask is referred to. Need to be one of the following:
  • SL_DEVICE_EVENT_CLASS_GLOBAL
  • SL_DEVICE_EVENT_CLASS_DEVICE
  • SL_DEVICE_EVENT_CLASS_WLAN
  • SL_DEVICE_EVENT_CLASS_BSD
  • SL_DEVICE_EVENT_CLASS_NETAPP
  • SL_DEVICE_EVENT_CLASS_NETCFG
  • SL_DEVICE_EVENT_CLASS_FS
[out]pMaskPointer to mask bitmap where the value should be stored. Bitmasks are the same as in sl_DeviceEventMaskSet
Returns
Zero on success, or a negative value if an error occurred
See also
sl_DeviceEventMaskSet
Note
Belongs to ext_api
Warning
Example
  • Getting an event mask for WLAN class:
    _u32 maskWlan;
    sl_DeviceEventMaskGet(SL_DEVICE_EVENT_CLASS_WLAN,&maskWlan);

Definition at line 439 of file device.c.

440 {
441  _SlEventMaskGetMsg_u Msg;
442 
443  /* verify that this api is allowed. if not allowed then
444  ignore the API execution and return immediately with an error */
445  VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
446 
447  Msg.Cmd.Group = EventClass;
448 
449  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskGetCmdCtrl, &Msg, NULL));
450 
451  *pMask = Msg.Rsp.Mask;
452 
453  return SL_RET_CODE_OK;
454 }

§ sl_DeviceEventMaskSet()

_i16 sl_DeviceEventMaskSet ( const _u8  EventClass,
const _u32  Mask 
)

Set asynchronous event mask.

Mask asynchronous events from the device.
Masked events do not generate asynchronous messages from the device.
By default - all events are active

Parameters
[in]EventClassThe classification groups that the mask is referred to. Need to be one of the following:
  • SL_DEVICE_EVENT_CLASS_DEVICE
  • SL_DEVICE_EVENT_CLASS_WLAN
  • SL_DEVICE_EVENT_CLASS_BSD
  • SL_DEVICE_EVENT_CLASS_NETAPP
  • SL_DEVICE_EVENT_CLASS_NETCFG
  • SL_DEVICE_EVENT_CLASS_FS
[in]MaskEvent Mask bitmap. Valid mask are (per group):
  • SL_DEVICE_EVENT_CLASS_WLAN user events
    • SL_WLAN_EVENT_CONNECT
    • SL_WLAN_EVENT_P2P_CONNECT
    • SL_WLAN_EVENT_DISCONNECT
    • SL_WLAN_EVENT_P2P_DISCONNECT
    • SL_WLAN_EVENT_STA_ADDED
    • SL_WLAN_EVENT_STA_REMOVED
    • SL_WLAN_EVENT_P2P_CLIENT_ADDED
    • SL_WLAN_EVENT_P2P_CLIENT_REMOVED
    • SL_WLAN_EVENT_P2P_DEVFOUND
    • SL_WLAN_EVENT_P2P_REQUEST
    • SL_WLAN_EVENT_P2P_CONNECTFAIL
    • SL_WLAN_EVENT_PROVISIONING_STATUS
    • SL_WLAN_EVENT_PROVISIONING_PROFILE_ADDED
    • SL_WLAN_EVENT_RXFILTER
  • SL_DEVICE_EVENT_CLASS_DEVICE user events
    • SL_DEVICE_EVENT_ERROR
  • SL_DEVICE_EVENT_CLASS_BSD user events
    • SL_SOCKET_TX_FAILED_EVENT
    • SL_SOCKET_ASYNC_EVENT
  • SL_DEVICE_EVENT_CLASS_NETAPP user events
    • SL_NETAPP_EVENT_IPV4_ACQUIRED
    • SL_NETAPP_EVENT_IPV6_ACQUIRED
    • SL_NETAPP_EVENT_DHCPV4_LEASED
    • SL_NETAPP_EVENT_DHCPV4_RELEASED
    • SL_NETAPP_EVENT_IP_COLLISION
    • SL_NETAPP_EVENT_IPV4_LOST
    • SL_NETAPP_EVENT_DHCP_IPV4_ACQUIRE_TIMEOUT
    • SL_NETAPP_EVENT_IPV6_LOST
Returns
Zero on success, or a negative value if an error occurred
Persistent System Persistent
See also
sl_DeviceEventMaskGet
Note
Belongs to ext_api
Warning
Example
  • Masking connection/disconnection async events from WLAN class:
    sl_DeviceEventMaskSet(SL_DEVICE_EVENT_CLASS_WLAN, (SL_DEVICE_EVENT_BIT(SL_WLAN_EVENT_CONNECT) | SL_DEVICE_EVENT_BIT(SL_WLAN_EVENT_DISCONNECT) ) );

Definition at line 401 of file device.c.

402 {
403  _SlEventMaskSetMsg_u Msg;
404 
405  /* verify that this api is allowed. if not allowed then
406  ignore the API execution and return immediately with an error */
407  VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
408 
409  Msg.Cmd.Group = EventClass;
410  Msg.Cmd.Mask = Mask;
411 
412  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskSetCmdCtrl, &Msg, NULL));
413 
414  return (_i16)Msg.Rsp.status;
415 }

§ sl_DeviceGet()

_i16 sl_DeviceGet ( const _u8  DeviceGetId,
_u8 *  pOption,
_u16 *  pConfigLen,
_u8 *  pValues 
)

Internal function for getting device configurations.

Parameters
[in]DeviceGetIdconfiguration id:
  • SL_DEVICE_STATUS
  • SL_DEVICE_GENERAL
  • SL_DEVICE_IOT
[out]pOptionGet configurations option:
  • SL_DEVICE_STATUS:
    • SL_DEVICE_EVENT_CLASS_DEVICE
    • SL_DEVICE_EVENT_CLASS_WLAN
    • SL_DEVICE_EVENT_CLASS_BSD
    • SL_DEVICE_EVENT_CLASS_NETAPP
    • SL_DEVICE_EVENT_CLASS_NETCFG
    • SL_DEVICE_EVENT_CLASS_FS
  • SL_DEVICE_GENERAL:
    • SL_DEVICE_GENERAL_VERSION
    • SL_DEVICE_GENERAL_DATE_TIME
    • SL_DEVICE_GENERAL_PERSISTENT
  • SL_DEVICE_IOT:
    • SL_DEVICE_IOT_UDID
[out]pConfigLenThe length of the allocated memory as input, when the function complete, the value of this parameter would be the len that actually read from the device.
If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return SL_ESMALLBUF
[out]pValuesGet requested configurations values
Returns
Zero on success, or a negative value if an error occurred
See also
Note
Warning
Examples
  • Getting WLAN class status (status is always cleared on read):
    _u32 statusWlan;
    _u8 pConfigOpt;
    _u16 pConfigLen;
    pConfigOpt = SL_DEVICE_EVENT_CLASS_WLAN;
    pConfigLen = sizeof(_u32);
    sl_DeviceGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(_u8 *)(&statusWlan));
    if (SL_DEVICE_STATUS_WLAN_STA_CONNECTED & statusWlan )
    {
    printf("Device is connected\n");
    }
    if (SL_DEVICE_EVENT_DROPPED_WLAN_RX_FILTERS & statusWlan )
    {
    printf("RX filer event dropped\n");
    }

  • Getting version:
    pConfigLen = sizeof(ver);
    pConfigOpt = SL_DEVICE_GENERAL_VERSION;
    sl_DeviceGet(SL_DEVICE_GENERAL,&pConfigOpt,&pConfigLen,(_u8 *)(&ver));
    printf("CHIP %d\nMAC 31.%d.%d.%d.%d\nPHY %d.%d.%d.%d\nNWP %d.%d.%d.%d\nROM %d\nHOST %d.%d.%d.%d\n",
    ver.ChipId,
    ver.FwVersion[0],ver.FwVersion[1],
    ver.FwVersion[2],ver.FwVersion[3],
    ver.PhyVersion[0],ver.PhyVersion[1],
    ver.PhyVersion[2],ver.PhyVersion[3],
    ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
    ver.RomVersion,
    SL_MAJOR_VERSION_NUM,SL_MINOR_VERSION_NUM,SL_VERSION_NUM,SL_SUB_VERSION_NUM);

  • Getting Device time and date:
    SlDateTime_t dateTime = {0};
    _i16 configLen = sizeof(SlDateTime_t);
    _i8 configOpt = SL_DEVICE_GENERAL_DATE_TIME;
    sl_DeviceGet(SL_DEVICE_GENERAL,&configOpt, &configLen,(_u8 *)(&dateTime));
    printf("Day %d,Mon %d,Year %d,Hour %,Min %d,Sec %d\n",dateTime.tm_day,dateTime.tm_mon,dateTime.tm_year,
    dateTime.tm_hour,dateTime.tm_min,dateTime.tm_sec);
  • Getting persistency system configuration:
    _i16 configLen = sizeof(_u8);
    _i8 configOpt = SL_DEVICE_GENERAL_PERSISTENT;
    sl_DeviceGet(SL_DEVICE_GENERAL,&configOpt, &configLen,&persistent);

Definition at line 480 of file device.c.

481 {
482  _SlDeviceMsgGet_u Msg;
483  _SlCmdExt_t CmdExt;
484 
485  /* verify that this api is allowed. if not allowed then
486  ignore the API execution and return immediately with an error */
487  VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
488 
489  if (*pConfigLen == 0)
490  {
491  return SL_EZEROLEN;
492  }
493 
494  if( pOption )
495  {
496 
497  _SlDrvResetCmdExt(&CmdExt);
498  CmdExt.RxPayloadLen = (_i16)*pConfigLen;
499  CmdExt.pRxPayload = (_u8 *)pValues;
500 
501  Msg.Cmd.DeviceSetId = DeviceGetId;
502 
503  Msg.Cmd.Option = (_u16)*pOption;
504 
505  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlDeviceGetCmdCtrl, &Msg, &CmdExt));
506 
507  if( pOption )
508  {
509  *pOption = (_u8)Msg.Rsp.Option;
510  }
511 
512  if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
513  {
514  *pConfigLen = (_u16)CmdExt.RxPayloadLen;
515 
516  return SL_ESMALLBUF;
517  }
518  else
519  {
520  *pConfigLen = (_u16)CmdExt.ActualRxPayloadLen;
521  }
522 
523  return (_i16)Msg.Rsp.Status;
524  }
525  else
526  {
527  return SL_RET_CODE_INVALID_INPUT;
528  }
529 }

§ sl_DeviceSet()

_i16 sl_DeviceSet ( const _u8  DeviceSetId,
const _u8  Option,
const _u16  ConfigLen,
const _u8 *  pValues 
)

Setting device configurations.

Parameters
[in]DeviceSetIdconfiguration id:
  • SL_DEVICE_GENERAL
[in]Optionconfigurations option:
  • SL_DEVICE_GENERAL_DATE_TIME
  • SL_DEVICE_GENERAL_PERSISTENT
[in]ConfigLenconfigurations len
[in]pValuesconfigurations values
Returns
Zero on success, or a negative value if an error occurred
Persistent
SL_DEVICE_GENERAL_DATE_TIME - Non-Persistent (Kept during hibernate) SL_DEVICE_GENERAL_PERSISTENT - Persistent
See also
Note
Warning
Examples:
  • Setting device time and date example:
    SlDateTime_t dateTime= {0};
    dateTime.tm_day = (_u32)23; // Day of month (DD format) range 1-31
    dateTime.tm_mon = (_u32)6; // Month (MM format) in the range of 1-12
    dateTime.tm_year = (_u32)2014; // Year (YYYY format)
    dateTime.tm_hour = (_u32)17; // Hours in the range of 0-23
    dateTime.tm_min = (_u32)55; // Minutes in the range of 0-59
    dateTime.tm_sec = (_u32)22; // Seconds in the range of 0-59
    sl_DeviceSet(SL_DEVICE_GENERAL,
    SL_DEVICE_GENERAL_DATE_TIME,
    sizeof(SlDateTime_t),
    (_u8 *)(&dateTime));

  • Setting system persistent configuration:
    Sets the default system-wide configuration persistence mode. In case true, all APIs that follow 'system configured' persistence (see persistence attribute noted per API) shall maintain the configured settings. In case false, all calls to APIs that follow 'system configured' persistence shall be volatile. Configuration should revert to default after reset or power recycle
    _u8 persistent = 1;
    sl_DeviceSet(SL_DEVICE_GENERAL,
    SL_DEVICE_GENERAL_PERSISTENT,
    sizeof(_u8),
    (_u8 *)(&persistent));

Definition at line 552 of file device.c.

553 {
554  _SlDeviceMsgSet_u Msg;
555  _SlCmdExt_t CmdExt;
556 
557  /* verify that this api is allowed. if not allowed then
558  ignore the API execution and return immediately with an error */
559  VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
560 
561  _SlDrvResetCmdExt(&CmdExt);
562 
563  CmdExt.TxPayload1Len = (ConfigLen+3) & (~3);
564  CmdExt.pTxPayload1 = (_u8 *)pValues;
565 
566  Msg.Cmd.DeviceSetId = DeviceSetId;
567  Msg.Cmd.ConfigLen = ConfigLen;
568  Msg.Cmd.Option = Option;
569 
570  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlDeviceSetCmdCtrl, &Msg, &CmdExt));
571 
572  return (_i16)Msg.Rsp.status;
573 }

§ sl_DeviceUartSetMode()

_i16 sl_DeviceUartSetMode ( const SlDeviceUartIfParams_t pUartParams)

Setting the internal uart mode.

Parameters
[in]pUartParamsPointer to the uart configuration parameter set:
  • baudrate - up to 711 Kbps
  • flow control - enable/disable
  • comm port - the comm port number
Returns
On success zero is returned, otherwise - Failed.
See also
Note
Belongs to basic_api
Warning
This function must consider the host uart capability

Definition at line 725 of file device.c.

726 {
727  _SlUartSetModeMsg_u Msg;
728  _u32 magicCode = (_u32)0xFFFFFFFF;
729 
730  Msg.Cmd.BaudRate = pUartParams->BaudRate;
731  Msg.Cmd.FlowControlEnable = pUartParams->FlowControlEnable;
732 
733 
734  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlUartSetModeCmdCtrl, &Msg, NULL));
735 
736  /* cmd response OK, we can continue with the handshake */
737  if (SL_RET_CODE_OK == Msg.Rsp.status)
738  {
739  sl_IfMaskIntHdlr();
740 
741  /* Close the comm port */
742  sl_IfClose(g_pCB->FD);
743 
744  /* Re-open the comm port */
745  sl_IfOpen((void * )pUartParams, SL_IF_UART_REOPEN_FLAGS);
746 
747  sl_IfUnMaskIntHdlr();
748 
749  /* send the magic code and wait for the response */
750  sl_IfWrite(g_pCB->FD, (_u8* )&magicCode, 4);
751 
752  magicCode = UART_SET_MODE_MAGIC_CODE;
753  sl_IfWrite(g_pCB->FD, (_u8* )&magicCode, 4);
754 
755  /* clear magic code */
756  magicCode = 0;
757 
758  /* wait (blocking) till the magic code to be returned from device */
759  sl_IfRead(g_pCB->FD, (_u8* )&magicCode, 4);
760 
761  /* check for the received magic code matching */
762  if (UART_SET_MODE_MAGIC_CODE != magicCode)
763  {
764  _SL_ASSERT(0);
765  }
766  }
767 
768  return (_i16)Msg.Rsp.status;
769 }

§ sl_Start()

_i16 sl_Start ( const void *  pIfHdl,
_i8 *  pDevName,
const P_INIT_CALLBACK  pInitCallBack 
)

Start the SimpleLink device.

This function initialize the communication interface, set the enable pin of the device, and call to the init complete callback.

Parameters
[in]pIfHdlOpened Interface Object. In case the interface must be opened outside the SimpleLink Driver, the user might give the handler to be used in
any access of the communication interface with the device (UART/SPI).
The SimpleLink driver will open an interface port only if this parameter is null!
[in]pDevNameThe name of the device to open. Could be used when the pIfHdl is null, to transfer information to the open interface function
This pointer could be used to pass additional information to sl_IfOpen in case it is required (e.g. UART com port name)
[in]pInitCallBackPointer to function that would be called on completion of the initialization process.
If this parameter is NULL the function is blocked until the device initialization is completed, otherwise the function returns immediately.
Returns
Returns the current active role (STA/AP/P2P) or an error code:
  • ROLE_STA, ROLE_AP, ROLE_P2P in case of success, otherwise in failure one of the following is return:
  • SL_ERROR_ROLE_STA_ERR (Failure to load MAC/PHY in STA role)
  • SL_ERROR_ROLE_AP_ERR (Failure to load MAC/PHY in AP role)
  • SL_ERROR_ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role)
  • SL_ERROR_CALIB_FAIL (Failure of calibration)
  • SL_ERROR_FS_CORRUPTED_ERR (FS is corrupted, Return to Factory Image or Program new image should be invoked (see sl_FsCtl, sl_FsProgram))
  • SL_ERROR_FS_ALERT_ERR (Device is locked, Return to Factory Image or Program new image should be invoked (see sl_FsCtl, sl_FsProgram))
  • SL_ERROR_RESTORE_IMAGE_COMPLETE (Return to factory image completed, perform reset)
  • SL_ERROR_GENERAL_ERR (General error during init)
See also
sl_Stop
Note
Belongs to basic_api
Warning
This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device
Example:
  • Open interface without callback routine. The interface name and handler are handled by the sl_IfOpen routine:
    if( sl_Start(NULL, NULL, NULL) < 0 )
    {
    LOG("Error opening interface to device\n");
    }

  • Open interface with a callback routine:
    void SimpleLinkInitCallback(_u32 status)
    {
    LOG("Handle SimpleLink Interface acording to ststus %d\n", status);
    }
    void main(void)
    {
    if (sl_Start(NULL, NULL, SimpleLinkInitCallback) < 0)
    {
    LOG("Error opening interface to device\n");
    }
    }

Definition at line 119 of file device.c.

120 {
121  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
122  InitComplete_t AsyncRsp;
123 
124  _SlDrvMemZero(&AsyncRsp, sizeof(InitComplete_t));
125 
126  /* verify no erorr handling in progress. if in progress than
127  ignore the API execution and return immediately with an error */
128  VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
129  if (SL_IS_DEVICE_STARTED)
130  {
131  return SL_RET_CODE_DEV_ALREADY_STARTED;
132  }
133  /* Perform any preprocessing before enable networking services */
134 #ifdef sl_DeviceEnablePreamble
135  sl_DeviceEnablePreamble();
136 #endif
137 
138  /* ControlBlock init */
139  (void)_SlDrvDriverCBInit();
140 
141  /* open the interface: usually SPI or UART */
142  if (NULL == pIfHdl)
143  {
144  g_pCB->FD = sl_IfOpen((void *)pDevName, SL_IF_OPEN_FLAGS);
145  }
146  else
147  {
148  g_pCB->FD = (_SlFd_t)pIfHdl;
149  }
150 
151  ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS);
152 
153  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
154  {
155  return SL_POOL_IS_EMPTY;
156  }
157 
158  if( g_pCB->FD >= (_SlFd_t)0)
159  {
160  /* store the interface parameters for the internal call of the
161  sl_start to be called upon reset request handling */
162  DeviceCB.pIfHdl = pIfHdl;
163  DeviceCB.pDevName = pDevName;
164 
165  /* Mark that device is in progress! */
166  SL_SET_DEVICE_START_IN_PROGRESS;
167 
168  sl_DeviceDisable();
169 
170  sl_IfRegIntHdlr((SL_P_EVENT_HANDLER)_SlDrvRxIrqHandler, NULL);
171 
172  g_pCB->pInitCallback = pInitCallBack;
173  sl_DeviceEnable();
174 
175  if (NULL == pInitCallBack)
176  {
177 #ifdef SL_TINY
178  _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
179 #else
180  SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj,
181  INIT_COMPLETE_TIMEOUT,
182  SL_OPCODE_DEVICE_INITCOMPLETE);
183 #endif
184 
185  SL_UNSET_DEVICE_START_IN_PROGRESS;
186 
187  SL_SET_DEVICE_STARTED;
188 
189  /* release Pool Object */
190  _SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex);
191  return _SlDeviceGetStartResponseConvert(AsyncRsp.Status);
192  }
193  else
194  {
195  return SL_RET_CODE_OK;
196  }
197  }
198  return SL_BAD_INTERFACE;
199 }

§ sl_Stop()

_i16 sl_Stop ( const _u16  Timeout)

Stop the SimpleLink device.

This function clears the enable pin of the device, closes the communication
interface and invokes the stop complete callback

Parameters
[in]TimeoutStop timeout in msec. Should be used to give the device time to finish
any transmission/reception that is not completed when the function was called.
Additional options:
  • 0 Enter to hibernate immediately
  • 0xFFFF Host waits for device's response before
    hibernating, without timeout protection
  • 0 < Timeout[msec] < 0xFFFF Host waits for device's response before
    hibernating, with a defined timeout protection
    This timeout defines the max time to wait. The NWP
    response can be sent earlier than this timeout.
Returns
Zero on success, or a negative value if an error occurred
See also
sl_Start
Note
This API will shutdown the device and invoke the "i/f close" function regardless
if it was opened implicitly or explicitly.
It is up to the platform interface library to properly handle interface close
routine
Belongs to basic_api
Warning

Definition at line 278 of file device.c.

279 {
280  _i16 RetVal=0;
281  _SlStopMsg_u Msg;
282  _BasicResponse_t AsyncRsp;
283  _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
284  _u8 ReleasePoolObject = FALSE;
285  _u8 IsProvInProgress = FALSE;
286 
287  /* In case the device has already stopped,
288  * return an error code .
289  */
290  if (!SL_IS_DEVICE_STARTED)
291  {
292  return SL_RET_CODE_DEV_NOT_STARTED;
293  }
294 
295  /* NOTE: don't check VERIFY_API_ALLOWED(), this command is not
296  * filtered in error handling and also not filtered in NWP lock state.
297  * If we are in the middle of assert handling than ignore stopping
298  * the device with timeout and force immediate shutdown as we would like
299  * to avoid any additional commands to the NWP */
300  if( (Timeout != 0)
301 #ifndef SL_TINY
302  && (!SL_IS_RESTART_REQUIRED)
303 #endif
304  )
305  {
306  /* Clear the Async response structure */
307  _SlDrvMemZero(&AsyncRsp, sizeof(_BasicResponse_t));
308 
309  /* let the device make the shutdown using the defined timeout */
310  Msg.Cmd.Timeout = Timeout;
311 
312  IsProvInProgress = SL_IS_PROVISIONING_IN_PROGRESS;
313 
314  /* if provisioning in progress do not take pool object as we are not going to wait for it */
315  if (!IsProvInProgress)
316  {
317  ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS);
318  if (MAX_CONCURRENT_ACTIONS == ObjIdx)
319  {
320  return SL_POOL_IS_EMPTY;
321  }
322 
323  ReleasePoolObject = TRUE;
324  }
325 
326  /* Set the stop-in-progress flag */
327  SL_SET_DEVICE_STOP_IN_PROGRESS;
328 
329  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlStopCmdCtrl, &Msg, NULL));
330 
331  /* Do not wait for stop async event if provisioning is in progress */
332  if((SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status) && (!(IsProvInProgress)))
333  {
334 
335 #ifdef SL_TINY
336  _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
337  /* Wait for sync object to be signaled */
338 #else
339  SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj,
340  STOP_DEVICE_TIMEOUT,
341  SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE);
342 #endif
343  Msg.Rsp.status = AsyncRsp.status;
344  RetVal = Msg.Rsp.status;
345  }
346 
347  /* Release pool object only if taken */
348  if (ReleasePoolObject == TRUE)
349  {
350  _SlDrvReleasePoolObj(ObjIdx);
351  }
352 
353  /* This macro wait for the NWP to raise a ready for shutdown indication.
354  * This function is unique for the CC32XX family, and expected to return
355  * in less than 600 mSec, which is the time takes for NWP to gracefully shutdown. */
356  WAIT_NWP_SHUTDOWN_READY;
357  }
358  else
359  {
360  /* Set the stop-in-progress flag */
361  SL_SET_DEVICE_STOP_IN_PROGRESS;
362  }
363 
364  sl_IfRegIntHdlr(NULL, NULL);
365  sl_DeviceDisable();
366  RetVal = sl_IfClose(g_pCB->FD);
367 
368  (void)_SlDrvDriverCBDeinit();
369 
370  /* clear the stop-in-progress flag */
371  SL_UNSET_DEVICE_STOP_IN_PROGRESS;
372 
373  /* clear the device started flag */
374  SL_UNSET_DEVICE_STARTED;
375 
376  return RetVal;
377 }

§ sl_Task()

void* sl_Task ( void *  pEntry)

The SimpleLink task entry.

This function must be called from the main loop or from dedicated thread in the following cases:

  • Non-Os Platform - should be called from the mail loop
  • Multi Threaded Platform when the user does not implement the external spawn functions - should be called from dedicated thread allocated to the SimpleLink driver. In this mode the function never return.
parameters
None
Returns
None
See also
Note
Belongs to basic_api
Warning
This function must be called from a thread that is start running before any call to other SimpleLink API

Definition at line 105 of file device.c.

106 {
107 #ifdef _SlTaskEntry
108  return (void*)_SlTaskEntry();
109 #else
110  return (void*)0;
111 #endif
112 }

Data Structure Documentation

§ SlDeviceEventResetRequest_t

struct SlDeviceEventResetRequest_t

Definition at line 87 of file device.h.

Data Fields
_u16 Caller
_i16 Status

§ SlDeviceEventError_t

struct SlDeviceEventError_t

Definition at line 104 of file device.h.

Data Fields
_i16 Code
SlDeviceSource_e Source

§ SlDeviceEventData_u

union SlDeviceEventData_u

Definition at line 110 of file device.h.

Data Fields
SlDeviceEventError_t Error
SlDeviceEventResetRequest_t ResetRequest

§ SlDeviceEvent_t

struct SlDeviceEvent_t

Definition at line 125 of file device.h.

Data Fields
SlDeviceEventData_u Data
_u32 Id

§ SlDeviceFatalDeviceAssert_t

struct SlDeviceFatalDeviceAssert_t

Definition at line 139 of file device.h.

Data Fields
_u32 Code
_u32 Value

§ SlDeviceFatalNoCmdAck_t

struct SlDeviceFatalNoCmdAck_t

Definition at line 146 of file device.h.

Data Fields
_u32 Code

§ SlDeviceFatalData_u

union SlDeviceFatalData_u

Definition at line 152 of file device.h.

Data Fields
SlDeviceFatalCmdTimeout_t CmdTimeout
SlDeviceFatalDeviceAssert_t DeviceAssert
SlDeviceFatalNoCmdAck_t NoCmdAck

§ SlDeviceFatal_t

struct SlDeviceFatal_t

Definition at line 160 of file device.h.

Data Fields
SlDeviceFatalData_u Data
_u32 Id

§ SlDeviceUartIfParams_t

struct SlDeviceUartIfParams_t

Definition at line 234 of file device.h.

Data Fields
_u32 BaudRate
_u8 CommPort
_u8 FlowControlEnable

§ SlDeviceVersion_t

struct SlDeviceVersion_t

Definition at line 256 of file device.h.

Data Fields
_u32 ChipId
_u8 FwVersion[4]
_u8 NwpVersion[4]
_u16 Padding
_u8 PhyVersion[4]
_u16 RomVersion

§ SlDateTime_t

struct SlDateTime_t

Definition at line 267 of file device.h.

Data Fields
_u32 reserved[3]
_u32 tm_day
_u32 tm_hour
_u32 tm_min
_u32 tm_mon
_u32 tm_sec
_u32 tm_week_day
_u32 tm_year
_u32 tm_year_day

§ SlDeviceInitInfo_t

struct SlDeviceInitInfo_t

Definition at line 286 of file device.h.

Data Fields
_u32 ChipId
_u32 MoreData