TI-RTOS for TivaC  2.14.04.31
Data Structures | Macros | Typedefs | Functions
WiFi.h File Reference

Detailed Description

WiFi driver interface.

============================================================================

The WiFi header file should be included in an application as follows:

Operation

The TI-RTOS WiFi driver implements many of the crucial elements necessary to communicate with a TI Wi-Fi device. It uses the TI-RTOS SPI module and implements a state machine to send and receive commands, data, and events to and from a Wi-Fi device.

The APIs in this driver give the user the ability to open a WiFi driver instance that will communicate with the Wi-Fi device's host driver without further direct calls to the driver from the application.

Opening the driver

WiFi_Handle handle;
WiFi_Params params;
params.bitRate = bitRateValue;
handle = WiFi_open(WiFi_configIndex, SPI_configIndex, callbackPtr,
&params);
if (!handle) {
System_printf("WiFi did not open");
}
// Wi-Fi device's host driver APIs (such as socket()) may now be used

Configuration

SimpleLink CC3100 device

The SimpleLink Host Driver for CC3100 the device requires a mechanism to allow functions to execute in a temporary context. A SpawnTask is dynamically created to meet satisfy this requirement. The priority for the SpawnTask can be changed via the graphical editor, or by editing the script as a text file, with the following line of code:

WiFi.spawnTaskPriority = 3;

The default will create the SpawnTask with the priority set to 3.

Implementation

The WiFi driver interface module is joined (at link time) to a NULL-terminated array of WiFi_Config data structures named WiFi_config. WiFi_config is implemented in the application with each entry being an instance of a WiFi driver. Each entry in WiFi_config contains a:

The WiFi driver currently only supports one instance of the module. This means that the WiFi_config structure may only contain one non-NULL entry, and it must be located at index 0.

Currently the following WiFi implementations are supported:

Instrumentation

The WiFi driver interface produces log statements if instrumentation is enabled.

Diagnostics Mask Log details
Diags_USER1 basic operations performed
Diags_USER2 detailed operations performed

#include <stdint.h>
Include dependency graph for WiFi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WiFi_Params
 WiFi Parameters. More...
 
struct  WiFi_FxnTable
 The definition of a WiFi function table that contains the required set of functions to control a specific WiFi driver implementation. More...
 
struct  WiFi_Config
 WiFi Global configuration. More...
 

Macros

#define WiFi_CMD_RESERVED   32
 
#define WiFi_STATUS_RESERVED   -32
 
#define WiFi_STATUS_SUCCESS   0
 Successful status code returned by WiFi_control(). More...
 
#define WiFi_STATUS_ERROR   -1
 Generic error status code returned by WiFi_control(). More...
 
#define WiFi_STATUS_UNDEFINEDCMD   -2
 An error status code returned by WiFi_control() for undefined command codes. More...
 

Typedefs

typedef void(* WiFi_evntCallback) (long eventType, char *data, unsigned char length)
 A typedef to a an unsolicited event callback function. More...
 
typedef struct WiFi_ConfigWiFi_Handle
 A handle that is returned from a WiFi_open() call. More...
 
typedef struct WiFi_Params WiFi_Params
 WiFi Parameters. More...
 
typedef void(* WiFi_InitFxn) (WiFi_Handle handle)
 A function pointer to a driver specific implementation of WiFi_init(). More...
 
typedef WiFi_Handle(* WiFi_OpenFxn) (WiFi_Handle handle, unsigned int spiIndex, WiFi_evntCallback evntCallback, WiFi_Params *params)
 A function pointer to a driver specific implementation of WiFi_open(). More...
 
typedef void(* WiFi_CloseFxn) (WiFi_Handle handle)
 A function pointer to a driver specific implementation of WiFi_close(). More...
 
typedef int(* WiFi_ControlFxn) (WiFi_Handle handle, unsigned int cmd, void *arg)
 A function pointer to a driver specific implementation of WiFi_control(). More...
 
typedef struct WiFi_FxnTable WiFi_FxnTable
 The definition of a WiFi function table that contains the required set of functions to control a specific WiFi driver implementation. More...
 
typedef struct WiFi_Config WiFi_Config
 WiFi Global configuration. More...
 

Functions

void WiFi_close (WiFi_Handle handle)
 Function to close a WiFi peripheral specified by the WiFi handle. More...
 
int WiFi_control (WiFi_Handle handle, unsigned int cmd, void *arg)
 Function performs implementation specific features on a given WiFi_Handle. More...
 
void WiFi_init (void)
 Function to initialize the WiFi module. More...
 
WiFi_Handle WiFi_open (unsigned int wifiIndex, unsigned int spiIndex, WiFi_evntCallback evntCallback, WiFi_Params *params)
 Function to initialize a given WiFi peripheral. More...
 
void WiFi_Params_init (WiFi_Params *params)
 Function to initialize the WiFi_Params structure to its defaults. More...
 

Macro Definition Documentation

#define WiFi_CMD_RESERVED   32

Common WiFi_control command code reservation offset. WiFi driver implementations should offset command codes with WiFi_CMD_RESERVED growing positively

Example implementation specific command codes:

1 #define WiFiXYZ_CMD_COMMAND0 WiFi_CMD_RESERVED + 0
2 #define WiFiXYZ_CMD_COMMAND1 WiFi_CMD_RESERVED + 1
#define WiFi_STATUS_RESERVED   -32

