Data Structures | |
struct | wlp_network_t |
Defines | |
#define | WLP_INVALID_SOCKET_ID 0 |
#define | WLP_VERSION_CODE WLP_VERSION(1,1,3) |
Functions | |
int | wlp_init (uint32_t baudrate, uint8_t rtscts, 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_get_fw_version (uint32_t *code, char *build, int len) |
Get the firmware version. |
These functions manage the library in general.
#define WLP_INVALID_SOCKET_ID 0 |
#define WLP_VERSION_CODE WLP_VERSION(1,1,3) |
int wlp_get_fw_version | ( | uint32_t * | code, | |
char * | build, | |||
int | len | |||
) |
Get the firmware version.
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. |
int wlp_init | ( | uint32_t | baudrate, | |
uint8_t | rtscts, | |||
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_api() will perform the following steps when invoked 1) 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. 2) Send a uart configuration message which will configure the wifi device according to the provided baudrate and rtscts parameters.
Note again that the uart which the callback parameters readf and writef uses must be configured for 57600 8N1 before calling wlp_init().
Upon successful return, the wifi device will use the new uart configuration. If the configured is changed (i.e. not 57600), the host must change its uart settings accordingly before any other function in wlp_api is called.
Allow the wifi device up to 200 ms to boot before calling wlp_init() after power up. Also allow the wifi device up to 100 ms after wlp_init() has returned before the next call to any wlp api function.
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) Reconfigure host uart if the baudrate and rtcts parameters to wlp_init() was not 57600 and 0, respectively. 5) Wait 100 ms afer wlp_init() has returned to allow the device to reconfigure its uart. 6) Done, now the wifi device is ready to use.
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.
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. |