micropython: add micropython component

This commit is contained in:
KY-zhang-X
2022-09-29 12:10:37 +08:00
parent 1514f1cb9b
commit dd76146324
2679 changed files with 354110 additions and 0 deletions

View File

@@ -0,0 +1,656 @@
/*
* device.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __DEVICE_H__
#define __DEVICE_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup device
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/* SL internal Error codes */
/* Receive this error in case there are no resources to issue the command
If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
If not, try again later */
#define SL_POOL_IS_EMPTY (-2000)
/* Receive this error in case a given length for RX buffer was too small.
Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size
Recommend to increase buffer size */
#define SL_ESMALLBUF (-2001)
/* Receive this error in case zero length is supplied to a "get" API
Recommend to supply length according to requested information (view options defines for help) */
#define SL_EZEROLEN (-2002)
/* User supplied invalid parameter */
#define SL_INVALPARAM (-2003)
/* Failed to open interface */
#define SL_BAD_INTERFACE (-2004)
/* End of SL internal Error codes */
/*****************************************************************************/
/* Errors returned from the general error async event */
/*****************************************************************************/
/* Send types */
typedef enum
{
SL_ERR_SENDER_HEALTH_MON,
SL_ERR_SENDER_CLI_UART,
SL_ERR_SENDER_SUPPLICANT,
SL_ERR_SENDER_NETWORK_STACK,
SL_ERR_SENDER_WLAN_DRV_IF,
SL_ERR_SENDER_WILINK,
SL_ERR_SENDER_INIT_APP,
SL_ERR_SENDER_NETX,
SL_ERR_SENDER_HOST_APD,
SL_ERR_SENDER_MDNS,
SL_ERR_SENDER_HTTP_SERVER,
SL_ERR_SENDER_DHCP_SERVER,
SL_ERR_SENDER_DHCP_CLIENT,
SL_ERR_DISPATCHER,
SL_ERR_NUM_SENDER_LAST=0xFF
}SlErrorSender_e;
/* Error codes */
#define SL_ERROR_STATIC_ADDR_SUBNET_ERROR (-60) /* network stack error*/
#define SL_ERROR_ILLEGAL_CHANNEL (-61) /* supplicant error */
#define SL_ERROR_SUPPLICANT_ERROR (-72) /* init error code */
#define SL_ERROR_HOSTAPD_INIT_FAIL (-73) /* init error code */
#define SL_ERROR_HOSTAPD_INIT_IF_FAIL (-74) /* init error code */
#define SL_ERROR_WLAN_DRV_INIT_FAIL (-75) /* init error code */
#define SL_ERROR_WLAN_DRV_START_FAIL (-76) /* wlan start error */
#define SL_ERROR_FS_FILE_TABLE_LOAD_FAILED (-77) /* init file system failed */
#define SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED (-78) /* init file system failed */
#define SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR (-79) /* Ap configurations BSSID error */
#define SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE (-80) /* Ap configurations interface error */
#define SL_ERROR_MDNS_ENABLE_FAIL (-81) /* mDNS enable failed */
#define SL_ERROR_HTTP_SERVER_ENABLE_FAILED (-82) /* HTTP server enable failed */
#define SL_ERROR_DHCP_SERVER_ENABLE_FAILED (-83) /* DHCP server enable failed */
#define SL_ERROR_PREFERRED_NETWORK_LIST_FULL (-93) /* supplicant error */
#define SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED (-94) /* supplicant error */
#define SL_ERROR_DHCP_CLIENT_RENEW_FAILED (-100) /* DHCP client error */
/* WLAN Connection management status */
#define SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED (-102)
#define SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT (-103)
#define SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT (-104)
#define SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE (-105)
#define SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE (-106)
#define SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE (-107)
#define SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER (-108)
#define SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT (-109)
#define SL_ERROR_CON_MGMT_STATUS_SG_RESELECT (-110)
#define SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE (-111)
#define SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE (-112)
/* end of WLAN connection management error statuses */
#define SL_ERROR_WAKELOCK_ERROR_PREFIX (-115) /* Wake lock expired */
#define SL_ERROR_LENGTH_ERROR_PREFIX (-116) /* Uart header length error */
#define SL_ERROR_MDNS_CREATE_FAIL (-121) /* mDNS create failed */
#define SL_ERROR_GENERAL_ERROR (-127)
#define SL_DEVICE_GENERAL_CONFIGURATION (1)
#define SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME (11)
#define SL_DEVICE_GENERAL_VERSION (12)
#define SL_DEVICE_STATUS (2)
/*
Declare the different event group classifications
The SimpleLink device send asynchronous events. Each event has a group
classification according to its nature.
*/
/* SL_EVENT_CLASS_WLAN connection user events */
#define SL_WLAN_CONNECT_EVENT (1)
#define SL_WLAN_DISCONNECT_EVENT (2)
/* WLAN Smart Config user events */
#define SL_WLAN_SMART_CONFIG_COMPLETE_EVENT (3)
#define SL_WLAN_SMART_CONFIG_STOP_EVENT (4)
/* WLAN AP user events */
#define SL_WLAN_STA_CONNECTED_EVENT (5)
#define SL_WLAN_STA_DISCONNECTED_EVENT (6)
/* WLAN P2P user events */
#define SL_WLAN_P2P_DEV_FOUND_EVENT (7)
#define SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT (8)
#define SL_WLAN_CONNECTION_FAILED_EVENT (9)
/* SL_EVENT_CLASS_DEVICE user events */
#define SL_DEVICE_FATAL_ERROR_EVENT (1)
#define SL_DEVICE_ABORT_ERROR_EVENT (2)
/* SL_EVENT_CLASS_BSD user events */
#define SL_SOCKET_TX_FAILED_EVENT (1)
#define SL_SOCKET_ASYNC_EVENT (2)
/* SL_EVENT_CLASS_NETAPP user events */
#define SL_NETAPP_IPV4_IPACQUIRED_EVENT (1)
#define SL_NETAPP_IPV6_IPACQUIRED_EVENT (2)
#define SL_NETAPP_IP_LEASED_EVENT (3)
#define SL_NETAPP_IP_RELEASED_EVENT (4)
/* Server Events */
#define SL_NETAPP_HTTPGETTOKENVALUE_EVENT (1)
#define SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT (2)
/*
Declare the different event group classifications for sl_DevGet
for getting status indications
*/
/* Events list to mask/unmask*/
#define SL_EVENT_CLASS_GLOBAL (0)
#define SL_EVENT_CLASS_DEVICE (1)
#define SL_EVENT_CLASS_WLAN (2)
#define SL_EVENT_CLASS_BSD (3)
#define SL_EVENT_CLASS_NETAPP (4)
#define SL_EVENT_CLASS_NETCFG (5)
#define SL_EVENT_CLASS_FS (6)
/****************** DEVICE CLASS status ****************/
#define EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
#define STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
/****************** WLAN CLASS status ****************/
#define EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
#define EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
#define EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
#define EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
#define STATUS_WLAN_STA_CONNECTED (0x80000000L)
/****************** NETAPP CLASS status ****************/
#define EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
#define EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
#define EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
#define EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
/****************** BSD CLASS status ****************/
#define EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
/****************** FS CLASS ****************/
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
#define ROLE_UNKNOWN_ERR (-1)
#ifdef SL_IF_TYPE_UART
typedef struct
{
_u32 BaudRate;
_u8 FlowControlEnable;
_u8 CommPort;
} SlUartIfParams_t;
#endif
typedef struct
{
_u32 ChipId;
_u32 FwVersion[4];
_u8 PhyVersion[4];
}_SlPartialVersion;
typedef struct
{
_SlPartialVersion ChipFwAndPhyVersion;
_u32 NwpVersion[4];
_u16 RomVersion;
_u16 Padding;
}SlVersionFull;
typedef struct
{
_u32 AbortType;
_u32 AbortData;
}sl_DeviceReportAbort;
typedef struct
{
_i8 status;
SlErrorSender_e sender;
}sl_DeviceReport;
typedef union
{
sl_DeviceReport deviceEvent;
sl_DeviceReportAbort deviceReport;
} _SlDeviceEventData_u;
typedef struct
{
_u32 Event;
_SlDeviceEventData_u EventData;
} SlDeviceEvent_t;
typedef struct
{
/* time */
_u32 sl_tm_sec;
_u32 sl_tm_min;
_u32 sl_tm_hour;
/* date */
_u32 sl_tm_day; /* 1-31 */
_u32 sl_tm_mon; /* 1-12 */
_u32 sl_tm_year; /* YYYY 4 digits */
_u32 sl_tm_week_day; /* not required */
_u32 sl_tm_year_day; /* not required */
_u32 reserved[3];
}SlDateTime_t;
/******************************************************************************/
/* Type declarations */
/******************************************************************************/
typedef void (*P_INIT_CALLBACK)(_u32 Status);
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Start the SimpleLink device
This function initialize the communication interface, set the enable pin
of the device, and call to the init complete callback.
\param[in] pIfHdl Opened Interface Object. In case the interface
must be opened outside the SimpleLink Driver, the
user might give the handler to be used in \n
any access of the communication interface with the
device (UART/SPI). \n
The SimpleLink driver will open an interface port
only if this parameter is null! \n
\param[in] pDevName The name of the device to open. Could be used when
the pIfHdl is null, to transfer information to the
open interface function \n
This pointer could be used to pass additional information to
sl_IfOpen in case it is required (e.g. UART com port name)
\param[in] pInitCallBack Pointer to function that would be called
on completion of the initialization process.\n
If this parameter is NULL the function is
blocked until the device initialization
is completed, otherwise the function returns
immediately.
\return 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:
- ROLE_STA_ERR (Failure to load MAC/PHY in STA role)
- ROLE_AP_ERR (Failure to load MAC/PHY in AP role)
- ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role)
\sa sl_Stop
\note belongs to \ref 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
\par Example:
\code
An example for 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");
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_Start)
_i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
#endif
/*!
\brief Stop the SimpleLink device
This function clears the enable pin of the device, closes the communication \n
interface and invokes the stop complete callback
\param[in] timeout Stop timeout in msec. Should be used to give the device time to finish \n
any transmission/reception that is not completed when the function was called. \n
Additional options:
- 0 Enter to hibernate immediately \n
- 0xFFFF Host waits for device's response before \n
hibernating, without timeout protection \n
- 0 < Timeout[msec] < 0xFFFF Host waits for device's response before \n
hibernating, with a defined timeout protection \n
This timeout defines the max time to wait. The NWP \n
response can be sent earlier than this timeout.
\return On success, zero is returned. On error, -1 is returned
\sa sl_Start
\note This API will shutdown the device and invoke the "i/f close" function regardless \n
if it was opened implicitly or explicitly. \n
It is up to the platform interface library to properly handle interface close \n
routine \n
belongs to \ref basic_api \n
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Stop)
_i16 sl_Stop(const _u16 timeout);
#endif
/*!
\brief Internal function for setting device configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] DeviceSetId configuration id
\param[in] Option configurations option
\param[in] ConfigLen configurations len
\param[in] pValues configurations values
\sa
\note
\warning
\par Examples:
\code
Setting device time and date example:
SlDateTime_t dateTime= {0};
dateTime.sl_tm_day = (_u32)23; // Day of month (DD format) range 1-31
dateTime.sl_tm_mon = (_u32)6; // Month (MM format) in the range of 1-12
dateTime.sl_tm_year = (_u32)2014; // Year (YYYY format)
dateTime.sl_tm_hour = (_u32)17; // Hours in the range of 0-23
dateTime.sl_tm_min = (_u32)55; // Minutes in the range of 0-59
dateTime.sl_tm_sec = (_u32)22; // Seconds in the range of 0-59
sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
sizeof(SlDateTime_t),
(_u8 *)(&dateTime));
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_DevSet)
_i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const _u8 *pValues);
#endif
/*!
\brief Internal function for getting device configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] DeviceGetId configuration id - example SL_DEVICE_STATUS
\param[out] pOption Get configurations option, example for get status options
- SL_EVENT_CLASS_GLOBAL
- SL_EVENT_CLASS_DEVICE
- SL_EVENT_CLASS_WLAN
- SL_EVENT_CLASS_BSD
- SL_EVENT_CLASS_NETAPP
- SL_EVENT_CLASS_NETCFG
- SL_EVENT_CLASS_FS
\param[out] pConfigLen The 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.\n
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
\param[out] pValues Get configurations values
\sa
\note
\warning
\par Examples:
\code
Example for getting WLAN class status:
_u32 statusWlan;
_u8 pConfigOpt;
_u8 pConfigLen;
pConfigOpt = SL_EVENT_CLASS_WLAN;
pConfigLen = sizeof(_u32);
sl_DevGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(_u8 *)(&statusWlan));
Example for getting version:
SlVersionFull ver;
pConfigLen = sizeof(ver);
pConfigOpt = SL_DEVICE_GENERAL_VERSION;
sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&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.ChipFwAndPhyVersion.ChipId,
ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.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);
\endcode
\code
Getting Device time and date example:
SlDateTime_t dateTime = {0};
_i8 configLen = sizeof(SlDateTime_t);
_i8 configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME;
sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(_u8 *)(&dateTime));
printf("Day %d,Mon %d,Year %d,Hour %,Min %d,Sec %d\n",dateTime.sl_tm_day,dateTime.sl_tm_mon,dateTime.sl_tm_year
dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_DevGet)
_i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues);
#endif
/*!
\brief 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
\param[in] EventClass The classification groups that the
mask is referred to. Need to be one of
the following:
- SL_EVENT_CLASS_GLOBAL
- SL_EVENT_CLASS_DEVICE
- SL_EVENT_CLASS_WLAN
- SL_EVENT_CLASS_BSD
- SL_EVENT_CLASS_NETAPP
- SL_EVENT_CLASS_NETCFG
- SL_EVENT_CLASS_FS
\param[in] Mask Event Mask bitmap. Valid mask are (per group):
- SL_EVENT_CLASS_WLAN user events
- SL_WLAN_CONNECT_EVENT
- SL_WLAN_DISCONNECT_EVENT
- SL_EVENT_CLASS_DEVICE user events
- SL_DEVICE_FATAL_ERROR_EVENT
- SL_EVENT_CLASS_BSD user events
- SL_SOCKET_TX_FAILED_EVENT
- SL_SOCKET_ASYNC_EVENT
- SL_EVENT_CLASS_NETAPP user events
- SL_NETAPP_IPV4_IPACQUIRED_EVENT
- SL_NETAPP_IPV6_IPACQUIRED_EVENT
\return On success, zero is returned. On error, -1 is returned
\sa sl_EventMaskGet
\note belongs to \ref ext_api
\warning
\par Example:
\code
An example of masking connection/disconnection async events from WLAN class:
sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) );
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_EventMaskSet)
_i16 sl_EventMaskSet(const _u8 EventClass ,const _u32 Mask);
#endif
/*!
\brief Get current event mask of the device
return the events bit mask from the device. In case that event is
masked, the device is not sending this event.
\param[in] EventClass The classification groups that the
mask is referred to. Need to be one of
the following:
- SL_EVENT_CLASS_GLOBAL
- SL_EVENT_CLASS_DEVICE
- SL_EVENT_CLASS_WLAN
- SL_EVENT_CLASS_BSD
- SL_EVENT_CLASS_NETAPP
- SL_EVENT_CLASS_NETCFG
- SL_EVENT_CLASS_FS
\param[out] pMask Pointer to Mask bitmap where the
value should be stored. Bitmasks are the same as in \ref sl_EventMaskSet
\return On success, zero is returned. On error, -1 is returned
\sa sl_EventMaskSet
\note belongs to \ref ext_api
\warning
\par Example:
\code
An example of getting an event mask for WLAN class
_u32 maskWlan;
sl_StatusGet(SL_EVENT_CLASS_WLAN,&maskWlan);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_EventMaskGet)
_i16 sl_EventMaskGet(const _u8 EventClass,_u32 *pMask);
#endif
/*!
\brief the simple link task entry
\Param
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.
\return None
\sa sl_Stop
\note belongs to \ref basic_api
\warning This function must be called from a thread that is start running before
any call to other simple link API
*/
#if _SL_INCLUDE_FUNC(sl_Task)
void sl_Task(void);
#endif
/*!
\brief Setting the internal uart mode
\param[in] pUartParams Pointer to the uart configuration parameter set:
baudrate - up to 711 Kbps
flow control - enable/disable
comm port - the comm port number
\return On success zero is returned, otherwise - Failed.
\sa sl_Stop
\note belongs to \ref basic_api
\warning This function must consider the host uart capability
*/
#ifdef SL_IF_TYPE_UART
#if _SL_INCLUDE_FUNC(sl_UartSetMode)
_i16 sl_UartSetMode(const SlUartIfParams_t* pUartParams);
#endif
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DEVICE_H__ */

View File

@@ -0,0 +1,247 @@
/*
* driver.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __DRIVER_INT_H__
#define __DRIVER_INT_H__
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#ifndef CPU_FREQ_IN_MHZ
#define CPU_FREQ_IN_MHZ (200)
#endif
#define USEC_DELAY (50)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef struct
{
_SlOpcode_t Opcode;
_SlArgSize_t TxDescLen;
_SlArgSize_t RxDescLen;
}_SlCmdCtrl_t;
typedef struct
{
_u16 TxPayloadLen;
_i16 RxPayloadLen;
_i16 ActualRxPayloadLen;
_u8 *pTxPayload;
_u8 *pRxPayload;
}_SlCmdExt_t;
typedef struct _SlArgsData_t
{
_u8 *pArgs;
_u8 *pData;
} _SlArgsData_t;
typedef struct _SlPoolObj_t
{
_SlSyncObj_t SyncObj;
_u8 *pRespArgs;
_u8 ActionID;
_u8 AdditionalData; /* use for socketID and one bit which indicate supprt IPV6 or not (1=support, 0 otherwise) */
_u8 NextIndex;
} _SlPoolObj_t;
typedef enum
{
SOCKET_0,
SOCKET_1,
SOCKET_2,
SOCKET_3,
SOCKET_4,
SOCKET_5,
SOCKET_6,
SOCKET_7,
MAX_SOCKET_ENUM_IDX,
#ifndef SL_TINY_EXT
ACCEPT_ID = MAX_SOCKET_ENUM_IDX,
CONNECT_ID,
#else
CONNECT_ID = MAX_SOCKET_ENUM_IDX,
#endif
#ifndef SL_TINY_EXT
SELECT_ID,
#endif
GETHOSYBYNAME_ID,
#ifndef SL_TINY_EXT
GETHOSYBYSERVICE_ID,
PING_ID,
#endif
START_STOP_ID,
RECV_ID
}_SlActionID_e;
typedef struct _SlActionLookup_t
{
_u8 ActionID;
_u16 ActionAsyncOpcode;
_SlSpawnEntryFunc_t AsyncEventHandler;
} _SlActionLookup_t;
typedef struct
{
_u8 TxPoolCnt;
_SlLockObj_t TxLockObj;
_SlSyncObj_t TxSyncObj;
}_SlFlowContCB_t;
typedef enum
{
RECV_RESP_CLASS,
CMD_RESP_CLASS,
ASYNC_EVT_CLASS,
DUMMY_MSG_CLASS
}_SlRxMsgClass_e;
typedef struct
{
_u8 *pAsyncBuf; /* place to write pointer to buffer with CmdResp's Header + Arguments */
_u8 ActionIndex;
_SlSpawnEntryFunc_t AsyncEvtHandler; /* place to write pointer to AsyncEvent handler (calc-ed by Opcode) */
_SlRxMsgClass_e RxMsgClass; /* type of Rx message */
} AsyncExt_t;
typedef _u8 _SlSd_t;
typedef struct
{
_SlCmdCtrl_t *pCmdCtrl;
_u8 *pTxRxDescBuff;
_SlCmdExt_t *pCmdExt;
AsyncExt_t AsyncExt;
}_SlFunctionParams_t;
typedef struct
{
_SlFd_t FD;
_SlLockObj_t GlobalLockObj;
_SlCommandHeader_t TempProtocolHeader;
P_INIT_CALLBACK pInitCallback;
_SlPoolObj_t ObjPool[MAX_CONCURRENT_ACTIONS];
_u8 FreePoolIdx;
_u8 PendingPoolIdx;
_u8 ActivePoolIdx;
_u32 ActiveActionsBitmap;
_SlLockObj_t ProtectionLockObj;
_SlSyncObj_t CmdSyncObj;
_u8 IsCmdRespWaited;
_SlFlowContCB_t FlowContCB;
_u8 TxSeqNum;
_u8 RxDoneCnt;
_u8 SocketNonBlocking;
_u8 SocketTXFailure;
/* for stack reduction the parameters are globals */
_SlFunctionParams_t FunctionParams;
_u8 ActionIndex;
}_SlDriverCb_t;
extern _volatile _u8 RxIrqCnt;
extern _SlDriverCb_t* g_pCB;
extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
extern void _SlDrvDriverCBInit(void);
extern void _SlDrvDriverCBDeinit(void);
extern void _SlDrvRxIrqHandler(void *pValue);
extern _SlReturnVal_t _SlDrvCmdOp(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern _SlReturnVal_t _SlDrvCmdSend(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern _SlReturnVal_t _SlDrvDataReadOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern _SlReturnVal_t _SlDrvDataWriteOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern void _sl_HandleAsync_InitComplete(void *pVoidBuf);
extern void _sl_HandleAsync_Connect(void *pVoidBuf);
#ifndef SL_TINY_EXT
extern _i16 _SlDrvBasicCmd(_SlOpcode_t Opcode);
extern void _sl_HandleAsync_Accept(void *pVoidBuf);
extern void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf);
extern void _sl_HandleAsync_Select(void *pVoidBuf);
#endif
extern void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf);
extern void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
extern void _sl_HandleAsync_PingResponse(void *pVoidBuf);
extern void _SlDrvNetAppEventHandler(void* pArgs);
extern void _SlDrvDeviceEventHandler(void* pArgs);
extern void _sl_HandleAsync_Stop(void *pVoidBuf);
extern _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID);
extern void _SlDrvReleasePoolObj(_u8 pObj);
extern _u16 _SlDrvAlignSize(_u16 msgLen);
extern _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID);
extern void _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj);
extern void _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj);
extern void _SlDrvObjLock(_SlLockObj_t *pLockObj, _SlTime_t Timeout);
extern void _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj);
extern void _SlDrvProtectionObjLockWaitForever();
extern void _SlDrvObjUnLock(_SlLockObj_t *pLockObj);
extern void _SlDrvProtectionObjUnLock();
extern void _SlDrvMemZero(void* Addr, _u16 size);
extern void _SlDrvResetCmdExt(_SlCmdExt_t* pCmdExt);
#define _SL_PROTOCOL_ALIGN_SIZE(msgLen) (((msgLen)+3) & (~3))
#define _SL_IS_PROTOCOL_ALIGNED_SIZE(msgLen) (!((msgLen) & 3))
#define _SL_PROTOCOL_CALC_LEN(pCmdCtrl,pCmdExt) ((pCmdExt) ? \
(_SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen) + _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->TxPayloadLen)) : \
(_SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen)))
#endif /* __DRIVER_INT_H__ */