Common WiFi_control status code reservation offset. WiFi driver implementations should offset status codes with WiFi_STATUS_RESERVED growing negatively.

Example implementation specific status codes:

1 #define WiFiXYZ_STATUS_ERROR0 WiFi_STATUS_RESERVED - 0
2 #define WiFiXYZ_STATUS_ERROR1 WiFi_STATUS_RESERVED - 1
3 #define WiFiXYZ_STATUS_ERROR2 WiFi_STATUS_RESERVED - 2
#define WiFi_STATUS_SUCCESS   0

Successful status code returned by WiFi_control().

WiFi_control() returns WiFi_STATUS_SUCCESS if the control code was executed successfully.

#define WiFi_STATUS_ERROR   -1

Generic error status code returned by WiFi_control().

WiFi_control() returns WiFi_STATUS_ERROR if the control code was not executed successfully.

#define WiFi_STATUS_UNDEFINEDCMD   -2

An error status code returned by WiFi_control() for undefined command codes.

WiFi_control() returns WiFi_STATUS_UNDEFINEDCMD if the control code is not recognized by the driver implementation.

Typedef Documentation

typedef void(* WiFi_evntCallback) (long eventType, char *data, unsigned char length)

A typedef to a an unsolicited event callback function.

This is the definition describing the function that is to be called when the Wi-Fi device has informed the host MCU that an event has occurred. For more details, see Doxygen documentation for the specific driver\ implementation in use.

Parameters
eventTypeType of event
dataPointer to extra data that some events may supply
lengthLength of data
typedef struct WiFi_Config* WiFi_Handle

A handle that is returned from a WiFi_open() call.

typedef struct WiFi_Params WiFi_Params

WiFi Parameters.

WiFi parameters are used to with the WiFi_open() call. Default values for these parameters are set using WiFi_Params_init().

See also
WiFi_Params_init()
typedef void(* WiFi_InitFxn) (WiFi_Handle handle)

A function pointer to a driver specific implementation of WiFi_init().

typedef WiFi_Handle(* WiFi_OpenFxn) (WiFi_Handle handle, unsigned int spiIndex, WiFi_evntCallback evntCallback, WiFi_Params *params)

A function pointer to a driver specific implementation of WiFi_open().

typedef void(* WiFi_CloseFxn) (WiFi_Handle handle)

A function pointer to a driver specific implementation of WiFi_close().

typedef int(* WiFi_ControlFxn) (WiFi_Handle handle, unsigned int cmd, void *arg)

A function pointer to a driver specific implementation of WiFi_control().

typedef struct WiFi_FxnTable WiFi_FxnTable

The definition of a WiFi function table that contains the required set of functions to control a specific WiFi driver implementation.

typedef struct WiFi_Config WiFi_Config

WiFi Global configuration.

The WiFi_Config structure contains a set of pointers used to characterize the WiFi driver implementation.

This structure needs to be defined before calling WiFi_init() and it must not be changed thereafter.

See also
WiFi_init()

Function Documentation

void WiFi_close ( WiFi_Handle  handle)

Function to close a WiFi peripheral specified by the WiFi handle.

Precondition
WiFi_open() has to be called first.
Parameters
handleA WiFi_Handle returned from WiFi_open
See also
WiFi_open()
int WiFi_control ( WiFi_Handle  handle,
unsigned int  cmd,
void *  arg 
)

Function performs implementation specific features on a given WiFi_Handle.

Precondition
WiFi_open() has to be called first.
Parameters
handleA WiFi handle returned from WiFi_open()
cmdA command value defined by the driver specific implementation
argAn optional R/W (read/write) argument that is accompanied with cmd
Returns
Implementation specific return codes. Negative values indicate unsuccessful operations.
See also
WiFi_open()
void WiFi_init ( void  )

Function to initialize the WiFi module.

Precondition
The WiFi_config structure must exist and be persistent before this function can be called. This function must also be called before any other WiFi driver APIs. This function call does not modify any peripheral registers.
WiFi_Handle WiFi_open ( unsigned int  wifiIndex,
unsigned int  spiIndex,
WiFi_evntCallback  evntCallback,
WiFi_Params params 
)

Function to initialize a given WiFi peripheral.

Function to initialize a given WiFi peripheral specified by the particular index value. It initializes the specified SPI peripheral and registers the callbacks that the Wi-Fi device's host driver requires. WiFi_open() may only be called in the context of a Task.

Precondition
WiFi_init() has been called
Parameters
wifiIndexLogical peripheral number for the WiFi indexed into the WiFi_config table
spiIndexLogical peripheral number for SPI to be used with the WiFi indexed into the SPI_config table
evntCallbackPointer to callback function to handle unsolicited events from the WiFi device. For details, see WiFi_evntCallback and the Doxygen documentation for the specific driver implementation in use.
paramsPointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only).
Returns
A WiFi_Handle on success or a NULL on an error or if it has been opened already.
See also
WiFi_init()
WiFi_close()
void WiFi_Params_init ( WiFi_Params params)

Function to initialize the WiFi_Params structure to its defaults.

Parameters
paramsAn pointer to WiFi_Params structure for initialization

Default values are: bitRate = 1000000;

Copyright 2015, Texas Instruments Incorporated