TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
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.

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...
 

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.

Commands for WiFi_control can originate from WiFi.h or from implementation specific WiFi*.h (WiFiCC26XX.h, WiFiTiva.h, etc.. ) files. While commands from WiFi.h are API portable across driver implementations, not all implementations may support all these commands. Conversely, commands from driver implementation specific WiFi*.h files add unique driver capabilities but are not API portable across all WiFi driver implementations.

Commands supported by WiFi.h follow a WiFi_CMD_<cmd> naming convention.
Commands supported by WiFi*.h follow a WiFi*_CMD_<cmd> naming convention.
Each control command defines arg differently. The types of arg are documented with each command.

See WiFi_control command codes for command codes.

See WiFi_control return status codes for status codes.

Precondition
WiFi_open() has to be called first.
Parameters
handleA WiFi handle returned from WiFi_open()
cmdWiFi.h or WiFi*.h commands.
argAn optional R/W (read/write) command argument 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 2016, Texas Instruments Incorporated