View File

@@ -0,0 +1,61 @@
/*
* flowcont.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __FLOWCONT_H__
#define __FLOWCONT_H__
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define FLOW_CONT_MIN 1
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
extern void _SlDrvFlowContInit(void);
extern void _SlDrvFlowContDeinit(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FLOWCONT_H__ */

View File

@@ -0,0 +1,382 @@
/*
* fs.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __FS_H__
#define __FS_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup FileSystem
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/* FS error codes */
#define SL_FS_OK (0)
#define SL_FS_ERR_EMPTY_SFLASH (-67)
#define SL_FS_ERR_FILE_IS_NOT_SECURE_AND_SIGN (-66)
#define SL_FS_ERASING_FLASH (-65)
#define SL_FS_FILE_HAS_NOT_BEEN_CLOSE_CORRECTLY (-64)
#define SL_FS_WRONG_SIGNATURE (-63)
#define SL_FS_WRONG_SIGNATURE_OR_CERTIFIC_NAME_LENGTH (-62)
#define SL_FS_NOT_16_ALIGNED (-61)
#define SL_FS_CERT_CHAIN_ERROR (-60)
#define SL_FS_FILE_NAME_EXIST (-59)
#define SL_FS_SECURITY_BUF_ALREADY_ALLOC (-58)
#define SL_FS_SECURE_FILE_MUST_BE_COMMIT (-57)
#define SL_FS_ERR_INCORRECT_OFFSET_ALIGNMENT (-56)
#define SL_FS_ERR_FAILED_READ_NVMEM_HEADER (-55)
#define SL_FS_WRONG_FILE_NAME (-54)
#define SL_FS_FILE_SYSTEM_IS_LOCKED (-53)
#define SL_FS_SECURITY_ALLERT (-52)
#define SL_FS_FILE_UNVALID_FILE_SIZE (-51)
#define SL_FS_ERR_TOKEN_IS_NOT_VALID (-50)
#define SL_FS_NO_DEVICE_IS_LOADED (-49)
#define SL_FS_DATA_ADDRESS_SHOUD_BE_IN_DATA_RAM (-48)
#define SL_FS_DATA_IS_NOT_ALIGNED (-47)
#define SL_FS_ERR_OVERLAP_DETECTION_THRESHHOLD (-46)
#define SL_FS_FILE_HAS_RESERVED_NV_INDEX (-45)
#define SL_FS_ERR_MAX_FS_FILES_IS_LARGER (-44)
#define SL_FS_ERR_MAX_FS_FILES_IS_SMALLER (-43)
#define SL_FS_FILE_MAX_SIZE_EXCEEDED (-42)
#define SL_FS_INVALID_BUFFER_FOR_READ (-41)
#define SL_FS_INVALID_BUFFER_FOR_WRITE (-40)
#define SL_FS_ERR_FILE_IMAGE_IS_CORRUPTED (-39)
#define SL_FS_ERR_SIZE_OF_FILE_EXT_EXCEEDED (-38)
#define SL_FS_WARNING_FILE_NAME_NOT_KEPT (-37)
#define SL_FS_ERR_DEVICE_IS_NOT_FORMATTED (-36)
#define SL_FS_ERR_FAILED_WRITE_NVMEM_HEADER (-35)
#define SL_FS_ERR_NO_AVAILABLE_NV_INDEX (-34)
#define SL_FS_ERR_FAILED_TO_ALLOCATE_MEM (-33)
#define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_2 (-32)
#define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_1 (-31)
#define SL_FS_ERR_NO_AVAILABLE_BLOCKS (-30)
#define SL_FS_ERR_FILE_MAX_SIZE_BIGGER_THAN_EXISTING_FILE (-29)
#define SL_FS_ERR_FILE_EXISTS_ON_DIFFERENT_DEVICE_ID (-28)
#define SL_FS_ERR_INVALID_ACCESS_TYPE (-27)
#define SL_FS_ERR_FILE_ALREADY_EXISTS (-26)
#define SL_FS_ERR_PROGRAM (-25)
#define SL_FS_ERR_NO_ENTRIES_AVAILABLE (-24)
#define SL_FS_ERR_FILE_ACCESS_IS_DIFFERENT (-23)
#define SL_FS_ERR_BAD_FILE_MODE (-22)
#define SL_FS_ERR_FAILED_READ_NVFILE (-21)
#define SL_FS_ERR_FAILED_INIT_STORAGE (-20)
#define SL_FS_ERR_CONTINUE_WRITE_MUST_BE_MOD_4 (-19)
#define SL_FS_ERR_FAILED_LOAD_FILE (-18)
#define SL_FS_ERR_INVALID_HANDLE (-17)
#define SL_FS_ERR_FAILED_TO_WRITE (-16)
#define SL_FS_ERR_OFFSET_OUT_OF_RANGE (-15)
#define SL_FS_ERR_ALLOC (-14)
#define SL_FS_ERR_READ_DATA_LENGTH (-13)
#define SL_FS_ERR_INVALID_FILE_ID (-12)
#define SL_FS_ERR_FILE_NOT_EXISTS (-11)
#define SL_FS_ERR_EMPTY_ERROR (-10)
#define SL_FS_ERR_INVALID_ARGS (-9)
#define SL_FS_ERR_FAILED_TO_CREATE_FILE (-8)
#define SL_FS_ERR_FS_ALREADY_LOADED (-7)
#define SL_FS_ERR_UNKNOWN (-6)
#define SL_FS_ERR_FAILED_TO_CREATE_LOCK_OBJ (-5)
#define SL_FS_ERR_DEVICE_NOT_LOADED (-4)
#define SL_FS_ERR_INVALID_MAGIC_NUM (-3)
#define SL_FS_ERR_FAILED_TO_READ (-2)
#define SL_FS_ERR_NOT_SUPPORTED (-1)
/* end of error codes */
#define _FS_MODE_ACCESS_RESERVED_OFFSET (24)
#define _FS_MODE_ACCESS_RESERVED_MASK (0xFF)
#define _FS_MODE_ACCESS_FLAGS_OFFSET (16)
#define _FS_MODE_ACCESS_FLAGS_MASK (0xFF)
#define _FS_MODE_ACCESS_OFFSET (12)
#define _FS_MODE_ACCESS_MASK (0xF)
#define _FS_MODE_OPEN_SIZE_GRAN_OFFSET (8)
#define _FS_MODE_OPEN_SIZE_GRAN_MASK (0xF)
#define _FS_MODE_OPEN_SIZE_OFFSET (0)
#define _FS_MODE_OPEN_SIZE_MASK (0xFF)
#define MAX_MODE_SIZE (0xFF)
#define _FS_MODE(Access, SizeGran, Size,Flags) (_u32)(((_u32)((Access) & _FS_MODE_ACCESS_MASK)<<_FS_MODE_ACCESS_OFFSET) | \
((_u32)((SizeGran) & _FS_MODE_OPEN_SIZE_GRAN_MASK)<<_FS_MODE_OPEN_SIZE_GRAN_OFFSET) | \
((_u32)((Size) & _FS_MODE_OPEN_SIZE_MASK)<<_FS_MODE_OPEN_SIZE_OFFSET) | \
((_u32)((Flags) & _FS_MODE_ACCESS_FLAGS_MASK)<<_FS_MODE_ACCESS_FLAGS_OFFSET))
/* sl_FsOpen options */
/* Open for Read */
#define FS_MODE_OPEN_READ _FS_MODE(_FS_MODE_OPEN_READ,0,0,0)
/* Open for Write (in case file exist) */
#define FS_MODE_OPEN_WRITE _FS_MODE(_FS_MODE_OPEN_WRITE,0,0,0)
/* Open for Creating a new file */
#define FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) _sl_GetCreateFsMode(maxSizeInBytes,accessModeFlags)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef struct
{
_u16 flags;
_u32 FileLen;
_u32 AllocatedLen;
_u32 Token[4];
}SlFsFileInfo_t;
typedef enum
{
_FS_MODE_OPEN_READ = 0,
_FS_MODE_OPEN_WRITE,
_FS_MODE_OPEN_CREATE,
_FS_MODE_OPEN_WRITE_CREATE_IF_NOT_EXIST
}SlFsFileOpenAccessType_e;
typedef enum
{
_FS_FILE_OPEN_FLAG_COMMIT = 0x1, /* MIRROR - for fail safe */
_FS_FILE_OPEN_FLAG_SECURE = 0x2, /* SECURE */
_FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST = 0x4, /* Relevant to secure file only */
_FS_FILE_OPEN_FLAG_STATIC = 0x8, /* Relevant to secure file only */
_FS_FILE_OPEN_FLAG_VENDOR = 0x10, /* Relevant to secure file only */
_FS_FILE_PUBLIC_WRITE= 0x20, /* Relevant to secure file only, the file can be opened for write without Token */
_FS_FILE_PUBLIC_READ = 0x40 /* Relevant to secure file only, the file can be opened for read without Token */
}SlFileOpenFlags_e;
typedef enum
{
_FS_MODE_SIZE_GRAN_256B = 0, /* MAX_SIZE = 64K */
_FS_MODE_SIZE_GRAN_1KB, /* MAX_SIZE = 256K */
_FS_MODE_SIZE_GRAN_4KB, /* MAX_SZIE = 1M */
_FS_MODE_SIZE_GRAN_16KB, /* MAX_SIZE = 4M */
_FS_MODE_SIZE_GRAN_64KB, /* MAX_SIZE = 16M */
_FS_MAX_MODE_SIZE_GRAN
}_SlFsFileOpenMaxSizeGran_e;
/*****************************************************************************/
/* Internal Function prototypes */
/*****************************************************************************/
_u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags);
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief open file for read or write from/to storage device
\param[in] pFileName File Name buffer pointer
\param[in] AccessModeAndMaxSize Options: As described below
\param[in] pToken Reserved for future use. Use NULL for this field
\param[out] pFileHandle Pointing on the file and used for read and write commands to the file
AccessModeAndMaxSize possible input \n
FS_MODE_OPEN_READ - Read a file \n
FS_MODE_OPEN_WRITE - Open for write for an existing file \n
FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) - Open for creating a new file. Max file size is defined in bytes. \n
For optimal FS size, use max size in 4K-512 bytes steps (e.g. 3584,7680,117760) \n
Several access modes bits can be combined together from SlFileOpenFlags_e enum
\return On success, zero is returned. On error, an error code is returned
\sa sl_FsRead sl_FsWrite sl_FsClose
\note belongs to \ref basic_api
\warning
\par Example:
\code
char* DeviceFileName = "MyFile.txt";
unsigned long MaxSize = 63 * 1024; //62.5K is max file size
long DeviceFileHandle = -1;
long RetVal; //negative retval is an error
unsigned long Offset = 0;
unsigned char InputBuffer[100];
// Create a file and write data. The file in this example is secured, without signature and with a fail safe commit
RetVal = sl_FsOpen((unsigned char *)DeviceFileName,
FS_MODE_OPEN_CREATE(MaxSize , _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST | _FS_FILE_OPEN_FLAG_COMMIT ),
NULL, &DeviceFileHandle);
Offset = 0;
//Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
RetVal = sl_FsWrite( DeviceFileHandle, Offset, (unsigned char *)"HelloWorld", strlen("HelloWorld"));
RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
// open the same file for read, using the Token we got from the creation procedure above
RetVal = sl_FsOpen((unsigned char *)DeviceFileName,
FS_MODE_OPEN_READ,
NULL, &DeviceFileHandle);
Offset = 0;
RetVal = sl_FsRead( DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));
RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsOpen)
_i32 sl_FsOpen(const _u8 *pFileName,const _u32 AccessModeAndMaxSize,_u32 *pToken,_i32 *pFileHandle);
#endif
/*!
\brief close file in storage device
\param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
\param[in] pCeritificateFileName Reserved for future use. Use NULL.
\param[in] pSignature Reserved for future use. Use NULL.
\param[in] SignatureLen Reserved for future use. Use 0.
\return On success, zero is returned. On error, an error code is returned
\sa sl_FsRead sl_FsWrite sl_FsOpen
\note Call the fs_Close with signature = 'A' signature len = 1 for activating an abort action
\warning
\par Example:
\code
sl_FsClose(FileHandle,0,0,0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsClose)
_i16 sl_FsClose(const _i32 FileHdl,const _u8* pCeritificateFileName,const _u8* pSignature,const _u32 SignatureLen);
#endif
/*!
\brief Read block of data from a file in storage device
\param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
\param[in] Offset Offset to specific read block
\param[out] pData Pointer for the received data
\param[in] Len Length of the received data
\return On success, returns the number of read bytes. On error, negative number is returned
\sa sl_FsClose sl_FsWrite sl_FsOpen
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsRead(FileHandle, 0, &readBuff[0], readSize);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsRead)
_i32 sl_FsRead(const _i32 FileHdl,_u32 Offset ,_u8* pData,_u32 Len);
#endif
/*!
\brief write block of data to a file in storage device
\param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
\param[in] Offset Offset to specific block to be written
\param[in] pData Pointer the transmitted data to the storage device
\param[in] Len Length of the transmitted data
\return On success, returns the number of written bytes. On error, an error code is returned
\sa
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsWrite(FileHandle, 0, &buff[0], readSize);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsWrite)
_i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset,_u8* pData,_u32 Len);
#endif
/*!
\brief get info on a file
\param[in] pFileName File name
\param[in] Token Reserved for future use. Use 0
\param[out] pFsFileInfo Returns the File's Information: flags,file size, allocated size and Tokens
\return On success, zero is returned. On error, an error code is returned
\sa sl_FsOpen
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsGetInfo("FileName.html",0,&FsFileInfo);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsGetInfo)
_i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileInfo);
#endif
/*!
\brief Delete specific file from a storage or all files from a storage (format)
\param[in] pFileName File Name
\param[in] Token Reserved for future use. Use 0
\return On success, zero is returned. On error, an error code is returned
\sa
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsDel("FileName.html",0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsDel)
_i16 sl_FsDel(const _u8 *pFileName,const _u32 Token);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FS_H__ */

View File

