PIC18F97J60+MRF24WB WIFI API

Source: Internet
Author: User

Unlike Ethernet, a WiFi application needs to initiate a connection to an access point or an ad hoc network) before data Co Mmunications can commence. In order to initiate an connection there are a sequence of steps that should be followed.

1) A connection profile must is created (see Wf_cpcreate ()). The connection profile contains information directing the Wi-Fi driver about the nature of the connection so would be ESTA Blished. The connection profile defines:

A. SSID (name of Access point)

B. Security (open, WEP, WPA, etc.)

C. Network type (infrastructure or ad hoc).

The Connection profile functions is used to create and define a Connection profile. These functions all begin with WF_CP ...

2) The connection algorithm must is defined, and applies to all connection profiles. For most applications the defaults would be sufficient. For example, the default connection algorithm channel list for scanning is 1, 6, and 11. However, if, in your application you know the Access point would always have on channel 6 your could change this setting, thus Making the scan process more efficient. Functions pertaining to the connection algorithm all begin with Wf_ca ...

3) Once a connection profile and the connection algorithm is customized for an application, the Wf_cmconnect () function M UST is called to initiate the connection process.

4) after Wf_connect () is called the host application would be a notified when the mrf24wb0m have succeeded (or failed) in ESTA Blishing a connection via the event mechanism. The wf_config.c file has a function, wf_processevent (), which is a template for processing mrf24wb0m events. In the Wi-Fi demos it simply prints to the console (if the UART was enabled) that the event occurred. This file can is modified to suit the needs of an application–for example, an application could pend on a global flag th At would is set in Wf_processevent () when the connection succeeded. Please refer the wf_processevent for more information on WiFi event handling.

The mrf2wb0m demos (under the demo App, WiFi Console, and WiFi EZ Config Demo directories) contain a function, Wf_connect ( ), in MAINDEMO.C this executes the above steps and can be referred to as an example of what to initiate a WiFi connection. The Wf_config.h file has several Compile-time constants, can be customized (e.g. my_default_ssid_name) as needed.

This Help file book describes the host API to the mrf24wb0m on-chip Connection Manager which creates and maintains Wi-Fi c Onnections. The API is divided into these major sections:

API section Description
Initialization Functions to initialize the host API and mrf24wb0m
Connection profile Functions to create and maintain one or more connection profiles
Connection algorithm Functions to fine tune the connection algorithm
Connection Manager Functions to start and stop an 802.11 connection
Scan Functions to scan for wireless networks
Tx Power Control Functions to control the mrf24wb0m Tx power
Power Save Functions to save power consumption by the mrf24wb0m
Multicast Functions to create multicast filters
Miscellaneous Functions to set a custom MAC address, get device information, etc.
mrf24wb0m Events Functions to handle events from the mrf24wb0m

Spi

The Wf_spi.c file contains functions that the Wi-Fi Driver would use a to initialize, send, and receive SPI messages between The host CPU and the mrf24wb0m. To communicate with the mrf24wb0m, which are always a SPI slave, the host CPU SPI controller needs to be configured as fol Lows:mode = 0 Cpol (clock polarity) = 0 Cpha (clock phase) = 0 Host CPU set as master clock idles high 8-bit transfer len Gth data changes on falling edge Data sampled on rising Edge

Below is a list of functions in WF_SPI.C This must be customized for the specific host CPU architecture:

function  description 
wf_spiinit ()   initializes the host CPU SPI controller for usage by the Wi-Fi driver. Called by the Wi-Fi driver during initialization. 
wf_spitxrx ()   Tran Smits and/or receives SPI data from the mrf24wb0m. 
wf_spienablechipselect ()   Set Slave Select line on mrf24wb0m low (start SPI transfer).

If The SPI bus is a shared with any other devices then this function also needs to save the current SPI context and th En configure the mrf24wb0m SPI context. 
wf_spidisablechipselect ()   S Et slave select line in mrf24wb0m high (end SPI transfer).

If The SPI bus is a shared with any other devices then this function also needs to restore the SPI context (saved Duri ng Wf_spienablechipselect ()) . 

External Interrupt

