PIC18F97J60+mrf24wb WIFI API

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

 

1) A connection profile must be created (see WF_CPCreate()). The connection profile contains information directing the WiFi driver about the nature of the connection that will be established. 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 are used to create and define an connection profile. These functions all begin with WF_CP… 

 

2) The connection algorithm must be defined, and applies to all connection profiles. For most applications the defaults will 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 will always be on channel 6 you 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 are customized for an application, the WF_CMConnect() function must be called to initiate the connection process. 

 

4) After WF_Connect() is called the host application will be notified when the MRF24WB0M has succeeded (or failed) in establishing a connection via the event mechanism. The WF_Config.c file has a function, WF_ProcessEvent(), that is a template for processing MRF24WB0M events. In the WiFi demos it simply prints to the console (if the UART is enabled) that the event occurred. This file can be modified to suit the needs of an application – for example, an application could pend on a global flag that would be set in WF_ProcessEvent() when the connection succeeded. Please refer to 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 that executes the above steps and can be referred to as an example of how to initiate a WiFi connection. The WF_Config.h file has several compile-time constants that 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 connections. The API is divided into these major sections:

API Section 
Description 
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 will use to initialize, send, and receive SPI messages between the host CPU and the MRF24WB0M. To communicate with the MRF24WB0M, which is always an SPI slave, the host CPU SPI controller needs to be configured as follows:

  • Mode = 0
  • CPOL (clock polarity) = 0
  • CPHA (clock phase) = 0
  • Host CPU set as master
  • Clock idles high
  • 8-bit transfer length
  • Data changes on falling edge
  • Data sampled on rising edge

 

Below is a list of functions in WF_Spi.c that 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() 
Transmits and/or receives SPI data from the MRF24WB0M. 
WF_SpiEnableChipSelect() 
Set slave select line on MRF24WB0M low (start SPI transfer).

If SPI bus is shared with any other devices then this function also needs to save the current SPI context and then configure the MRF24WB0M SPI context. 
WF_SpiDisableChipSelect() 
Set slave select line on MRF24WB0M high (end SPI transfer).

If SPI bus is shared with any other devices then this function also needs to restore the SPI context (saved during WF_SpiEnableChipSelect()). 

 

External Interrupt

The WF_Eint.c file contains functions that the Wi-Fi Driver will use to enable and disable the MRF24WB0M external interrupt as well as get interrupt status. The functions in this module need to be 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 CPU has a choice to either configure the EXINT line to generate an actual interrupt, or, it can be polled. Below is a list of the Wi-Fi Driver functions within WF_Eint.c that must be customized for the specific Host CPU architecture.

Function 
Description 
WF_EintInit() 
Configures the interrupt for use and leaves it in a disabled state. Will be called by the Wi-Fi driver during initialization. If polling the EXINT pin then this function won’t have any work to do except leave the interrupt in a logically disabled state. 
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() 
This is 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 not need to be customized – it is part of the Wi-Fi driver. However, it is added to this list because it must be 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. Most of the customization of the Wi-Fi module is done from the context of this module.

Removal of Unused Driver Functions

In WF_Customize.h there is a block of defines that can be commented out to remove those sections of the Wi-Fi host driver that are 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_FUNCTIONS 
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_CAGetElements() 
WF_DEBUG

This define enables the WF_ASSERT macro in the Wi-Fi driver. Customer code is free to use this macro. The WF_ASSERT macro can be compiled in 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 that allows one to type in command lines and has them parsed. If this functionality is not needed than it can be compiled out by commenting out the WF_CONSOLE define.

WF_ProcessEvent()

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

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

Modules
Name 
Description 
Functions to setup, use, and teardown connection profiles 
Functions to alter the behavior of the connection process 
Functions to manage the connection process 
Functions to direct the MRF24WB0M to initiate a site survey 
API to control the Tx power of the MRF24WB0M 
Functions to alter the power savings features of the MRF24WB0M 
Functions for controlling miscellaneous features of the MRF24WB0M 
Topics
Name 
Description 
Describes how to receive and act on events from the MRF24WB0M 
 
Describes some basic tips for setting up and configuring a WiFi network. 
Lists some answers to some common WiFi questions. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
注意:只有安装在默认的安装目录才会是中文版,改变默认安装目录后可能会是英文版的!Picasa原为独立收费的图像管理、处理软件,其界面美观华丽,功能实用丰富。现已改为免费软件。只需拥有Picasa,你就可以随心所欲地体验你的数码相片了。  Picasa 是一个可在计算机上查看、整理、修改和共享数码照片的软件,它会让所有这些工作变得简单而有趣。Picasa 不会未经您的允许就删除照片或将照片放到网络上。  - 自动将你的相片从你的数码相机传输到你的电脑上.  - 管理图片并让你能在几秒中内查找到所需的图片.  - 让你轻松地编辑, 打印以及共享相片  - 创建幻灯片, 定购打印以及其它更多!  Picasa会自动根据照片拍摄的时间,目录,机型来判断,自动建立像簿,查找方便,还有timeline功能。  Picasa 要求:  配备 300MHz Pentium处理器和 MMX技术的计算机。  64 MB RAM(建议 128MB)  50 MB 的可用磁盘空间(建议 100MB)  800 ×600 像素,16 位彩色显示器  Microsoft Windows 2000 或 Microsoft Windows XP。  Microsoft Internet Explorer 5.01 或更高版本(建议 6.0 版)。任何时候,如果收到“无法授权”的出错信息,您应当升级到 IE 6.0。  Microsoft DirectX 7.0 或更高版本(XP 系统应配备 8.1,建议配备 9.0b)。  可选:56K 或更快的互联网连接速度(以便访问所有联机服务)。  支持的文件类型有:  图片:jpg、bmp、gif、png、psd、tif  电影:avi、mpg、wmv、asf、mov (QuickTime)  RAW 数据文件,包括 Canon、Nikon、Kodak、Minolta 和 Pentax 相机支持这种格式的文件。  目前可用于中文(简体及繁体)、荷兰语、英语(美国和英国)、法语、德语、意大利语、日语、韩语、葡萄牙语、俄语以及西班牙语。  注意:不支持 Microsoft Windows ME、Microsoft Windows 98 和其他早期版本的 Windows 操作系统在本网站上下载。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值