@@ -0,0 +1,884 @@
/*
* netapp.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __NETAPP_H__
#define __NETAPP_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup netapp
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/*ERROR code*/
#define SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR (-230)
/* Http Server interface */
#define MAX_INPUT_STRING (64) /* because of WPA */
#define MAX_AUTH_NAME_LEN (20)
#define MAX_AUTH_PASSWORD_LEN (20)
#define MAX_AUTH_REALM_LEN (20)
#define MAX_DEVICE_URN_LEN (15+1)
#define MAX_DOMAIN_NAME_LEN (24+1)
#define MAX_ACTION_LEN (30)
/* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
#define MAX_TOKEN_NAME_LEN (20)
#define MAX_TOKEN_VALUE_LEN MAX_INPUT_STRING
#define NETAPP_MAX_SERVICE_TEXT_SIZE (256)
#define NETAPP_MAX_SERVICE_NAME_SIZE (60)
#define NETAPP_MAX_SERVICE_HOST_NAME_SIZE (64)
/* Server Responses */
#define SL_NETAPP_RESPONSE_NONE (0)
#define SL_NETAPP_HTTPSETTOKENVALUE (1)
#define SL_NETAPP_FAMILY_MASK (0x80)
/* mDNS types */
#define SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE (0x00000001)
#define SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE (0x00000002)
#define SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE (0x00000004)
#define SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE (0x00000008)
#define SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE (0x00000010)
#define SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE (0x00000020)
#define SL_NET_APP_MASK_H323_TYPE_OF_SERVICE (0x00000040)
#define SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE (0x00000080)
#define SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE (0x00000100)
#define SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE (0x00000200)
#define SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE (0x00000400)
#define SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE (0x00000800)
#define SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE (0x00001000)
#define SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE (0x00002000)
#define SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE (0x00004000)
#define SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE (0x00008000)
#define SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE (0x00010000)
#define SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE (0x00020000)
#define SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE (0x00040000)
#define SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE (0x00080000)
#define SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE (0xFFFFFFFF)
/********************************************************************************************************/
/* sl_NetAppDnsGetHostByName error codes */
#define SL_NET_APP_DNS_QUERY_NO_RESPONSE (-159) /* DNS query failed, no response */
#define SL_NET_APP_DNS_NO_SERVER (-161) /* No DNS server was specified */
#define SL_NET_APP_DNS_PARAM_ERROR (-162) /* mDNS parameters error */
#define SL_NET_APP_DNS_QUERY_FAILED (-163) /* DNS query failed; no DNS server sent an 'answer' */
#define SL_NET_APP_DNS_INTERNAL_1 (-164)
#define SL_NET_APP_DNS_INTERNAL_2 (-165)
#define SL_NET_APP_DNS_MALFORMED_PACKET (-166) /* Improperly formed or corrupted DNS packet received */
#define SL_NET_APP_DNS_INTERNAL_3 (-167)
#define SL_NET_APP_DNS_INTERNAL_4 (-168)
#define SL_NET_APP_DNS_INTERNAL_5 (-169)
#define SL_NET_APP_DNS_INTERNAL_6 (-170)
#define SL_NET_APP_DNS_INTERNAL_7 (-171)
#define SL_NET_APP_DNS_INTERNAL_8 (-172)
#define SL_NET_APP_DNS_INTERNAL_9 (-173)
#define SL_NET_APP_DNS_MISMATCHED_RESPONSE (-174) /* Server response type does not match the query request*/
#define SL_NET_APP_DNS_INTERNAL_10 (-175)
#define SL_NET_APP_DNS_INTERNAL_11 (-176)
#define SL_NET_APP_DNS_NO_ANSWER (-177) /* No response for one-shot query */
#define SL_NET_APP_DNS_NO_KNOWN_ANSWER (-178) /* No known answer for query */
#define SL_NET_APP_DNS_NAME_MISMATCH (-179) /* Illegal service name according to the RFC */
#define SL_NET_APP_DNS_NOT_STARTED (-180) /* mDNS is not running */
#define SL_NET_APP_DNS_HOST_NAME_ERROR (-181) /* Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 */
#define SL_NET_APP_DNS_NO_MORE_ENTRIES (-182) /* No more entries be found. */
#define SL_NET_APP_DNS_MAX_SERVICES_ERROR (-200) /* Maximum advertise services are already configured */
#define SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR (-201) /* Trying to register a service that is already exists */
#define SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR (-203) /* Trying to delete service that does not existed */
#define SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR (-204) /* Illegal service name according to the RFC */
#define SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR (-205) /* Retry request */
#define SL_NET_APP_DNS_BUFFER_SIZE_ERROR (-206) /* List size buffer is bigger than internally allowed in the NWP */
#define SL_NET_APP_DNS_NET_APP_SET_ERROR (-207) /* Illegal length of one of the mDNS Set functions */
#define SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR (-208)
#define SL_NET_APP_DNS_NO_CONFIGURATION_ERROR (-209)
/* Set Dev name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
#define SL_ERROR_DEVICE_NAME_LEN_ERR (-117)
#define SL_ERROR_DEVICE_NAME_INVALID (-118)
/* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
#define SL_ERROR_DOMAIN_NAME_LEN_ERR (-119)
#define SL_ERROR_DOMAIN_NAME_INVALID (-120)
/********************************************************************************************************/
/* NetApp application IDs */
#define SL_NET_APP_HTTP_SERVER_ID (1)
#define SL_NET_APP_DHCP_SERVER_ID (2)
#define SL_NET_APP_MDNS_ID (4)
#define SL_NET_APP_DNS_SERVER_ID (8)
#define SL_NET_APP_DEVICE_CONFIG_ID (16)
/* NetApp application set/get options */
#define NETAPP_SET_DHCP_SRV_BASIC_OPT (0)
/* HTTP server set/get options */
#define NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER (0)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK (1)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_NAME (2)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD (3)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_REALM (4)
#define NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS (5)
#define NETAPP_SET_GET_MDNS_CONT_QUERY_OPT (1)
#define NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT (2)
#define NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT (3)
/* DNS server set/get options */
#define NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME (0)
/* Device Config set/get options */
#define NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN (0)
#define NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME (1)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef struct
{
_u32 PacketsSent;
_u32 PacketsReceived;
_u16 MinRoundTime;
_u16 MaxRoundTime;
_u16 AvgRoundTime;
_u32 TestTime;
}SlPingReport_t;
typedef struct
{
_u32 PingIntervalTime; /* delay between pings, in milliseconds */
_u16 PingSize; /* ping packet size in bytes */
_u16 PingRequestTimeout; /* timeout time for every ping in milliseconds */
_u32 TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */
_u32 Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. */
_u32 Ip; /* IPv4 address or IPv6 first 4 bytes */
_u32 Ip1OrPaadding;
_u32 Ip2OrPaadding;
_u32 Ip3OrPaadding;
}SlPingStartCommand_t;
typedef struct _slHttpServerString_t
{
_u8 len;
_u8 *data;
} slHttpServerString_t;
typedef struct _slHttpServerData_t
{
_u8 value_len;
_u8 name_len;
_u8 *token_value;
_u8 *token_name;
} slHttpServerData_t;
typedef struct _slHttpServerPostData_t
{
slHttpServerString_t action;
slHttpServerString_t token_name;
slHttpServerString_t token_value;
}slHttpServerPostData_t;
typedef union
{
slHttpServerString_t httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
slHttpServerPostData_t httpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */
} SlHttpServerEventData_u;
typedef union
{
slHttpServerString_t token_value;
} SlHttpServerResponsedata_u;
typedef struct
{
_u32 Event;
SlHttpServerEventData_u EventData;
}SlHttpServerEvent_t;
typedef struct
{
_u32 Response;
SlHttpServerResponsedata_u ResponseData;
}SlHttpServerResponse_t;
typedef struct
{
_u32 lease_time;
_u32 ipv4_addr_start;
_u32 ipv4_addr_last;
}SlNetAppDhcpServerBasicOpt_t;
/*mDNS parameters*/
typedef enum
{
SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
} SlNetAppGetServiceListType_e;
typedef struct
{
_u32 service_ipv4;
_u16 service_port;
_u16 Reserved;
}SlNetAppGetShortServiceIpv4List_t;
typedef struct
{
_u32 service_ipv4;
_u16 service_port;
_u16 Reserved;
_u8 service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
_u8 service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
}SlNetAppGetFullServiceIpv4List_t;
typedef struct
{
_u32 service_ipv4;
_u16 service_port;
_u16 Reserved;
_u8 service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
_u8 service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
_u8 service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
}SlNetAppGetFullServiceWithTextIpv4List_t;
typedef struct
{
/*The below parameters are used to configure the advertise times and interval
For example:
If:
Period is set to T
Repetitions are set to P
Telescopic factor is K=2
The transmission shall be:
advertise P times
wait T
advertise P times
wait 4 * T
advertise P time
wait 16 * T ... (till max time reached / configuration changed / query issued)
*/
_u32 t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
_u32 p; /* Number of repetitions. Default value is 1 */
_u32 k; /* Telescopic factor. Default value is 2. */
_u32 RetransInterval;/* Announcing retransmission interval */
_u32 Maxinterval; /* Announcing max period interval */
_u32 max_time; /* Announcing max time */
}SlNetAppServiceAdvertiseTimingParameters_t;
/*****************************************************************************/
/* Types declarations */
/*****************************************************************************/
typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Starts a network application
Gets and starts network application for the current WLAN mode
\param[in] AppBitMap application bitmap, could be one or combination of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
\return On error, negative number is returned
\sa Stop one or more the above started applications using sl_NetAppStop
\note This command activates the application for the current WLAN mode (AP or STA)
\warning
\par Example:
\code
For example: Starting internal HTTP server + DHCP server:
sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppStart)
_i16 sl_NetAppStart(const _u32 AppBitMap);
#endif
/*!
\brief Stops a network application
Gets and stops network application for the current WLAN mode
\param[in] AppBitMap application id, could be one of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
\return On error, negative number is returned
\sa
\note This command disables the application for the current active WLAN mode (AP or STA)
\warning
\par Example:
\code
For example: Stopping internal HTTP server:
sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppStop)
_i16 sl_NetAppStop(const _u32 AppBitMap);
#endif
/*!
\brief Get host IP by name
Obtain the IP Address of machine on network, by machine name.
\param[in] hostname host name
\param[in] usNameLen name length
\param[out] out_ip_addr This parameter is filled in with
host IP address. In case that host name is not
resolved, out_ip_addr is zero.
\param[in] family protocol family
\return On success, 0 is returned.
On error, negative is returned
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
Possible DNS error codes:
- SL_NET_APP_DNS_QUERY_NO_RESPONSE
- SL_NET_APP_DNS_NO_SERVER
- SL_NET_APP_DNS_QUERY_FAILED
- SL_NET_APP_DNS_MALFORMED_PACKET
- SL_NET_APP_DNS_MISMATCHED_RESPONSE
\sa
\note Only one sl_NetAppDnsGetHostByName can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning
In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not
try to access the DNS and it will return the input address on the 'out_ip_addr' field
\par Example:
\code
_u32 DestinationIP;
sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(80);
Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
AddrSize = sizeof(SlSockAddrIn_t);
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
_i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ip_addr,const _u8 family );
#endif
/*!
\brief Return service attributes like IP address, port and text according to service name
\par
The user sets a service name Full/Part (see example below), and should get:
- IP of service
- The port of service
- The text of service
Hence it can make a connection to the specific service and use it.
It is similar to get host by name method.
It is done by a single shot query with PTR type on the service name.
The command that is sent is from constant parameters and variables parameters.
\param[in] pService Service name can be full or partial. \n
Example for full service name:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local \n
.
Example for partial service name:
1. _ipp._tcp.local
2. _ftp._tcp.local
\param[in] ServiceLen The length of the service name (in_pService).
\param[in] Family IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
\param[out] pAddr Contains the IP address of the service.
\param[out] pPort Contains the port of the service.
\param[out] pTextLen Has 2 options. One as Input field and the other one as output:
- Input: \n
Contains the max length of the text that the user wants to get.\n
It means that if the text len of service is bigger that its value than
the text is cut to inout_TextLen value.
- Output: \n
Contain the length of the text that is returned. Can be full text or part of the text (see above).
\param[out] pOut_pText Contains the text of the service full or partial
\return On success, zero is returned
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
\note The returns attributes belongs to the first service found.
There may be other services with the same service name that will response to the query.
The results of these responses are saved in the peer cache of the Device and should be read by another API.
Only one sl_NetAppDnsGetHostByService can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning Text length can be 120 bytes only
*/
#if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
_i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */
const _u8 ServiceLen,
const _u8 Family, /* 4-IPv4 , 16-IPv6 */
_u32 pAddr[],
_u32 *pPort,
_u16 *pTextLen, /* in: max len , out: actual len */
_i8 *pText
);
#endif
/*!
\brief Get service List
Insert into out pBuffer a list of peer's services that are the NWP.
The list is in a form of service struct. The user should chose the type
of the service struct like:
- Full service parameters with text.
- Full service parameters.
- Short service parameters (port and IP only) especially for tiny hosts.
The different types of struct are made to give the
Possibility to save memory in the host
The user also chose how many max services to get and start point index
NWP peer cache.
For example:
1. Get max of 3 full services from index 0.Up to 3 full services
from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
2. Get max of 4 full services from index 3.Up to 4 full services
from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
3. Get max of 2 int services from index 6.Up to 2 int services
from index 6 are inserted into pBuffer (services that are in indexes 6,7).
See below - command parameters.
\param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
\param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
in the peer cache
\param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
- use SlNetAppGetFullServiceWithTextIpv4List_t
- use SlNetAppGetFullServiceIpv4List_t
- use SlNetAppGetShortServiceIpv4List_t
\param[out] Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
input parameter.
\return ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
negative number means an error
\sa sl_NetAppMDNSRegisterService
\note
\warning
if the out pBuffer size is bigger than an RX packet(1480), than
an error is returned because there
is no place in the RX packet.
The size is a multiply of MaxServiceCount and size of service struct(that is set
according to flag value).
*/
#if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
_i16 sl_NetAppGetServiceList(const _u8 IndexOffest,
const _u8 MaxServiceCount,
const _u8 Flags,
_i8 *pBuffer,
const _u32 RxBufferLength
);
#endif
/*!
\brief Unregister mDNS service
This function deletes the mDNS service from the mDNS package and the database.
The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
The service name should be the full service name according to RFC
of the DNS-SD - meaning the value in name field in the SRV answer.
Examples for service names:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
\param[in] pServiceName Full service name. \n
Example for service name:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
\param[in] ServiceLen The length of the service.
\return On success, zero is returned
\sa sl_NetAppMDNSRegisterService
\note
\warning
The size of the service length should be smaller than 255.
*/
#if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
_i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNameLen);
#endif
/*!
\brief Register a new mDNS service
\par
This function registers a new mDNS service to the mDNS package and the DB.
This registered service is a service offered by the application.
The service name should be full service name according to RFC
of the DNS-SD - meaning the value in name field in the SRV answer.
Example for service name:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
If the option is_unique is set, mDNS probes the service name to make sure
it is unique before starting to announce the service on the network.
Instance is the instance portion of the service name.
\param[in] ServiceLen The length of the service.
\param[in] TextLen The length of the service should be smaller than 64.
\param[in] port The port on this target host port.
\param[in] TTL The TTL of the service
\param[in] Options bitwise parameters: \n
- bit 0 - service is unique (means that the service needs to be unique)
- bit 31 - for internal use if the service should be added or deleted (set means ADD).
- bit 1-30 for future.
\param[in] pServiceName The service name.
Example for service name: \n
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
\param[in] pText The description of the service.
should be as mentioned in the RFC
(according to type of the service IPP,FTP...)
\return On success, zero is returned
Possible error codes:
- Maximum advertise services are already configured.
Delete another existed service that is registered and then register again the new service
- Trying to register a service that is already exists
- Trying to delete service that does not existed
- Illegal service name according to the RFC
- Retry request
- Illegal length of one of the mDNS Set functions
- mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
- mDNS parameters error
- mDNS internal cache error
- mDNS internal error
- Adding a service is not allowed as it is already exist (duplicate service)
- mDNS is not running
- Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
- List size buffer is bigger than internally allowed in the NWP (API get service list),
change the APIs<49> parameters to decrease the size of the list
\sa sl_NetAppMDNSUnRegisterService
\warning 1) Temporary - there is an allocation on stack of internal buffer.
Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
It means that the sum of the text length and service name length cannot be bigger than
NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
If it is - An error is returned. \n
2) According to now from certain constraints the variables parameters are set in the
attribute part (contain constant parameters)
*/
#if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
_i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName,
const _u8 ServiceNameLen,
const _i8* pText,
const _u8 TextLen,
const _u16 Port,
const _u32 TTL,
_u32 Options);
#endif
/*!
\brief send ICMP ECHO_REQUEST to network hosts
Ping uses the ICMP protocol's mandatory ECHO_REQUEST
\param[in] pPingParams Pointer to the ping request structure: \n
- if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
- if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
- if flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones.
For stopping an ongoing ping activity, set parameters IP address to 0
\param[in] family SL_AF_INET or SL_AF_INET6
\param[out] pReport Ping pReport
\param[out] pCallback Callback function upon completion.
If callback is NULL, the API is blocked until data arrives
\return On success, zero is returned. On error, -1 is returned
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_NetAppPingReport
\note Only one sl_NetAppPingStart can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning
\par Example:
\code
An example of sending 20 ping requests and reporting results to a callback routine when
all requests are sent:
// callback routine
void pingRes(SlPingReport_t* pReport)
{
// handle ping results
}
// ping activation
void PingTest()
{
SlPingReport_t report;
SlPingStartCommand_t pingCommand;
pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
pingCommand.PingSize = 150; // size of ping, in bytes
pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever
pingCommand.Flags = 0; // report only when finished
sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
_i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback);
#endif
/*!
\brief Internal function for setting network application configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] AppId Application id, could be one of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
- SL_NET_APP_DEVICE_CONFIG_ID
\param[in] SetOptions set option, could be one of the following: \n
- SL_NET_APP_DHCP_SERVER_ID
- NETAPP_SET_DHCP_SRV_BASIC_OPT
- SL_NET_APP_HTTP_SERVER_ID
- NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
- NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
- NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
- NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
- NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
- NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
- SL_NET_APP_MDNS_ID
- NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
- NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
- NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
- SL_NET_APP_DEVICE_CONFIG_ID
- NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
- NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
\param[in] OptionLen option structure length
\param[in] pOptionValues pointer to the option structure
\sa
\note
\warning
\par
\code
Set DHCP Server (AP mode) parameters example:
SlNetAppDhcpServerBasicOpt_t dhcpParams;
_u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
dhcpParams.ipv4_addr_start = SL_IPV4_VAL(192,168,1,10); // first IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
dhcpParams.ipv4_addr_last = SL_IPV4_VAL(192,168,1,16); // last IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID); // Stop DHCP server before settings
sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (_u8* )&dhcpParams); // set parameters
sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID); // Start DHCP server with new settings
\endcode
\code
Set Device URN name example:
Device name, maximum length of 33 characters
Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
In case no device URN name set, the default name is "mysimplelink"
Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
_u8 *my_device = "MY-SIMPLELINK-DEV";
sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (_u8 *) my_device);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppSet)
_i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u8 *pOptionValue);
#endif
/*!
\brief Internal function for getting network applications configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] AppId Application id, could be one of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
- SL_NET_APP_DEVICE_CONFIG_ID
\param[in] SetOptions set option, could be one of the following: \n
- SL_NET_APP_DHCP_SERVER_ID
- NETAPP_SET_DHCP_SRV_BASIC_OPT
- SL_NET_APP_HTTP_SERVER_ID
- NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
- NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
- NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
- NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
- NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
- NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
- SL_NET_APP_MDNS_ID
- NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
- NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
- NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
- SL_NET_APP_DEVICE_CONFIG_ID
- NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
- NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
\param[in] OptionLen The 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 ESMALLBUF
\param[out] pValues pointer to the option structure which will be filled with the response from the device
\sa
\note
\warning
\par
\code
Get DHCP Server parameters example:
SlNetAppDhcpServerBasicOpt_t dhcpParams;
_u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (_u8* )&dhcpParams);
printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
dhcpParams.lease_time);
\endcode
\code
Get Device URN name example:
Maximum length of 33 characters of device name.
Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
in case no device URN name set, the default name is "mysimplelink"
_u8 my_device_name[35];
sl_NetAppGet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device_name), (_u8 *)my_device_name);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppGet)
_i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __NETAPP_H__ */

View File

@@ -0,0 +1,283 @@
/*
* netcfg.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __NETCFG_H__
#define __NETCFG_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup netcfg
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define SL_MAC_ADDR_LEN (6)
#define SL_IPV4_VAL(add_3,add_2,add_1,add_0) ((((_u32)add_3 << 24) & 0xFF000000) | (((_u32)add_2 << 16) & 0xFF0000) | (((_u32)add_1 << 8) & 0xFF00) | ((_u32)add_0 & 0xFF) )
#define SL_IPV4_BYTE(val,index) ( (val >> (index*8)) & 0xFF )
#define IPCONFIG_MODE_DISABLE_IPV4 (0)
#define IPCONFIG_MODE_ENABLE_IPV4 (1)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef enum
{
SL_MAC_ADDRESS_SET = 1,
SL_MAC_ADDRESS_GET = 2,
SL_IPV4_STA_P2P_CL_GET_INFO = 3,
SL_IPV4_STA_P2P_CL_DHCP_ENABLE = 4,
SL_IPV4_STA_P2P_CL_STATIC_ENABLE = 5,
SL_IPV4_AP_P2P_GO_GET_INFO = 6,
SL_IPV4_AP_P2P_GO_STATIC_ENABLE = 7,
SL_SET_HOST_RX_AGGR = 8,
MAX_SETTINGS = 0xFF
}Sl_NetCfg_e;
typedef struct
{
_u32 ipV4;
_u32 ipV4Mask;
_u32 ipV4Gateway;
_u32 ipV4DnsServer;
}SlNetCfgIpV4Args_t;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Internal function for setting network configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] ConfigId configuration id
\param[in] ConfigOpt configurations option
\param[in] ConfigLen configurations len
\param[in] pValues configurations values
\sa
\note
\warning
\par Examples:
\code
SL_MAC_ADDRESS_SET:
Setting MAC address to the Device.
The new MAC address will override the default MAC address and it be saved in the FileSystem.
Requires restarting the device for updating this setting.
_u8 MAC_Address[6];
MAC_Address[0] = 0x8;
MAC_Address[1] = 0x0;
MAC_Address[2] = 0x28;
MAC_Address[3] = 0x22;
MAC_Address[4] = 0x69;
MAC_Address[5] = 0x31;
sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)newMacAddress);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
\code
SL_IPV4_STA_P2P_CL_STATIC_ENABLE:
Setting a static IP address to the device working in STA mode or P2P client.
The IP address will be stored in the FileSystem.
In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET
SlNetCfgIpV4Args_t ipV4;
ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P
ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
\code
SL_IPV4_STA_P2P_CL_DHCP_ENABLE:
Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client.
This should be done once if using Serial Flash.
This is the system's default mode for acquiring an IP address after WLAN connection.
_u8 val = 1;
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,1,&val);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
\code
SL_IPV4_AP_P2P_GO_STATIC_ENABLE:
Setting a static IP address to the device working in AP mode or P2P go.
The IP address will be stored in the FileSystem. Requires restart.
SlNetCfgIpV4Args_t ipV4;
ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this AP/P2P
ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetCfgSet)
_i32 sl_NetCfgSet(const _u8 ConfigId,const _u8 ConfigOpt,const _u8 ConfigLen,const _u8 *pValues);
#endif
/*!
\brief Internal function for getting network configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] ConfigId configuration id
\param[out] pConfigOpt Get configurations option
\param[out] pConfigLen The 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.\n
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 ESMALLBUF
\param[out] pValues - get configurations values
\sa
\note
\warning
\par Examples:
\code
SL_MAC_ADDRESS_GET:
Get the device MAC address.
The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address
is retrieved from HW.
_u8 macAddressVal[SL_MAC_ADDR_LEN];
_u8 macAddressLen = SL_MAC_ADDR_LEN;
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(_u8 *)macAddressVal);
\endcode
\code
SL_IPV4_STA_P2P_CL_GET_INFO:
Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP.
_u8 len = sizeof(SlNetCfgIpV4Args_t);
_u8 dhcpIsOn = 0;
SlNetCfgIpV4Args_t ipV4 = {0};
sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
(dhcpIsOn > 0) ? "ON" : "OFF",
SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
\endcode
\code
SL_IPV4_AP_P2P_GO_GET_INFO:
Get static IP address for AP or P2P go.
_u8 len = sizeof(SlNetCfgIpV4Args_t);
_u8 dhcpIsOn = 0; // this flag is meaningless on AP/P2P go.
SlNetCfgIpV4Args_t ipV4 = {0};
sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetCfgGet)
_i32 sl_NetCfgGet(const _u8 ConfigId ,_u8 *pConfigOpt, _u8 *pConfigLen, _u8 *pValues);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __NETCFG_H__ */

View File