The wf_eint.c file contains functions that the Wi-Fi Driver would use to enable and disable the mrf24wb0m external Interrup T as well as get interrupt status. The functions in this module need to is customized for the specific host CPU architecture.

The mrf24wb0m asserts its exint (external interrupt) line (active low) when specific events occur, such as a data message Being received. Note that the host CPUs have a choice to either configure the Exint line to generate an actual interrupt, or, it can be poll Ed. Below is a list of the Wi-Fi Driver functions within wf_eint.c that must being customized for the specific Host CPU Archi Tecture.

Function Description
Wf_eintinit () Configures the interrupt for use and leaves it in a disabled state. Would be called by the Wi-Fi driver during initialization. If polling the Exint pin then this function won ' t has any work to does except leave the interrupt in a logically disabled s Tate.
Wf_eintenable () Enables the mrf24wb0m external interrupt. If using real interrupts then enable the interrupt. If polling the Exint pin then this function enables polling of the pin.
Wf_eintdisable () Disables the mrf24wb0m external interrupt. If using real interrupts then disable the interrupt. If polling the Exint pin then this function disables polling of the pin.
WF_EINTISR () The interrupt service routine invoked when the Exint line goes low. It should perform any necessary housekeeping, such as clearing the interrupt. The interrupt must remain disabled until the Wi-Fi Driver calls Wf_eintenable (). The Wi-Fi driver function, Wfeinthandler () must be called.
Wf_eintisdisabled () Returns true if the external interrupt is disabled, else Returns false.
Wfeinthandler () This function does isn't need to being customized–it is part of the Wi-Fi driver. However, it's added to this list because it must being called each time the mrf24wb0m Interrupt Service Routine (ISR) occurs .
Wf_config

The Wf_config module (WF_CONFIG.H/WF_CONFIG.C) is used to control several aspects of the WiFi Driver behavior. The most of the customization of the Wi-Fi module is do from the context of this module. Removal of Unused Driver Functions

In Wf_customize.h there are a block of defines that can being commented out to remove those sections of the Wi-Fi host driver That is not needed by the application. This allows the saving of code and data space.

#define   controlling functions 
wf_use_scan_functions  SCAN api 
wf_use_tx_power_control_functio ns  Tx power control api 
wf_use_power_save_functions  Power Save api 
wf_use_multicast_functions  multicast api 
wf_use_individual_set_gets  affects all get and SET functions, except the following:
Wf_cpsetelements ()
wf_cpgetelements ()
wf_casetelements ()
Wf_cagetelements ()  
wf_use_group_set_gets  affects the following functions:
wf_cpsetelements ()
wf_cpgetelements ()
wf_casetelements ()
Wf_cage Telements ()  
Wf_debug

This define enables the Wf_assert macro in the Wi-Fi driver. Customer code is the free to use the This macro. The Wf_assert macro can be compiled on or out via the Wf_debug define. See the comment above the Wf_debug define in wf_customize.h for details. Wf_console

The Wi-Fi driver has a UART console, application built in, allows one to type in command lines and have them parsed. If This functionality was not needed than it can be compiled out by commenting out the Wf_console define. Wf_processevent ()

This function was called by the Wi-Fi Driver When an event occurs, the host CPU needs to be notified of. There is several Wi-Fi connection related events, the application can choose whether to being notified or not. And, there is several events the application would always be notified of.

The function wf_processevent () can be customized to support desired handling of events. Modules

Name Description
Wi-Fi Connection profile Functions to setup, use, and teardown connection profiles
Wi-Fi Connection algorithm Functions to alter the behavior of the connection process
Wi-Fi Connection Manager Functions to manage the connection process
Wi-Fi Scan Functions to direct the mrf24wb0m to initiate a site survey
Wi-Fi Tx Power Control API to control the Tx power of the mrf24wb0m
Wi-Fi Power Save Functions to alter the power savings features of the mrf24wb0m
Wi-Fi Miscellaneous Functions for controlling miscellaneous features of the mrf24wb0m
Topics
Name Description
Wf_processevent Describes how to receive and act on events from the mrf24wb0m
Access Point Compatibility
WiFi Tips and Tricks Describes some basic tips for setting up and configuring a WiFi network.
Hot Topics Lists some answers to some common WiFi questions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.