Library support functions

Data Structures

struct  wlp_network_t

Defines

#define WLP_INVALID_SOCKET_ID   0
#define WLP_VERSION_CODE   WLP_VERSION(1,2,2)

Functions

int wlp_init (int(*readf)(void *ctx, void *data, int len), int(*writef)(void *ctx, const void *data, int len), void *ctx)
 Initialize the wifi device.
int wlp_set_baudrate (uint32_t baudrate, uint8_t rtscts)
 Change the baudrate of the device.
int wlp_reset (void)
int wlp_get_fw_version (uint32_t *code, char *build, int len)
 Get the firmware version.

Detailed Description

These functions manage the library in general.


Define Documentation

#define WLP_INVALID_SOCKET_ID   0
#define WLP_VERSION_CODE   WLP_VERSION(1,2,2)

Function Documentation

int wlp_get_fw_version ( uint32_t *  code,
char *  build,
int  len 
)

Get the firmware version.

Parameters:
code will contain the fw version code upon successful return. The version can be compared to the driver version (WLP_VERSION_CODE) using the WLP_VERSION(), WLP_MAJOR_VERSION(), WLP_MINOR_VERSION() and the WLP_PATCH_VERSION() macros.
build will hold the build information upon successful return. The build information is a string of information for the particular fw build used on the device. No more then
len characters, including null termination, will be copied to the string pointed to by build.
len is the maximum amount of chars, including null termination, that will be copied to
build. 
Returns:
  • 0 on success
  • WLP_FAILURE if any failure occurs
int wlp_init ( int(*)(void *ctx, void *data, int len)  readf,
int(*)(void *ctx, const void *data, int len)  writef,
void *  ctx 
)

Initialize the wifi device.

Initialize the wlp api and configure the uart settings on the wifi device. Must be called before any other function in the wlp api.

wlp_init() will send a 'w' character, a 'w' will be received once the wifi device is ready. The 'w' chars must be transmitted and received at 57600 8N1.

Note again that the uart which the callback parameters readf and writef uses must be configured for 57600 8N1 before calling wlp_init().

Allow the wifi device up to 200 ms to boot before calling wlp_init() after power up.

The sequence on the host becomes 1) Power on host and wifi device 2) Wait 200 ms 3) Call wlp_init() with host uart configured as 57600 8N1 4) Done, now the wifi device is ready to use.

Parameters:
readf is a pointer to a function which reads chars from the bus which the wifi device is connected to and stores them in the location pointed to by the data paramter. Note that readf should block until the number of bytes specified in the len parameter are read.
writef should read chars from the location pointed to by the data paramter send them to the bus which the wifi device is connected to. Note that writef should block until the number of bytes specified in the len parameter are written.
ctx is an opaque context pointer that will be passed back to readf and writef.
Returns:
  • 0 on success
int wlp_reset ( void   ) 

Reset the device. wlp_init() must be called after wlp_reset() to complete the reset. This function is typically used to switch betweeen AP and STA modes after wlp_set_mode() has been used.

NOTE: In this release the baudrate must be 57600 before this function is called. See wlp_set_baudrate() for details on how to change the baudrate.

int wlp_set_baudrate ( uint32_t  baudrate,
uint8_t  rtscts 
)

Change the baudrate of the device.

Send a uart configuration message which will configure the wifi device according to the provided baudrate and rtscts parameters.

Upon successful return, the wifi device will use the new uart configuration. The host must change its uart settings accordingly before any other function in wlp_api is called.

The sequence on the host becomes 1) Call wlp_set_baudrate() to reconfigure the device baudrate. 2) Wait 100 ms afer wlp_set_baudrate() has returned to allow the device to reconfigure its uart. 3) Reconfigure host uart baudrate. 4) Done, now the wifi device is ready to use with the new baudrate setting.

The device supports the following baudrates:

 *
 *    Baudrate | Error (%)
 *    --------------------
 *       9600  | 0
 *      19200  | 0
 *      38400  | 0
 *      57600  | 0.08
 *     115200  | 0.16
 *     230400  | 0.16
 *     460800  | 0.16
 *     921600  | 0.16
 *    1000000  | 0
 *    1500000  | 0
 *    2000000  | 0
 *    3000000  | 0
 *    4000000  | 0
 *
 * 

Note that the actual baudrate used might differ from the desired baudrate. This is due to the fractional baud rate generation. It is recommended to keep the sum of the transmitter and receiver error less than 2.00 %. As shown by the table above, the SPB800 has a very small fractional error on the baudrates.

Parameters:
baudrate is the baudrate which the wifi device should switch to.
rtcts is the hardware handshake configuration which the wifi device should switch to. Set to 1 to enabled hardware handshaking, and 0 to disable hardware handshaking. Any hardware handshake will use the RTS and CTS pins.
readf is a pointer to a function which reads chars from the bus which the wifi device is connected to and stores them in the location pointed to by the data paramter. Note that readf should block until the number of bytes specified in the len parameter are read.
writef should read chars from the location pointed to by the data paramter send them to the bus which the wifi device is connected to. Note that writef should block until the number of bytes specified in the len parameter are written.
ctx is an opaque context pointer that will be passed back to readf and writef.
Returns:
  • 0 on success
  • WLP_ERR_PARAM if invalid baudrate or rtscts parameters.
Generated on Fri Jul 15 16:14:04 2011 for API Reference Manual by  doxygen 1.6.3