@@ -0,0 +1,325 @@
/*
* nonos.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __NONOS_H__
#define __NONOS_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SL_PLATFORM_MULTI_THREADED
/* This function call the user defined function, if defined, from the sync wait loop */
/* The use case of this function is to allow nonos system to call a user function to put the device into sleep */
/* The wake up should be activated after getting an interrupt from the device to Host */
/* The user function must return without blocking to prevent a delay on the event handling */
/*
#define _SlSyncWaitLoopCallback UserSleepFunction
*/
#define NONOS_WAIT_FOREVER 0xFF
#define NONOS_NO_WAIT 0x00
#define NONOS_RET_OK (0)
#define NONOS_RET_ERR (0xFF)
#define OSI_OK NONOS_RET_OK
#define __NON_OS_SYNC_OBJ_CLEAR_VALUE 0x11
#define __NON_OS_SYNC_OBJ_SIGNAL_VALUE 0x22
#define __NON_OS_LOCK_OBJ_UNLOCK_VALUE 0x33
#define __NON_OS_LOCK_OBJ_LOCK_VALUE 0x44
/*!
\brief type definition for the return values of this adaptation layer
*/
typedef _i8 _SlNonOsRetVal_t;
/*!
\brief type definition for a time value
*/
typedef _u8 _SlNonOsTime_t;
/*!
\brief type definition for a sync object container
Sync object is object used to synchronize between two threads or thread and interrupt handler.
One thread is waiting on the object and the other thread send a signal, which then
release the waiting thread.
The signal must be able to be sent from interrupt context.
This object is generally implemented by binary semaphore or events.
*/
typedef _u8 _SlNonOsSemObj_t;
#define _SlTime_t _SlNonOsTime_t
#define _SlSyncObj_t _SlNonOsSemObj_t
#define _SlLockObj_t _SlNonOsSemObj_t
#define SL_OS_WAIT_FOREVER NONOS_WAIT_FOREVER
#define SL_OS_RET_CODE_OK NONOS_RET_OK
#define SL_OS_NO_WAIT NONOS_NO_WAIT
/*!
\brief This function creates a sync object
The sync object is used for synchronization between different thread or ISR and
a thread.
\param pSyncObj - pointer to the sync object control block
\return upon successful creation the function return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjCreate(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_CLEAR_VALUE)
/*!
\brief This function deletes a sync object
\param pSyncObj - pointer to the sync object control block
\return upon successful deletion the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0)
/*!
\brief This function generates a sync signal for the object.
All suspended threads waiting on this sync object are resumed
\param pSyncObj - pointer to the sync object control block
\return upon successful signaling the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note the function could be called from ISR context
\warning
*/
#define _SlNonOsSyncObjSignal(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE)
/*!
\brief This function waits for a sync signal of the specific sync object
\param pSyncObj - pointer to the sync object control block
\param Timeout - numeric value specifies the maximum number of mSec to
stay suspended while waiting for the sync signal
Currently, the simple link driver uses only two values:
- NONOS_WAIT_FOREVER
- NONOS_NO_WAIT
\return upon successful reception of the signal within the timeout window return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjWait(pSyncObj , Timeout) _SlNonOsSemGet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE,__NON_OS_SYNC_OBJ_CLEAR_VALUE,Timeout)
/*!
\brief This function clears a sync object
\param pSyncObj - pointer to the sync object control block
\return upon successful clearing the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjClear(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_CLEAR_VALUE)
/*!
\brief This function creates a locking object.
The locking object is used for protecting a shared resources between different
threads.
\param pLockObj - pointer to the locking object control block
\return upon successful creation the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjCreate(pLockObj) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
/*!
\brief This function deletes a locking object.
\param pLockObj - pointer to the locking object control block
\return upon successful deletion the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0)
/*!
\brief This function locks a locking object.
All other threads that call this function before this thread calls
the _SlNonOsLockObjUnlock would be suspended
\param pLockObj - pointer to the locking object control block
\param Timeout - numeric value specifies the maximum number of mSec to
stay suspended while waiting for the locking object
Currently, the simple link driver uses only two values:
- NONOS_WAIT_FOREVER
- NONOS_NO_WAIT
\return upon successful reception of the locking object the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjLock(pLockObj , Timeout) _SlNonOsSemGet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE,__NON_OS_LOCK_OBJ_LOCK_VALUE,Timeout)
/*!
\brief This function unlock a locking object.
\param pLockObj - pointer to the locking object control block
\return upon successful unlocking the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjUnlock(pLockObj) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
/*!
\brief This function call the pEntry callback from a different context
\param pEntry - pointer to the entry callback function
\param pValue - pointer to any type of memory structure that would be
passed to pEntry callback from the execution thread.
\param flags - execution flags - reserved for future usage
\return upon successful registration of the spawn the function return 0
(the function is not blocked till the end of the execution of the function
and could be returned before the execution is actually completed)
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
_SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags);
/*!
\brief This function must be called from the main loop in non-os paltforms
\param None
\return 0 - No more activities
1 - Activity still in progress
\note
\warning
*/
_SlNonOsRetVal_t _SlNonOsMainLoopTask(void);
extern _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout);
extern _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value);
extern _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags);
#if (defined(_SlSyncWaitLoopCallback))
extern void _SlSyncWaitLoopCallback(void);
#endif
/*****************************************************************************
Overwrite SimpleLink driver OS adaptation functions
*****************************************************************************/
#undef sl_SyncObjCreate
#define sl_SyncObjCreate(pSyncObj,pName) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_CLEAR_VALUE)
#undef sl_SyncObjDelete
#define sl_SyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0)
#undef sl_SyncObjSignal
#define sl_SyncObjSignal(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE)
#undef sl_SyncObjSignalFromIRQ
#define sl_SyncObjSignalFromIRQ(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE)
#undef sl_SyncObjWait
#define sl_SyncObjWait(pSyncObj,Timeout) _SlNonOsSemGet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE,__NON_OS_SYNC_OBJ_CLEAR_VALUE,Timeout)
#undef sl_LockObjCreate
#define sl_LockObjCreate(pLockObj,pName) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
#undef sl_LockObjDelete
#define sl_LockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0)
#undef sl_LockObjLock
#define sl_LockObjLock(pLockObj,Timeout) _SlNonOsSemGet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE,__NON_OS_LOCK_OBJ_LOCK_VALUE,Timeout)
#undef sl_LockObjUnlock
#define sl_LockObjUnlock(pLockObj) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
#undef sl_Spawn
#define sl_Spawn(pEntry,pValue,flags) _SlNonOsSpawn(pEntry,pValue,flags)
#undef _SlTaskEntry
#define _SlTaskEntry _SlNonOsMainLoopTask
#endif /* !SL_PLATFORM_MULTI_THREADED */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,322 @@
/*
* objInclusion.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <simplelink.h>
#ifndef OBJINCLUSION_H_
#define OBJINCLUSION_H_
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
For future use
*******************************************************************************/
#define __inln /* if inline functions requiered: #define __inln inline */
#define SL_DEVICE /* Device silo is currently always mandatory */
/******************************************************************************
Qualifiers for package customizations
*******************************************************************************/
#if defined (SL_DEVICE)
#define __dev 1
#else
#define __dev 0
#endif
#if defined (SL_DEVICE) && defined (SL_INC_EXT_API)
#define __dev__ext 1
#else
#define __dev__ext 0
#endif
#if (!defined (SL_PLATFORM_MULTI_THREADED)) || (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
#define __int__spwn 1
#else
#define __int__spwn 0
#endif
#if defined (SL_INC_NET_APP_PKG)
#define __nap 1
#else
#define __nap 0
#endif
#if defined (SL_INC_NET_APP_PKG) && defined (SL_INC_SOCK_CLIENT_SIDE_API)
#define __nap__clt 1
#else
#define __nap__clt 0
#endif
#if defined (SL_INC_NET_APP_PKG) && defined (SL_INC_EXT_API)
#define __nap__ext 1
#else
#define __nap__ext 0
#endif
#if defined (SL_INC_NET_CFG_PKG)
#define __ncg 1
#else
#define __ncg 0
#endif
#if defined (SL_INC_NET_CFG_PKG) && defined (SL_INC_EXT_API)
#define __ncg__ext 1
#else
#define __ncg__ext 0
#endif
#if defined (SL_INC_NVMEM_PKG)
#define __nvm 1
#else
#define __nvm 0
#endif
#if defined (SL_INC_SOCKET_PKG)
#define __sck 1
#else
#define __sck 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_EXT_API)
#define __sck__ext 1
#else
#define __sck__ext 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_SERVER_SIDE_API)
#define __sck__srv 1
#else
#define __sck__srv 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_CLIENT_SIDE_API)
#define __sck__clt 1
#else
#define __sck__clt 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_RECV_API)
#define __sck__rcv 1
#else
#define __sck__rcv 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_SEND_API)
#define __sck__snd 1
#else
#define __sck__snd 0
#endif
#if defined (SL_INC_WLAN_PKG)
#define __wln 1
#else
#define __wln 0
#endif
#if defined (SL_INC_WLAN_PKG) && defined (SL_INC_EXT_API)
#define __wln__ext 1
#else
#define __wln__ext 0
#endif
/* The return 1 is the function need to be included in the output */
#define _SL_INCLUDE_FUNC(Name) (_SL_INC_##Name)
/* Driver */
#define _SL_INC_sl_NetAppStart __nap__ext
#define _SL_INC_sl_NetAppStop __nap__ext
#define _SL_INC_sl_NetAppDnsGetHostByName __nap__clt
#define _SL_INC_sl_NetAppDnsGetHostByService __nap__ext
#define _SL_INC_sl_NetAppMDNSRegisterService __nap__ext
#define _SL_INC_sl_NetAppMDNSUnRegisterService __nap__ext
#define _SL_INC_sl_NetAppMDNSRegisterUnregisterService __nap__ext
#define _SL_INC_sl_NetAppGetServiceList __nap__ext
#define _SL_INC_sl_DnsGetHostByAddr __nap__ext
#define _SL_INC_sl_NetAppPingStart __nap__ext
#define _SL_INC_sl_NetAppPingReport __nap__ext
#define _SL_INC_sl_NetAppSet __nap__ext
#define _SL_INC_sl_NetAppGet __nap__ext
/* FS */
#define _SL_INC_sl_FsOpen __nvm
#define _SL_INC_sl_FsClose __nvm
#define _SL_INC_sl_FsRead __nvm
#define _SL_INC_sl_FsWrite __nvm
#define _SL_INC_sl_FsGetInfo __nvm
#define _SL_INC_sl_FsDel __nvm
/* netcfg */
#define _SL_INC_sl_MacAdrrSet __ncg
#define _SL_INC_sl_MacAdrrGet __ncg
#define _SL_INC_sl_NetCfgGet __ncg
#define _SL_INC_sl_NetCfgSet __ncg
/* socket */
#define _SL_INC_sl_Socket __sck
#define _SL_INC_sl_Close __sck
#define _SL_INC_sl_Accept __sck__srv
#define _SL_INC_sl_Bind __sck
#define _SL_INC_sl_Listen __sck__srv
#define _SL_INC_sl_Connect __sck__clt
#define _SL_INC_sl_Select __sck
#define _SL_INC_sl_SetSockOpt __sck
#define _SL_INC_sl_GetSockOpt __sck__ext
#define _SL_INC_sl_Recv __sck__rcv
#define _SL_INC_sl_RecvFrom __sck__rcv
#define _SL_INC_sl_Write __sck__snd
#define _SL_INC_sl_Send __sck__snd
#define _SL_INC_sl_SendTo __sck__snd
#define _SL_INC_sl_Htonl __sck
#define _SL_INC_sl_Htons __sck
/* wlan */
#define _SL_INC_sl_WlanConnect __wln__ext
#define _SL_INC_sl_WlanDisconnect __wln__ext
#define _SL_INC_sl_WlanProfileAdd __wln__ext
#define _SL_INC_sl_WlanProfileGet __wln__ext
#define _SL_INC_sl_WlanProfileDel __wln__ext
#define _SL_INC_sl_WlanPolicySet __wln__ext
#define _SL_INC_sl_WlanPolicyGet __wln__ext
#define _SL_INC_sl_WlanGetNetworkList __wln__ext
#define _SL_INC_sl_WlanRxFilterAdd __wln__ext
#define _SL_INC_sl_WlanRxFilterSet __wln__ext
#define _SL_INC_sl_WlanRxFilterGet __wln__ext
#define _SL_INC_sl_SmartConfigStart __wln
#define _SL_INC_sl_SmartConfigOptSet __wln__ext
#define _SL_INC_sl_WlanSmartConfigStart __wln
#define _SL_INC_sl_WlanSmartConfigStop __wln
#define _SL_INC_sl_WlanSetMode __wln
#define _SL_INC_sl_WlanSet __wln
#define _SL_INC_sl_WlanGet __wln
#define _SL_INC_sl_SmartConfigOptSet __wln__ext
#define _SL_INC_sl_SmartConfigOptGet __wln__ext
#define _SL_INC_sl_WlanRxStatStart __wln__ext
#define _SL_INC_sl_WlanRxStatStop __wln__ext
#define _SL_INC_sl_WlanRxStatGet __wln__ext
/* device */
#define _SL_INC_sl_Task __int__spwn
#define _SL_INC_sl_Start __dev
#define _SL_INC_sl_Stop __dev
#define _SL_INC_sl_StatusGet __dev
#ifdef SL_IF_TYPE_UART
#define _SL_INC_sl_UartSetMode __dev__ext
#endif
#define _SL_INC_sl_EventMaskGet __dev__ext
#define _SL_INC_sl_EventMaskSet __dev__ext
#define _SL_INC_sl_DevGet __dev__ext
#define _SL_INC_sl_DevSet __dev__ext
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*OBJINCLUSION_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,948 @@
/*
* simplelink.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*!
\mainpage SimpleLink Driver
\section intro_sec Introduction
The SimpleLink CC31xx/CC2xx family allows to add Wi-Fi and networking capabilities
to low-cost embedded products without having prior Wi-Fi, RF or networking expertise.
The CC31xx/CC32xx is an ideal solution for microcontroller-based sensor and control
applications such as home appliances, home automation and smart metering.
The CC31xx/CC32xx has integrated a comprehensive TCP/IP network stack, Wi-Fi driver and
security supplicant leading to easier portability to microcontrollers, to an
ultra-low memory footprint, all without compromising the capabilities and robustness
of the final application.
\section modules_sec Module Names
To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo).
These capabilities range from basic device management through wireless
network configuration, standard BSD socket and much more.
Listed below are the various modules in the SimpleLink CC31xx/CC32xx driver:
-# \ref device - controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status)
-# \ref wlan - controls the use of the WiFi WLAN module including:
- Connection features, such as: profiles, policies, SmartConfig<69>
- Advanced WLAN features, such as: scans, rx filters and rx statistics collection
-# \ref socket - controls standard client/server sockets programming options and capabilities
-# \ref netapp - activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS.
-# \ref netcfg - controls the configuration of the device addresses (i.e. IP and MAC addresses)
-# \ref FileSystem - provides file system capabilities to TI's CC31XX that can be used by both the CC31XX device and the user.
\section proting_sec Porting Guide
The porting of the SimpleLink driver to any new platform is based on few simple steps.
This guide takes you through this process step by step. Please follow the instructions
carefully to avoid any problems during this process and to enable efficient and proper
work with the device.
Please notice that all modifications and porting adjustments of the driver should be
made in the user.h header file only.
Keep making any of the changes only in this file will ensure smoothly transaction to
new versions of the driver at the future!
\subsection porting_step1 Step 1 - Create your own user.h file
The first step is to create a user.h file that will include your configurations and
adjustments. You can use the empty template provided as part of this driver or
you can choose to base your file on file from one of the wide range of examples
applications provided by Texas Instruments
\subsection porting_step2 Step 2 - Select the capabilities set required for your application
Texas Instruments made a lot of efforts to build set of predefined capability sets that would
fit most of the target application.
It is recommended to try and choose one of this predefined capabilities set before going to
build your own customized set. If you find compatible set you can skip the rest of this step.
The available sets are:
-# SL_TINY - Compatible to be used on platforms with very limited resources. Provides
the best in class foot print in terms of Code and Data consumption.
-# SL_SMALL - Compatible to most common networking applications. Provide the most
common APIs with decent balance between code size, data size, functionality
and performances
-# SL_FULL - Provide access to all SimpleLink functionalities
\subsection porting_step3 Step 3 - Bind the device enable/disable output line
The enable/disable line (nHib) provide mechanism to enter the device into the least current
consumption mode. This mode could be used when no traffic is required (tx/rx).
when this line is not connected to any IO of the host this define should be left empty.
Not connecting this line results in ability to start the driver only once.
\subsection porting_step4 Step 4 - Writing your interface communication driver
The SimpleLink device support several standard communication protocol among SPI and
UART. Depending on your needs and your hardware design, you should choose the
communication channel type.
The interface for this communication channel should include 4 simple access functions:
-# open
-# close
-# read
-# write
The way this driver would be implemented is directly effecting the efficiency and
the performances of the SimpleLink device on this platform.
If your system has DMA you should consider to use it in order to increase the utilization
of the communication channel
If you have enough memory resources you should consider using a buffer to increase the
efficiency of the write operations.
\subsection porting_step5 Step 5 - Choose your memory management model
The SimpleLink driver support two memory models:
-# Static (default)
-# Dynamic
If you choose to work in dynamic model you will have to provide alloc and free functions
to be used by the Simple Link driver otherwise nothing need to be done.
\subsection porting_step6 Step 6 - OS adaptation
The SimpleLink driver could run on two kind of platforms:
-# Non-Os / Single Threaded (default)
-# Multi-Threaded
If you choose to work in multi-threaded environment under operating system you will have to
provide some basic adaptation routines to allow the driver to protect access to resources
for different threads (locking object) and to allow synchronization between threads (sync objects).
In additional the driver support running without dedicated thread allocated solely to the simple
link driver. If you choose to work in this mode, you should also supply a spawn method that
will enable to run function on a temporary context.
\subsection porting_step7 Step 7 - Set your asynchronous event handlers routines
The SimpleLink device generate asynchronous events in several situations.
These asynchronous events could be masked.
In order to catch these events you have to provide handler routines.
Please notice that if you not provide a handler routine and the event is received,
the driver will drop this event without any indication of this drop.
\subsection porting_step8 Step 8 - Run diagnostic tools to validate the correctness of your porting
The driver is delivered with some porting diagnostic tools to simplify the porting validation process
and to reduce issues latter. It is very important to follow carefully this process.
The diagnostic process include:
-# Validating Interface Communication Driver
-# Validating OS adaptation layer
-# Validating HW integrity
-# Validating basic work with the device
\section sw_license License
*
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __SIMPLELINK_H__
#define __SIMPLELINK_H__
#include "user.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*! \attention Async event activation notes
Function prototypes for event callback handlers
Event handler function names should be defined in the user.h file
e.g.
"#define sl_WlanEvtHdlr SLWlanEventHandler"
Indicates all WLAN events are handled by User func "SLWlanEventHandler"
Important notes:
1. Event handlers cannot activate another SimpleLink API from the event's context
2. Event's data is valid during event's context. Any application data
which is required for the user application should be copied or marked
into user's variables
3. It is not recommended to delay the execution of the event callback handler
*/
/*!
\addtogroup UserEvents
@{
*/
/*****************************************************************************/
/* Macro declarations for Host Driver version */
/*****************************************************************************/
#define SL_DRIVER_VERSION "1.0.0.10"
#define SL_MAJOR_VERSION_NUM 1L
#define SL_MINOR_VERSION_NUM 0L
#define SL_VERSION_NUM 0L
#define SL_SUB_VERSION_NUM 10L
/*****************************************************************************/
/* Macro declarations for predefined configurations */
/*****************************************************************************/
#ifdef SL_TINY
#undef SL_INC_ARG_CHECK
#undef SL_INC_EXT_API
#undef SL_INC_SOCK_SERVER_SIDE_API
#undef SL_INC_WLAN_PKG
#undef SL_INC_NET_CFG_PKG
#undef SL_INC_FS_PKG
#undef SL_INC_SET_UART_MODE
#undef SL_INC_STD_BSD_API_NAMING
#undef SL_INC_SOCK_CLIENT_SIDE_API
#undef SL_INC_NET_APP_PKG
#undef SL_INC_SOCK_RECV_API
#undef SL_INC_SOCK_SEND_API
#undef SL_INC_SOCKET_PKG
#endif
#ifdef SL_SMALL
#undef SL_INC_EXT_API
#undef SL_INC_NET_APP_PKG
#undef SL_INC_NET_CFG_PKG
#undef SL_INC_FS_PKG
#define SL_INC_ARG_CHECK
#define SL_INC_WLAN_PKG
#define SL_INC_SOCKET_PKG
#define SL_INC_SOCK_CLIENT_SIDE_API
#define SL_INC_SOCK_SERVER_SIDE_API
#define SL_INC_SOCK_RECV_API
#define SL_INC_SOCK_SEND_API
#define SL_INC_SET_UART_MODE
#endif
#ifdef SL_FULL
#define SL_INC_EXT_API
#define SL_INC_NET_APP_PKG
#define SL_INC_NET_CFG_PKG
#define SL_INC_FS_PKG
#define SL_INC_ARG_CHECK
#define SL_INC_WLAN_PKG
#define SL_INC_SOCKET_PKG
#define SL_INC_SOCK_CLIENT_SIDE_API
#define SL_INC_SOCK_SERVER_SIDE_API
#define SL_INC_SOCK_RECV_API
#define SL_INC_SOCK_SEND_API
#define SL_INC_SET_UART_MODE
#endif
#define SL_RET_CODE_OK (0)
#define SL_RET_CODE_INVALID_INPUT (-2)
#define SL_RET_CODE_SELF_ERROR (-3)
#define SL_RET_CODE_NWP_IF_ERROR (-4)
#define SL_RET_CODE_MALLOC_ERROR (-5)
#define sl_Memcpy memcpy
#define sl_Memset memset
#define sl_SyncObjClear(pObj) sl_SyncObjWait(pObj,SL_OS_NO_WAIT)
#ifndef SL_TINY_EXT
#define SL_MAX_SOCKETS (8)
#else
#define SL_MAX_SOCKETS (2)
#endif
/*****************************************************************************/
/* Types definitions */
/*****************************************************************************/
typedef void (*_SlSpawnEntryFunc_t)(void* pValue);
#ifndef NULL
#define NULL (0)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#ifndef OK
#define OK (0)
#endif
#ifndef _SL_USER_TYPES
typedef unsigned char _u8;
typedef signed char _i8;
typedef unsigned short _u16;
typedef signed short _i16;
typedef unsigned long _u32;
typedef signed long _i32;
#define _volatile volatile
#define _const const
#endif
typedef _u16 _SlOpcode_t;
typedef _u8 _SlArgSize_t;
typedef _i16 _SlDataSize_t;
typedef _i16 _SlReturnVal_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
/*
* This event status used to block or continue the event propagation
* through all the registered external libs/user application
*
*/
typedef enum {
EVENT_PROPAGATION_BLOCK = 0,
EVENT_PROPAGATION_CONTINUE
} _SlEventPropogationStatus_e;
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#ifdef SL_PLATFORM_MULTI_THREADED
#include "spawn.h"
#else
#include "nonos.h"
#endif
/*
objInclusion.h and user.h must be included before all api header files
objInclusion.h must be the last arrangement just before including the API header files
since it based on the other configurations to decide which object should be included
*/
#include "objInclusion.h"
#include "trace.h"
#include "fs.h"
#include "socket.h"
#include "netapp.h"
#include "wlan.h"
#include "device.h"
#include "netcfg.h"
#include "wlan_rx_filters.h"
/* The general events dispatcher which is
* initialized to the user handler */
#ifdef sl_GeneralEvtHdlr
#define _SlDrvHandleGeneralEvents sl_GeneralEvtHdlr
#endif
/* The wlan events dispatcher which is
* initialized to the user handler */
#ifdef sl_WlanEvtHdlr
#define _SlDrvHandleWlanEvents sl_WlanEvtHdlr
#endif
/* The NetApp events dispatcher which is
* initialized to the user handler */
#ifdef sl_NetAppEvtHdlr
#define _SlDrvHandleNetAppEvents sl_NetAppEvtHdlr
#endif
/* The http server events dispatcher which is
* initialized to the user handler if exists */
#ifdef sl_HttpServerCallback
#define _SlDrvHandleHttpServerEvents sl_HttpServerCallback
#endif
/* The socket events dispatcher which is
* initialized to the user handler */
#ifdef sl_SockEvtHdlr
#define _SlDrvHandleSockEvents sl_SockEvtHdlr
#endif
#ifndef __CONCAT
#define __CONCAT(x,y) x ## y
#endif
#define __CONCAT2(x,y) __CONCAT(x,y)
/*
* The section below handles the external lib event registration
* according to the desired events it specified in its API header file.
* The external lib should be first installed by the user (see user.h)
*/
#ifdef SL_EXT_LIB_1
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib1GeneralEventHandler __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib1WlanEventHandler __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib1NetAppEventHandler __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib1HttpServerEventHandler __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib1SockEventHandler __CONCAT2(SL_EXT_LIB_1, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_2
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib2GeneralEventHandler __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib2WlanEventHandler __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib2NetAppEventHandler __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib2HttpServerEventHandler __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib2SockEventHandler __CONCAT2(SL_EXT_LIB_2, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_3
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib3GeneralEventHandler __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib3WlanEventHandler __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib3NetAppEventHandler __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib3HttpServerEventHandler __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib3SockEventHandler __CONCAT2(SL_EXT_LIB_3, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_4
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib4GeneralEventHandler __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib4WlanEventHandler __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib4NetAppEventHandler __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib4HttpServerEventHandler __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib4SockEventHandler __CONCAT2(SL_EXT_LIB_4, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_5
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib5GeneralEventHandler __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib5WlanEventHandler __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib5NetAppEventHandler __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib5HttpServerEventHandler __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib5SockEventHandler __CONCAT2(SL_EXT_LIB_5, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#if defined(EXT_LIB_REGISTERED_GENERAL_EVENTS)
extern void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent);
#endif
#if defined(EXT_LIB_REGISTERED_WLAN_EVENTS)
extern void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent);
#endif
#if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS)
extern void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent);
#endif
#if defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
extern void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse);
#endif
#if defined(EXT_LIB_REGISTERED_SOCK_EVENTS)
extern void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent);
#endif
typedef void (*_SlSpawnEntryFunc_t)(void* pValue);
/* Async functions description*/
/*!
\brief General async event for inspecting general events
\param[out] pSlDeviceEvent pointer to SlDeviceEvent_t
\par
Parameters: \n
- <b>pSlDeviceEvent->Event = SL_DEVICE_FATAL_ERROR_EVENT </b>
- pSlDeviceEvent->EventData.deviceEvent fields:
- status: An error code indication from the device
- sender: The sender originator which is based on SlErrorSender_e enum
- <b>pSlDeviceEvent->Event = SL_DEVICE_ABORT_ERROR_EVENT </b>
Indicates a severe error occured and the device stopped
- pSlDeviceEvent->EventData.deviceReport fields:
- AbortType: An idication of the event type
- AbortData: Additional info about the data error
\par Example for fatal error:
\code
printf(General Event Handler - ID=%d Sender=%d\n\n",
pSlDeviceEvent->EventData.deviceEvent.status, // status of the general event
pSlDeviceEvent->EventData.deviceEvent.sender); // sender type
\endcode
\par Example for abort request:
\code
printf(Abort type =%d Abort Data=%d\n\n",
pSlDeviceEvent->EventData.deviceReport.AbortType,
pSlDeviceEvent->EventData.deviceReport.AbortData);
\endcode
*/
#if (defined(sl_GeneralEvtHdlr))
extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent);
#endif
/*!
\brief WLAN Async event handler
\param[out] pSlWlanEvent pointer to SlWlanEvent_t data
\par
Parameters:
- <b>pSlWlanEvent->Event = SL_WLAN_CONNECT_EVENT </b>, STA or P2P client connection indication event
- pSlWlanEvent->EventData.STAandP2PModeWlanConnected main fields:
- ssid_name
- ssid_len
- bssid
- go_peer_device_name
- go_peer_device_name_len
- <b>pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT </b>, STA or P2P client disconnection event
- pSlWlanEvent->EventData.STAandP2PModeDisconnected main fields:
- ssid_name
- ssid_len
- reason_code
- <b>pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT </b>, AP/P2P(Go) connected STA/P2P(Client)
- pSlWlanEvent->EventData.APModeStaConnected fields:
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- own_ssid_len: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT </b>, AP/P2P(Go) disconnected STA/P2P(Client)
- pSlWlanEvent->EventData.APModestaDisconnected fields:
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- own_ssid_len: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT </b>
- pSlWlanEvent->EventData.smartConfigStartResponse fields:
- status
- ssid_len
- ssid
- private_token_len
- private_token
- <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT </b>
- pSlWlanEvent->EventData.smartConfigStopResponse fields:
- status
- <b>pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT </b>
- pSlWlanEvent->EventData.P2PModeDevFound fields:
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- own_ssid_len: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT </b>
- pSlWlanEvent->EventData.P2PModeNegReqReceived fields
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_CONNECTION_FAILED_EVENT </b>, P2P only
- pSlWlanEvent->EventData.P2PModewlanConnectionFailure fields:
- status
*/
#if (defined(sl_WlanEvtHdlr))
extern void sl_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent);
#endif
/*!
\brief NETAPP Async event handler
\param[out] pSlNetApp pointer to SlNetAppEvent_t data
\par
Parameters:
- <b>pSlNetApp->Event = SL_NETAPP_IPV4_IPACQUIRED_EVENT</b>, IPV4 acquired event
- pSlNetApp->EventData.ipAcquiredV4 fields:
- ip
- gateway
- dns
- <b>pSlNetApp->Event = SL_NETAPP_IP_LEASED_EVENT</b>, AP or P2P go dhcp lease event
- pSlNetApp->EventData.ipLeased fields:
- ip_address
- lease_time
- mac
- <b>pSlNetApp->Event = SL_NETAPP_IP_RELEASED_EVENT</b>, AP or P2P go dhcp ip release event
- pSlNetApp->EventData.ipReleased fields
- ip_address
- mac
- reason
*/
#if (defined(sl_NetAppEvtHdlr))
extern void sl_NetAppEvtHdlr(SlNetAppEvent_t* pSlNetApp);
#endif
/*!
\brief Socket Async event handler
\param[out] pSlSockEvent pointer to SlSockEvent_t data
\par
Parameters:\n
- <b>pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT</b>
- pSlSockEvent->SockTxFailData fields:
- sd
- status
- <b>pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT</b>
- pSlSockEvent->SockAsyncData fields:
- sd
- type: SSL_ACCEPT or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED
- val
*/
#if (defined(sl_SockEvtHdlr))
extern void sl_SockEvtHdlr(SlSockEvent_t* pSlSockEvent);
#endif
/*!
\brief HTTP server async event
\param[out] pSlHttpServerEvent pointer to SlHttpServerEvent_t
\param[in] pSlHttpServerResponse pointer to SlHttpServerResponse_t
\par
Parameters: \n
- <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT</b>
- pSlHttpServerEvent->EventData fields:
- httpTokenName
- data
- len
- pSlHttpServerResponse->ResponseData fields:
- data
- len
- <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT</b>
- pSlHttpServerEvent->EventData.httpPostData fields:
- action
- token_name
- token_value
- pSlHttpServerResponse->ResponseData fields:
- data
- len
*/
#if (defined(sl_HttpServerCallback))
extern void sl_HttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SIMPLELINK_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
/*
* spawn.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __NONOS_H__
#define __NONOS_H__
#ifdef __cplusplus
extern "C" {
#endif
#if (defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
extern void _SlInternalSpawnTaskEntry();
extern _i16 _SlInternalSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags);
#undef sl_Spawn
#define sl_Spawn(pEntry,pValue,flags) _SlInternalSpawn(pEntry,pValue,flags)
#undef _SlTaskEntry
#define _SlTaskEntry _SlInternalSpawnTaskEntry
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,173 @@
/*
* trace.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "simplelink.h"
#ifndef __SIMPLELINK_TRACE_H__
#define __SIMPLELINK_TRACE_H__
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000)
#define _SL_ASSERT(expr) { ASSERT(expr); }
#define _SL_ERROR(expr, error) { if(!(expr)){return (error); } }
#define SL_HANDLING_ASSERT 2
#define SL_HANDLING_ERROR 1
#define SL_HANDLING_NONE 0
#define SL_SELF_COND_HANDLING SL_HANDLING_NONE
#define SL_PROTOCOL_HANDLING SL_HANDLING_NONE
#define SL_DRV_RET_CODE_HANDLING SL_HANDLING_NONE
#define SL_NWP_IF_HANDLING SL_HANDLING_NONE
#define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE
#define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE
#define SL_USER_ARGS_HANDLING SL_HANDLING_NONE
#if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT)
#define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
#elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR)
#define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
#else
#define VERIFY_RET_OK(Func) (Func);
#endif
#if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT)
#define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr)
#elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR)
#define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR)
#else
#define VERIFY_PROTOCOL(expr)
#endif
#if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT))
#define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr)
#elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR))
#define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR)
#else
#define VERIFY_SOCKET_CB(expr)
#endif
#if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT)
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
#define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
#elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR)
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
#define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
#else
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));}
#define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));}
#endif
#if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT)
#define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
#elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR)
#define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
#else
#define OSI_RET_OK_CHECK(Func) (Func);
#endif
#if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT)
#define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr)
#elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR)
#define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR)
#else
#define MALLOC_OK_CHECK(Ptr)
#endif
#ifdef SL_INC_ARG_CHECK
#if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT)
#define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr)
#elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR)
#define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT)
#else
#define ARG_CHECK_PTR(Ptr)
#endif
#else
#define ARG_CHECK_PTR(Ptr)
#endif
#define SL_TRACE0(level,msg_id,str)
#define SL_TRACE1(level,msg_id,str,p1)
#define SL_TRACE2(level,msg_id,str,p1,p2)
#define SL_TRACE3(level,msg_id,str,p1,p2,p3)
#define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)
#define SL_ERROR_TRACE(msg_id,str)
#define SL_ERROR_TRACE1(msg_id,str,p1)
#define SL_ERROR_TRACE2(msg_id,str,p1,p2)
#define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)
#define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)
#define SL_TRACE_FLUSH()
/* #define SL_DBG_CNT_ENABLE */
#ifdef SL_DBG_CNT_ENABLE
#define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++
#define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(_u32 *)&g_DbgCnt.SyncLog[index] = *(_u32 *)(value);}}
#else
#define _SL_DBG_CNT_INC(Cnt)
#define _SL_DBG_SYNC_LOG(index,value)
#endif
#define SL_DBG_LEVEL_1 1
#define SL_DBG_LEVEL_2 2
#define SL_DBG_LEVEL_3 4
#define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3)
#define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK)
#define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3
#define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1
#ifdef __cplusplus
}
#endif
#endif /*__SIMPLELINK_TRACE_H__*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,932 @@
/*
* wlan_rx_filters.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef RX_FILTERS_PREPROCESSOR_CLI_IF_H_
#define RX_FILTERS_PREPROCESSOR_CLI_IF_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/*!
* \def SL_RX_FILTER_MAX_FILTERS
* The Max number of filters for 64 filters
*/
#define SL_RX_FILTER_MAX_FILTERS 64
/*!
* \def SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS
* The Max number of software filters
*/
#define SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS (32)
/*!
* \def SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS (2)
/*!
* \def SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS (2)
/*!
* \def SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_COMBINATION_TYPE_ARGS (2)
/*!
* \def SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH
*
*/
#define SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH (32)
/* List of possible error numbers */
#define RXFL_OK (0) /* O.K */
#define RXFL_OUTPUT_OR_INPUT_BUFFER_LENGTH_TOO_SMALL (76) /* ! The output buffer length is smaller than required for that operation */
#define RXFL_DEPENDENT_FILTER_SOFTWARE_FILTER_NOT_FIT (75) /* Node filter can't be child of software filter and vice_versa */
#define RXFL_DEPENDENCY_IS_NOT_PERSISTENT (74) /* Dependency filter is not persistent */
#define RXFL_SYSTEM_STATE_NOT_SUPPORTED_FOR_THIS_FILTER (72) /* System state is not supported */
#define RXFL_TRIGGER_USE_REG5_TO_REG8 (71) /* Only counters 5 - 8 are allowed, for Tigger */
#define RXFL_TRIGGER_USE_REG1_TO_REG4 (70) /* Only counters 1 - 4 are allowed, for trigger */
#define RXFL_ACTION_USE_REG5_TO_REG8 (69) /* Only counters 5 - 8 are allowed, for action */
#define RXFL_ACTION_USE_REG1_TO_REG4 (68) /* Only counters 1 - 4 are allowed, for action */
#define RXFL_FIELD_SUPPORT_ONLY_EQUAL_AND_NOTEQUAL (67) /* Rule compare function Id is out of range */
#define RXFL_WRONG_MULTICAST_BROADCAST_ADDRESS (66) /* The address should be of type mutlicast or broadcast */
#define RXFL_THE_FILTER_IS_NOT_OF_HEADER_TYPE (65) /* The filter should be of header type */
#define RXFL_WRONG_COMPARE_FUNC_FOR_BROADCAST_ADDRESS (64) /* The compare funcion is not suitable for broadcast address */
#define RXFL_WRONG_MULTICAST_ADDRESS (63) /* The address should be of muticast type */
#define RXFL_DEPENDENT_FILTER_IS_NOT_PERSISTENT (62) /* The dependency filter is not persistent */
#define RXFL_DEPENDENT_FILTER_IS_NOT_ENABLED (61) /* The dependency filter is not enabled */
#define RXFL_FILTER_HAS_CHILDS (60) /* The filter has childs and can't be removed */
#define RXFL_CHILD_IS_ENABLED (59) /* Can't disable filter while the child is enabled */
#define RXFL_DEPENDENCY_IS_DISABLED (58) /* Can't enable filetr in case its depndency filter is disabled */
#define RXFL_NUMBER_OF_CONNECTION_POINTS_EXCEEDED (52) /* Number of connection points exceeded */
#define RXFL_DEPENDENT_FILTER_DEPENDENCY_ACTION_IS_DROP (51) /* The dependent filter has Drop action, thus the filter can't be created */
#define RXFL_FILTER_DO_NOT_EXISTS (50) /* The filter doesn't exists */
#define RXFL_DEPEDENCY_NOT_ON_THE_SAME_LAYER (49) /* The filter and its dependency must be on the same layer */
#define RXFL_NUMBER_OF_ARGS_EXCEEDED (48) /* Number of arguments excceded */
#define RXFL_ACTION_NO_REG_NUMBER (47) /* Action require counter number */
#define RXFL_DEPENDENT_FILTER_LAYER_DO_NOT_FIT (46) /* the filter and its dependency should be from the same layer */
#define RXFL_DEPENDENT_FILTER_SYSTEM_STATE_DO_NOT_FIT (45) /* The filter and its dependency system state don't fit */
#define RXFL_DEPENDENT_FILTER_DO_NOT_EXIST_2 (44) /* The parent filter don't exist */
#define RXFL_DEPENDENT_FILTER_DO_NOT_EXIST_1 (43) /* The parent filter is null */
#define RXFL_RULE_HEADER_ACTION_TYPE_NOT_SUPPORTED (42) /* The action type is not supported */
#define RXFL_RULE_HEADER_TRIGGER_COMPARE_FUNC_OUT_OF_RANGE (41) /* The Trigger comparision function is out of range */
#define RXFL_RULE_HEADER_TRIGGER_OUT_OF_RANGE (40) /* The Trigger is out of range */
#define RXFL_RULE_HEADER_COMPARE_FUNC_OUT_OF_RANGE (39) /* The rule compare function is out of range */
#define RXFL_FRAME_TYPE_NOT_SUPPORTED (38) /* ASCII frame type string is illegal */
#define RXFL_RULE_FIELD_ID_NOT_SUPPORTED (37) /* Rule field ID is out of range */
#define RXFL_RULE_HEADER_FIELD_ID_ASCII_NOT_SUPPORTED (36) /* This ASCII field ID is not supported */
#define RXFL_RULE_HEADER_NOT_SUPPORTED (35) /* The header rule is not supported on current release */
#define RXFL_RULE_HEADER_OUT_OF_RANGE (34) /* The header rule is out of range */
#define RXFL_RULE_HEADER_COMBINATION_OPERATOR_OUT_OF_RANGE (33) /* Combination function Id is out of ramge */
#define RXFL_RULE_HEADER_FIELD_ID_OUT_OF_RANGE (32) /* rule field Id is out of range */
#define RXFL_UPDATE_NOT_SUPPORTED (31) /* Update not supported */
#define RXFL_NO_FILTERS_ARE_DEFINED (24) /* No filters are defined in the system */
#define RXFL_NUMBER_OF_FILTER_EXCEEDED (23) /* Number of max filters excceded */
/******************************************************************************/
/* Type declarations */
/******************************************************************************/
/*!
* \typedef SlrxFilterID_t
* Unique filter ID which is allocated by the system , negative number means error
*/
typedef _i8 SlrxFilterID_t;
/*!
* \typedef SlrxFilterCompareMask_t
* The mask is used for the rule comparison function
*/
typedef _u8 SlrxFilterCompareMask_t;
/*!
* \typedef SlrxFilterIdMask_t
* Representation of filters Id as a bit field
* The bit field is used to declare which filters are involved
* in operation. Number of filter can be up to 128 filters. i.e. 128 bits are needed.
* On the current release, up to 64 filters can be defined.
*/
typedef _u8 SlrxFilterIdMask_t[128/8];
/*!
* \typedef SlrxFilterPrePreparedFilters_t
* Describes the supported software filter sets,
*/
typedef _u8 SlrxFilterPrePreparedFilters_t;
#define SL_ARP_AUTO_REPLY_PRE_PREPARED_FILTERS (0)
#define SL_MULTICASTSIPV4_DROP_PREPREPARED_FILTERS (1)
#define SL_MULTICASTSIPV6_DROP_PREPREPARED_FILTERS (2)
#define SL_MULTICASTSWIFI_DROP_PREPREPARED_FILTERS (3)
/*!
* \typedef SlrxFilterPrePreparedFiltersMask_t
* Describes the supported software filter sets,
* each bit represents different software filter set
* The filter sets are defined at SlrxFilterPrePreparedFilters_t
*/
typedef _u8 SlrxFilterPrePreparedFiltersMask_t[SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS/8];
/*! \typedef SlrxFilterRegxPattern_t
* The struct contains the regular expression pattern which is used in case of payload rule.
* Not supported in the current release
*/
typedef struct SlrxFilterRegxPattern_t
{
_u8 x[SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH];
}SlrxFilterRegxPattern_t;
/*! \typedef SlrxFilterAsciiArg_t
* The buffer is used to provide container for ASCII argument, which may be used in case of HEADER rule.
* example for ASCII argument can be : IP = 256.0.67.1
*/
typedef _u8 SlrxFilterAsciiArg_t;
/*! \typedef SlrxFilterBinaryArg_t
* The buffer provides container for binary argument, which may be used in case of HEADER rule
*/
typedef _u8 SlrxFilterBinaryArg_t ;
/*! \typedef SlrxFilterActionArg_t
* Provides container for the filter action argument.
* for example: in case action is to send automatic response , the argument is the template to be used for the automatic response.
*
*
*/
typedef _u8 SlrxFilterActionArg_t ;
/*! \typedef SlrxFilterOffset_t
* The offset relative to the packet payload start location.
* Not supported on current release
*/
typedef _u32 SlrxFilterOffset_t;
/*! \typedef SlrxFilterRuleType_t
* Enumerates the different filter types.
* On the current release only HEADER and COMBINATION are supported.
*/
typedef _u8 SlrxFilterRuleType_t;
/* possible values for SlrxFilterRuleType_t */
#define HEADER (0)
#define COMBINATION (1)
#define EXACT_PATTERN (2)
#define LIKELIHOOD_PATTERN (3)
#define ALWAYS_TRUE (4)
#define NUM_OF_FILTER_TYPES (5)
/*! \typedef SlrxFilterFlags_t
* Bit field which sets the behaviour of the RX filter
*
*/
#define RX_FILTER_BINARY (0x1)
#define RX_FILTER_PERSISTENT (0x8)
#define RX_FILTER_ENABLE (0x10)
typedef union SlrxFilterFlags_t
{
/* struct
{ */
/*!
* The filter argument can be set as binary argument or ASCII arguments.
* When the bit is on the argument are binary.
*/
/* _u8 Binary: 1; */
/*!
*
*/
/* _u8 AutoSort : 1; */
/*!
*
*/
/* _u8 AutoFaultDetect : 1; */
/*!
* When the bit is on it means the the node is enabled .
*/
/* _u8 Enabled : 1; */
/* _u8 padding : 3; */
/*
};*/
_u8 IntRepresentation;
}SlrxFilterFlags_t;
/*! \typedef SlrxFilterCompareFunction_t
* Used as comparison function for the header type arguments
*
*/
typedef _u8 SlrxFilterCompareFunction_t;
/* Possible values for SlrxFilterCompareFunction_t */
#define COMPARE_FUNC_IN_BETWEEN (0)
#define COMPARE_FUNC_EQUAL (1)
#define COMPARE_FUNC_NOT_EQUAL_TO (2)
#define COMPARE_FUNC_NOT_IN_BETWEEN (3)
#define COMPARE_FUNC_NUM_OF_FILTER_COMPARE_FUNC (4)
/*! \typedef SlrxFilterCompareFunction_t
* Used as comparison function for the header type arguments
*
*/
typedef _u8 SlrxTriggerCompareFunction_t;
/* Possible values for SlrxTriggerCompareFunction_t */
#define TRIGGER_COMPARE_FUNC_EQUAL (0)
/* arg1 == protocolVal ,not supported in current release */
#define TRIGGER_COMPARE_FUNC_NOT_EQUAL_TO (1)
/* arg1 == protocolVal */
#define TRIGGER_COMPARE_FUNC_SMALLER_THAN (2)
/* arg1 == protocolVal */
#define TRIGGER_COMPARE_FUNC_BIGGER_THAN (3)
/* definition */
#define TRIGGER_COMPARE_FUNC_NUM_OF_FILTER_COMPARE_FUNC (4)
/*! \typedef SlrxFilterHdrField_t
* Provides list of possible header types which may be defined as part of the rule
*
*/
typedef _u8 SlrxFilterHdrField_t;
/* Possible values for SlrxFilterHdrField_t */
#define NULL_FIELD_ID_TYPE (0)
/* 802.11 control\data\management */
#define FRAME_TYPE_FIELD (1)
/* 802.11 beacon\probe\.. */
#define FRAME_SUBTYPE_FIELD (2)
/* 802.11 bssid type */
#define BSSID_FIELD (3)
/* */
#define MAC_SRC_ADDRESS_FIELD (4)
/* */
#define MAC_DST_ADDRESS_FIELD (5)
/* */
#define FRAME_LENGTH_FIELD (6)
/* */
#define PROTOCOL_TYPE_FIELD (7)
/* */
#define IP_VERSION_FIELD (8)
/* TCP / UDP */
#define IP_PROTOCOL_FIELD (9)
/* */
#define IPV4_SRC_ADRRESS_FIELD (10)
/* */
#define IPV4_DST_ADDRESS_FIELD (11)
/* */
#define IPV6_SRC_ADRRESS_FIELD (12)
/* */
#define IPV6_DST_ADDRESS_FIELD (13)
/* */
#define SRC_PORT_FIELD (14)
/* */
#define DST_PORT_FIELD (15)
/* Definition */
#define NUM_OF_FIELD_NAME_FIELD (16)
/*! \union SlrxFilterHeaderArg_t
* The structure holds the header ARGS which are used in case of HDR rule.
*/
/* -- 36 bytes */
typedef union SlrxFilterHeaderArg_t
{
/*----------------------------- Large size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* example : IPV6 16 bytes, 39 characters
* ipv6 Ascii address: 2001:0db8:3c4d:0015:0000:0000:abcd:ef12
*/
SlrxFilterBinaryArg_t RxFilterDB16BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][16 ]; /* Binary Values for comparition */
/*! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* example : IPV6 16 bytes, 39 characters
* ipv6 Ascii address: 2001:0db8:3c4d:0015:0000:0000:abcd:ef12
* Ascii format for ipV6 is not supported
*/
/*----------------------------- Medium size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* MAC address: 6 bytes, 17 chars
*/
SlrxFilterBinaryArg_t RxFilterDB6BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][6]; /* Binary Values for comparition */
/*!
* ! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* IP address: 4 bytes, 15 chars
* 2 bytes are added for padding
*/
SlrxFilterAsciiArg_t RxFilterDB18BytesAsciiRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][18]; /* Ascii Values for comparison */
/*----------------------------- Small size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* IP address: 4 bytes, 15 chars
* Port: 2 bytes, chars: 5 chars
*/
SlrxFilterBinaryArg_t RxFilterDB4BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][4]; /* Binary Values for comparison */
/*! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* Port: 2 bytes, chars: 5 chars
*/
SlrxFilterAsciiArg_t RxFilterDB5BytesRuleAsciiArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][5]; /* Ascii Values for comparison */
/*----------------------------- 1 byte size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
*/
SlrxFilterBinaryArg_t RxFilterDB1BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][1]; /* Binary Values for comparison */
}SlrxFilterHeaderArg_t;
/*! \typedef SlrxFilterRuleHeaderArgsAndMask_t
* Structure which defines the Header Args and mask
*/
/* -- 52 bytes */
typedef struct SlrxFilterRuleHeaderArgsAndMask_t
{
/*! Argument for the comparison function */
/* -- 36 byte */
SlrxFilterHeaderArg_t RuleHeaderArgs;
/*! the mask is used in order to enable partial comparison,
* Use the 0xFFFFFFFF in case you don't want to use mask
*/
/* -- 16 bytes */
SlrxFilterCompareMask_t RuleHeaderArgsMask[16];
}SlrxFilterRuleHeaderArgsAndMask_t;
/*! \typedef SlrxFilterHeaderType_t
* Structure which defines the Header rule
* The header rule defines compare function on the protocol header
* For example destMacAddre is between ( 12:6::78:77, 12:6::78:90 )
*
*/
/* -- 56 byte */
typedef struct SlrxFilterHeaderType_t
{
/*! see :: SlrxFilterRuleHeaderArgsAndMask_t */
/* -- 52 bytes */
SlrxFilterRuleHeaderArgsAndMask_t RuleHeaderArgsAndMask;
/*! Packet HDR field which will be compared to the argument */
/* -- 1 byte */
SlrxFilterHdrField_t RuleHeaderfield;
/* -- 1 byte */
/*! type of the comparison function
* see :: SlrxFilterCompareFunction_t
*/
SlrxFilterCompareFunction_t RuleCompareFunc;
/*! padding */
/* -- 2 bytes */
_u8 RulePadding[2];
}SlrxFilterHeaderType_t;
/*! \typedef SlrxFilterPayloadType_t
* Structure which defines payload rule.
* Not supported on current release.
*/
/* -- 40 byte */
typedef struct SlrxFilterPayloadType_t
{
/*! Not supported on current release */
/* -- 32 byte */
SlrxFilterRegxPattern_t RegxPattern;
/*! Not supported on current release */
/* -- 4 byte */
SlrxFilterOffset_t LowerOffset;
/*! Not supported on current release */
/* -- 4 byte */
SlrxFilterOffset_t UpperOffset;
}SlrxFilterPayloadType_t;
/*! \typedef SlrxFilterCombinationTypeOperator_t
* Enumerate the optional operators for the combination type
* filterID1 is located in the first arg , filterId2 is the second arg,see ::SlrxFilterCombinationType_t.CombinationFilterId
*/
typedef _u8 SlrxFilterCombinationTypeOperator_t;
/* Possible values for SlrxFilterCombinationTypeOperator_t */
/*! !filterID1 */
#define COMBINED_FUNC_NOT (0)
/*! filterID1 && filterID2 */
#define COMBINED_FUNC_AND (1)
/*! filterID1 && filterID2 */
#define COMBINED_FUNC_OR (2)
/*! \typedef SlrxFilterCombinationType_t
* Defines the structure which define the combination type filter
* The combined filter enable to make operation on one or two filter,
* for example !filterId1 or and(filterId2,filterId3).
*
*/
/* -- 4 byte */
typedef struct SlrxFilterCombinationType_t
{
/* ! combination operator */
/* -- 1 byte */
SlrxFilterCombinationTypeOperator_t CombinationTypeOperator;
/* ! filterID, may be one or two depends on the combination operator type */
/* -- 2 byte */
SlrxFilterID_t CombinationFilterId[SL_RX_FILTER_NUM_OF_COMBINATION_TYPE_ARGS];
/* ! Padding */
/* -- 1 byte */
_u8 Padding;
}SlrxFilterCombinationType_t;
/*! \typedef SlrxFilterRule_t
* Rule structure composed of behavioral flags and the filter rule definitions
*
*/
/* -- 56 byte */
typedef union SlrxFilterRule_t
{
/* ! Header type rule , see explanation on the ::SlrxFilterHeaderType_t structure */
/* -- 56 byte */
SlrxFilterHeaderType_t HeaderType;
/* ! Payload rule, not supported in current release */
/* -- 40 byte */
SlrxFilterPayloadType_t PayLoadHeaderType; /* future for exact pattern or like hood pattern */
/* ! Combined type rule , see explanation in ::SlrxFilterCombinationType_t structure */
/* -- 4 byte */
SlrxFilterCombinationType_t CombinationType;
}SlrxFilterRule_t;
/*! \typedef SlrxFilterTriggerRoles_t
* Bit field which represents the roleId possible values
* In the current release only Station/AP roles are supported.
*/
#define RX_FILTER_ROLE_AP (1)
#define RX_FILTER_ROLE_STA (2)
#define RX_FILTER_ROLE_PROMISCUOUS (4)
#define RX_FILTER_ROLE_NULL (0)
typedef union SlrxFilterTriggerRoles_t
{
/* struct */
/* { */
/* _u8 RoleAP :1; */
/* _u8 RoleStation :1; */
/* The filter is activated only in Promiscuous mode */
/* _u8 PromiscuousMode :1; */
/* _u8 RoleReserved :5; */
/* }; */
/* ! Bit fiels of the Filter role */
_u8 IntRepresentation;
}SlrxFilterTriggerRoles_t;
/*! \typedef SlrxFilterTriggerConnectionStates_t
* Bit field representing the possible values of the When section of the rule
*
*/
#define RX_FILTER_CONNECTION_STATE_STA_CONNECTED (1)
#define RX_FILTER_CONNECTION_STATE_STA_NOT_CONNECTED (2)
#define RX_FILTER_CONNECTION_STATE_STA_HAS_IP (4)
#define RX_FILTER_CONNECTION_STATE_STA_HAS_NO_IP (8)
typedef union SlrxFilterTriggerConnectionStates_t
{
/* struct */
/* { */
/* _u8 RoleStationWiFiConnected :1; */
/* _u8 RoleStationWiFiDisconneted:1; */
/* _u8 RoleStationWiFiHasIp:1; */
/* _u8 RoleStationWiFiHasNoIp:1; */
/* _u8 RoleStationWiFiSocketOpened:1; */
/* _u8 RoleStationWiFiSocketclosed:1; */
/* }; */
/* */
/* ! */
_u8 IntRepresentation;
}SlrxFilterTriggerConnectionStates_t;
/*! \typedef SlrxFilterDBTriggerArg_t
* Provides container for entering the filter 'when' argument.
* The current release support 'When rules' which has no arguments.
* For example :
* When connect to specific AP -- the AP bssid is the argument.
*
*/
typedef _u32 SlrxFilterDBTriggerArg_t;
/*! \typedef SlrxFilterCounterId_t
* the counter ID we have 4 counters
*/
typedef _u8 SlrxFilterCounterId_t;
/* Possible values for SlrxFilterCounterId_t */
#define NO_TRIGGER (0)
#define RX_FILTER_COUNTER1 (1)
#define RX_FILTER_COUNTER2 (2)
#define RX_FILTER_COUNTER3 (3)
#define RX_FILTER_COUNTER4 (4)
#define RX_FILTER_COUNTER5 (5)
#define RX_FILTER_COUNTER6 (6)
#define RX_FILTER_COUNTER7 (7)
#define RX_FILTER_COUNTER8 (8)
#define MAX_RX_FILTER_COUNTER (9)
/*! \typedef SlrxFilterActionArgs_t
* Possible value for filter action args
*
*/
typedef _u8 SlrxFilterActionArgs_t;
/* Possible values for SlrxFilterActionArgs_t */
#define ACTION_ARG_REG_1_4 (0)
/* ! Can be use as counter */
#define ACTION_ARG_TEMPLATE (1)
/* ! Can be use as counter */
#define ACTION_ARG_EVENT (2)
/* ! GPIO number */
#define ACTION_ARG_GPIO (4)
/*!
* \def SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS (5)
/*! \typedef SlrxFilterTrigger_t
* The filter trigger, determine when the filter is triggered,
* The filter is triggered in the following condition :\n
* 1. The filter parent is triggered\n
* 2. The requested connection type exists, i.e. wlan_connect\n
* 3. The filter role is the same as the system role\n
*
*/
/* -- 12 byte */
typedef struct SlrxFilterTrigger_t
{
/*! The parent filter ID, this is the way to build filter tree. */
/* NULL value means tree root.
*/
/* -- 1 byte */
SlrxFilterID_t ParentFilterID;
/* ! See ::SlrxFilterCounterId_t explanation */
/* -- 1 byte */
SlrxFilterCounterId_t Trigger;
/* ! See :: SlrxFilterTriggerConnectionStates_t */
/* -- 1 byte */
SlrxFilterTriggerConnectionStates_t TriggerArgConnectionState;
/* ! See ::SlrxFilterTriggerRoles_t */
/* -- 1 byte */
SlrxFilterTriggerRoles_t TriggerArgRoleStatus;
/* ! The Trigger arguments are in the same order as the Trigger bit field order. */
/* -- 4 byte */
SlrxFilterDBTriggerArg_t TriggerArg;
/** The compare function which will be operate for each bit that is turned on in the ::SlrxFilterTrigger_t.Trigger field,
* for example , in case the second bit in the Trigger function is on the second function in the list will be executed.
*
*/
/* -- 1 byte */
SlrxTriggerCompareFunction_t TriggerCompareFunction;
/* ! padding */
/* -- 3 byte */
_u8 Padding[3];
} SlrxFilterTrigger_t;
/*! \typedef SlrxFilterActionType_t
* The actions are executed only if the filter is matched,\n
* In case of false match the packet is transfered to the HOST. \n
* The action is composed of bit field structure,
* up to 2 actions can be defined per filter.
*
*/
#define RX_FILTER_ACTION_NULL (0x0)
#define RX_FILTER_ACTION_DROP (0x1)
#define RX_FILTER_ACTION_GPIO (0x2)
#define RX_FILTER_ACTION_ON_REG_INCREASE (0x4)
#define RX_FILTER_ACTION_ON_REG_DECREASE (0x8)
#define RX_FILTER_ACTION_ON_REG_RESET (0x10)
#define RX_FILTER_ACTION_SEND_TEMPLATE (0x20) /* unsupported */
#define RX_FILTER_ACTION_EVENT_TO_HOST (0x40) /* unsupported */
typedef union SlrxFilterActionType_t
{
/* struct */
/* { */
/* ! No action to execute the packet is dropped,drop is always on leaf. */
/* ! If not dropped ,The packet is passed to the next filter or in case it is the last filter to the host */
/* _u8 ActionDrop : 1; */
/* ! Not Supported in the current release */
/* _u8 ActionGpio : 1; */
/*! action can increase counter registers.
* 1 = Increase
* 2 = decrease
* 3 = reset
*/
/* _u8 ActionOnREGIncrease : 1; */
/* _u8 ActionOnREGDecrease : 1; */
/* _u8 ActionOnREGReset : 1; */
/* ! Not Supported in the current release */
/* _u8 ActionSendTemplate : 1; */
/* ! Not Supported in the current release */
/* _u8 ActionEventToHost: 1; */
/* _u8 padding: 1; */
/* }; */
_u8 IntRepresentation;
}SlrxFilterActionType_t;
/*! \typedef SlrxFilterAction_t
* Several actions can be defined,\n
* The action is executed in case the filter rule is matched.
*/
/* -- 8 byte */
typedef struct SlrxFilterAction_t
{
/* -- 1 byte */
/* ! Determine which actions are supported */
SlrxFilterActionType_t ActionType;
/* ! Buffer for the action arguments */
/**
* <b>location 0</b> - The counter to increase
* In case the action is of type "increase" the arg will contain the counter number,
* The counter number values are as in ::SlrxFilterCounterId_t.\n
* <b>location 1</b> - The template arg.\n
* <b>location 2</b> - The event arg.\n
*
*/
/* -- 5 byte */
SlrxFilterActionArg_t ActionArg[SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS];
/* ! Padding */
/* - 2 Bytes */
_u8 Padding[2];
} SlrxFilterAction_t;
/*! \struct _WlanRxFilterOperationCommandBuff_t
* The structure is used for the interface HOST NWP.\n
* The supported operation : \n
* ::ENABLE_DISABLE_RX_FILTER,\n
* ::REMOVE_RX_FILTER,\n
*
*/
/* 20 bytes */
typedef struct _WlanRxFilterOperationCommandBuff_t
{
/* -- 16 bytes */
SlrxFilterIdMask_t FilterIdMask;
/* 4 bytes */
_u8 Padding[4];
}_WlanRxFilterOperationCommandBuff_t;
/* -- 56 bytes */
typedef struct _WlanRxFilterUpdateArgsCommandBuff_t
{
/* -- 1 bytes */
_u8 FilterId;
/* -- 1 bytes */
/* ! the args representation */
_u8 BinaryRepresentation;
/* -- 52 byte */
SlrxFilterRuleHeaderArgsAndMask_t FilterRuleHeaderArgsAndMask;
/* -- 2 bytes */
_u8 Padding[2];
}_WlanRxFilterUpdateArgsCommandBuff_t;
/*! \typedef _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t
* The structure is used for the interface HOST NWP.\n
*
*/
/* -- 16 bytes */
typedef struct _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t
{
/* ! the filter set bit map */
/* -- 16 bytes */
SlrxFilterIdMask_t FilterIdMask;
}_WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t;
/*! \struct _WlanRxFilterPrePreparedFiltersCommandBuff_t
* The function enables to perform operations on pre-prepared filters
*
*/
typedef struct _WlanRxFilterPrePreparedFiltersCommandBuff_t
{
/* ! the filter set bit map */
/* -- 4 bytes */
SlrxFilterPrePreparedFiltersMask_t FilterPrePreparedFiltersMask;
}_WlanRxFilterPrePreparedFiltersCommandBuff_t;
/*! \typedef sl_protocol_WlanRxFilterPrePreparedFiltersCommandResponseBuff_t
*
*/
/*-- 4 bytes */
typedef struct _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t
{
/* -- 4 bytes */
/* ! the filter set bit map */
SlrxFilterPrePreparedFiltersMask_t FilterPrePreparedFiltersMask;
}_WlanRxFilterPrePreparedFiltersCommandResponseBuff_t;
typedef _u8 SLrxFilterOperation_t;
#define SL_ENABLE_DISABLE_RX_FILTER (0)
#define SL_REMOVE_RX_FILTER (1)
#define SL_STORE_RX_FILTERS (2)
#define SL_UPDATE_RX_FILTER_ARGS (3)
#define SL_FILTER_RETRIEVE_ENABLE_STATE (4)
#define SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE (5)
#define SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE (6)
/* Bit manipulation for 8 bit */
#define ISBITSET8(x,i) ((x[i>>3] & (0x80>>(i&7)))!=0) /* < Is bit set, 8 bit unsigned numbers = x , location = i */
#define SETBIT8(x,i) x[i>>3]|=(0x80>>(i&7)); /* < Set bit,8 bit unsigned numbers = x , location = i */
#define CLEARBIT8(x,i) x[i>>3]&=(0x80>>(i&7))^0xFF; /* < Clear bit,8 bit unsigned numbers = x , location = i */
/*********************************************************************************************/
/* Function prototypes */
/*********************************************************************************************/
/*!
\addtogroup wlan
@{
*/
/*!
\brief Adds new filter rule to the system
\param[in] RuleType The rule type
\param[in] FilterFlags Flags which set the type of header rule Args and sets the persistent flag
\param[in] pRule Determine the filter rule logic
\param[in] pTrigger Determine when the rule is triggered also sets rule parent.
\param[in] pAction Sets the action to be executed in case the match functions pass
\param[out] pFilterId The filterId which was created
\return On success, zero is returned. Otherwise error code is returned
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd)
SlrxFilterID_t sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType,
SlrxFilterFlags_t FilterFlags,
const SlrxFilterRule_t* const Rule,
const SlrxFilterTrigger_t* const Trigger,
const SlrxFilterAction_t* const Action,
SlrxFilterID_t* pFilterId);
#endif
/*!
\brief Sets parameters to Rx filters
\param[in] RxFilterOperation
possible operations :
- SL_ENABLE_DISABLE_RX_FILTER - Enables\disables filter in a filter list
- SL_REMOVE_RX_FILTER - Removes filter from memory ( to remove from flash call SL_STORE_RX_FILTERS after this command)
- SL_STORE_RX_FILTERS - Save the filters for persistent
- SL_UPDATE_RX_FILTER_ARGS - Update the arguments of existing filter
- SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE - Change the default creation of the pre-prepared filters
\param[in] pInputBuffer options:
The buffer input is _WlanRxFilterOperationCommandBuff_t:
- SL_ENABLE_DISABLE_RX_FILTER
- SL_REMOVE_RX_FILTER
- SL_STORE_RX_FILTERS
The buffer input is _WlanRxFilterUpdateArgsCommandBuff_t:
- SL_UPDATE_RX_FILTER_ARGS
The buffer input is _WlanRxFilterPrePreparedFiltersCommandBuff_t:
- SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE
\param[in] InputbufferLength The length in byte of the input buffer
\return On success, zero is returned. Otherwise error code is returned
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxFilterSet)
_i16 sl_WlanRxFilterSet( const SLrxFilterOperation_t RxFilterOperation,
const _u8* const pInputBuffer,
_u16 InputbufferLength);
#endif
/*!
\brief Gets parameters of Rx filters
\param[in] RxFilterOperation
possible operations :
- SL_FILTER_RETRIEVE_ENABLE_STATE - Retrieves the enable disable status
- SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE - Retrieves the pre-prepared filters creation status
\param[in] pOutputBuffer
The buffer input is _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t:
- SL_FILTER_RETRIEVE_ENABLE_STATE
The buffer input is _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t:
- SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE
\param[in] OutputbufferLength The length in byte of the output buffer
\return On success, zero is returned. Otherwise error code is returned
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxFilterGet)
_i16 sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation,
_u8* pOutputBuffer,
_u16 OutputbufferLength);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* RX_FILTERS_PREPROCESSOR_CLI_IF_H_ */

