Home
WIFI DRIVER FOR FREESCALE MQX
Contents
1. 11 lm LAlr m ti 23t 1 tt1 CONFIDENTIAL PAGE 6 OF 44 GainSpan GS WIFI DRIVER GUIDE 1 5Reference GS IP2WIFI adaptor guide TWR WIFI G1011M User Manual TWR K60N512 Tower Module User Manual Rev 1 0 Freescale Coldfire documents www freescale com mcf5225x K60 Sub Family Reference Manual Document Number K60P144M100SF2RM www freescale com Kinetis vY v V yy y P Freescale MQX 3 7 reference documents www freescale com mqx L CONFIDENTIAL PAGE 7 OF 44 GainSpan GS WIFI DRIVER GUIDE 2 Design Considerations 2 1 Usage Scenario This Wi Fi driver connects the Freescale MQX 3 6 MQX 3 7 network stack to the wireless interface provided by the GS1011M 2 2 Objective The primary objectives of this design document are to address implementation of the Wi Fi driver on the Freescale MQX 3 6 MQX 3 7 operating system and its interface to the IP2WIFI firmware running on the GainSpan GS1011M module 2 3 Dependencies The interface of IP2WIFI stack running on the GS1011M supports both UART and SPI Use of UART or SPI depends on the state of the GPIO26 pin of the GS1011M If GPIO26 is pulled HIGH and then it is SPI if itis a no connect or pulled LOW it is UART Default interface is SPI for the TWR WIFI G1011MI and TWR K60N512 Tower Module board Refer the TWR WIFI G1011M and TWR K60N512 Tower Module user Manual for jumper setting The default interface is SPI and compile time option shall be
2. GainSpan GS WIFI DRIVER GUIDE 1 Overview 1 1 Purpose This document describes the driver source code and the related APIs for the Freescale MQX RTOS to integrate it with Gainspan GS1011 Wi Fi module 1 2 Scope Scope of this document is to explain the GainSpan Wi Fi Driver APIs in MQX operating system which runs on the Freescale ColdFire MCF52259 and K60 MK60N512VMD100 processor This document does not explain the design of the pre existing MQX components that may be present in the system 1 3Overview The IP2WIFI stack on the GainSpan GS1011M is used to provide Wi Fi Capability to any devices having serial interface The serial interface can be either UART or SPI These serial hosts use simple command interface to configure the IP2WIFI Adapter GainSpan GS1011M and to create the wireless connections LTTE CONFIDENTIAL PAGE 5 OF 44 GainSpan GS WIFI DRIVER GUIDE 1 4 Terminology API Application Programmer s Interface GS GainSpan CS Chip Select UART Universal Asynchronous Receiver Transmitter SPI Serial Peripheral Interface CONT Continuous Host Refers Microcontroller Freescale processor with master SPI Node Refers to Freescale tower board with GS1011M Octet 8 bit data RX Receive TX Transmit XOFF Transmit OFF AP Wireless Access Point SOC System On Chip SW Software HW Hardware XON Transmit ON _ 1 zt v cu Fr_rk t r Ad1t t
3. Default WiFi Device parameter Auto_Negotiate 0 BSPCFG TX RING LEN NOT USED IN GS1011 BSPCFG TX RING LEN NOT USED IN GS1011 ENET FRAMESIZE NOT USED IN GS1011 BSPCFG RX RING LEN NOT USED IN GS1011 BSPCFG RX RING LEN NOT USED IN GS1011 ENET FRAMESIZE NOT USED IN GS1011 BSPCFG GS PCB rx PCBs 0 LATE CONFIDENTIAL PAGE 25 OF 44 GainSpan GS WIFI DRIVER GUIDE 0 pointer amp gs_wifi_param endif Include the gs_prv h and phy_gs h headers in this file Place the driver files in the directory mqx source io enet and add them to the BSP project Add Modify the following defines in the mqx source bsp twrmcf52259 twrmcf52259 h file define BSP_ENET_DEVICE_COUNT MCF5XXX_FEC_DEVICE_COUNT BSPCFG_ENABLE_GS 1 0 GainSpan wifi Device configuration macro ifndef BSPCFG_ENABLE_GS define BSPCFG_ENABLE_GS 0 endif ifndef BSPCFG_GS_PCB define BSPCFG GS PCB 16 Hendif Define the BSPCFG ENABLE GS macro in the config twrmcf52259 user config h file as follows define BSPCFG ENABLE GS 1 Enable the SPIO device and GPIO inclusion into the BSP this is disabled by default as below in the config twrmcf52259 user_config h file define BSPCFG ENABLE SPIO 1 define BSPCFG ENABLE GPIODEV 1 Define the following macros in mqx source bsp twrmcf52259 twrmcf52259 h file define BSP_GS_SPI_DEVICE spi0 define BSP_GS_GPIO_DEVICE gpio input define BSP_GS_GPIO_INT_PIN GPIO_PORT
4. z gt 1 111_1__ CONFIDENTIAL PAGE 28 OF 44 GainSpan GS WIFI DRIVER GUIDE BSP_GS_GPIO_INT_PIN hi Hendif const ENET_PARAM_STRUCT ENET default params BSP ENET DEVICE COUNT amp ENET 0 Auto Negotiate ENET OPTION RMII BSPCFG TX RING LEN tx ring entries BSPCFG TX RING LEN t large tx packets ENET FRAMESIZE tx packet size BSPCFG RX RING LEN rxring entries BSPCFG RX RING LEN normal rx packets must be gt rx ring entries ENET FRAMESIZE ENET FRAMESIZE rx packet size BSPCFG RX RING LEN rx PCBs should be gt large rx packets 0 0 if BSPCFG_ENABLE_GS amp ENET_1 Auto_Negotiate 0 BSPCFG_TX_RING_LEN BSPCFG_TX_RING_LEN ENET_FRAMESIZE BSPCFG_RX_RING_LEN BSPCFG_RX_RING_LEN ENET_FRAMESIZE BSPCFG_GS_PCB rx PCBs 0 LTTE CONFIDENTIAL PAGE 29 OF 44 GainSpan GS WIFI DRIVER GUIDE 0 pointer amp gs_wifi_param endif E LTTE CONFIDENTIAL PAGE 30 OF 44 GS WIFI DRIVER GUIDE GainSpan 8 3 2 GS WI FI Driver specific configuration update gt File Name twrk60n512 h a Newly added Macro list ifndef BSPCFG_ENABLE_GS define BSPCFG_ENABLE_GS 0 Hendif If GS driver module is NOT enabled if BSPCFG_ENABLE_GS GainSpan UART channel configuration define BSP_GS_UART_DEVICE ittye define BSP GS SPI DEVICE spi2 GainSpan SPI channel define BSP GS GPIO DEVICE gpio input GPIO pin as i
5. Data Processing Engine sise 11 4 GS1011 DRIVER INTERFACES upstart rara 12 4 1 DRIVER DESIGN DESCRIPTIONS cccscerrerireezienizionierizioniezinio EEE EEEE zine 12 4 2 INITIALIZATION PT iaia 12 4 3 SERIAL INPUT HANDLING wos ia ai ir 12 4 4 SPLDATA HANDEER TASK Sii ina 13 4 5 DATA SENDHANDLING reci tii ten AE etant cart s relanc idad 15 4 6 CONNECTION MANAGEMENT HANDLING c ceri 15 4 7 COMMAND RESPONSE HANDLING cccccrreeiieiee ceci 15 5 DRIVER CALLBACKS FOR ENET LAYER sense 16 5A IMI lele 16 DLL vD esSenptiona su aiunt aint usu eit redet ieee 16 Dil PEROlOtVDO as sete e ede AMAGER ee 16 SL Par mtersa usu ie e ette dee td eee 16 SLA ROMPM AY PO hans MH 16 SEZ NGS NK OM EE 16 PU MEME Xu ET E 16 92222 APOLO PEN A A E E Eaa 16 _ CONFIDENTIAL PAGE 3 OF 44 GainSpan GS WIFI DRIVER GUIDE 3 2 3 PALOMO ii oia 16 SDA RA A O 17 SS GS SENDi iii 17 Did DEeScrpliot telde 17 23 3 2 POLO PEA naacal ica 17 33 3 ParametetS RN 17 IIA Re A O UE 17 A E LA RE I M M Ed 18 SE SEMEN mum dense 18 b MEE c 18 34 3 uml p baii iia 18 RES MB CDI IL E nei aLaaa dial 20 AS PHY_GS_GET_LINK_STATUS rene inde at lare 20 391 E AA aaa aa tan 20 b D MENU I 20 23 2 2 P rametersc iain dudo RH Wed e n ee A ce E ee 20 554 Return type iios e TEE t AA E eve
6. cep epu Ee aaa 21 JUOMMEG Rudi b 21 5 7 GS A aite ine Five eie speed E eer ei andere ln net net 21 Dio GONE 21 S OS ON es 21 6 MEDIA CONTROL INTERFACES eere eese eene essen senses etna nice nio s toss sazio nece sen necnecenionicnezeneo 22 T NETWORK INTERFACE ss pis 23 8 GS1011 DRIVER INTEGRATION WITH BSP eeeeeeeeee eese essen ei nece enses sioni necezioneoneceneo 24 8 1 INTEGRATION INSTRUCTIONS cccsccccsssssceeseseeeesssseeeesseseeccsseseeecessseeeesscseeecesesaeeesseaaeeeeseeeeeseeaaes 24 8 2 TWR WIFI GI011MI TOWER MODULE WITH MCF52259 PROCESSOR coocococccoccnoncnonnnonnconncnnncnnos 24 8 3 TWR K60N512 TOWER MODULE WITH MK60N512VMD100 PROCESSOR 27 8 3 1 ENET parameter update aaa 28 8 3 2 GS WI FI Driver specific configuration update ss 31 8 4 GSIOI11 AND MCU INTERFACE rrrvrnennrnrnvnnenrnsrnrnesnsnsnnensenrnenesnrnsnesnsnsnesnsssresnesnssnnnenesnsnsnesnsssresnsenn 32 85 GS1011 DRIVER SOURCE CODE licia 33 9 APPENDIX A EXAMPLE USAGE IN THE APPLICATION ssneeneneennenense 34 10 APPENDIX B INTERFACE DIAGRAM seeseesvesvevnennennevnnvnnennnvnnnnnennnsnnenneennennnnnnennenneenneeneenesene 36 11 APPENDIX decr 38 11 1 DATA TRANSFER OVER SPI INTERFACE cirie 38 12 ADDING GS WI FI DRIVER FILE TO IAR WORKBENCH esee e eene tentata etn anne 41 A CONFIDENTIAL PAGE 4 OF 44
7. data Similarly if host controller is sending data at higher rate flow control mechanism is required In order to differentiate these special control codes such as idle pattern flow control codes and other control octets from user data byte stuffing mechanism is incorporated SPI transmit data handling procedure The SPI data transfer layer makes use of an octet or byte stuffing procedure The Control Escape octet is defined as binary 11111011 hexadecimal OxFB most significant bit first Each special control pattern is replaced by a two octet sequences consisting of the Control Escape octet followed by the original octet exclusive ord XOR with hexadecimal 0x20 Receiving implementations must correctly process all Control Escape sequences Escaped data is transmitted on the link as follows Pattern Encoded as Description OxFD OxFB OxDD Flow control XON OxFA OxFB OxDA Flow control XOFF 0x00 OxFB 0x20 Inactive link detection OxFB OxFB OxDB Control ESCAPE OxF5 OxFB 0xD5 IDLE character OxFF OxFB OxDF Inactive link detection OxF3 OxFB OxD3 SPI link ready indication One dedicated GPIO signal GS SPI HOST WAKEUP GPIO 28 is available for data ready indications from Slave GS1011 node to Master Host controller This GS SPI HOST WAKEUP signal is asserted high during valid data transmission period so that the host master SPI starts pulling out data by giving SPI clock and GS SPI HOST WAKEUP signal is de a
8. is being associated to the AP 4 7Command response handling The commands to the GS SOC are simple AT commands to access the GS IP2WIFI stack running on the GS SOC These commands are issued by the application which internally calls the GS WIFI driver APIs to communicate to the GS SOC Commands are basically of two types 1 Set command This type basically configures the GS SOC with the application specific parameters 2 Get Command This type is used to get the configured information from the GS SOC All commands are mapped by a corresponding driver APIs and can access using the driver ioctl gs mediactl function LTEMA CONFIDENTIAL PAGE 15 OF 44 GainSpan GS WIFI DRIVER GUIDE 5 Driver Callbacks for ENET Layer This section describes the GS1011 Driver Callbacks for the ENET Layer 5 1Gs initialize 5 1 1 Description During the initialization G51011 driver associates itself with the ENET layer allocates private area for the driver control block prepares the PCB pool for host receive packets creates the driver task for handling the events from GS1011 module which also include receiving packets registers the interrupt handler IRQ Falling to receive the interrupt requests from GS1011 module setting up the GS1011 module firmware boot loading module SPI initialization etc 5 1 2 Prototype uint 32 Gs initialize ENET CONTEXT STRUCT PTR enet ptr 5 1 3 Paramters enet ptr The Ethernet state structure 5 1 4 R
9. optional flags zero default 5 3 4 Return type The return type for this handler will be one of the following ENET OK on success CONFIDENTIAL PAGE 17 OF 44 GainSpan GS WIFI DRIVER GUIDE ENETERR INVALID DEVICE is returned when driver control block could not be retrieved ENETERR SEND FULL is returned when the packet cannot be transmitted gt ENETERR SEND SHORT is returned when the packet is smaller than Ethernet header length ENETERR SEND LONG is returned when the packet is bigger than ENET_FRAME_ SIZE 5 4Gs mediactl 5 4 1 Description The Gs mediactl handler of the GS1011 driver provides the interface to configure and control wireless connection parameters 5 4 2 Prototype uint 32 Gs mediactl ENET CONTEXT STRUCT PTR enet ptr uint 32 command id pointer inout param 5 4 3 Parameters enet ptr The Ethernet state structure command id The particular control operation identifier inout param Data for the command The supported command id are ENET SET MEDIACTL MODE This command saves the mode of the Wi Fi as either infrastructure or ad hoc and starts the Wi Fi association ENET SET MEDIACTL SCAN This command starts the scan of all Wi Fi networks present in the vicinity ENET SET MEDIACTL PASSPHRASE This command set the wpa wpa2 passphrase of the Wi Fi module ENET SET MEDIACTL ESSID LTTE CONFIDENTIAL PAGE 18 OF 44 GainSpan GS WIFI DRIVER GUIDE This co
10. source psp cortex Preinclude file PROJ_DIR source psp cortex psp_abi h Defined symbols one per line MOX_DISABLE_CONFIG_CHE C Preprocessor output to file _DEBUG 1 SS e Hline directive LTTE CONFIDENTIAL PAGE 43 OF 44 GainSpan GS WIFI DRIVER GUIDE Debugger configuration for IAR work bench 1 Open the main application project file for example in case of http server application open the following project rtcs examples ittpsrwiar httsrv_twrk60n512 ewp 2 Right click on project file httsrv_twrk60n512 and select options 3 Click on Debugger 4 Select Driver as PE micro A CONFIDENTIAL PAGE 44 OF 44
11. GainSpan WIFI DRIVER ror FREESCALE MQX Reference GS WiFiDriver Version SP 1 2 Date 18 May 11 GainSpan GS WIFI DRIVER GUIDE 1 0 14 Dec 2010 Initial release 1 1 05 April 2011 K60N512 Tower Module support added 1 2 17 May 2011 IAR IDE support added Copyright 2010 2011 by GainSpan Corporation All rights reserved GainSpan Corporation 125 South Market Street Suite 400 San Jose CA 95113 U S A 1 408 673 2900 info GainSpan com www GainSpan com GainSpan and GainSpan logo are trademarks or registered trademarks of GainSpan Corporation Specifications features and availability are subject to change without notice L CONFIDENTIAL PAGE 2 OF 44 GainSpan GS WIFI DRIVER GUIDE Table of Contents 1 OVERVIEW 5 1 1 PURPOSE Luse 5 1 2 SCOPE iL Lea ee 5 1 3 OVERVIEW isole eee ed okse tonus eat 5 1 4 TERMINOLOG A O 6 1 5 REFERENCE 7 2 DESIGN CONSIDERATIONS lara 8 2 1 USAGE SCENARIO LE 8 2 2 BETTE HR 8 2 3 DEPENDENCIES uenige beseire 8 3 SOFTWARE ARCHITECTURE OVERVIEW esenesnveneesevnensensenssnvenesnsnnennennensenesnsensenesnvenennennensensen 9 SL HOSTE 10 SP 10 SAD IV CE DE 10 3 2 GSTOU MODULE PR 10 DA SP sante M 10 SURT 10 3 23 H st Interface Layer usan e A cda 10 3 24 Station Management Entity isset ete in ceret eda peel do ori redi ea bn due 11 3 25 WPA WPAZ alia ir eat ae ESTEE ve te EE Vae it a eet abel deeper 1l 3 2 6
12. Host transmits receives raw data using SPI or UART interface when the GS1011 module is configured for SPI UART mode A thin driver on the Host takes care of interacting with the Wi Fi module through the SPI or UART Host interface The following sections explain in brief the various components illustrated in the above figure 3 1 Host The host is any system that has applications being executed and has an SPI or UART interface to connect to the GS1011 Wi Fi module 3 1 1 SPI The SPI on the Host side provides an interface for the Host to access the Wi Fi module SPI on the Host acts as the Master 3 1 2 UART The UART on the host side interface for the Host to access the Wi Fi module the baud rate of the UART interface is 115200 3 2GS1011 Module The GS1011 module incorporates Wi Fi functionality 3 2 1 SPI The SPI on the GS1011 module acts as a SPI slave It is a standard 4 wire SPI and can support a maximum frequency of 3 MHz 3 2 2 UART The UART on the GS1011 module is a standard UART interface with a baud rate of 115200 3 2 3 Host Interface Layer This layer abstracts the lower layers in the host interface with which the GS1011 module is connected This layer interacts with the station management layer for wireless control actions and data processing layer for IP Arp and DHCP packet transmission This is the AT command layer of GS1011 module L CONFIDENTIAL PAGE 10 OF 44 GainSpan GS WIFI DRIVER GUIDE 3 2 4 St
13. NFIDENTIAL PAGE 40 OF 44 GainSpan GS WIFI DRIVER GUIDE 12 Adding GS Wi Fi Driver file to IAR workbench Adding driver files to BSP project 1 Open the project file mqx build iar bsp_twrk60n512 ewp 2 Click on Peripheral I O Drivers 3 Right click on enet and select add gt add group AK Embedded Workbench ID File Edit View Project Simulator Tools Window Help T E bsp twrk60n512 Debug v Generic IO Drivers Peripheral IO Drivers a De Options Cfi Of Compile c id On g i core El Add serl pol Qu Remove cre Group Catwrk X Rename twrk Source Code Control E out Overview bsp_twrk60n512 psp_twrk60n512 rtes_twrk60n512 shell_twrk60n51 4 4 Type group name as gs 5 Now Right click on gs and select add gt add files option 6 Select all the files in the folder mqx source io enet gs A CONFIDENTIAL PAGE 41 OF 44 GainSpan GS WIFI DRIVER GUIDE 2 IAR Embedded Workbench IDE File Edit View Project Simulator Tools Window Help Suda I Peripheral IO Drive Ca wk60n512BSPFIL sje m Ctwk60n512 User C Rebuild all E Output de Stop Build Add 3 Remove Source Code Control File Properties Overview bsp_twrk60n512 psp twk60n512 ttcs shell twrk60n512 rtos_twrk60n512 st 7 Similarly right click on p
14. T GET MEDIACTL MODE This command returns the mode of the Wi Fi module configured ENET GET MEDIACTL SCAN LATE CONFIDENTIAL PAGE 19 OF 44 GainSpan GS WIFI DRIVER GUIDE This command returns the scan details of all Wi Fi networks present in the vicinity gt ENET GET MEDIACTL RETRY This command returns the retry count of the Wi Fi module configured ENET GET MEDIACTL ENCODE This command returns the WEP authentication details of the Wi Fi module configured ENET GET MEDIACTL POWER This command returns the power save mode of the Wi Fi module configured ENET MEDIACTL IS INITIALIZED This command returns the state of the Wi Fi module initialized as either true or false gt ENET GET WEB PROV PARAM USRNAME This command returns the username authentication of web server to be created on the Wi Fi module for the web provisioning feature ENET GET WEB PROV PARAM PWD This command returns the password authentication of web server to be created on the Wi Fi module for the web provisioning feature 5 4 4 Return type The status of operation either ENET OK on success or ENET ERROR on failure is returned 5 5phy gs get link status 5 5 1 Description This callback reports the link status when queried 5 5 2 Prototype uint 32 phy gs get link status ENET CONTEXT STRUCT PTR enet ptr 5 5 3 Parameters enet ptr The Ethernet state structure A CONFIDENTIAL PAGE 20 OF 44 G
15. _NQ GPIO_PIN_IRQ_RISING GPIO_PIN1 Now build the BSP followed by the RTCS and the application CONFIDENTIAL PAGE 26 OF 44 GainSpan GS WIFI DRIVER GUIDE 8 3 TWR K60N512 tower module with MK60N512VMD100 processor The GS1011 driver is integrated with MQX version 3 7 Tower Module IDE TWR K60N512 IAR Embedded Workbench version 6 20 The following files must be modified to enable the GS1011 module support in the K60N512 BSP S No File to modify 1 max source bsp twrk60n512 init_enet c 2 max source bsp twrk60n512 twrk60n512 h 3 config twrk60n512 user config h 4 lt us soummm tlt ld lllt BtaaA Ad r1r t 1 t 3tx r CONFIDENTIAL PAGE 27 OF 44 GainSpan GS WIFI DRIVER GUIDE 8 3 1 ENET parameter update gt File Name init_enet c a Include GS driver specific header files if BSPCFG_ENABLE_GS include lt gs_prv h gt include phy_gs h endif b Update ENET default params structure if BSPCFG ENABLE GS const ENET IF STRUCT ENET 1 amp Gs IF amp phy gs IF GS PARAM WIFI STRUCT gs wifi param PARAM CONFIG ESSID PARAM CONFIG PASSPHRASE PARAM CONFIG PASSPHRASE LEN PARAM CONFIG ESSID LEN PARAM CONFIG SECURITY PARAM CONFIG REG DOMAIN PARAM CONFIG CHANNEL PARAM CONFIG PS MODE PARAM CONFIG IW MODE BSP GS SPI DEVICE BSP GS GPIO DEVICE _ _ _ t_t_t_ _ t 11 1 1_ _ t kq
16. ainSpan GS WIFI DRIVER GUIDE 5 5 4 Return type Returns zero if link is up else a non zero value The following APIs are dummy functions 5 6Gs_read 5 7Gs_write 5 8Gs join 5 9Gs rejoin LTTE CONFIDENTIAL PAGE 21 OF 44 GainSpan GS WIFI DRIVER GUIDE 6 Media Control Interfaces This section describes the Media Control Interfaces and how the GS1011 module can be configured using these interfaces The Free scale RTCS provides the Wireless media parameters control and configuration interfaces through the iwconfig set get API or ENET mediactl API All the control and configuration commands issued by the application for a particular device are directed to the media control callback submitted by that device driver For the GS1011 module Gs mediactl is the callback The GS1011 device driver s set get functions are invoked by the Gs mediactl in response to the iwconfig ENET mediactl invocations from the application The following are the parameters that can be configured Power save mode Wireless retry count both set and get Scan both set and get Security type both set and get Network to join essid both set and get Network mode both set and get Wpa wpa2 psk security passphrase both set and get Wep key both set and get Wps Web provisioning VVVVVVVVVY Arguments for some of the above parameters are defined in enet_wifi h The iwconfig APIs for setting the power save model getting the scan
17. ation Management Entity This is the core layer which manages the Wi Fi connectivity This maintains the state machine to detect the activity on the Wi Fi network and indicates to the user accordingly It interacts with the WPA supplicant if Security is enabled in the Wi Fi network 3 2 5 WPA WPA2 The WPA supplicant is used to initiate the 802 1x EAP authentication if WPA WPA2 PSK is used as the security parameter It also plays a major part in performing the 4 way handshake to derive the PTK in WPA WPA2 PSK modes 3 2 6 Data Processing Engine The layer processes data obtained from the Host or from the network The functioning of this layer depends on the direction and type of the frame This layer interacts with the host through the host interface layer which uses ESC sequence to send receive data from host REESE CONFIDENTIAL PAGE 11 OF 44 GainSpan GS WIFI DRIVER GUIDE 4 GS1011 Driver Interfaces 4 1 Driver Design Descriptions This section describes the GS1011 Wi Fi driver implementation in details 4 2 Initialization The initialization of the GS Wi Fi driver starts with the Gs initialize function which is getting called from the Freescale network stack This function initializes the serial interface on the Freescale processor allocating all resources and sends some commands to get the basic information of the GS SOC This initialization function creates the necessary task to handle the serial data response from th
18. e GS SOC also Once initialization is done this function puts the node into the ready state so the Wi Fi driver can accept any other APIs The interface structure between the GS WIFI driver and Freescale MQX network stack is Gs IF of type ENET MAC IF STRUCT This structure contains the entire WIFI driver APIs that the network stack can access each one through this structure 4 3Serial input handling For handling the serial data from GS1011 module a separate task has been created during initialization This task receives all the serial incoming data from the GainSpan soc and process Task function gs serial task uint 32 initial data The serial incoming data are three types AT Command response Data Asynchronous message This task runs as a state machine This task process each command response signaling the task which is waits for the response and store or forwards that information to the application The data comes from the GS SOC is packed with a header and tail This serial input task strip the header and pass the data to the MQX network stack The data coming from GS SOC in the following format ESC lt R gt lt Length gt lt Data gt LTTE CONFIDENTIAL PAGE 12 OF 44 GainSpan GS WIFI DRIVER GUIDE 4 4 SPI Data Handler Task In case of SPI interface additional task is required to handle SPI data transfer SPI data transfer always works in full duplex mode Task function gs_spi_hlr_task SPI data transf
19. er request will be triggered by following events gt Data transfer request by Host Application Task write request After receiving the data transfer request from application task via write operation SPI data handler task starts transmitting data to slave GS1011 node till all the data transferred and host wake up signal is in de asserted state host wake up signal becomes LOW While transmitting the data it also receives data from S2w Application resulting in full duplex transfer gt Data ready indication from Slave GS101 node via host wake up signal Host wake up signal assertion LOW to HIGH transition is detected by GPIO driver and appropriate callback will be executed to send an event to SPI handler task After receiving host wake up signal event SPI handler task starts pulling out the data by giving clock i e write IDLE dummy pattern It continues to pull the data as long as Host wake up signal is HIGH During this period if any transmit request is pending that s getting serviced This approach results in full duplex data transfer During data transfer it also handles flow control If there is no data to transmit then IDLE fill pattern shall be transmitted Byte stuffing and de stuffing is incorporated by this task Refer Appendix section for more details on SPI data transfer L CONFIDENTIAL PAGE 13 OF 44 GainSpan GS WIFI DRIVER GUIDE SPIDATA HANDLER SPI TX RX event Is flow control is ON i NO i XOFF prev
20. eturn type The status of operation either ENET OK on success or ENET ERROR on failure is returned 5 2Gs stop 5 2 1 Description This API reset the GS1011 and free all the resources allocated for the GS1011 Wi Fi driver 5 2 2 Prototype uint 32 Gs stop ENET CONTEXT STRUCT PTR enet ptr 5 2 3 Paramters enet ptr The Ethernet state structure LTTE CONFIDENTIAL PAGE 16 OF 44 GainSpan GS WIFI DRIVER GUIDE 5 2 4 Return type The status of operation either ENET OK on success or ENET_ERROR on failure is returned 5 3Gs send 5 3 1 Description The Gs_send handler is responsible for packet transmission The packet to be transmitted is sent to the GS1011 module only if the wireless link setup is finished and the GS1011 module is not running out of buffers In either of the cases error is returned The packet to be transmitted is sent to the GS1011 module through SPI or UART This is done in the calling task TCPIP task context itself If the packet is successfully sent to the GS1011 module the Packet Control Block PCB and corresponding packet memory is freed up otherwise error is returned 5 3 2 Prototype uint_32 Gs_send ENET CONTEXT STRUCT PTR enet ptr PCB PTR packet uint 32 size uint 32 frags uint 32 flags y 5 3 3 Parameters enet ptr The Ethernet state structure packet the packet to send size total size of the packet frags total fragments in the packet V v v NN flags
21. hy and select add gt add files option 8 Select phy_gs c and phy gs h files to add Now include header file path 1 Open the project file mqx build iar bsp_twrk60n512 ewp 2 Right click on bsp twrk60n512 and select options L CONFIDENTIAL PAGE 42 OF 44 GainSpan 2 IAR Embedded Workbench IDE File Edit View Project Simulator Tools Window Help DENS sS else Sa bsp_twrk60n512 Debu GS WIFI DRIVER GUIDE E Generic 10 Drivers C Peripheral lO Drive Make Iwrk60n512BSPFI ce m Ctwk60n512 User C Rebuild all E Output Clean Remove Source Code Control File Properties Set as Active Overview bsp_twrk60n512 psp twk60n512 ttes_shell_twrk60n512 rtcs twkBOn512 st gt 3 Click on C C Compiler 4 Click on Preprocessor 5 Add PROJ_DIR source io enet gs path in Additional include directory window Options for node bsp_twrk60n51 2 DE Factory Settings General Options CI Multi file Compilation C C Compiler Discard Unused Publics Assembler ns Be CINDIA a E Custom Build Language 1 Language 2 Code Optimizations Output List F4 gt Build Actions Library Builder ignore standard include directories Additional include directories fone per line ource io enethgs configvcommon Aconfigitwk60n512 Asourcelinclude PROJ_DIR
22. iously detected So wait till Do byte stuffing XON indication Start data transfer Process received bytes If XOFF pattern is detected then set appropriate flag indicating XOFF condition DATA TRANSFER DONE Is HOST WAKE UP asserted Fig SPI data transfer handling Figure SPI data handling flow chart CONFIDENTIAL PAGE 14 OF 44 GainSpan GS WIFI DRIVER GUIDE 4 5 Data Send handling The Wi Fi driver provides glue logic to interface the data send from MQX network stack to the IP2WIFI stack running on the GS SOC This glue logic adds the header to the data comes from the MQX network stack and sends to the GS SOC The data send format to the GS SOC is ESC lt R gt lt Length gt lt Data gt 4 6 Connection management handling The connection management state machine starts with the Wi Fi mode setting on the Wi Fi driver using the GS Wi Fi driver ioctl gs mediactl function Before setting the mode the application should fill the ssid security type and security key information on the GS Wi Fi driver using the GS Wi Fi driver ioctl gs mediactl functions The connection management state machine function is gs conn handler The main states of this connection management are Station Ready Station Down not associated Station security set done Station management done v v vV V Station association done This connection management handling any disconnect event from the AP and make sure the node
23. mmand sets the ssid to which the Wi Fi module to be associated ENET SET MEDIACTL RETRY This command set the retry count of the Wi Fi module ENET SET MEDIACTL ENCODE This command set the wep authentication details of the Wi Fi module ENET SET MEDIACTL POWER This command enable disable the power save mode of the Wi Fi module ENET SET MEDIACTL SEC TYPE This command sets the security type of the Wi Fi module ENET SET WPS ENABLE This command starts the wps push button method of the Wi Fi module ENET SET WEB PROV ENABLE This command starts the web provisioning feature of the Wi Fi module ENET SET WEB PROV PARAM SSID This command set the ssid of the ad hoc network to be created for the web provisioning feature of the Wi Fi module ENET SET WEB PROV PARAM CH This command set the channel of the ad hoc network to be created for the web provisioning feature of the Wi Fi module ENET SET WEB PROV PARAM USRNAME This command set the username authentication of webserver to be created on the Wi Fi module for the web provisioning feature ENET SET WEB PROV PARAM PWD This command set the password authentication of webserver to be created on the Wi Fi module for the web provisioning feature ENET GET MEDIACTL SEC TYPE This command return the security type of the Wi Fi module configured ENET SET MEDIACTL PASSPHRASE This command returns the wpa wpa2 passphrase of the Wi Fi module configured ENE
24. nels and get the scan information as shown below The scan results are getting printed on the serial console iwcfg set scan IPCFG default enet device NULL Similarly using the ENET mediactl to scan all channels as shown below ENET SCAN LIST param ENET mediactl ENET handle ENET SET MEDIACTL SCAN NULL ENET mediactl ENET handle ENET GET MEDIACTL SCAN amp param A CONFIDENTIAL PAGE 35 OF 44 GainSpan GS WIFI DRIVER GUIDE 10 Appendix B Interface Diagram UARTO RX UART RX Host Controller E iFi Freescale UARTOTX GS1011M MCU MPU UART CTS UARTO RTS UART RTS UARTO CTS GROUND Fig 1 Hardware Interface diagram UART LETE CONFIDENTIAL PAGE 36 OF 44 GainSpan GS WIFI DRIVER GUIDE SPI_DOUT SSPI_DIN Host Controller GainSpan WiFi Freescale SSPI_DOUT GS1011M MCU MPU SLAVE MASTER spr cso SSPI_SS SPI CLK SSPI_CLK GS_SPI_HOST_WAKEUP GPIO Host interface selection pin GPIO 26 Fig 2 Hardware Interface diagram SPI O CONFIDENTIAL PAGE 37 OF 44 GainSpan GS WIFI DRIVER GUIDE 11 Appendix C 11 1 Data transfer over SPI interface In the case of SPI interface the GS101X node acts as slave and will communicate to master SPI controller By default SPI interface supports Motorola protocol with clock polarity 0 and clock phase 0 Since SPI data transfer works in full duplex mode it s required to make use of special octet to indicate idle
25. net gs gs_prv h define GS_SPI_PORT_ENABLE Comment out the macro GS_SPI_PORT_ENABLE LTTE CONFIDENTIAL PAGE 32 OF 44 GainSpan GS WIFI DRIVER GUIDE 8 5GS1011 Driver Source Code To integrate the GS1011 device driver with the BSP GS1011 driver source code has been placed in the enet directory mqx source io enet along with the other network device drivers under the directory name gs This source code contains the MAC interfaces and definitions of GS1011 device driver to the ENET layer The PHY related source and header for the GS1011 module have been placed in the phy directory mqx source io enet phy These files contain the phy interfaces to the ENET layer The other BSP interface files have been placed under the below mentioned directory Target processor BSP files directory Remarks MCF52259 max source bsp twrmcf52259 K60N512 max source bsp twrk60n512 All the above mentioned files and directories are similarly added to the bsp_twrmcf52259 bsp_twrk60n512 project mqx build phy_gs c and phy_gs h are the files that go into phy directory mqx source io enet phy These files must be added to bsp_twrmcf52259 bsp_twrk60n512 project In the gs directory Gs init c contains the driver initialization interface initialization and resource allocation for the GS1011 wifi driver Gs_open c contains the driver open function Gs utils c contains various functions which communicate t
26. nput GPIO pins configuration PORT A pin 27 define BSP GS GPIO INT PIN GPIO PORT A GPIO PIN IRQ RISING GPIO PIN27 ifndef BSPCFG GS PCB define BSPCFG GS PCB 16 Hendif Hendif PCB count for GS driver module b Existing Macro s modified ENET device count added for GS driver itdefine BSP ENET DEVICE COUNT MACNET DEVICE COUNT BSPCFG ENABLE GS 1 0 File Name user config h a Newly added Macro list define BSPCFG ENABLE GS 1 New macro defined to enable GS driver b Modified Macro list define BSPCFG ENABLE ITTYE define BSPCFG ENABLE TTYF define BSPCFG ENABLE SPI2 1 define BSPCFG_ENABLE_FLASHX 1 1 serial interface to GS1011 SOC O Not used in case of GS1011 SOC interface SPI interface to GS1011 SOC Now build the BSP project followed by the RTCS and the application O NN II eDAl ALOLEcI UXL UUGIuoGAA4GAL 0UI UCBSGr A LLO PLLL Le PbLDEAALL LOA LILLLAILUSAL L4GTGg1L4QGUAU c LoUI LG1 U 5 49 04 oUlLILLL AL b OooOLOHLUU G Ge CONFIDENTIAL PAGE 31 OF 44 GainSpan GS WIFI DRIVER GUIDE 8 4GS1011 and MCU Interface The default interface between the MCU and GS1011 module is SPI To enable the UART interface modify the following files Processor File Name Modifications Remarks MCF52259 config twrmcf52259 user_config h define BSPCFG ENABLE ITTYC 1 K60 config twrk60n512 user_config h define BSPCFG ENABLE ITTYE 1 ANY max source io e
27. o the GS1011 module through SPI or uart interface with predefined command set Gs_send c contains the data send function which sends data from MCU to GS1011 module Gs_receive c contains the data receive function which receive data from GS1011 module pass to the MCU network stack Gs_conn_mgt c contains the connection management functions Gs_con_manage c contains the network connection handler gs mediactl c contains the media control handlers Gs prv h contains the GS1011 module specific definitions _____ Y 111_____ m _ 1mt121_ 12111kLk11_ mmrr w CONFIDENTIAL PAGE 33 OF 44 GainSpan GS WIFI DRIVER GUIDE 9 Appendix A Example Usage in the Application To enable the GS1011 NIC the application needs to invoke the following APIs iwcfg_set_essid IPCFG default enet device essid This API sets the network to which the GS1011 module has to connect The first argument is the device number 1 for the GS1011 module and the second argument is the string that contains the network name to which the module will connect define DEMOCFG SECURITY none iwcfg set sec type IPCFG default enet device DEMOCFG_ SECURITY This API sets the security type of the network to join as open iwcfg set mode IPCFG default enet device DEMOCFG NW MODE This API triggers the GS1011 module to scan and connect to a network The above calls are sufficient for the GS1011 module
28. provided to select UART interface The compile time flag is GS SPI PORT ENABLE and it is defined in gs prv h If this define flag is used then SPI is enabled else if this flag is commented out then UART is used to communicate with GS1011M board The UART Baud rate is 115200 with no HW SW flow support With SPI interface by default SPI Mode 0 is selected CPOL 0 and CPH 0 With SPI interface one GPIO is reserved for GS1011M Slave data ready detection B62 IRQ A SPI supports only Motorola mode with 8 bit SPI data word size Max SPI clock rate supported in burst mode is 1200KHz With SPI interface the GS1011M SPI always runs as a slave device O CONFIDENTIAL PAGE 8 OF 44 GainSpan GS WIFI DRIVER GUIDE 3 Software Architecture Overview The following figure illustrates the software architecture of the Gainspan wifi module GS101 1 integrated with a Freescale microcontroller Application FTP Other Applications Socket Interface Freescale Real Time TCP IP Communication Suite RTCS TCP UDP DHCP ARP ICMP GS1011 WiFi Driver Freescle MQX QSPI DSPI TTY HAL GS1011 SPI UART Host Interface layer Station Management Entity Data Processing Engine WPA WPA2 802 11 b g Mac Phy CONFIDENTIAL PAGE 9 OF 44 GainSpan GS WIFI DRIVER GUIDE As shown in the figure above the GS1011 module is integrated with the Freescale Host Microcontroller using SPI or UART The
29. results and setting transmit rate are provided as part of the RTCS These APIs have been added in the iwcfg c file rtcs source if In order to make these APIs available for the application the RTCS has to be re built by including these additions lt c7um rr ll ll lr1lr trrdanMTP1 t k d r tt 1111111 21 CONFIDENTIAL PAGE 22 OF 44 GainSpan GS WIFI DRIVER GUIDE 7 Network Interface The GS1011 device driver interfaces with the ENET layer of RTCS as an NIC The GS1011 module is added as the ENET device 1 whereas the Ethernet controller FEC is ENET device 0 The MAC and PHY callbacks and the default ENET device parameters submitted for GS1011 module are as follows gt Gs IF global structure is declared in mqx source io enet gs gs init c file const ENET MAC IF STRUCT Gs IF Gs initialize Gs stop Gs send Gs read Gs write if BSPCFG ENABLE ENET MULTICAST Gs join Gs rejoin endif Gs_mediactl gt phy gs IF global structure is declared in mqx source source io enet phy phy gs c file const ENET PHY IF STRUCT phy gs IF phy gs discover addr phy gs init phy gs get speed phy gs get link status LTTE CONFIDENTIAL PAGE 23 OF 44 GainSpan GS WIFI DRIVER GUIDE 8 GS1011 Driver integration with BSP 8 1 Integration Instructions Following sections describes steps needed for porting GS WiFi driver to MQX BSPs 8 2 TWR WIFI G1011MI tower module with MCF52259 processor The GS1011 driver is in
30. sserted once transmission is completed Master host controller must provide clock as long as GS SPI HOST WAKEUP signal is active Special character 0xF5 will be transmitted during idle period if there is no more data to transmit and must be dropped at the receiving Host LTEMA CONFIDENTIAL PAGE 38 OF 44 GainSpan GS WIFI DRIVER GUIDE SPI Receive data handling Since byte stuffing is used each Control Escape octet must be removed and the next immediate octet is exclusive or d XOR with hexadecimal 0x20 If receive buffer is reached upper water mark then XOFF character 0xFA will be sent out informing the host to stop transmitting actual data After receiving XOFF character host must stop transmitting actual data Once the application starts processing received data and enough space available for further reception reached lower water mark XON 0xFD will be transmitted Once host receives XON then it can resume the valid data transmission Special IDLE characters 0xF5 will be dropped at receiver A CONFIDENTIAL PAGE 39 OF 44 GainSpan GS WIFI DRIVER GUIDE HOST MCU S2W APP NODE APPLICATION RESPONSE ASYNC MESSAGE RECEIVE DATA PARSER ey E FLOW CONTROL HANDLING FLOW CONTROL HANDLING E SPI LINK LEVEL BYTE STUFFING SPI LINK LEVEL BYTE SPI LINK LEVEL BYTE SPI LINK LEVEL BYTE DE STUFFING STUFFING DE STUFFING SPI TRANSMIT RECEIVE SPI link Fig Data transfer over SPI interface LEA CO
31. tegrated with MQX version 3 7 The CodeWarrior version is CW for Microcontrollers v 10 1 All the directory paths mentioned are with respect to C Program Files Freescale Freescale MQX 3 7 The following are the steps followed to enable the GS1011 module support in the BSP In the enet ini c path mqx source bsp twrmcf52259 enet_ini c declare the following variables if BSPCFG_ENABLE_GS const ENET IF STRUCT ENET_1 amp Gs IF amp phy gs IF 1 E GS PARAM WIFI STRUCT gs wifi param PARAM CONFIG ESSID PARAM_CONFIG_PASSPHRASE PARAM CONFIG PASSPHRASE LEN PARAM CONFIG ESSID LEN PARAM CONFIG SECURITY PARAM CONFIG REG DOMAIN PARAM CONFIG CHANNEL PARAM CONFIG PS MODE PARAM CONFIG IW MODE BSP GS SPI DEVICE BSP GS GPIO DEVICE BSP GS GPIO INT PIN y Hendif LTTE CONFIDENTIAL PAGE 24 OF 44 GainSpan GS WIFI DRIVER GUIDE Next edit the ENET default params as follows to add an entry for the GS1011 module const ENET_PARAM_STRUCT ENET_default_params BSP_ENET_DEVICE_COUNT amp ENET 0 Auto Negotiate 0 BSPCFG TX RING LEN tx ring entries BSPCFG TX RING LEN large tx packets ENET FRAMESIZE tx packet size BSPCFG RX RING LEN rxring entries BSPCFG RX RING LEN normal rx packets must be gt rx ring entries ENET FRAMESIZE ENET FRAMESIZE rx packet size BSPCFG RX RING LEN rx PCBs should be gt large rx packets if BSPCFG_ENABLE_GS amp ENET_1
32. to set up a Wireless link If the network to join is security enabled security key and security type have to be configured with iwcfg set passphrase and iwcfg set sec type as follows before iwcfg set mode define DEMOCFGPSK 12345678 iwcfg set passphrase IPCFG default enet device char ptr DEMOCFGPSK define DEMOCFG SECURITY wpa2 iwcfg set sec type IPCFG default enet device DEMOCFG SECURITY The following are the example calls to set the transmit power wireless retry count etc These parameters need to be configured prior to making a call to iwcfg set mode Some of the iwconfig interfaces like set wps and set web provisioning parameters are currently not available in the RTCS To include them the RTCS can be re built with the supplied iwconfig c and iwconfig h that contain these missing interface definitions If the RTCS is not updated in this manner then set wps set webprovisioning calls have to be avoided by the application and the ENET mediactl interface can directly be used To put the GS1011 module into power save mode the following iwconfig interface needs to be invoked as shown below iwcfg set power nn CONFIDENTIAL PAGE 34 OF 44 GainSpan GS WIFI DRIVER GUIDE IPCFG default enet device 0 FALSE h To bring the GS1011 module out of power save mode use the same iwconfig interface as shown below iwcfg set power IPCFG default enet device 0 TRUE Similarly to scan all chan
Download Pdf Manuals
Related Search
Related Contents
Europäisch - Black & Decker Service Technical Home Page Manuale dell`utente 拡張モジュールYBC-1PRI-M/YBC-4BRI Ventanas de Madera sin Moldura Exterior ni Aleta Clavada - Jeld-Wen Rhythm® Flash! - GE Measurement & Control User Guide TL-LSC02 - Pro Pâte à chichis Versión PDF - Green Mangrey Copyright © All rights reserved.
Failed to retrieve file