View File

@@ -0,0 +1,557 @@
/*
* device.c - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#include "protocol.h"
#include "flowcont.h"
#include "driver.h"
/*****************************************************************************/
/* Internal functions */
/*****************************************************************************/
const _i8 StartResponseLUT[8] =
{
ROLE_UNKNOWN_ERR,
ROLE_STA,
ROLE_STA_ERR,
ROLE_AP,
ROLE_AP_ERR,
ROLE_P2P,
ROLE_P2P_ERR,
ROLE_UNKNOWN_ERR
};
_i16 _sl_GetStartResponseConvert(_u32 Status)
{
return (_i16)StartResponseLUT[Status & 0x7];
}
/*****************************************************************************/
/* API Functions */
/*****************************************************************************/
/*****************************************************************************/
/* sl_Task */
/*****************************************************************************/
#if _SL_INCLUDE_FUNC(sl_Task)
void sl_Task(void)
{
#ifdef _SlTaskEntry
_SlTaskEntry();
#endif
}
#endif
/*****************************************************************************/
/* sl_Start */
/*****************************************************************************/
#if _SL_INCLUDE_FUNC(sl_Start)
_i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack)
{
_i16 ObjIdx = MAX_CONCURRENT_ACTIONS;
InitComplete_t AsyncRsp;
/* Perform any preprocessing before enable networking services */
sl_DeviceEnablePreamble();
/* ControlBlock init */
_SlDrvDriverCBInit();
/* open the interface: usually SPI or UART */
if (NULL == pIfHdl)
{
g_pCB->FD = sl_IfOpen((void *)pDevName, 0);
}
else
{
g_pCB->FD = (_SlFd_t)pIfHdl;
}
ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS);
if (MAX_CONCURRENT_ACTIONS == ObjIdx)
{
return SL_POOL_IS_EMPTY;
}
if( g_pCB->FD >= (_SlFd_t)0)
{
sl_DeviceDisable();
sl_IfRegIntHdlr((SL_P_EVENT_HANDLER)_SlDrvRxIrqHandler, NULL);
g_pCB->pInitCallback = pInitCallBack;
sl_DeviceEnable();
if (NULL == pInitCallBack)
{
_SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
/* release Pool Object */
_SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex);
return _sl_GetStartResponseConvert(AsyncRsp.Status);
}
else
{
return SL_RET_CODE_OK;
}
}
return SL_BAD_INTERFACE;
}
#endif
/***************************************************************************
_sl_HandleAsync_InitComplete - handles init complete signalling to
a waiting object
****************************************************************************/
void _sl_HandleAsync_InitComplete(void *pVoidBuf)
{
InitComplete_t *pMsgArgs = (InitComplete_t *)_SL_RESP_ARGS_START(pVoidBuf);
_SlDrvProtectionObjLockWaitForever();
if(g_pCB->pInitCallback)
{
g_pCB->pInitCallback(_sl_GetStartResponseConvert(pMsgArgs->Status));
}
else
{
sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(InitComplete_t));
_SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
}
_SlDrvProtectionObjUnLock();
if(g_pCB->pInitCallback)
{
_SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex);
}
}
/***************************************************************************
_sl_HandleAsync_Stop - handles stop signalling to
a waiting object
****************************************************************************/
void _sl_HandleAsync_Stop(void *pVoidBuf)
{
_BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
VERIFY_SOCKET_CB(NULL != g_pCB->StopCB.pAsyncRsp);
_SlDrvProtectionObjLockWaitForever();
sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_BasicResponse_t));
_SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
_SlDrvProtectionObjUnLock();
return;
}
/*****************************************************************************
sl_stop
******************************************************************************/
typedef union
{
_DevStopCommand_t Cmd;
_BasicResponse_t Rsp;
}_SlStopMsg_u;
const _SlCmdCtrl_t _SlStopCmdCtrl =
{
SL_OPCODE_DEVICE_STOP_COMMAND,
sizeof(_DevStopCommand_t),
sizeof(_BasicResponse_t)
};
#if _SL_INCLUDE_FUNC(sl_Stop)
_i16 sl_Stop(const _u16 timeout)
{
_i16 RetVal=0;
_SlStopMsg_u Msg;
_BasicResponse_t AsyncRsp;
_i8 ObjIdx = MAX_CONCURRENT_ACTIONS;
/* if timeout is 0 the shutdown is forced immediately */
if( 0 == timeout )
{
sl_IfRegIntHdlr(NULL, NULL);
sl_DeviceDisable();
RetVal = sl_IfClose(g_pCB->FD);
}
else
{
/* let the device make the shutdown using the defined timeout */
Msg.Cmd.Timeout = timeout;
ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS);
if (MAX_CONCURRENT_ACTIONS == ObjIdx)
{
return SL_POOL_IS_EMPTY;
}
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlStopCmdCtrl, &Msg, NULL));
if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status)
{
_SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
Msg.Rsp.status = AsyncRsp.status;
RetVal = Msg.Rsp.status;
}
_SlDrvReleasePoolObj(ObjIdx);
sl_IfRegIntHdlr(NULL, NULL);
sl_DeviceDisable();
sl_IfClose(g_pCB->FD);
}
_SlDrvDriverCBDeinit();
return RetVal;
}
#endif
/*****************************************************************************
sl_EventMaskSet
*****************************************************************************/
typedef union
{
_DevMaskEventSetCommand_t Cmd;
_BasicResponse_t Rsp;
}_SlEventMaskSetMsg_u;
#if _SL_INCLUDE_FUNC(sl_EventMaskSet)
const _SlCmdCtrl_t _SlEventMaskSetCmdCtrl =
{
SL_OPCODE_DEVICE_EVENTMASKSET,
sizeof(_DevMaskEventSetCommand_t),
sizeof(_BasicResponse_t)
};
_i16 sl_EventMaskSet(const _u8 EventClass ,const _u32 Mask)
{
_SlEventMaskSetMsg_u Msg;
Msg.Cmd.group = EventClass;
Msg.Cmd.mask = Mask;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskSetCmdCtrl, &Msg, NULL));
return (_i16)Msg.Rsp.status;
}
#endif
/******************************************************************************
sl_EventMaskGet
******************************************************************************/
typedef union
{
_DevMaskEventGetCommand_t Cmd;
_DevMaskEventGetResponse_t Rsp;
}_SlEventMaskGetMsg_u;
#if _SL_INCLUDE_FUNC(sl_EventMaskGet)
const _SlCmdCtrl_t _SlEventMaskGetCmdCtrl =
{
SL_OPCODE_DEVICE_EVENTMASKGET,
sizeof(_DevMaskEventGetCommand_t),
sizeof(_DevMaskEventGetResponse_t)
};
_i16 sl_EventMaskGet(const _u8 EventClass,_u32 *pMask)
{
_SlEventMaskGetMsg_u Msg;
Msg.Cmd.group = EventClass;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskGetCmdCtrl, &Msg, NULL));
*pMask = Msg.Rsp.mask;
return SL_RET_CODE_OK;
}
#endif
/******************************************************************************
sl_DevGet
******************************************************************************/
typedef union
{
_DeviceSetGet_t Cmd;
_DeviceSetGet_t Rsp;
}_SlDeviceMsgGet_u;
#if _SL_INCLUDE_FUNC(sl_DevGet)
const _SlCmdCtrl_t _SlDeviceGetCmdCtrl =
{
SL_OPCODE_DEVICE_DEVICEGET,
sizeof(_DeviceSetGet_t),
sizeof(_DeviceSetGet_t)
};
_i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues)
{
_SlDeviceMsgGet_u Msg;
_SlCmdExt_t CmdExt;
if (*pConfigLen == 0)
{
return SL_EZEROLEN;
}
if( pOption )
{
_SlDrvResetCmdExt(&CmdExt);
CmdExt.RxPayloadLen = *pConfigLen;
CmdExt.pRxPayload = (_u8 *)pValues;
Msg.Cmd.DeviceSetId = DeviceGetId;
Msg.Cmd.Option = (_u16)*pOption;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlDeviceGetCmdCtrl, &Msg, &CmdExt));
if( pOption )
{
*pOption = (_u8)Msg.Rsp.Option;
}
if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
{
*pConfigLen = (_u8)CmdExt.RxPayloadLen;
return SL_ESMALLBUF;
}
else
{
*pConfigLen = (_u8)CmdExt.ActualRxPayloadLen;
}
return (_i16)Msg.Rsp.Status;
}
else
{
return -1;
}
}
#endif
/******************************************************************************
sl_DevSet
******************************************************************************/
typedef union
{
_DeviceSetGet_t Cmd;
_BasicResponse_t Rsp;
}_SlDeviceMsgSet_u;
#if _SL_INCLUDE_FUNC(sl_DevSet)
const _SlCmdCtrl_t _SlDeviceSetCmdCtrl =
{
SL_OPCODE_DEVICE_DEVICESET,
sizeof(_DeviceSetGet_t),
sizeof(_BasicResponse_t)
};
_i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const _u8 *pValues)
{
_SlDeviceMsgSet_u Msg;
_SlCmdExt_t CmdExt;
_SlDrvResetCmdExt(&CmdExt);
CmdExt.TxPayloadLen = (ConfigLen+3) & (~3);
CmdExt.pTxPayload = (_u8 *)pValues;
Msg.Cmd.DeviceSetId = DeviceSetId;
Msg.Cmd.ConfigLen = ConfigLen;
Msg.Cmd.Option = Option;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlDeviceSetCmdCtrl, &Msg, &CmdExt));
return (_i16)Msg.Rsp.status;
}
#endif
/******************************************************************************
_SlDrvDeviceEventHandler - handles internally device async events
******************************************************************************/
void _SlDrvDeviceEventHandler(void* pArgs)
{
_SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs;
switch(pHdr->GenHeader.Opcode)
{
case SL_OPCODE_DEVICE_INITCOMPLETE:
_sl_HandleAsync_InitComplete(pHdr);
break;
case SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE:
_sl_HandleAsync_Stop(pHdr);
break;
case SL_OPCODE_DEVICE_ABORT:
{
#if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS)
SlDeviceEvent_t devHandler;
devHandler.Event = SL_DEVICE_ABORT_ERROR_EVENT;
devHandler.EventData.deviceReport.AbortType = *((_u32*)pArgs + 2);
devHandler.EventData.deviceReport.AbortData = *((_u32*)pArgs + 3);
_SlDrvHandleGeneralEvents(&devHandler);
#endif
}
break;
case SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR:
#if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS)
{
_BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pHdr);
SlDeviceEvent_t devHandler;
devHandler.Event = SL_DEVICE_FATAL_ERROR_EVENT;
devHandler.EventData.deviceEvent.status = pMsgArgs->status & 0xFF;
devHandler.EventData.deviceEvent.sender = (SlErrorSender_e)((pMsgArgs->status >> 8) & 0xFF);
_SlDrvHandleGeneralEvents(&devHandler);
}
#endif
break;
default:
SL_ERROR_TRACE2(MSG_306, "ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %1", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode);
}
}
/******************************************************************************
sl_UartSetMode
******************************************************************************/
#ifdef SL_IF_TYPE_UART
typedef union
{
_DevUartSetModeCommand_t Cmd;
_DevUartSetModeResponse_t Rsp;
}_SlUartSetModeMsg_u;
#if _SL_INCLUDE_FUNC(sl_UartSetMode)
const _SlCmdCtrl_t _SlUartSetModeCmdCtrl =
{
SL_OPCODE_DEVICE_SETUARTMODECOMMAND,
sizeof(_DevUartSetModeCommand_t),
sizeof(_DevUartSetModeResponse_t)
};
_i16 sl_UartSetMode(const SlUartIfParams_t* pUartParams)
{
_SlUartSetModeMsg_u Msg;
_u32 magicCode = 0xFFFFFFFF;
Msg.Cmd.BaudRate = pUartParams->BaudRate;
Msg.Cmd.FlowControlEnable = pUartParams->FlowControlEnable;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlUartSetModeCmdCtrl, &Msg, NULL));
/* cmd response OK, we can continue with the handshake */
if (SL_RET_CODE_OK == Msg.Rsp.status)
{
sl_IfMaskIntHdlr();
/* Close the comm port */
sl_IfClose(g_pCB->FD);
/* Re-open the comm port */
sl_IfOpen((void * )pUartParams, UART_IF_OPEN_FLAG_RE_OPEN);
sl_IfUnMaskIntHdlr();
/* send the magic code and wait for the response */
sl_IfWrite(g_pCB->FD, (_u8* )&magicCode, 4);
magicCode = UART_SET_MODE_MAGIC_CODE;
sl_IfWrite(g_pCB->FD, (_u8* )&magicCode, 4);
/* clear magic code */
magicCode = 0;
/* wait (blocking) till the magic code to be returned from device */
sl_IfRead(g_pCB->FD, (_u8* )&magicCode, 4);
/* check for the received magic code matching */
if (UART_SET_MODE_MAGIC_CODE != magicCode)
{
_SL_ASSERT(0);
}
}
return (_i16)Msg.Rsp.status;
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/*
* flowcont.c - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#include "protocol.h"
#include "driver.h"
#include "flowcont.h"
/*****************************************************************************/
/* _SlDrvFlowContInit */
/*****************************************************************************/
void _SlDrvFlowContInit(void)
{
g_pCB->FlowContCB.TxPoolCnt = FLOW_CONT_MIN;
OSI_RET_OK_CHECK(sl_LockObjCreate(&g_pCB->FlowContCB.TxLockObj, "TxLockObj"));
OSI_RET_OK_CHECK(sl_SyncObjCreate(&g_pCB->FlowContCB.TxSyncObj, "TxSyncObj"));
}
/*****************************************************************************/
/* _SlDrvFlowContDeinit */
/*****************************************************************************/
void _SlDrvFlowContDeinit(void)
{
g_pCB->FlowContCB.TxPoolCnt = 0;
OSI_RET_OK_CHECK(sl_LockObjDelete(&g_pCB->FlowContCB.TxLockObj));
OSI_RET_OK_CHECK(sl_SyncObjDelete(&g_pCB->FlowContCB.TxSyncObj));
}

View File

@@ -0,0 +1,424 @@
/*
* fs.c - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#include "protocol.h"
#include "driver.h"
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define sl_min(a,b) (((a) < (b)) ? (a) : (b))
#define MAX_NVMEM_CHUNK_SIZE 1460
/*****************************************************************************/
/* Internal functions */
/*****************************************************************************/
/*****************************************************************************/
/* _sl_Strlen */
/*****************************************************************************/
_u16 _sl_Strlen(const _u8 *buffer)
{
_u16 len = 0;
if( buffer != NULL )
{
while(*buffer++) len++;
}
return len;
}
/*****************************************************************************/
/* _sl_GetCreateFsMode */
/*****************************************************************************/
_u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags)
{
_u32 granIdx = 0;
_u32 granNum = 0;
_u32 granTable[_FS_MAX_MODE_SIZE_GRAN] = {256,1024,4096,16384,65536};
for(granIdx= _FS_MODE_SIZE_GRAN_256B ;granIdx< _FS_MAX_MODE_SIZE_GRAN;granIdx++)
{
if( granTable[granIdx]*255 >= maxSizeInBytes )
break;
}
granNum = maxSizeInBytes/granTable[granIdx];
if( maxSizeInBytes % granTable[granIdx] != 0 )
granNum++;
return _FS_MODE(_FS_MODE_OPEN_WRITE_CREATE_IF_NOT_EXIST, granIdx, granNum, accessFlags);
}
/*****************************************************************************/
/* API functions */
/*****************************************************************************/
/*****************************************************************************/
/* sl_FsOpen */
/*****************************************************************************/
typedef union
{
_FsOpenCommand_t Cmd;
_FsOpenResponse_t Rsp;
}_SlFsOpenMsg_u;
#if _SL_INCLUDE_FUNC(sl_FsOpen)
const _SlCmdCtrl_t _SlFsOpenCmdCtrl =
{
SL_OPCODE_NVMEM_FILEOPEN,
sizeof(_FsOpenCommand_t),
sizeof(_FsOpenResponse_t)
};
_i32 sl_FsOpen(const _u8 *pFileName,const _u32 AccessModeAndMaxSize, _u32 *pToken,_i32 *pFileHandle)
{
_SlReturnVal_t RetVal;
_SlFsOpenMsg_u Msg;
_SlCmdExt_t CmdExt;
CmdExt.TxPayloadLen = (_sl_Strlen(pFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */
CmdExt.RxPayloadLen = 0;
CmdExt.pTxPayload = (_u8*)pFileName;
CmdExt.pRxPayload = NULL;
Msg.Cmd.Mode = AccessModeAndMaxSize;
if(pToken != NULL)
{
Msg.Cmd.Token = *pToken;
}
else
{
Msg.Cmd.Token = 0;
}
RetVal = _SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsOpenCmdCtrl, &Msg, &CmdExt);
*pFileHandle = Msg.Rsp.FileHandle;
if (pToken != NULL)
{
*pToken = Msg.Rsp.Token;
}
/* in case of an error, return the erros file handler as an error code */
if( *pFileHandle < 0 )
{
return *pFileHandle;
}
return (_i32)RetVal;
}
#endif
/*****************************************************************************/
/* sl_FsClose */
/*****************************************************************************/
typedef union
{
_FsCloseCommand_t Cmd;
_BasicResponse_t Rsp;
}_SlFsCloseMsg_u;
#if _SL_INCLUDE_FUNC(sl_FsClose)
const _SlCmdCtrl_t _SlFsCloseCmdCtrl =
{
SL_OPCODE_NVMEM_FILECLOSE,
sizeof(_FsCloseCommand_t),
sizeof(_FsCloseResponse_t)
};
_i16 sl_FsClose(const _i32 FileHdl, const _u8* pCeritificateFileName,const _u8* pSignature ,const _u32 SignatureLen)
{
_SlFsCloseMsg_u Msg = {{0, 0}};
_SlCmdExt_t ExtCtrl;
Msg.Cmd.FileHandle = FileHdl;
if( pCeritificateFileName != NULL )
{
Msg.Cmd.CertificFileNameLength = (_sl_Strlen(pCeritificateFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */
}
Msg.Cmd.SignatureLen = SignatureLen;
ExtCtrl.TxPayloadLen = ((SignatureLen+3) & (~3)); /* align */
ExtCtrl.pTxPayload = (_u8*)pSignature;
ExtCtrl.RxPayloadLen = (_i16)Msg.Cmd.CertificFileNameLength;
ExtCtrl.pRxPayload = (_u8*)pCeritificateFileName; /* Add signature */
if(ExtCtrl.pRxPayload != NULL && ExtCtrl.RxPayloadLen != 0)
{
ExtCtrl.RxPayloadLen = ExtCtrl.RxPayloadLen * (-1);
}
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsCloseCmdCtrl, &Msg, &ExtCtrl));
return (_i16)((_i16)Msg.Rsp.status);
}
#endif
/*****************************************************************************/
/* sl_FsRead */
/*****************************************************************************/
typedef union
{
_FsReadCommand_t Cmd;
_FsReadResponse_t Rsp;
}_SlFsReadMsg_u;
#if _SL_INCLUDE_FUNC(sl_FsRead)
const _SlCmdCtrl_t _SlFsReadCmdCtrl =
{
SL_OPCODE_NVMEM_FILEREADCOMMAND,
sizeof(_FsReadCommand_t),
sizeof(_FsReadResponse_t)
};
_i32 sl_FsRead(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len)
{
_SlFsReadMsg_u Msg;
_SlCmdExt_t ExtCtrl;
_u16 ChunkLen;
_SlReturnVal_t RetVal =0;
_i32 RetCount = 0;
ExtCtrl.TxPayloadLen = 0;
ExtCtrl.pTxPayload = NULL;
ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len);
ExtCtrl.RxPayloadLen = ChunkLen;
ExtCtrl.pRxPayload = (_u8 *)(pData);
Msg.Cmd.Offset = Offset;
Msg.Cmd.Len = ChunkLen;
Msg.Cmd.FileHandle = FileHdl;
do
{
RetVal = _SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsReadCmdCtrl, &Msg, &ExtCtrl);
if(SL_OS_RET_CODE_OK == RetVal)
{
if( Msg.Rsp.status < 0)
{
if( RetCount > 0)
{
return RetCount;
}
else
{
return Msg.Rsp.status;
}
}
RetCount += (_i32)Msg.Rsp.status;
Len -= ChunkLen;
Offset += ChunkLen;
Msg.Cmd.Offset = Offset;
ExtCtrl.pRxPayload += ChunkLen;
ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len);
ExtCtrl.RxPayloadLen = ChunkLen;
Msg.Cmd.Len = ChunkLen;
Msg.Cmd.FileHandle = FileHdl;
}
else
{
return RetVal;
}
}while(ChunkLen > 0);
return (_i32)RetCount;
}
#endif
/*****************************************************************************/
/* sl_FsWrite */
/*****************************************************************************/
typedef union
{
_FsWriteCommand_t Cmd;
_FsWriteResponse_t Rsp;
}_SlFsWriteMsg_u;
#if _SL_INCLUDE_FUNC(sl_FsWrite)
const _SlCmdCtrl_t _SlFsWriteCmdCtrl =
{
SL_OPCODE_NVMEM_FILEWRITECOMMAND,
sizeof(_FsWriteCommand_t),
sizeof(_FsWriteResponse_t)
};
_i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len)
{
_SlFsWriteMsg_u Msg;
_SlCmdExt_t ExtCtrl;
_u16 ChunkLen;
_SlReturnVal_t RetVal;
_i32 RetCount = 0;
ExtCtrl.RxPayloadLen = 0;
ExtCtrl.pRxPayload = NULL;
ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len);
ExtCtrl.TxPayloadLen = ChunkLen;
ExtCtrl.pTxPayload = (_u8 *)(pData);
Msg.Cmd.Offset = Offset;
Msg.Cmd.Len = ChunkLen;
Msg.Cmd.FileHandle = FileHdl;
do
{
RetVal = _SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsWriteCmdCtrl, &Msg, &ExtCtrl);
if(SL_OS_RET_CODE_OK == RetVal)
{
if( Msg.Rsp.status < 0)
{
if( RetCount > 0)
{
return RetCount;
}
else
{
return Msg.Rsp.status;
}
}
RetCount += (_i32)Msg.Rsp.status;
Len -= ChunkLen;
Offset += ChunkLen;
Msg.Cmd.Offset = Offset;
ExtCtrl.pTxPayload += ChunkLen;
ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len);
ExtCtrl.TxPayloadLen = ChunkLen;
Msg.Cmd.Len = ChunkLen;
Msg.Cmd.FileHandle = FileHdl;
}
else
{
return RetVal;
}
}while(ChunkLen > 0);
return (_i32)RetCount;
}
#endif
/*****************************************************************************/
/* sl_FsGetInfo */
/*****************************************************************************/
typedef union
{
_FsGetInfoCommand_t Cmd;
_FsGetInfoResponse_t Rsp;
}_SlFsGetInfoMsg_u;
#if _SL_INCLUDE_FUNC(sl_FsGetInfo)
const _SlCmdCtrl_t _SlFsGetInfoCmdCtrl =
{
SL_OPCODE_NVMEM_FILEGETINFOCOMMAND,
sizeof(_FsGetInfoCommand_t),
sizeof(_FsGetInfoResponse_t)
};
_i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileInfo)
{
_SlFsGetInfoMsg_u Msg;
_SlCmdExt_t CmdExt;
CmdExt.TxPayloadLen = (_sl_Strlen(pFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */
CmdExt.RxPayloadLen = 0;
CmdExt.pTxPayload = (_u8*)pFileName;
CmdExt.pRxPayload = NULL;
Msg.Cmd.Token = Token;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsGetInfoCmdCtrl, &Msg, &CmdExt));
pFsFileInfo->flags = Msg.Rsp.flags;
pFsFileInfo->FileLen = Msg.Rsp.FileLen;
pFsFileInfo->AllocatedLen = Msg.Rsp.AllocatedLen;
pFsFileInfo->Token[0] = Msg.Rsp.Token[0];
pFsFileInfo->Token[1] = Msg.Rsp.Token[1];
pFsFileInfo->Token[2] = Msg.Rsp.Token[2];
pFsFileInfo->Token[3] = Msg.Rsp.Token[3];
return (_i16)((_i16)Msg.Rsp.Status);
}
#endif
/*****************************************************************************/
/* sl_FsDel */
/*****************************************************************************/
typedef union
{
_FsDeleteCommand_t Cmd;
_FsDeleteResponse_t Rsp;
}_SlFsDeleteMsg_u;
#if _SL_INCLUDE_FUNC(sl_FsDel)
const _SlCmdCtrl_t _SlFsDeleteCmdCtrl =
{
SL_OPCODE_NVMEM_FILEDELCOMMAND,
sizeof(_FsDeleteCommand_t),
sizeof(_FsDeleteResponse_t)
};
_i16 sl_FsDel(const _u8 *pFileName,const _u32 Token)
{
_SlFsDeleteMsg_u Msg;
_SlCmdExt_t CmdExt;
CmdExt.TxPayloadLen = (_sl_Strlen(pFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */
CmdExt.RxPayloadLen = 0;
CmdExt.pTxPayload = (_u8*)pFileName;
CmdExt.pRxPayload = NULL;
Msg.Cmd.Token = Token;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsDeleteCmdCtrl, &Msg, &CmdExt));
return (_i16)((_i16)Msg.Rsp.status);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,150 @@
/*
* netcfg.c - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#include "protocol.h"
#include "driver.h"
/*****************************************************************************/
/* sl_NetCfgSet */
/*****************************************************************************/
typedef union
{
_NetCfgSetGet_t Cmd;
_BasicResponse_t Rsp;
}_SlNetCfgMsgSet_u;
#if _SL_INCLUDE_FUNC(sl_NetCfgSet)
const _SlCmdCtrl_t _SlNetCfgSetCmdCtrl =
{
SL_OPCODE_DEVICE_NETCFG_SET_COMMAND,
sizeof(_NetCfgSetGet_t),
sizeof(_BasicResponse_t)
};
_i32 sl_NetCfgSet(const _u8 ConfigId ,const _u8 ConfigOpt,const _u8 ConfigLen,const _u8 *pValues)
{
_SlNetCfgMsgSet_u Msg;
_SlCmdExt_t CmdExt;
_SlDrvResetCmdExt(&CmdExt);
CmdExt.TxPayloadLen = (ConfigLen+3) & (~3);
CmdExt.pTxPayload = (_u8 *)pValues;
Msg.Cmd.ConfigId = ConfigId;
Msg.Cmd.ConfigLen = ConfigLen;
Msg.Cmd.ConfigOpt = ConfigOpt;
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetCfgSetCmdCtrl, &Msg, &CmdExt));
return (_i16)Msg.Rsp.status;
}
#endif
/*****************************************************************************/
/* sl_NetCfgGet */
/*****************************************************************************/
typedef union
{
_NetCfgSetGet_t Cmd;
_NetCfgSetGet_t Rsp;
}_SlNetCfgMsgGet_u;
#if _SL_INCLUDE_FUNC(sl_NetCfgGet)
const _SlCmdCtrl_t _SlNetCfgGetCmdCtrl =
{
SL_OPCODE_DEVICE_NETCFG_GET_COMMAND,
sizeof(_NetCfgSetGet_t),
sizeof(_NetCfgSetGet_t)
};
_i32 sl_NetCfgGet(const _u8 ConfigId, _u8 *pConfigOpt,_u8 *pConfigLen, _u8 *pValues)
{
_SlNetCfgMsgGet_u Msg;
_SlCmdExt_t CmdExt;
if (*pConfigLen == 0)
{
return SL_EZEROLEN;
}
_SlDrvResetCmdExt(&CmdExt);
CmdExt.RxPayloadLen = *pConfigLen;
CmdExt.pRxPayload = (_u8 *)pValues;
Msg.Cmd.ConfigLen = *pConfigLen;
Msg.Cmd.ConfigId = ConfigId;
if( pConfigOpt )
{
Msg.Cmd.ConfigOpt = (_u16)*pConfigOpt;
}
VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetCfgGetCmdCtrl, &Msg, &CmdExt));
if( pConfigOpt )
{
*pConfigOpt = (_u8)Msg.Rsp.ConfigOpt;
}
if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
{
*pConfigLen = (_u8)CmdExt.RxPayloadLen;
if( SL_MAC_ADDRESS_GET == ConfigId )
{
return SL_RET_CODE_OK; /* sp fix */
}
else
{
return SL_ESMALLBUF;
}
}
else
{
*pConfigLen = (_u8)CmdExt.ActualRxPayloadLen;
}
return (_i16)Msg.Rsp.Status;
}
#endif

View File

@@ -0,0 +1,171 @@
/*
* nonos.c - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#include "protocol.h"
#include "driver.h"
#ifndef SL_PLATFORM_MULTI_THREADED
#include "nonos.h"
#ifndef SL_TINY_EXT
#define NONOS_MAX_SPAWN_ENTRIES 5
#else
#define NONOS_MAX_SPAWN_ENTRIES 1
#endif
typedef struct
{
_SlSpawnEntryFunc_t pEntry;
void* pValue;
}_SlNonOsSpawnEntry_t;
typedef struct
{
_SlNonOsSpawnEntry_t SpawnEntries[NONOS_MAX_SPAWN_ENTRIES];
}_SlNonOsCB_t;
_SlNonOsCB_t g__SlNonOsCB;
_SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value)
{
*pSemObj = Value;
return NONOS_RET_OK;
}
_SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout)
{
#ifdef _SlSyncWaitLoopCallback
_SlNonOsTime_t timeOutRequest = Timeout;
#endif
while (Timeout>0)
{
if (WaitValue == *pSyncObj)
{
*pSyncObj = SetValue;
break;
}
if (Timeout != NONOS_WAIT_FOREVER)
{
Timeout--;
}
_SlNonOsMainLoopTask();
#ifdef _SlSyncWaitLoopCallback
if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) )
{
if (WaitValue == *pSyncObj)
{
*pSyncObj = SetValue;
break;
}
_SlSyncWaitLoopCallback();
}
#endif
}
if (0 == Timeout)
{
return NONOS_RET_ERR;
}
else
{
return NONOS_RET_OK;
}
}
_SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags)
{
_i8 i = 0;
#ifndef SL_TINY_EXT
for (i=0 ; i<NONOS_MAX_SPAWN_ENTRIES ; i++)
#endif
{
_SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
if (NULL == pE->pEntry)
{
pE->pValue = pValue;
pE->pEntry = pEntry;
#ifndef SL_TINY_EXT
break;
#endif
}
}
return NONOS_RET_OK;
}
_SlNonOsRetVal_t _SlNonOsMainLoopTask(void)
{
_i8 i=0;
#ifndef SL_TINY_EXT
for (i=0 ; i<NONOS_MAX_SPAWN_ENTRIES ; i++)
#endif
{
_SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
_SlSpawnEntryFunc_t pF = pE->pEntry;
if (NULL != pF)
{
if(RxIrqCnt != (g_pCB)->RxDoneCnt)
{
pF(0); /* (pValue) */
}
pE->pEntry = NULL;
pE->pValue = NULL;
}
}
return NONOS_RET_OK;
}
#endif /*(SL_PLATFORM != SL_PLATFORM_NON_OS)*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,197 @@
/*
* spawn.c - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#if (defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
#define _SL_MAX_INTERNAL_SPAWN_ENTRIES 10
typedef struct _SlInternalSpawnEntry_t
{
_SlSpawnEntryFunc_t pEntry;
void* pValue;
struct _SlInternalSpawnEntry_t* pNext;
}_SlInternalSpawnEntry_t;
typedef struct
{
_SlInternalSpawnEntry_t SpawnEntries[_SL_MAX_INTERNAL_SPAWN_ENTRIES];
_SlInternalSpawnEntry_t* pFree;
_SlInternalSpawnEntry_t* pWaitForExe;
_SlInternalSpawnEntry_t* pLastInWaitList;
_SlSyncObj_t SyncObj;
_SlLockObj_t LockObj;
}_SlInternalSpawnCB_t;
_SlInternalSpawnCB_t g_SlInternalSpawnCB;
void _SlInternalSpawnTaskEntry()
{
_i16 i;
_SlInternalSpawnEntry_t* pEntry;
_u8 LastEntry;
/* create and lock the locking object. lock in order to avoid race condition
on the first creation */
sl_LockObjCreate(&g_SlInternalSpawnCB.LockObj,"SlSpawnProtect");
sl_LockObjLock(&g_SlInternalSpawnCB.LockObj,SL_OS_NO_WAIT);
/* create and clear the sync object */
sl_SyncObjCreate(&g_SlInternalSpawnCB.SyncObj,"SlSpawnSync");
sl_SyncObjWait(&g_SlInternalSpawnCB.SyncObj,SL_OS_NO_WAIT);
g_SlInternalSpawnCB.pFree = &g_SlInternalSpawnCB.SpawnEntries[0];
g_SlInternalSpawnCB.pWaitForExe = NULL;
g_SlInternalSpawnCB.pLastInWaitList = NULL;
/* create the link list between the entries */
for (i=0 ; i<_SL_MAX_INTERNAL_SPAWN_ENTRIES - 1 ; i++)
{
g_SlInternalSpawnCB.SpawnEntries[i].pNext = &g_SlInternalSpawnCB.SpawnEntries[i+1];
g_SlInternalSpawnCB.SpawnEntries[i].pEntry = NULL;
}
g_SlInternalSpawnCB.SpawnEntries[i].pNext = NULL;
_SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj);
/* here we ready to execute entries */
while (TRUE)
{
sl_SyncObjWait(&g_SlInternalSpawnCB.SyncObj,SL_OS_WAIT_FOREVER);
/* go over all entries that already waiting for execution */
LastEntry = FALSE;
do
{
/* get entry to execute */
_SlDrvObjLockWaitForever(&g_SlInternalSpawnCB.LockObj);
pEntry = g_SlInternalSpawnCB.pWaitForExe;
if ( NULL == pEntry )
{
_SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj);
break;
}
g_SlInternalSpawnCB.pWaitForExe = pEntry->pNext;
if (pEntry == g_SlInternalSpawnCB.pLastInWaitList)
{
g_SlInternalSpawnCB.pLastInWaitList = NULL;
LastEntry = TRUE;
}
_SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj);
/* pEntry could be null in case that the sync was already set by some
of the entries during execution of earlier entry */
if (NULL != pEntry)
{
pEntry->pEntry(pEntry->pValue);
/* free the entry */
_SlDrvObjLockWaitForever(&g_SlInternalSpawnCB.LockObj);
pEntry->pNext = g_SlInternalSpawnCB.pFree;
g_SlInternalSpawnCB.pFree = pEntry;
if (NULL != g_SlInternalSpawnCB.pWaitForExe)
{
/* new entry received meanwhile */
LastEntry = FALSE;
}
_SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj);
}
}while (!LastEntry);
}
}
_i16 _SlInternalSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags)
{
_i16 Res = 0;
_SlInternalSpawnEntry_t* pSpawnEntry;
if (NULL == pEntry)
{
Res = -1;
}
else
{
_SlDrvObjLockWaitForever(&g_SlInternalSpawnCB.LockObj);
pSpawnEntry = g_SlInternalSpawnCB.pFree;
g_SlInternalSpawnCB.pFree = pSpawnEntry->pNext;
pSpawnEntry->pEntry = pEntry;
pSpawnEntry->pValue = pValue;
pSpawnEntry->pNext = NULL;
if (NULL == g_SlInternalSpawnCB.pWaitForExe)
{
g_SlInternalSpawnCB.pWaitForExe = pSpawnEntry;
g_SlInternalSpawnCB.pLastInWaitList = pSpawnEntry;
}
else
{
g_SlInternalSpawnCB.pLastInWaitList->pNext = pSpawnEntry;
g_SlInternalSpawnCB.pLastInWaitList = pSpawnEntry;
}
_SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj);
/* this sync is called after releasing the lock object to avoid unnecessary context switches */
_SlDrvSyncObjSignal(&g_SlInternalSpawnCB.SyncObj);
}
return Res;
}
#endif

File diff suppressed because it is too large Load Diff