wifi framework user's manual - renesas electronics · wifi framework user’s manual ......

124
Rev.1.08 Jun 2017 Renesas Synergy™ Platform Synergy Software Synergy Software Add-Ons www.renesas.com All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp. without notice. Please review the latest information published by Renesas Electronics Corp. through various means, including the Renesas Electronics Corp. website (http://www.renesas.com). WiFi Framework User’s Manual User’ s Manual

Upload: dangkiet

Post on 28-Jul-2018

236 views

Category:

Documents


0 download

TRANSCRIPT

Rev.1.08 Jun 2017

Renesas Synergy™ Platform Synergy Software Synergy Software Add-Ons

Users M

anual

www.renesas.com

All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp. without notice. Please review the latest information published by Renesas Electronics Corp. through various means, including the Renesas Electronics Corp. website (http://www.renesas.com).

WiFi Framework

User’s Manual

User’s M

anual

Notice

1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for the incorporation or any other use of the circuits, software, and information in the design of your product or system. Renesas Electronics disclaims any and all liability for any losses and damages incurred by you or third parties arising from the use of these circuits, software, or information.

2. Renesas Electronics hereby expressly disclaims any warranties against and liability for infringement or any other disputes involving patents, copyrights, or other intellectual property rights of third parties, by or arising from the use of Renesas Electronics products or technical information described in this document, including but not limited to, the product data, drawing, chart, program, algorithm, application examples.

3. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others.

4. You shall not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. Renesas Electronics disclaims any and all liability for any losses or damages incurred by you or third parties arising from such alteration, modification, copy or otherwise misappropriation of Renesas Electronics products.

5. Renesas Electronics products are classified according to the following two quality grades: "Standard" and "High Quality". The intended applications for each Renesas Electronics product depends on the product’s quality grade, as indicated below. "Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual

equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial robots etc. "High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control (traffic lights); large-scale

communication equipment; key financial terminal systems; safety control equipment; etc. Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to

human life or bodily injury (artificial life support devices or systems, surgical implantations etc.), or may cause serious property damages (space and undersea repeaters; nuclear power control systems; aircraft control systems; key plant systems; military equipment; etc.). Renesas Electronics disclaims any and all liability for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics.

6. When using the Renesas Electronics products, refer to the latest product information (data sheets, user’s manuals, application notes, "General Notes for Handling and Using Semiconductor Devices" in the reliability handbook, etc.), and ensure that usage conditions are within the ranges specified by Renesas Electronics with respect to maximum ratings, operating power supply voltage range, heat radiation characteristics, installation, etc. Renesas Electronics disclaims any and all liability for any malfunctions or failure or accident arising out of the use of Renesas Electronics products beyond such specified ranges.

7. Although Renesas Electronics endeavors to improve the quality and reliability of Renesas Electronics products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please ensure to implement safety measures to guard them against the possibility of bodily injury, injury or damage caused by fire, and social damage in the event of failure or malfunction of Renesas Electronics products, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures by your own responsibility as warranty for your products/system. Because the evaluation of microcomputer software alone is very difficult and not practical, please evaluate the safety of the final products or systems manufactured by you.

8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. Please investigate applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive carefully and sufficiently and use Renesas Electronics products in compliance with all these applicable laws and regulations. Renesas Electronics disclaims any and all liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.

9. Renesas Electronics products and technologies shall not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. You shall not use Renesas Electronics products or technologies for (1) any purpose relating to the development, design, manufacture, use, stockpiling, etc., of weapons of mass destruction, such as nuclear weapons, chemical weapons, or biological weapons, or missiles (including unmanned aerial vehicles (UAVs)) for delivering such weapons, (2) any purpose relating to the development, design, manufacture, or use of conventional weapons, or (3) any other purpose of disturbing international peace and security, and you shall not sell, export, lease, transfer, or release Renesas Electronics products or technologies to any third party whether directly or indirectly with knowledge or reason to know that the third party or any other party will engage in the activities described above. When exporting, selling, transferring, etc., Renesas Electronics products or technologies, you shall comply with any applicable export control laws and regulations promulgated and administered by the governments of the countries asserting jurisdiction over the parties or transactions.

10. Please acknowledge and agree that you shall bear all the losses and damages which are incurred from the misuse or violation of the terms and conditions described in this document, including this notice, and hold Renesas Electronics harmless, if such misuse or violation results from your resale or making Renesas Electronics products available any third party.

11. This document shall not be reprinted, reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.

12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products.

(Note 1) "Renesas Electronics" as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries.

(Note 2) "Renesas Electronics product(s)" means any product developed or manufactured by or for Renesas Electronics. (Rev.3.0-1 November 2016)

Contents 1 Overview .............................................................................................................. 1 1.1 Synergy WiFi Framework APIs ................................................................................................... 1 1.2 Network Stack Abstraction Layer ................................................................................................. 2 1.3 SSP HAL Interface ....................................................................................................................... 2 1.4 Socket APIs .................................................................................................................................. 2 1.5 On-chip Stack APIs ...................................................................................................................... 2

2 Paths for WiFi Use ............................................................................................... 3 2.1 Path 1 - NetX ................................................................................................................................ 3

2.1.1 Zero-copy support .............................................................................................................. 5 2.2 Path 2 – BSD Socket .................................................................................................................... 5

3 WiFi Chipsets Covered In This Document .......................................................... 7

4 WiFi Functional Design Description ................................................................... 8 4.1 Open ............................................................................................................................................. 8 4.2 Close ............................................................................................................................................. 8 4.3 InfoGet .......................................................................................................................................... 8 4.4 StatisticsGet .................................................................................................................................. 9 4.5 Transmit ........................................................................................................................................ 9 4.6 Receive callback ........................................................................................................................... 9 4.7 ProvisioningGet ............................................................................................................................ 9 4.8 ProvisioningSet ............................................................................................................................. 9 4.9 Scan ............................................................................................................................................ 10 4.10 ACLAdd ..................................................................................................................................... 10 4.11 ACLDelete .................................................................................................................................. 10 4.12 MulticastListAdd ........................................................................................................................ 10 4.13 MultiCastListDelete .................................................................................................................... 10 4.14 MACAddressGet ........................................................................................................................ 10 4.15 MACAddressSet ......................................................................................................................... 10 4.16 On chip Networking Stack support APIs .................................................................................... 10

4.16.1 Open ................................................................................................................................. 11 4.16.2 Close ................................................................................................................................ 11 4.16.3 IpAddressCfg ................................................................................................................... 11 4.16.4 DhcpServerStart ............................................................................................................... 11 4.16.5 DhcpServerStop ............................................................................................................... 11

4.17 BSD Socket APIs ........................................................................................................................ 11 4.17.1 Open ................................................................................................................................. 11 4.17.2 Close ................................................................................................................................ 11 4.17.3 Socket APIs ...................................................................................................................... 11

4.18 WiFi NSAL ................................................................................................................................ 12 4.18.1 NetX/NetX Duo Driver Function ..................................................................................... 12 4.18.2 NSAL Transmit Function................................................................................................. 12 4.18.3 NSAL Receive Callback .................................................................................................. 12

5 Synergy WiFi Framework Instance ................................................................... 13 5.1 Control Structure ........................................................................................................................ 13 5.2 Config Structure ......................................................................................................................... 13 5.3 Framework APIs Structure ......................................................................................................... 13 5.4 On Chip Stack APIs Structure .................................................................................................... 13 5.5 BSD Socket APIs Structure ........................................................................................................ 13

6 Control Flow ...................................................................................................... 14 6.1 Application using on chip networking stack ............................................................................... 14 6.2 Driver Initialization .................................................................................................................... 15 6.3 Packet Transmission ................................................................................................................... 16 6.4 Packet Reception ........................................................................................................................ 17

7 Sample Code Snippets ....................................................................................... 18 7.1 WiFi Framework Instance .......................................................................................................... 18 7.2 WiFi Framework Open and Close .............................................................................................. 19 7.3 WiFi Framework Provisioning ................................................................................................... 19 7.4 AP Link Status Change Notification .......................................................................................... 20 7.5 Access Control ............................................................................................................................ 21 7.6 Multicast Filtering ...................................................................................................................... 22

8 WiFi framework usage ....................................................................................... 24 8.1 Requirements .............................................................................................................................. 24

8.1.1 Software Requirements .................................................................................................... 24 8.1.2 Hardware Requirements ................................................................................................... 24

8.2 Installation .................................................................................................................................. 24 8.3 Configuring WiFi Framework Components in e2 studio ............................................................ 25 8.4 Limitations and Notes ................................................................................................................. 26

9 Adding New WiFi Module Support To Synergy WiFi Framework .................. 27 9.1 WiFi Framework Source and Header Files ................................................................................. 27

9.1.1 Instance Header File ........................................................................................................ 28 9.1.2 Driver Source Code .......................................................................................................... 28 9.1.3 Reference Configuration File ........................................................................................... 28 9.1.4 Framework APIs .............................................................................................................. 28 9.1.5 Private Structure/Macro Definitions ................................................................................ 28 9.1.6 Framework API Implementation ...................................................................................... 28

9.2 On-Chip Stack Interface Source and Header Files ..................................................................... 29 9.2.1 Instance Header File ........................................................................................................ 30 9.2.2 Reference Configuration File ........................................................................................... 30 9.2.3 Interface APIs .................................................................................................................. 31 9.2.4 Interface API Implementation .......................................................................................... 31

9.3 Socket Interface Source And Header Files ................................................................................. 31 9.3.1 Instance Header File ........................................................................................................ 33 9.3.2 Reference Configuration File ........................................................................................... 33 9.3.3 Interface APIs .................................................................................................................. 33 9.3.4 Interface API Implementation .......................................................................................... 33

9.4 WiFi Driver Source .................................................................................................................... 33

10 API References: WiFi Framework Interface ..................................................... 34 10.1 SF WIFI Framework Interface .................................................................................................... 34

10.1.1 Interface APIs .................................................................................................................. 34 10.1.2 Data Structures ................................................................................................................. 34 10.1.3 Macros ............................................................................................................................. 35 10.1.4 Typedefs ........................................................................................................................... 35 10.1.5 Enumerations ................................................................................................................... 37

10.2 SF WIFI On-Chip Stack Interface .............................................................................................. 41 10.2.1 Interface APIs .................................................................................................................. 41 10.2.2 Data Structures ................................................................................................................. 41 10.2.3 Macros ............................................................................................................................. 42

10.2.4 Typedefs ........................................................................................................................... 42 10.2.5 Enumerations ................................................................................................................... 42

10.3 SF Socket WIFI Framework Interface ........................................................................................ 43 10.3.1 Interface APIs .................................................................................................................. 43 10.3.2 Data Structures ................................................................................................................. 43 10.3.3 Macros ............................................................................................................................. 43 10.3.4 Typedefs ........................................................................................................................... 44 10.3.5 Functions .......................................................................................................................... 44

10.4 SF WIFI NSAL Interface ............................................................................................................ 50 10.4.1 Data Structures ................................................................................................................. 50 10.4.2 Macros ............................................................................................................................. 50 10.4.3 Typedefs ........................................................................................................................... 50 10.4.4 Enumerations ................................................................................................................... 50

11 API References: WiFi Framework On GT202 .................................................. 52 11.1 WiFi Framework on GT202 ....................................................................................................... 52

11.1.1 Data Structures ................................................................................................................. 52 11.1.2 Macros ............................................................................................................................. 52 11.1.3 Typedefs ........................................................................................................................... 52 11.1.4 Functions .......................................................................................................................... 52

11.2 WiFi On Chip Stack on GT202 .................................................................................................. 57 11.2.1 Macros ............................................................................................................................. 57 11.2.2 Functions .......................................................................................................................... 57

11.3 BSD Socket on GT202 ............................................................................................................... 60 11.3.1 Macros ............................................................................................................................. 60 11.3.2 Typedefs ........................................................................................................................... 60 11.3.3 Enumerations ................................................................................................................... 60 11.3.4 Functions .......................................................................................................................... 61 11.3.5 Variables .......................................................................................................................... 62

11.4 SF WIFI NSAL on NetX ............................................................................................................ 62 11.4.1 Functions .......................................................................................................................... 63

11.5 Data Structure Documentation for WiFi Framework ................................................................. 63

12 Appendix ............................................................................................................ 78 12.1 Atheros GT202 ........................................................................................................................... 78

12.1.1 Atheros GT202 on DK-S7G2 .......................................................................................... 78 12.1.2 Atheros GT202 on DK-S3A7 .......................................................................................... 83 12.1.3 On chip stack configuration ............................................................................................. 87

12.2 BCM43362 ................................................................................................................................. 89 12.2.1 BCM43362 on DK-S7G2................................................................................................. 89 12.2.2 BCM43362 on DK-S3A7................................................................................................. 95

12.3 BCM4343W ............................................................................................................................. 101 12.3.1 BCM4343W on DK-S7G2 ............................................................................................. 101 12.3.2 BCM4343W on DK-S3A7 ............................................................................................. 106

12.4 Broadcom Chipset WiFi Firmware Image Location Settings ................................................... 111 12.5 NetX Usage Note ...................................................................................................................... 112 12.6 Security and Encryption details ................................................................................................ 113 12.7 WiFi Framework Error Codes .................................................................................................. 114

Note: In this document, the sections related to Broadcom/Cypress WiFi chipsets shall be applicable only if the driver software for these WiFi modules is made available for use with the Synergy WiFi Framework

WiFi Framework 1. Overview

R11UM0050EU0108 Rev.1.08 Page 1 of 114 Jun 9, 2017

1 Overview

The Synergy WiFi framework consists of the following logical blocks:

• SF WiFi APIs • Network stack abstraction layer • SSP HAL interface • WiFi device driver (vendor provided driver).

It also includes the following blocks to support the BSD Socket APIs in making use of an on-chip networking stack:

• On Chip Stack APIs • Socket APIs.

Figure 1.1 provides an overview of the Synergy WiFi framework layered architecture.

Figure 1.1 Synergy WiFi Framework layered architecture

1.1 Synergy WiFi Framework APIs

The WiFi framework provides a generic interface for the application to configure and provision the WiFi module and perform data transfers. The WiFi module has various parameters as specified by 802.11 standards family. It is possible that individual device drivers and/or WiFi chipsets may not support configuration of all the functions.

Application

WiFi Framework 1. Overview

R11UM0050EU0108 Rev.1.08 Page 2 of 114 Jun 9, 2017

The WiFi framework also provides provisioning interface to configure the WiFi interface either as an Access Point (AP) or as a client. For the interface to become active, at least the channel, Service Set Identifier (SSID), security scheme, and the security credentials need to be configured.

1.2 Network Stack Abstraction Layer

The WiFi framework provides a network stack abstraction layer (NSAL). NSAL implements the MAC layer, making use of WiFi framework APIs. This creates abstraction for the networking stack (NetX/NetX-Duo), which allows the network device driver (that is, the MAC layer implementation) to be re-used. Current NSAL implementation includes support for NetX (IPv4) and NetX-Duo (IPv6). Adding support for a new network stack requires implementing the appropriate NSAL.

1.3 SSP HAL Interface

The HAL interface implements an interface for SSP HAL components used by the WiFi module for lower level communication with the Synergy MCU. This implementation is specific to the WiFi module. WiFi modules make use of different HAL components such as the SPI, ICU, IOPORT, SDMMC, and so forth.

1.4 Socket APIs

Socket APIs provide an interface to the application to make use of BSD Socket APIs. This requires the WiFi module/driver to provide support for the on-chip networking stack and BSD socket APIs. When the application uses these APIs, it is using the on-chip networking stack present on the WiFi chipset, and is not using NSAL (or the networking stack running on the Synergy MCU).

1.5 On-chip Stack APIs

On-chip stack APIs provide an interface to the application to configure the IP address of the module, start/stop DHCP server (when configured in AP mode). These APIs make use of the networking stack running on the WiFi chipset. Like Socket APIs, the use of these APIs and NSAL are mutually exclusive.

WiFi Framework 2. Paths for WiFi Use

R11UM0050EU0108 Rev.1.08 Page 3 of 114 Jun 9, 2017

2 Paths for WiFi Use

The Synergy WiFi framework allows two paths for WiFi use. These paths are shown in Figure 2.1.

NetX

Wi-Fi Framework Interfacesf_wifi_api.h

On-Chip Stacksf_wifi_onchip_stack_api.h

BSD Socketssf_sockets_api.h

Path 1 Path2

Wi-Fi Network Stack Abstraction Layersf_wifi_nsal_api.h

Figure 2.1 Paths for WiFi use

2.1 Path 1 - NetX

The first option is to use the Synergy WiFi framework with NetX. The Synergy WiFi framework includes a Network Stack Abstraction Layer (NSAL) that implements the NetX/NetX-Duo device driver interface. This means that in applications where NetX is used with Ethernet, users can swap out the Ethernet driver, with sf_el_nx, for the Synergy WiFi framework.

Figure 2.2 captures NetX with Ethernet in the SSP Configuration page. Refer to the SSP User’s Manual for the SSP Configurator details.

WiFi Framework 2. Paths for WiFi Use

R11UM0050EU0108 Rev.1.08 Page 4 of 114 Jun 9, 2017

Figure 2.2 NetX with Ethernet

Figure 2.3 NetX with Synergy Wireless Framework

Figure 2.3 shows NetX with Synergy WiFi framework.

Once the NetX device driver has been swapped out, existing NetX applications should work as they did previously. You need to add a call from the application to set the WiFi provisioning. For detailed information, see section 12.2

WiFi Framework 2. Paths for WiFi Use

R11UM0050EU0108 Rev.1.08 Page 5 of 114 Jun 9, 2017

2.1.1 Zero-copy support

Having zero-copy support means that packets are not copied from one memory area to another when a packet moves between NetX and the WiFi chipset vendor supplied code. This feature improves performance and reduces the memory footprint. However, it requires the vendor code to be able to use NetX packet structures and NetX packet pools directly.

A WiFi device driver which supports zero-copy must add NetX source and setup packet pools that will be used by this device driver internally. If these conditions are not met, e2 studio displays an error in the Threads pane. When setting up the chipsets in e2 studio, the user does not have to specify zero-copy support because the tooling already knows the capabilities. The driver with zero-copy support uses the same memory from packet pools rather than creating a copy of packets and then copying these to the packet pool.

BCM43362 and BCM4343W drivers support zero-copy. Figure 2.4 shows the thread pane view of the Synergy WiFi framework for BCM43362 with two NetX packet pool instances, g_packet_pool1 and g_packet_pool2.

Figure 2.4 Thread configuration for BCM43362 module

2.2 Path 2 – BSD Socket

The other option is to use the BSD Sockets API. This path also uses the on-chip stack functionality of certain WiFi chipsets. Not all WiFi chipsets provide extra on-chip support. More information about the BSD Sockets API can be found at http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html.

WiFi Framework 2. Paths for WiFi Use

R11UM0050EU0108 Rev.1.08 Page 6 of 114 Jun 9, 2017

Figure 2.5 Thread configuration for GT202 module

WiFi Framework 3. WiFi Chipsets Covered In This Document

R11UM0050EU0108 Rev.1.08 Page 7 of 114 Jun 9, 2017

3 WiFi Chipsets Covered In This Document

This document covers usage of WiFi Framework with the following chipsets:

• Broadcom 43362 (BCM43362) • Broadcom 4343W (BCM4343W) • Longsys GT202 (uses Qualcomm QCA4002).

All the above chipsets support the path 1 approach as explained in section 2. However, only Broadcom modules, BCM43362 and BCM4343W, support zero-copy.

Only the GT202 module includes support for on-chip networking stack. So, it also supports path 2 approach as explained in section 2.2.

WiFi Framework 4. WiFi Functional Design Description

R11UM0050EU0108 Rev.1.08 Page 8 of 114 Jun 9, 2017

4 WiFi Functional Design Description

The WiFi framework provides a uniform interface for the network stacks and applications to integrate the WiFi chipsets from various vendors without the need for a vendor specific code. The WiFi module has various parameters as specified by the 802.11 a/b/g/n family of standards. It is possible that an individual device driver and/or WiFi chipset may not support the configuration of all parameters. WiFi framework APIs can be used to configure the WiFi module with given parameters. Get the information from the WiFi module/driver, transmit the data/packet, and configure callback to handle the received data/packet. The application is abstracted from the underlying vendor’s driver by the framework. The WiFi framework provides a common API interface to the application to integrate different WiFi modules.

4.1 Open

The WiFi framework open function initializes and enables the WiFi module. The open function returns the WiFi control structure, uniquely identifying the instance of the WiFi framework. The WiFi framework open function accepts the WiFi module configuration as an argument, with the following parameters:

• MAC address (byte array of size 6 bytes) • Hardware mode (enumeration) • Transmit power (unsigned integer 8 bits) • RTS/CTS handshake flag (enumeration) • Fragmentation threshold (unsigned integer 16 bits) • Delivery traffic indication map period (unsigned integer 8 bits) • High throughput mode (enumeration) • Preamble length (enumeration) • WiFi multimedia mode flag (enumeration) • Maximum permitted stations (unsigned integer 8 bits) [AP Mode only] • SSID broadcast flag(enumeration) [AP Mode only] • Beacon interval (unsigned integer 32 bits) [AP Mode only] • Station inactivity timeout value (unsigned integer 32 bits) [AP Mode only] • WDS (wireless distribution system) [AP Mode only] • Require high throughput flag (enumeration) [Only allow HT mode. AP mode only].

4.2 Close

This API un-initializes the WiFi module and powers it off. The WiFi framework close function takes the WiFi control structure as an argument.

4.3 InfoGet

The WiFi framework infoGet function takes the WiFi control structure as an argument and returns the following information obtained from the WiFi module:

• Chipset/driver information string • RSSI value (unsigned integer 16 bits) • Noise level (unsigned integer 16 bits) • Link Quality (unsigned integer 16 bits).

WiFi Framework 4. WiFi Functional Design Description

R11UM0050EU0108 Rev.1.08 Page 9 of 114 Jun 9, 2017

4.4 StatisticsGet

This API gets the data statistics from the WiFi module. StatisticsGet function takes the WiFi control structure as an argument and returns the following statistics:

• Received packets (unsigned integer 32 bits) • Transmitted packets (unsigned integer 32 bits) • Transmit packet errors (unsigned integer 32 bits).

4.5 Transmit

This API sends the data/packet out. The WiFi framework transmit function takes the WiFi control structure as an argument. It takes the network packet buffer, and the network packet buffer length as arguments. The WiFi framework transmit function passes the packet buffer to the WiFi driver for transmission.

4.6 Receive callback

This is a callback API, which gets called when the data/packet is received by the WiFi module. The receive callback function receives packet buffer and packet length as arguments.

4.7 ProvisioningGet

The WiFi framework provisioningGet function takes the WiFi control structure as an argument and returns the following parameters:

• Mode (enumeration, that is, AP or client) • Channel (unsigned integer 8 bits) • SSID (string) • Security type (enumeration) • Encryption type (enumeration) • Security key (string).

4.8 ProvisioningSet

This API sets the WiFi module in the given mode AP/Station. The provisioningSet function uses the following parameters to provision the WiFi module:

• Mode (enumeration, that is, AP or client) • Channel (unsigned integer 8 bits), only used in AP mode • SSID (string) • Security type (enumeration) • Encryption type (enumeration) • Security key (sting). • AP Link Status Notification Callback function: Used to get AP Link status change notification

when provisioned in Station mode Note: Once the WiFi device is provisioned in any mode, to switch to another mode, the application

should close and open it again. For example, if the WiFi device is provisioned in AP mode first and wants to switch to the station mode, then the application code should call close() to de-initialize it and open() API again to initialize it. Then, call provisioningSet() to set to station mode. The same applies for switching from the station to AP mode.

WiFi Framework 4. WiFi Functional Design Description

R11UM0050EU0108 Rev.1.08 Page 10 of 114 Jun 9, 2017

4.9 Scan

This API scans the available SSIDs (that is, access points) in range. The WiFi framework scan function takes the WiFi control structure as an argument and returns a list of SSIDs scanned by the WiFi module with the following parameters:

• HW mode (enumeration a/b/g/n) • RSSI (unsigned integer 16 bits) • SSID (string) • BSSID (byte array of size 6 bytes) • Channel (unsigned integer 8 bits) • Security type (enumeration) • Encryption type(enumeration) • BSS type (enumeration).

The WiFi framework scan function takes the SSID count as an argument, which acts as an in/out parameter. It specifies the size of the scan result array and the WiFi framework sets it to count the indicating number of scan results stored in the array.

4.10 ACLAdd

This API adds the given MAC address to the access control list. The ACLAdd function takes the WiFi control structure and the MAC address as arguments.

4.11 ACLDelete

This API deletes the given MAC address from the access control list. ACLDelete function takes the WiFi control structure and MAC address as arguments.

4.12 MulticastListAdd

This API adds the given Multicast IP address to the multicast filer list. MultiCastListAdd function takes the WiFi control structure and MAC address as arguments.

4.13 MultiCastListDelete

This API deletes the given Multicast IP address from the multicast filer list. MultiCastListDelete function takes the WiFi control structure and MAC address as arguments.

4.14 MACAddressGet

This API reads MAC address from WiFi module. MACAddressGet function takes the WiFi control structure as argument and returns MAC address read from WiFi module.

4.15 MACAddressSet

This API sets WiFi module’s MAC address. MACAddressSet function takes the WiFi control structure and MAC address as arguments.

4.16 On chip Networking Stack support APIs

These APIs configure the WiFi module when using an on-chip networking stack, which helps to configure the IP address for the interface, and start/stop DHCP server (when configured in the AP mode).

WiFi Framework 4. WiFi Functional Design Description

R11UM0050EU0108 Rev.1.08 Page 11 of 114 Jun 9, 2017

4.16.1 Open

This API calls WiFi framework open API which initializes the WiFi module.

4.16.2 Close

This API calls the WiFi framework close API which un-initializes the WiFi module.

4.16.3 IpAddressCfg

This API configures the IP address of the interface using an on-chip networking stack. It provides facility configure static IP address or using DHCP.

4.16.4 DhcpServerStart

This API starts the DHCP server on the interface (when configured in AP mode) using on-chip networking stack. It takes the range of IP addresses to be used by DHCP server.

4.16.5 DhcpServerStop

This API stops the DHCP server.

4.17 BSD Socket APIs

4.17.1 Open

This API calls the on-chip Networking stack open API which initializes the WiFi module.

4.17.2 Close

This API calls the on-chip Networking stack close API which un-initializes the WiFi module.

4.17.3 Socket APIs

These APIs can be used by application to perform data transfer using sockets. It includes socket APIs which are compliant with BSD APIs. It includes the following APIs:

• socket • close • bind • listen • accept • connect • send • recv • recvfrom • sendto • setsockopt • getsockopt • select

WiFi Framework 4. WiFi Functional Design Description

R11UM0050EU0108 Rev.1.08 Page 12 of 114 Jun 9, 2017

4.18 WiFi NSAL

Synergy WiFi framework supports NetX/NetX-Duo NSAL. This includes NetX/NetX-Duo driver, packet transmit, and receive callback functions implementation.

4.18.1 NetX/NetX Duo Driver Function

The driver function takes a NetX IP instance, WiFi framework instance, and NSAL configuration as arguments. NSAL configuration controls the behavior of transmit and receive callback functions. NSAL configuration includes flags which indicates that zero-copy support is enabled or disabled in the transmit and receive path. Driver functions implements various IP driver commands used by NetX/NetX-Duo. Interface attach command calls WiFi framework open API to initialize WiFi module. The initialize command calls WiFi framework macAddressGet API to read MAC address from WiFi module. The uninitialize command calls WiFi framework close API which deinitializes the WiFi module. The multicast-join command calls the WiFi framework multicastListAdd API to add given MAC address to the multicast list. The multicast-leave command calls the WiFi framework multicastListDelete API to delete a given MAC address from the multicast list. The Send/Broadcast command calls the WiFi framework transmit API to transmit packet.

4.18.2 NSAL Transmit Function

The NSAL transmit function takes a NetX IP instance, NetX packet, WiFi framework instance, and NSAL configuration as arguments. If zero-copy support is enabled then the same NetX packet is transferred from NetX to the WiFi driver. If zero-copy is not supported then the function copies data from the NetX packet to the driver buffer. It calls the WiFi framework transmit API, which passes the buffer/packet to the WiFi driver for further transmission.

4.18.3 NSAL Receive Callback

The NSAL receive callback function takes a NetX IP instance, packet buffer, packet buffer length, and NSAL configuration as arguments. This callback is called from the WiFi device driver. If zero-copy support is enabled then the same NetX packet is transferred from WiFi driver to NetX. If zero-copy is not supported then the function copies data from the driver buffer to the NetX packet and then passes the NetX stack for further processing. It calls the WiFi framework transmit API, which passes the buffer to the WiFi driver for further transmission.

WiFi Framework 5. Synergy WiFi Framework Instance

R11UM0050EU0108 Rev.1.08 Page 13 of 114 Jun 9, 2017

5 Synergy WiFi Framework Instance

The application must define the Synergy WiFi framework instance before it starts using it. The Synergy WiFi framework includes support for different WiFi modules (refer tosee section 3). Instance refers to WiFi module specific control, configuration data, and APIs. The application uses this instance to perform any operation on the WiFi module. An instance is a structure which includes pointers to a control structure, configuration structure, and framework APIs structure.

The following are the members of the Synergy WiFi framework instance.

5.1 Control Structure

This structure is used in all WiFi framework APIs. It includes the following fields:

• Pointer to driver handle, which is used by the framework while working with WiFi module’s device driver.

5.2 Config Structure

This structure is passed as an argument to the open call, which is used to configure various parameters of the WiFi module. These parameters are already mentioned in section 4.1.

5.3 Framework APIs Structure

This structure contains pointers to the framework APIs specific to a WiFi module. While using NetX/NetX-Duo as explained in section 2.1, WiFi framework APIs used are sections 4.1 to 4.15.

5.4 On Chip Stack APIs Structure

This structure contains pointers to on-chip stack APIs specific to a given module. These APIs are already mentioned in section 4.16.

5.5 BSD Socket APIs Structure

This structure contains pointer to BSD Socket interface APIs. These APIs are mentioned in section 4.17

WiFi Framework 6. Control Flow

R11UM0050EU0108 Rev.1.08 Page 14 of 114 Jun 9, 2017

6 Control Flow

6.1 Application using on chip networking stack

Figure 6.1 Application control flow using on Chip networking stack

WiFi Framework 6. Control Flow

R11UM0050EU0108 Rev.1.08 Page 15 of 114 Jun 9, 2017

6.2 Driver Initialization

Figure 6.2 Application control flow doing WiFi module initialization

WiFi Framework 6. Control Flow

R11UM0050EU0108 Rev.1.08 Page 16 of 114 Jun 9, 2017

6.3 Packet Transmission

Figure 6.3 Application control flow doing packet transmission using NetX

WiFi Framework 6. Control Flow

R11UM0050EU0108 Rev.1.08 Page 17 of 114 Jun 9, 2017

6.4 Packet Reception

Figure 6.4 Application control flow receiving packet using NetX

WiFi Framework 7. Sample Code Snippets

R11UM0050EU0108 Rev.1.08 Page 18 of 114 Jun 9, 2017

7 Sample Code Snippets

Please refer to the sf_wifi_test_application project from Synergy Gallery for sample code. Import this project into e2 studio and compile it. The following code samples refer to files under this project.

7.1 WiFi Framework Instance

The following code snippet shows Synergy WiFi framework instance using Broadcom’s BCM43362 chipset. Please refer to file common_data.c at path sf_wifi_test_application\src\synergy_gen\common_data.c.

static const sf_wifi_on_bcm43362_cfg_t g_sf_wifi0_on_bcm43362_cfg = { .p_lower_lvl_spi = &g_spi0, .p_lower_lvl_icu = &g_external_irq0, .pin_reset = IOPORT_PORT_09_PIN_11, .pin_slave_select = IOPORT_PORT_11_PIN_02, .p_buffer_pool_internal = &g_packet_pool2, .antenna = SF_WIFI_ANTENNA_AUTO }; static sf_wifi_ctrl_t g_sf_wifi0_ctrl; static const sf_wifi_cfg_t g_sf_wifi0_cfg = { .mac_addr = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, .hw_mode = SF_WIFI_INTERFACE_HW_MODE_11G, .tx_power = 10, .rts = SF_WIFI_RTS_DISABLE, .fragmentation = 0, .dtim = 3, .high_throughput = SF_WIFI_HIGH_THROUGHPUT_DISABLE, .preamble = SF_WIFI_PREAMBLE_SHORT, .wmm = SF_WIFI_WMM_DISABLE, .max_stations = 1, .ssid_broadcast = SF_WIFI_SSID_BROADCAST_ENABLE, .access_control = SF_WIFI_ACCESS_CONTROL_DENY, .beacon = 100, .station_inactivity_timeout = 100, .wds = SF_WIFI_WDS_DISABLE, .req_high_throughput = SF_WIFI_MANDATORY_HIGH_THROUGHPUT_DISABLE, .p_buffer_pool_rx = &g_packet_pool1, .p_callback = NULL, .p_context = NULL, .p_extend = &g_sf_wifi0_on_bcm43362_cfg, }; /* Instance structure to use this module. */ const sf_wifi_instance_t g_sf_wifi0 = { .p_ctrl = &g_sf_wifi0_ctrl, .p_cfg = &g_sf_wifi0_cfg, .p_api = &g_sf_wifi_on_sf_wifi_bcm43362 };

In the above code snippet, g_sf_wifi0 is a Synergy WiFi framework instance, which includes pointers to control, config, and WiFi framework APIs structures.

WiFi Framework 7. Sample Code Snippets

R11UM0050EU0108 Rev.1.08 Page 19 of 114 Jun 9, 2017

7.2 WiFi Framework Open and Close

The following is the code snippet shows the WiFi driver open() and close() using WiFi framework APIs.

ssp_err = g_sf_wifi0.p_api->open (g_sf_wifi0.p_ctrl, g_sf_wifi0.p_cfg);

if ( (ssp_err != SSP_SUCCESS) && (ssp_err != SSP_ERR_ALREADY_OPEN)) {

ssp_error_code_to_string (ssp_err);

return; }

g_sf_wifi0.p_api->close(g_sf_wifi0.p_ctrl);

The application must call open() first before making a call to any other WiFi framework APIs or on chip stack APIs. It should also call close() when it does not want to use the WiFi module anymore. The test application calls open and close APIs form NSAL code. Please refer to sf_wifi_nsal_nx.c at path sf_wifi_test_application\synergy\ssp_supplemental\add_on\src\framework\sf_wifi_nsal_nx\sf_wifi_nsal_nx.c.

The nsal_netx_driver() function in this file calls open() and close() APIs. Before making the call to open, NSAL configures its own callback function which is used to process received packets. Please refer to Figure 7.1Error! Reference source not found. and Figure 7.2

Error! Reference source not found. Figure 7.1 SF WiFi open API call from NSAL code

Figure 7.2 SF WiFi close API call from NSAL code

7.3 WiFi Framework Provisioning

The following code snippet shows the WiFi driver provisioningSet() and provisioningGet() using WiFi framework APIs.

WiFi Framework 7. Sample Code Snippets

R11UM0050EU0108 Rev.1.08 Page 20 of 114 Jun 9, 2017

Please refer to file new_thread0_entry.c at path sf_wifi_test_application\src\new_thread0_entry.c.

static sf_wifi_provisioning_t g_sf_wifi_provisioninfo = { .channel = 2, .encryption = SF_WIFI_ENCRYPTION_TYPE_AUTO, .security = SF_WIFI_SECURITY_TYPE_WPA2, .ssid = "SF_WIFI_TESTAP", .key = "12345678", .mode = SF_WIFI_INTERFACE_MODE_AP };

sf_wifi_provisioning_t sf_wifi_provisioninfo;

/** Provision WiFi module in AP mode */ ssp_err = g_sf_wifi0.p_api->provisioningSet (g_sf_wifi0.p_ctrl, &g_sf_wifi_provisioninfo); if (ssp_err != SSP_SUCCESS) { blink_led (); }

/** Get Provisioning Information */ ssp_err = g_sf_wifi0.p_api->provisioningGet (g_sf_wifi0.p_ctrl, &sf_wifi_provisioninfo); if (ssp_err != SSP_SUCCESS) { blink_led (); }

The new_thread0_entry() function in this file calls provisioningSet() and provisioningGet()APIs.

7.4 AP Link Status Change Notification

The following code snippet shows how to register for the AP Link status change notification when WiFi module is provisioned in Station mode. The application needs to register AP Link status notification callback in the sf_wifi_provisioning_t structure while provisioning the WiFi module in Station mode. After the connection with AP is successfully established, if the AP goes down or up the user registered callback will be called to notify the AP status change to the user.

WiFi Framework 7. Sample Code Snippets

R11UM0050EU0108 Rev.1.08 Page 21 of 114 Jun 9, 2017

static void ap_link_status_event_notification(sf_wifi_callback_args_t * p_args) { switch(p_args->event)

{ case SF_WIFI_EVENT_AP_CONNECT: /** AP Link UP handling */ break; case SF_WIFI_EVENT_AP_DISCONNECT: /** AP Link Down handling */ break; }

} static sf_wifi_provisioning_t g_sf_wifi_provisioninfo = { .channel = 2, .encryption = SF_WIFI_ENCRYPTION_TYPE_AUTO, .security = SF_WIFI_SECURITY_TYPE_WPA2, .ssid = "SF_WIFI_TESTAP", .key = "12345678", .mode = SF_WIFI_INTERFACE_MODE_STATION, .p_callback = ap_link_status_event_notification };

/** Provision WiFi module in AP mode */ ssp_err = g_sf_wifi0.p_api->provisioningSet (g_sf_wifi0.p_ctrl, &g_sf_wifi_provisioninfo); if (ssp_err != SSP_SUCCESS) { blink_led (); }

7.5 Access Control

The following code snippet shows access control configuration using the WiFi framework APIs. The application can use ACLAdd() and ACLDelete() APIs to add/delete a MAC address from the access control list. These APIs are valid only when the WiFi module is provisioned in AP mode. Whether to allow or deny MAC addresses in an access control list to join AP depends on the access control mode set in configuration structure, which is passed to framework during open call.

Please refer to file new_thread0_entry.c at path sf_wifi_test_application\src\new_thread0_entry.c.

The new_thread0_entry() function in this file calls ACLAdd()API. The test application has configured the WiFi module access control in deny mode (see section 7.1) which means MAC addresses added to the access control list will not be allowed to join AP.

In the test application, a device whose MAC address is specified in the peer_device_mac variable will not be able to join AP if it is added to access control list. In order to allow the same device to join, the application should call ACLDelete() API with peer_device_mac as an argument.

WiFi Framework 7. Sample Code Snippets

R11UM0050EU0108 Rev.1.08 Page 22 of 114 Jun 9, 2017

static sf_wifi_provisioning_t g_sf_wifi_provisioninfo = { .channel = 2, .encryption = SF_WIFI_ENCRYPTION_TYPE_AUTO, .security = SF_WIFI_SECURITY_TYPE_WPA2, .ssid = "SF_WIFI_TESTAP", .key = "12345678", .mode = SF_WIFI_INTERFACE_MODE_AP };

static uint8_t peer_device_mac[] = {0xf8, 0xe0, 0x79, 0x98, 0xd6, 0xa7};

/** Provision WiFi module in AP mode */ ssp_err = g_sf_wifi0.p_api->provisioningSet (g_sf_wifi0.p_ctrl, &g_sf_wifi_provisioninfo); if (ssp_err != SSP_SUCCESS) { blink_led (); }

/** Add MAC address to Access Control List, it will prevent it from joining */ ssp_err = g_sf_wifi0.p_api->ACLAdd (g_sf_wifi0.p_ctrl, peer_device_mac); if (ssp_err != SSP_SUCCESS) { blink_led (); }

7.6 Multicast Filtering

The following code snippet shows multicast filtering using WiFi framework APIs. The application calls nx_igmp_multicast_join()/nx_igmp_multicast_leave() to join/leave multicast group. These APIs internally make use of multicastListAdd() and multicastListDelete() APIs to add/delete an MAC address from the multicast filter list. The WiFi module can send/receive packets on only those multicast groups whose MAC address in added in the multicast list.

Please refer to file new_thread0_entry.c at path sf_wifi_test_application\src\new_thread0_entry.c.

/** Join Multicast Group */ err = nx_igmp_multicast_join (&g_ip0, SF_WIFI_IPV4_ADDRESS(225, 0, 0, 15)); if (err != NX_SUCCESS) { blink_led (); } /** Leave Multicast Group */ err = nx_igmp_multicast_leave (&g_ip0, SF_WIFI_IPV4_ADDRESS(225, 0, 0, 15)); if (err != NX_SUCCESS) { blink_led (); }

WiFi Framework 7. Sample Code Snippets

R11UM0050EU0108 Rev.1.08 Page 23 of 114 Jun 9, 2017

The new_thread0_entry() function in this file calls the nx_igmp_multicast_join()NetX API so that it can join and send/receive data from a multicast group. It also calls nx_igmp_multicast_leave()NetX API so that it can leave a multicast group. These nx_igmp_multicast_join() and nx_igmp_multicast_leave() APIs take Multicast group IP address as arguments.

Please refer to sf_wifi_nsal_nx.c at path sf_wifi_test_application\synergy\ssp_supplemental\add_on\src\framework\sf_wifi_nsal_nx\sf_wifi_nsal_nx.c.

The nsal_netx_driver() function in this file calls multicastListAdd () and multicastListDelete () APIs. Please refer to Error! Reference source not found.

Figure 7.3 SF WiFi mulicastListAdd() and multicastListDelete() API calls from NSAL code

WiFi Framework 8. WiFi framework usage

R11UM0050EU0108 Rev.1.08 Page 24 of 114 Jun 9, 2017

8 WiFi framework usage

8.1 Requirements

8.1.1 Software Requirements

Please refer to Synergy Software Pack (SSP) WiFi Add-on Framework Package Release Notes.

8.1.2 Hardware Requirements

• DK-S7G2 Version 3.1 or higher • DK-S3A7 Version 2.0 or higher • BCM43362: Murata SN8000 PMOD-WiFi Version 1.0 • BCM4343W: Murata Type 1DX Version 1

SDIO 60 PIN Adapter Version 1. • GT202: LongSys PMOD Adapter Version 1.1.

8.2 Installation

1. Please refer to the Release package and installation information section in the Release Notes.

2. To update the license, use following steps:

a. In e2 studio, click Window > Preferences.

b. Click C/C++ > Renesas > Synergy License. Browse to the license file. Select license file +SSP_License_Example_EvalLicense_20160629.xml.

c. See Figure 8.1.

Figure 8.1 Updating license file

WiFi Framework 8. WiFi framework usage

R11UM0050EU0108 Rev.1.08 Page 25 of 114 Jun 9, 2017

8.3 Configuring WiFi Framework Components in e2 studio

The following instructions list the common steps in creating an e2 studio project with the Synergy WiFi framework:

1. Start the Synergy Project wizard in e2 studio by clicking File > New > Synergy C Project. 2. Change the Synergy license file used to the evaluation license that is provided with this package. 3. Choose SSP version “1.2.0-b”, or newer, such as 1.2.x.release.

A. Choose the board S7G2 DK or S3A7 DK according to development platform being used. 4. Create a project with your desired Project Template. 5. Switch to Threads tab. 6. Add a thread to system if one is not already present. 7. Add NetX through the New Thread Stacks button.

A. Add NetX IP Instance.

Figure 8.2 Thread configuration – adding NetX IP Instance

8. Add sf_wifi_nsal_nx under NetX IP Instance as a NetX Network Driver.

Figure 8.3 Thread configuration for DK–S7G2 board – adding NetX Network Driver

WiFi Framework 8. WiFi framework usage

R11UM0050EU0108 Rev.1.08 Page 26 of 114 Jun 9, 2017

9. Add your desired Synergy WiFi framework component under the sf_wifi_nsal_nx.

Figure 8.8.4 Thread configuration for DK–S7G2 board – adding SF WiFi component

10. Add the corresponding low-level driver components under the selected WiFi framework device driver component. Refer to the thread pane view of the individual WiFi module in the Appendix section for details.

11. After completing the configuration, you can develop/write the application code around the WiFi framework. Compile it and if no compilation errors are found, then download and test it.

8.4 Limitations and Notes

1. When you are using the BCM43362/ BCM4343W chipset, NetX needs to be re-compiled (NetX Source is required for this) since the NetX packet physical header must be set to 44 at least, which is done through the Configurator.

2. When RSPI is used for the WiFi module driver, the DTC components that are auto-filled for the dependencies must be removed because of the limitation in the WiFi module SPI driver. The limitation is that when DTC is used with RSPI, 32-bit transfers are required but BCM43362/GT202 vendor code (that is, the WiFi module SPI driver) uses 8-bit transfers only.

3. The WiFi framework does not support the S124 (due to the CM0+ Core MCU) due to memory constraints.

4. When using WiFi demo applications for testing on the DK-S3A7 board, enable the USBF switch (dip switch S6) on the DK-S3A7 board. This is needed for the console communication of the test application. We strongly advised reviewing the documentation for the respective kits.

5. When testing with Windows 10, you must change the USBX Device Configuration Class Code from Communications to Miscellaneous. To do this, go to the Console Thread in the Threads tab and change the Class Code property of the USBX Device Configuration.

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 27 of 114 Jun 9, 2017

9 Adding New WiFi Module Support To Synergy WiFi Framework

This section describes how to add new WiFi module support to Synergy WiFi framework. It involves creating standard set of structures and APIs around WiFi device driver which will be used by user application.

Here we refer to the new WiFi module as “template”, while adding support for the actual module user should replace this “template” with actual module name, for example, BCM43362, GT202.

Please refer to sf_wifi_template.zip file from Synergy Gallery for sample source code.

9.1 WiFi Framework Source and Header Files

For new WiFi module support, you must create the following directory structure under e2 studio project.

synergy

|-- ssp_supplemental

|-- add_on

| |-- inc

| |-- framework

| | |-- instances

| | |- sf_wifi_template.h

| | |- sf_wifi_bcm43362.h

| |-- src

| |-- framework

| |-- sf_wifi_bcm43362

| |-- sf_wifi_template

| |-- ref

| |-- sf_wifi_template_praivate_api.h

| |-- sf_wifi_template_private.h

| |-- sf_wifi_template.c

| |-- sf_wifi_nsal_nx

|-- wifi_drivers

|-- wifi_driver_bcm43362

|-- wifi_driver

The directory structure shows how files for WiFi modules should be created. Here is the brief description of each file/folder:

• sf_wifi_template.h: This header file contains structure definition of extended configuration which includes lower level communication details. It also includes version information.

• wifi_driver: This directory contains WiFi module driver source code (third party vendor source code).

• ref: This directory contains reference configuration file • sf_wifi_template_private_api.h: This header file contains prototypes of WiFi

framework template APIs • sf_wifi_template_private.h: This header file contains private macro and structure

definitions used by WiFi framework module template. • sf_wifi_template.c: This source file contains implementations of WiFi framework APIs

template.

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 28 of 114 Jun 9, 2017

9.1.1 Instance Header File

The instance header file, sf_wifi_template.h, is placed at location synergy/ssp_supplemental/add_on/inc/framework/instances/sf_wifi_template.h.

This file has the structure definition of the extended configuration which includes pointer to lower level communication interface instances such as r_spi and r_sdmmc, IO PORT pins used by WiFi module such as reset pin and slave select pin, and the priority of the driver task thread (the priority of the thread created internally by WiFi module’s device driver code). This structure may also contain additional configurable fields which are specific to WiFi module.

9.1.2 Driver Source Code

The driver folder is placed at location synergy/ssp_supplemental/wifi_drivers/wifi_drive_template.

This folder contains the WiFi module device driver source code provided by vendor.

9.1.3 Reference Configuration File

The ref folder is placed at location synergy/ssp_supplemental/add_on/ src/framework/sf_wifi_template/ref.

This folder contains reference configuration file which includes common configurable macro definitions. Copy the same file at location synergy_cfg/framework/sf_wifi_template_cfg.h.

9.1.4 Framework APIs

The sf_wifi_template_private_api.h file is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template/sf_wifi_template_private_api.h.

This file contains prototypes of WiFi framework APIs which are described in sections 4.1 to 4.15

9.1.5 Private Structure/Macro Definitions

The sf_wifi_template_private.h file is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template/sf_wifi_template_private.h.

This file contains private structures and macros definitions used by WiFi framework template. This file should not contain device driver’s private structure/data types/macros definitions.

It contains structure definition which is used inside the control structure of the WiFi framework. It uses this as a handle for communication with the WiFi device driver.

9.1.6 Framework API Implementation

The sf_wifi_template.c is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template/sf_wifi_template.c.

This file contains the implementation of synergy WiFi framework APIs

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 29 of 114 Jun 9, 2017

Out of these framework APIs two APIs will be used by NSAL: transmit and receive callback. The transmit API accepts a pointer to data buffer and length of data as arguments. The receive callback will be called by the WiFi module device driver. While calling, this callback should fill in synergy WiFi callback arguments and pass them as argument to the callback function.

Below is sample code showing how receive callback is called.

sf_wifi_cfg_t * p_wifi_cfg = NULL;

sf_wifi_callback_args_t callback_args;

p_wifi_cfg = &g_template_driver.wifi_cfg;

if (p_wifi_cfg->p_callback)

{

callback_args.event = SF_WIFI_EVENT_RX;

callback_args.p_data = (uint8_t *)buffer;

callback_args.length = length;

callback_args.p_context = p_wifi_cfg->p_context;

p_wifi_cfg->p_callback(&callback_args);

}

9.2 On-Chip Stack Interface Source and Header Files

If the WiFi module supports on-chip networking stack then it should also implement on-chip stack interface. For on-chip stack interface support user should create below directory structure under e2 studio project

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 30 of 114 Jun 9, 2017

synergy

|-- ssp

|-- ssp_supplemental

|-- add_on

| |-- inc

| |-- framework

| | |-- api

| | |-- instances

| | |- sf_wifi_dummy.h

| | |- sf_wifi_template_onchip_stack.h

| |-- src

| |-- framework

| |-- sf_wifi_dummy

| |-- sf_wifi_template_onchip_stack

| |-- ref

| |-- sf_wifi_dummy_template_stack_praivate_api.h

| |-- sf_wifi_dummy_template_stack.c

|-- wifi_drivers

|-- wifi_driver

This directory structure shows how files for the on-chip stack interface of the WiFi module should be created. Here is the brief description of each file/folder:

• sf_wifi_template_onchip_stack.h: This header file contains version information and reference to on-chip stack API implementation.

• ref: This directory contains reference configuration file • sf_wifi_template_onchip_stack _private_api.h: This header file contains

prototypes of on-chip stack interface APIs template • sf_wifi_template_onchip_stack.c: This source file contains implementations of on-

chip stack interface APIs template. • wifi_driver: This directory contains WiFi module driver source code (third party vendor

source code).

9.2.1 Instance Header File

The instance header file, sf_wifi_onchip_stack_template.h, is placed at location synergy/ssp_supplemental/add_on/inc/framework/instances/sf_wifi _template_onchip_stack.h.

This header file contains version information and reference to on-chip stack API implementation.

9.2.2 Reference Configuration File

The ref folder, is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template_onchip_stack /ref.

This folder contains reference configuration file which includes common configurable macro definitions. Copy the same file at location synergy_cfg/framework/ sf_wifi_template_onchip_stack_cfg.h.

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 31 of 114 Jun 9, 2017

9.2.3 Interface APIs

The sf_wifi_template_onchip_stack_private_api.h is placed at location synergy/ssp_supplemental/add_on//src/framework/sf_wifi_onchip_stack_template/sf_wifi_template_onchip_stack_private_api.h.

This file contains prototypes of on-chip stack interface APIs which are described in section 4.16

9.2.4 Interface API Implementation

The sf_wifi_template_onchip_stack.c is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template/sf_wifi_template_onchip_stack.c.

This file contains implementation of synergy on-chip networking stack interface APIs

9.3 Socket Interface Source And Header Files

If the WiFi module supports on-chip networking stack then it should also implement on-chip stack interface. For on-chip stack interface support user should create below directory structure under e2 studio project

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 32 of 114 Jun 9, 2017

synergy

|-- ssp

|-- ssp_supplemental

|-- add_on

| |-- inc

| |-- framework

| | |-- api

| | |-- instances

| | |- sf_wifi_dummy.h

| | |- sf_wifi_dummy_onchip_stack.h

| | |- sf_wifi_template_socket.h

| |-- src

| |-- framework

| |-- sf_wifi_dummy

| |-- sf_wifi_dummy_onchip_stack

| |-- sf_wifi_template_socket

| |-- ref

| |-- sf_wifi_template_socket_praivate_api.h

| |-- sf_wifi_template_socket.c

|-- wifi_drivers

|-- wifi_driver

synergy

|-- ssp

|-- ssp_supplemental

|-- add_on

| |-- inc

| |-- framework

| | |-- api

| | |-- instances

| | |- sf_wifi_dummy.h

| | |- sf_wifi_dummy_onchip_stack.h

| | |- sf_wifi_template_socket.h

| |-- src

| |-- framework

| |-- sf_wifi_dummy

| |-- sf_wifi_dummy_onchip_stack

| |-- sf_wifi_template_socket

| |-- ref

| |-- sf_wifi_template_socket_praivate_api.h

| |-- sf_wifi_template_socket.c

|-- wifi_drivers

|-- wifi_driver

This directory structure shows how files for socket interface of the WiFi module should be created. Here is the brief description of each file/folder

• sf_socket_wifi_template.h: This header file contains version information and reference to socket interface API implementation.

• ref: This directory contains reference configuration file

WiFi Framework 9. Adding New WiFi Module Support To Synergy WiFi Framework

R11UM0050EU0108 Rev.1.08 Page 33 of 114 Jun 9, 2017

• sf_socket_wifi_template_private_api.h: This header file contains prototypes of socket interface APIs template.

• sf_socket_wifi_template.c: This source file contains implementations of socket interface APIs template.

• wifi_driver: This directory contains WiFi module driver source code (third party vendor source code).

9.3.1 Instance Header File

The instance header file, sf_wifi_template_socket.h, is placed at location synergy/ssp_supplemental/add_on /inc/framework/instances/sf_wifi_template_socket.h.

This header file contains version information and reference to socket API implementation.

9.3.2 Reference Configuration File

The ref folder, is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template_socket/ref.

This folder contains the reference configuration file which includes common configurable macro definitions. Copy the same file at location synergy_cfg/framework/ sf_wifi_template_socket_cfg.h.

9.3.3 Interface APIs

The sf_socket_wifi_template_private_api.h is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template_socket/sf_wifi_template_socket_private_api.h.

This file contains prototypes of socket interface APIs which are described in section 4.17

9.3.4 Interface API Implementation

The sf_socket_wifi_template.c is placed at location synergy/ssp_supplemental/add_on/src/framework/sf_wifi_template_socket /sf_wifi_template_socket.c.

This file contains implementation of synergy socket interface APIs. If WiFi module device driver code does not provide BSD compatible socket APIs then this file also implements BSD socket APIs. In such case these APIs will be wrapper over WiFi module driver APIs.

9.4 WiFi Driver Source

WiFi driver source code from a third party vendor should be kept under wifi_driver folder. As explained above, the wifi_driver folder contains template WiFi module driver code. This folder is placed at location synergy\ssp_supplemental\wifi_drivers\wifi_driver.

WiFi module driver should make use of the sf_wifi_on_template_cfg_t structure defined in sf_wifi_template.h, for low-level communication with Synergy MCU. This structure contains instances of HAL components used by WiFi module to communicate with MCU, that is, r_spi, IO PORT, r_icu and so on. This structure is passed as an extended configuration to the WiFi framework.

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 34 of 114 Jun 9, 2017

10 API References: WiFi Framework Interface

10.1 SF WIFI Framework Interface

RTOS-integrated SF WIFI Framework Interface.

10.1.1 Interface APIs

• ssp_err_t(* open )(sf_wifi_ctrl_t *p_ctrl, sf_wifi_cfg_t const *const p_cfg) Initialize the network interface for data transfers.

• ssp_err_t(* close )(sf_wifi_ctrl_t *const p_ctrl) De-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt.

• ssp_err_t(* multicastListAdd )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Add the given MAC address to the multicast filter list.

• ssp_err_t(* multicastListDelete )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) • ssp_err_t(* statisticsGet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_stats_t *const p_wifi_device_stats)

Get the interface statistics. • ssp_err_t(* transmit )(sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_buf, uint32_t length)

Transmit data packet. • ssp_err_t(* provisioningSet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t const *const

p_wifi_provisioning) Set WiFi module provisioning which will configure the module in AP or Client mode.

• ssp_err_t(* provisioningGet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t *const p_wifi_provisioning) Get the provisioning information of WiFi module.

• ssp_err_t(* infoGet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_info_t *const p_wifi_info) Get WiFi module information.

• ssp_err_t(* scan )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_scan_t *const p_scan, uint8_t *const p_cnt) Scan for WiFi SSIDs.

• ssp_err_t(* ACLAdd )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Add a MAC address to the Access Control List. Valid in AP mode only.

• ssp_err_t(* ACLDelete )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Delete a MAC address from Access Control List. Valid in AP mode only.

• ssp_err_t(* macAddressGet )(sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_mac) Get WiFi module MAC address.

• ssp_err_t(* macAddressSet )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Set WiFi module MAC address.

• ssp_err_t(* versionGet )(ssp_version_t *const p_version) Gets version and stores it in provided pointer p_version.

10.1.2 Data Structures

• struct st_sf_wifi_ip_addr • struct st_sf_wifi_info • struct st_sf_wifi_callback_arg • struct st_sf_wifi_provisioning • struct st_sf_wifi_cfg • struct st_sf_wifi_stats

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 35 of 114 Jun 9, 2017

• struct st_sf_wifi_scan • struct st_sf_wifi_ctrl • struct st_sf_wifi_api • struct st_sf_wifi_instance

10.1.3 Macros

• #define SF_WIFI_API_VERSION_MAJOR (1U) • #define SF_WIFI_API_VERSION_MINOR (0U) • #define SF_WIFI_SSID_LENGTH (32U)

WiFi SSID length. • #define SF_WIFI_SECURITY_KEY_LENGTH (128U)

WiFi Security Key length. • #define SF_WIFI_MAC_ADDR_LENGTH (6U)

WiFi MAC address length. • #define SF_WIFI_TRUE (1U)

Boolean True condition. • #define SF_WIFI_FALSE (0U)

Boolean False condition. • #define SF_WIFI_IPV4_ADDRESS(a, b, c, d) • #define SSP_ERR_WIFI_CONFIG_FAILED ((ssp_err_t)4000)

WiFi module Configuration failed. • #define SSP_ERR_WIFI_INIT_FAILED ((ssp_err_t)4001)

WiFi module initialization failed. • #define SSP_ERR_WIFI_TRANSMIT_FAILED ((ssp_err_t)4002)

Transmission failed. • #define SSP_ERR_WIFI_INVALID_MODE ((ssp_err_t)4003)

API called when provisioned in client mode. • #define SSP_ERR_WIFI_FAILED ((ssp_err_t)4004)

WiFi Failed.

Macro Definition Documentation

• #define SF_WIFI_API_VERSION_MAJOR (1U) Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file. Major Version of the API defined in this file

• #define SF_WIFI_API_VERSION_MINOR (0U) Minor Version of the API defined in this file

• #define SF_WIFI_IPV4_ADDRESS( a, b, c, d) Value:((((uint32_t) a) << (24U)) | (((uint32_t) b) << (16U)) | \ (((uint32_t) c) << (8U)) | ((uint32_t) d))

IP Address Generation Macro • #define SSP_ERR_WIFI_CONFIG_FAILED ((ssp_err_t)4000)

WiFi module Configuration failed. Start of SF_WIFI Specific

10.1.4 Typedefs

• typedef enum e_sf_wifi_ip_addr_version sf_wifi_ip_addr_version_t

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 36 of 114 Jun 9, 2017

• typedef enum e_sf_wifi_interface_mode sf_wifi_interface_mode_t • typedef enum e_sf_wifi_wep_key_format sf_wifi_wep_key_format_t • typedef enum e_sf_wifi_security_type sf_wifi_security_type_t • typedef enum e_sf_wifi_encryption_type sf_wifi_encryption_type_t • typedef enum e_sf_wifi_bss_type sf_wifi_bss_type_t • typedef enum e_sf_wifi_interface_hw_mode sf_wifi_interface_hw_mode_t • typedef enum e_sf_wifi_rts sf_wifi_rts_t • typedef enum e_sf_wifi_preamble sf_wifi_preamble_t • typedef enum e_sf_wifi_wmm sf_wifi_wmm_t • typedef enum e_sf_wifi_high_throughput sf_wifi_high_throughput_t • typedef enum e_sf_wifi_ssid_broadcast sf_wifi_ssid_broadcast_t • typedef enum e_sf_wifi_wds sf_wifi_wds_t • typedef enum e_sf_wifi_mandatory_high_throughput sf_wifi_mandatory_high_throughput_t • typedef enum e_sf_wifi_auto_negotiation sf_wifi_auto_negotiation_t • typedef enum e_sf_wifi_access_control sf_wifi_access_control_t • typedef struct st_sf_wifi_ip_addr sf_wifi_ip_addr_t • typedef struct st_sf_wifi_info sf_wifi_info_t • typedef enum e_sf_wifi_event sf_wifi_event_t • typedef struct st_sf_wifi_callback_arg sf_wifi_callback_args_t • typedef struct st_sf_wifi_provisioning sf_wifi_provisioning_t • typedef struct st_sf_wifi_cfg sf_wifi_cfg_t • typedef struct st_sf_wifi_stats sf_wifi_stats_t • typedef struct st_sf_wifi_scan sf_wifi_scan_t • typedef struct st_sf_wifi_ctrl sf_wifi_ctrl_t • typedef struct st_sf_wifi_api sf_wifi_api_t • typedef struct st_sf_wifi_instance sf_wifi_instance_t

Typedef Documentation

• typedef enum e_sf_wifi_access_control sf_wifi_access_control_t WiFi Framework AccessContol mode

• typedef struct st_sf_wifi_api sf_wifi_api_t Framework API structure. Implementations will use the following API.

• typedef enum e_sf_wifi_auto_negotiation sf_wifi_auto_negotiation_t WiFi Auto Negotiation flag

• typedef enum e_sf_wifi_bss_type sf_wifi_bss_type_t WiFi BSS type

• typedef struct st_sf_wifi_callback_arg sf_wifi_callback_args_t WiFi framework callback parameter definition

• typedef struct st_sf_wifi_cfg sf_wifi_cfg_t Define the WiFi configuration parameters

• typedef struct st_sf_wifi_ctrl sf_wifi_ctrl_t WiFi Framework control structure

• typedef enum e_sf_wifi_encryption_type sf_wifi_encryption_type_t WiFi Encryption type

• typedef enum e_sf_wifi_event sf_wifi_event_t

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 37 of 114 Jun 9, 2017

WiFi Framework event codes • typedef enum e_sf_wifi_high_throughput sf_wifi_high_throughput_t

WiFi High Throughput flag • typedef struct st_sf_wifi_info sf_wifi_info_t

Configuration about underlying device driver. • typedef struct st_sf_wifi_instance sf_wifi_instance_t

This structure encompasses everything that is needed to use an instance of this interface. • typedef enum e_sf_wifi_interface_hw_mode sf_wifi_interface_hw_mode_t

WiFi Hardware mode • typedef enum e_sf_wifi_interface_mode sf_wifi_interface_mode_t

WiFi Interface mode • typedef struct st_sf_wifi_ip_addr sf_wifi_ip_addr_t

IP address information • typedef enum e_sf_wifi_ip_addr_version sf_wifi_ip_addr_version_t

IP address version • typedef enum e_sf_wifi_mandatory_high_throughput

sf_wifi_mandatory_high_throughput_t WiFi Mandatory High Throughput flag

• typedef enum e_sf_wifi_preamble sf_wifi_preamble_t WiFi Preamble type

• typedef struct st_sf_wifi_provisioning sf_wifi_provisioning_t WiFi Provisioning parameters

• typedef enum e_sf_wifi_rts sf_wifi_rts_t WiFi RTS flag

• typedef struct st_sf_wifi_scan sf_wifi_scan_t Define the structure to store the SSID scan information

• typedef enum e_sf_wifi_security_type sf_wifi_security_type_t WiFi Security type

• typedef enum e_sf_wifi_ssid_broadcast sf_wifi_ssid_broadcast_t WiFi SSID Broadcast flag

• typedef struct st_sf_wifi_stats sf_wifi_stats_t Define the statistic and error counters for this IP instance.

• typedef enum e_sf_wifi_wds sf_wifi_wds_t WiFi WDS Flasg

• typedef enum e_sf_wifi_wep_key_format sf_wifi_wep_key_format_t WiFi WEP Key Format

• typedef enum e_sf_wifi_wmm sf_wifi_wmm_t WiFi WMM flag

10.1.5 Enumerations

• enum e_sf_wifi_ip_addr_version { SF_WIFI_IP_ADDR_VERSION_4, SF_WIFI_IP_ADDR_VERSION_6 }

• enum e_sf_wifi_interface_mode { SF_WIFI_INTERFACE_MODE_AP, SF_WIFI_INTERFACE_MODE_CLIENT }

• enum e_sf_wifi_wep_key_format { SF_WIFI_WEP_KEY_FORMAT_ASCII, SF_WIFI_WEP_KEY_FORMAT_HEX }

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 38 of 114 Jun 9, 2017

• enum e_sf_wifi_security_type { SF_WIFI_SECURITY_TYPE_OPEN, SF_WIFI_SECURITY_TYPE_WEP, SF_WIFI_SECURITY_TYPE_WPA, SF_WIFI_SECURITY_TYPE_WPA2 }

• enum e_sf_wifi_encryption_type { SF_WIFI_ENCRYPTION_TYPE_AUTO, SF_WIFI_ENCRYPTION_TYPE_TKIP, SF_WIFI_ENCRYPTION_TYPE_CCMP, SF_WIFI_ENCRYPTION_TYPE_WEP, SF_WIFI_ENCRYPTION_TYPE_NONE }

• enum e_sf_wifi_bss_type { SF_WIFI_BSS_TYPE_INFRASTRUCTURE = 0, SF_WIFI_BSS_TYPE_ADHOC = 1, SF_WIFI_BSS_TYPE_ANY = 2, SF_WIFI_BSS_TYPE_UNKNOWN = -1 }

• enum e_sf_wifi_interface_hw_mode { SF_WIFI_INTERFACE_HW_MODE_11A, SF_WIFI_INTERFACE_HW_MODE_11B, SF_WIFI_INTERFACE_HW_MODE_11G, SF_WIFI_INTERFACE_HW_MODE_11N }

• enum e_sf_wifi_rts { SF_WIFI_RTS_DISABLE, SF_WIFI_RTS_ENABLE } • enum e_sf_wifi_preamble { SF_WIFI_PREAMBLE_SHORT, SF_WIFI_PREAMBLE_LONG } • enum e_sf_wifi_wmm { SF_WIFI_WMM_DISABLE, SF_WIFI_WMM_ENABLE } • enum e_sf_wifi_high_throughput { SF_WIFI_HIGH_THROUGHPUT_DISABLE,

SF_WIFI_HIGH_THROUGHPUT_ENABLE } • enum e_sf_wifi_ssid_broadcast { SF_WIFI_SSID_BROADCAST_DISABLE,

SF_WIFI_SSID_BROADCAST_ENABLE } • enum e_sf_wifi_wds { SF_WIFI_WDS_DISABLE, SF_WIFI_WDS_ENABLE } • enum e_sf_wifi_mandatory_high_throughput {

SF_WIFI_MANDATORY_HIGH_THROUGHPUT_DISABLE, SF_WIFI_MANDATORY_HIGH_THROUGHPUT_ENABLE }

• enum e_sf_wifi_auto_negotiation { SF_WIFI_AUTO_NEGOTIATION_DISABLE, SF_WIFI_AUTO_NEGOTIATION_ENABLE }

• enum e_sf_wifi_access_control { SF_WIFI_ACCESS_CONTROL_DISABLE, SF_WIFI_ACCESS_CONTROL_DENY, SF_WIFI_ACCESS_CONTROL_ALLOW }

• enum e_sf_wifi_event { SF_WIFI_EVENT_RX = (1 << 0), SF_WIFI_EVENT_AP_CONNECT = (1 << 1), SF_WIFI_EVENT_AP_DISCONNECT = (1 << 2) }

Detailed Description

RTOS-integrated SF WIFI Framework Interface.

Summary

This SSP Interface provides access to the ThreadX-aware SF WIFI Framework.

Enumeration Type Documentation

• enum e_sf_wifi_access_control WiFi Framework AccessContol mode Enumerator:

SF_WIFI_ACCESS_CONTROL_DISABLE Disable MAC address matching.

SF_WIFI_ACCESS_CONTROL_DENY Deny association to stations on the MAC list.

SF_WIFI_ACCESS_CONTROL_ALLOW Allow association to stations on the MAC list.

• enum e_sf_wifi_auto_negotiation

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 39 of 114 Jun 9, 2017

WiFi Auto Negotiation flag Enumerator:

SF_WIFI_AUTO_NEGOTIATION_DISABLE Auto negotiation disable.

SF_WIFI_AUTO_NEGOTIATION_ENABLE Auto negotiation enable.

• enum e_sf_wifi_bss_type WiFi BSS type Enumerator:

SF_WIFI_BSS_TYPE_INFRASTRUCTURE Infrastructure network.

SF_WIFI_BSS_TYPE_ADHOC 802.11 ad-hoc IBSS network

SF_WIFI_BSS_TYPE_ANY Either infrastructure or ad-hoc network.

SF_WIFI_BSS_TYPE_UNKNOWN BSS type is unknown.

• enum e_sf_wifi_encryption_type WiFi Encryption type Enumerator:

SF_WIFI_ENCRYPTION_TYPE_AUTO Automatic selection of encryption protocol.

SF_WIFI_ENCRYPTION_TYPE_TKIP Temporal Key Integrity Protocol. Used by WPA.

SF_WIFI_ENCRYPTION_TYPE_CCMP CTR mode with CBC-MAC Protocol. Used by WPA2.

SF_WIFI_ENCRYPTION_TYPE_WEP WEP mode. Used by WEP.

SF_WIFI_ENCRYPTION_TYPE_NONE No Encryption. Used by Open Security type.

• enum e_sf_wifi_event WiFi Framework event codes Enumerator:

SF_WIFI_EVENT_RX Packet received event.

SF_WIFI_EVENT_AP_CONNECT Device Associated Successfully with AP.

SF_WIFI_EVENT_AP_DISCONNECT Device Disconnected with AP.

• enum e_sf_wifi_high_throughput WiFi High Throughput flag Enumerator:

SF_WIFI_HIGH_THROUGHPUT_DISABLE Disable high throughput mode.

SF_WIFI_HIGH_THROUGHPUT_ENABLE Enable high throughput mode. Also requires WMM to be enabled.

• enum e_sf_wifi_interface_hw_mode WiFi Hardware mode Enumerator:

SF_WIFI_INTERFACE_HW_MODE_11A 802.11a

SF_WIFI_INTERFACE_HW_MODE_11B 802.11b

SF_WIFI_INTERFACE_HW_MODE_11G 802.11g

SF_WIFI_INTERFACE_HW_MODE_11N 802.11n

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 40 of 114 Jun 9, 2017

• enum e_sf_wifi_interface_mode WiFi Interface mode Enumerator:

SF_WIFI_INTERFACE_MODE_AP Access Point mode.

SF_WIFI_INTERFACE_MODE_CLIENT Station Mode.

• enum e_sf_wifi_ip_addr_version IP address version Enumerator:

SF_WIFI_IP_ADDR_VERSION_4 IPv4 address.

SF_WIFI_IP_ADDR_VERSION_6 IPv6 address.

• enum e_sf_wifi_mandatory_high_throughput WiFi Mandatory High Throughput flag Enumerator:

SF_WIFI_MANDATORY_HIGH_THROUGHPUT_DISABLE Disable Mandatory HT requirement.

SF_WIFI_MANDATORY_HIGH_THROUGHPUT_ENABLE Enable mandatory HT requirement.

• enum e_sf_wifi_preamble WiFi Preamble type Enumerator:

SF_WIFI_PREAMBLE_SHORT Use short preamble.

SF_WIFI_PREAMBLE_LONG Use long preamble.

• enum e_sf_wifi_rts WiFi RTS flag Enumerator:

SF_WIFI_RTS_DISABLE Disable RTS/CTS handshake.

SF_WIFI_RTS_ENABLE Enable RTS/CTS handshake.

• enum e_sf_wifi_security_type WiFi Security type Enumerator:

SF_WIFI_SECURITY_TYPE_OPEN Open. No encryption used.

SF_WIFI_SECURITY_TYPE_WEP 128-bit WEP OPEN ASCII.

SF_WIFI_SECURITY_TYPE_WPA WiFi Protected Access.

SF_WIFI_SECURITY_TYPE_WPA2 WiFi Protected Access v2.

• enum e_sf_wifi_ssid_broadcast

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 41 of 114 Jun 9, 2017

WiFi SSID Broadcast flag Enumerator:

SF_WIFI_SSID_BROADCAST_DISABLE Disable SSID Broadcast.

SF_WIFI_SSID_BROADCAST_ENABLE Enable SSID Broadcast.

• enum e_sf_wifi_wds WiFi WDS Flasg Enumerator:

SF_WIFI_WDS_DISABLE Disable WDS.

SF_WIFI_WDS_ENABLE Enable WDS.

• enum e_sf_wifi_wep_key_format WiFi WEP Key Format Enumerator:

SF_WIFI_WEP_KEY_FORMAT_ASCII WEP Key in ASCII.

SF_WIFI_WEP_KEY_FORMAT_HEX WEP Key in Hex.

• enum e_sf_wifi_wmm WiFi WMM flag Enumerator:

SF_WIFI_WMM_DISABLE Disable WMM.

SF_WIFI_WMM_ENABLE Enable WMM.

10.2 SF WIFI On-Chip Stack Interface

RTOS-integrated SF WIFI On-Chip Stack Interface.

10.2.1 Interface APIs

• ssp_err_t(* open )(sf_wifi_onchip_stack_ctrl_t *p_ctrl, sf_wifi_onchip_stack_cfg_t const *const p_cfg)

• ssp_err_t(* close )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl) • ssp_err_t(* ipAddressCfg )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl,

sf_wifi_onchip_stack_ip_cfg_t *const p_cfg) • ssp_err_t(* dhcpServerStart )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_ip_addr_t const

*const p_start_ip, sf_wifi_ip_addr_t const *const p_end_ip) • ssp_err_t(* dhcpServerStop )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl) • ssp_err_t(* versionGet )(ssp_version_t *const p_version)

10.2.2 Data Structures

• struct st_sf_wifi_onchip_stack_ip_cfg • struct st_sf_wifi_onchip_stack_cfg • struct st_sf_wifi_onchip_stack_ctrl • struct st_sf_onchip_stack_wifi_api • struct st_sf_wifi_onchip_stack_instance

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 42 of 114 Jun 9, 2017

10.2.3 Macros

• #define SF_WIFI_ONCHIP_STACK_API_VER_MAJOR (1U) • #define SF_WIFI_ONCHIP_STACK_API_VER_MINOR (0U)

Macro Definition Documentation

• #define SF_WIFI_ONCHIP_STACK_API_VER_MAJOR (1U) Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file. Major Version of the API defined in this file

• #define SF_WIFI_ONCHIP_STACK_API_VER_MINOR (0U) Minor Version of the API defined in this file

10.2.4 Typedefs

• typedef enum e_sf_wifi_ip_addr_mode sf_wifi_onchip_stack_ip_addr_mode_t • typedef struct st_sf_wifi_onchip_stack_ip_cfg sf_wifi_onchip_stack_ip_cfg_t • typedef struct st_sf_wifi_onchip_stack_cfg sf_wifi_onchip_stack_cfg_t • typedef struct st_sf_wifi_onchip_stack_ctrl sf_wifi_onchip_stack_ctrl_t • typedef struct st_sf_onchip_stack_wifi_api sf_wifi_onchip_stack_api_t • typedef struct st_sf_wifi_onchip_stack_instance sf_wifi_onchip_stack_instance_t

Typedef Documentation

• typedef struct st_sf_onchip_stack_wifi_api sf_wifi_onchip_stack_api_t Framework API structure. Implementations will use the following API.

• typedef struct st_sf_wifi_onchip_stack_cfg sf_wifi_onchip_stack_cfg_t Define the WiFi configuration parameters

• typedef struct st_sf_wifi_onchip_stack_ctrl sf_wifi_onchip_stack_ctrl_t WiFi Framework control structure

• typedef struct st_sf_wifi_onchip_stack_instance sf_wifi_onchip_stack_instance_t SF WiFi On Chip Stack Instance structure

• typedef enum e_sf_wifi_ip_addr_mode sf_wifi_onchip_stack_ip_addr_mode_t IP addressing modes

• typedef struct st_sf_wifi_onchip_stack_ip_cfg sf_wifi_onchip_stack_ip_cfg_t Define IP Interface configuration information

10.2.5 Enumerations

• enum e_sf_wifi_ip_addr_mode { SF_WIFI_IP_ADDR_GET, SF_WIFI_IP_ADDR_STATIC, SF_WIFI_IP_ADDR_DHCP }

Enumeration Type Documentation

• enum e_sf_wifi_ip_addr_mode

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 43 of 114 Jun 9, 2017

IP addressing modes Enumerator:

SF_WIFI_IP_ADDR_GET Read the IP address assigned to interface.

SF_WIFI_IP_ADDR_STATIC Statically configure the IP address.

SF_WIFI_IP_ADDR_DHCP Get the IP address from DHCP server, dynamic assignment.

Detailed Description RTOS-integrated SF WIFI On-Chip Stack Interface.

Summary

This SSP Interface provides access to the ThreadX-aware SF WIFI Framework.

10.3 SF Socket WIFI Framework Interface

RTOS-integrated SF Socket WIFI Framework Interface.

10.3.1 Interface APIs

• ssp_err_t(* open )(sf_socket_ctrl_t *p_ctrl, sf_socket_cfg_t const *const p_cfg) Pointer to function which initializes the network interface for data transfers Initial driver configuration, enable the driver link, enable interrupts and make device ready for data transfer.

• ssp_err_t(* close )(sf_socket_ctrl_t *const p_ctrl) Pointer to function which un-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt.

• ssp_err_t(* versionGet )(ssp_version_t *const p_version) Gets version and stores it in provided pointer p_version.

10.3.2 Data Structures

• struct in_addr • struct sockaddr • struct sockaddr_in • struct st_sf_socket_ctrl • struct st_sf_socket_cfg • struct st_sf_socket_api • struct st_sf_socket_instance

10.3.3 Macros

• #define SF_SOCKET_WIFI_API_VER_MAJOR (1U) • #define SF_SOCKET_WIFI_API_VER_MINOR (0U)

Macro Definition Documentation

• #define SF_SOCKET_WIFI_API_VER_MAJOR (1U) Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file. Major Version of the API defined in this file

• #define SF_SOCKET_WIFI_API_VER_MINOR (0U) Minor Version of the API defined in this file

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 44 of 114 Jun 9, 2017

10.3.4 Typedefs

• typedef int32_t socklen_t • typedef struct st_sf_socket_ctrl sf_socket_ctrl_t • typedef struct st_sf_socket_cfg sf_socket_cfg_t

This API will not be used as part of the Socket’s API but it will be called beforehand to ensure stack is set up.

• typedef struct st_sf_socket_api sf_socket_api_t • typedef struct st_sf_socket_instance sf_socket_instance_t

Typedef Documentation

• typedef struct st_sf_socket_api sf_socket_api_t Socket Interface API

• typedef struct st_sf_socket_cfg sf_socket_cfg_t This API will not be used as part of the Socket’s API but it will be called beforehand to ensure stack is set up. Socket Interface configuration structure

• typedef struct st_sf_socket_ctrl sf_socket_ctrl_t Socket Interface control structure

• typedef struct st_sf_socket_instance sf_socket_instance_t This structure encompasses everything that is needed to use an instance of this interface.

• typedef int32_t socklen_t Socket Structure Length

10.3.5 Functions

• int socket (int domain, int type, int protocol) Creates socket for communication.

• int close (int socket_fd) Closes socket.

• int bind (int socket_fd, const struct sockaddr *p_local_sock_addr, socklen_t addrlen) Binds socket to IP address.

• int listen (int sockfd, int backlog) Listens for connection on socket.

• int connect (int sockfd, const struct sockaddr *p_serv_addr, socklen_t addrlen) Connects with remote socket(stream socket).

• int accept (int sockfd, struct sockaddr *p_cliaddr, socklen_t *p_addrlen) Accepts connection from remote socket.

• ssize_t send (int sockfd, const void *p_buf, size_t length, int flags) Sends data over STREAM socket.

• ssize_t recv (int sockfd, void *p_buf, size_t length, int flags) Receives data over STREAM socket.

• ssize_t sendto (int sockfd, const void *p_buf, size_t length, int flags, const struct sockaddr *p_dest_addr, socklen_t addrlen) Sends data over DGRAM socket.

• ssize_t recvfrom (int sockfd, void *p_buf, size_t length, int flags, struct sockaddr *p_src_addr, socklen_t *p_addrlen)

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 45 of 114 Jun 9, 2017

Receives data over DGRAM socket. • int setsockopt (int sockfd, int level, int optname, const void *p_optval, socklen_t optlen)

Sets socket specific options. • int getsockopt (int sockfd, int level, int optname, void *p_optval, socklen_t *p_optlen)

Gets socket specific options. • int select (int nfds, fd_set *p_readfds, fd_set *p_writefds, fd_set *p_exceptfds, struct timeval

*p_timeout) Waits for any activity on socket.

Function Documentation

• int accept (int sockfd, struct sockaddr * p_cliaddr, socklen_t * p_addrlen) Accepts connection from remote socket. Accept connection request from remote.

Parameters:

in sockfd Local socket

out p_cliaddr Pointer to remote socket address which trying to connect

out p_addrlen Pointer to address length of client socket address

Implements accept. This function accepts connection from remote socket. This API is used only with socket type STREAM. The call is blocked if no connection is present or the socket is blocking. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Error accepting the connection

Otherwise Connection is received successfully.

Remote socket descriptor. Increments open socket count

• int bind (int socket_fd, const struct sockaddr * p_local_sock_addr, socklen_t addrlen)

Binds socket to IP address. Bind socket to interface which is identified by IP address Parameters:

in socket_fd Local socket

in p_local_sock_addr Pointer to local socket address

in addrlen Size of sock address structure

Implements bind. This function binds socket to given IP address and port. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Binding socket failed

Otherwise Socket is bound successfully.

• int close (int socket_fd)

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 46 of 114 Jun 9, 2017

Closes socket. API which closes socket Parameters:

in socket_fd Local socket

Implements close. Close opened socket Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD

Closing socket failed

Otherwise Socket is closed successfully.

• int connect (int sockfd, const struct sockaddr * p_serv_addr, socklen_t addrlen) Connects with remote socket (stream socket). Establish TCP connection with remote socket Parameters:

in sockfd Local socket

in p_serv_addr Pointer to remote socket address

in addrlen Size of sock address structure

Implements connect. This function connects local socket with remote socket. The call is blocked until a connection is established or error is returned. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Error occurred.

Otherwise Socket is connected successfully.

• int getsockopt (int sockfd, int level, int optname, void * p_optval, socklen_t * p_optlen) Gets socket specific options. Get Socket options. Parameters:

in sockfd Local socket

in level Sockets API level

in optname Option to be get

out p_optval Option value to be get

in p_optlen Length of option value

Implements getsockopt. This gets options for an existing socket. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Error reading socket option

Otherwise Socket option read successfully.

• int listen (int sockfd, int backlog)

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 47 of 114 Jun 9, 2017

Listens for connection on socket. Listen for tcp connection. Set socket in listen mode for tcp connection. Parameters:

in sockfd Local socket

in backlog Max number of connection queue.

Implements listen. This function listens for connection on socket. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Failed to set socket in Listen mode

Otherwise Set socket in Listen mode successfully.

• ssize_t recv (int sockfd, void * p_buf, size_t length, int flags) Receives data over STREAM socket. Receive data from remote socket. Parameters:

in sockfd Local socket

out p_buf Pointer to data buffer where data will be received

in length Maximum length of data which can be received

in flags Socket flags

Implements receive. This function receives data on a stream socket in connected state. If no packet is available, the socket is blocked until it is set to non-blocking. The application must provide a valid buffer to receive the payload. If the buffer length is smaller than the available payload, the API will do a partial copy, and hold on the rest of the payload for a subsequent call to the API. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Failed to receive data.

Otherwise Data received successfully.

• ssize_t recvfrom (int sockfd, void * p_buf, size_t length, int flags, struct sockaddr * p_src_addr, socklen_t * p_addrlen) Receives data over DGRAM socket. Receive data from remote socket. Parameters:

in sockfd Local socket

out p_buf Pointer to data buffer where data will be received

in length Maximum length of data which can be received

in flags Socket flag

out p_src_addr Pointer to remote socket address which has sent data

out p_addrlen Length of socket address structure

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 48 of 114 Jun 9, 2017

Implements recvfrom. This function receives data on a dgram socket. If no packet is available, the socket is blocked until it is set to non-blocking. The application must provide a valid buffer to receive the payload. If the buffer length is smaller than the available payload, the API will do a partial copy, and hold on the rest of the payload for a subsequent call to the API. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Error receiving data

Otherwise Numbers of data bytes received successfully.

Number of bytes received • int select (int nfds, fd_set * p_readfds, fd_set * p_writefds, fd_set * p_exceptfds, struct

timeval * p_timeout) Waits for any activity on socket. Wait on a given socket for specified amount of time. In case of any activity, for example, arrival of packet, it comes out of wait. Parameters:

in nfds Max fd

in p_readfds Pointer to fd_set to check whether data is available for read

in p_writefds Pointer to fd_set to check whether data is available for write

in p_exceptfds Pointer to fd_set to check whether exceptional condition occurred

in p_timeout Wait time in milliseconds

Implements select. Allow an application thread to block on a given socket handle for a specified time period. This API checks for any activity on specified socket, for example arrival of a packet at the receive queue. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Timeout occurred, no activity.

Otherwise Activity detected(Packet available).

Wait interval in ticks Time in miliseconds Time in microseconds

• ssize_t send (int sockfd, const void * p_buf, size_t length, int flags) Sends data over STREAM socket. Send data to remote socket. Parameters:

in sockfd Local socket

in p_buf Pointer to data buffer

in length Data buffer length

in flags Socket flags

Implements send. This function sends data on a stream socket in connected state. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Failed to send data.

Otherwise Data sent successfully.

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 49 of 114 Jun 9, 2017

Number of sent bytes • ssize_t sendto (int sockfd, const void * p_buf, size_t length, int flags, const struct sockaddr

* p_dest_addr, socklen_t addrlen) Sends data over DGRAM socket. Send data to remote socket. Parameters:

in sockfd Local socket

in p_buf Pointer to data buffer to sent

in length Data buffer length

in flags Socket flag

in p_dest_addr Pointer to remote socket address where to send data

in addrlen Length of socket address structure

Implements sendto. This function sends data to remote. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Error Sending data.

Otherwise Numbers of bytes sent successfully.

Number of sent bytes Copy data to buffer

• int setsockopt (int sockfd, int level, int optname, const void * p_optval, socklen_t optlen) Sets socket specific options. Set Socket options. Parameters:

in sockfd Local socket

in level Sockets API level

in optname Option to be set

in p_optval Option value to be set

in optlen Length of option value

Implements setsockopt. This sets options for an existing socket. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Error setting socket option

Otherwise Socket option set successfully.

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 50 of 114 Jun 9, 2017

• int socket (int domain, int type, int protocol) Creates socket for communication. API which creates socket Parameters:

in domain Socket family

in type Socket type

in protocol Protocol type

Implements socket. Creates socket with given parameters. Return values:

SF_WIFI_GT202_SOCKET_INVALID_FD Socket creation failed

Otherwise Socket created successfully

10.4 SF WIFI NSAL Interface

RTOS-integrated SF WIFI NSAL Framework Interface.

10.4.1 Data Structures

• struct st_sf_wifi_nsal_cfg • struct st_sf_wifi_nsal_callback_args

10.4.2 Macros • #define SF_WIFI_NSAL_MAC_CHANGED (NX_LINK_USER_COMMAND + 1U)

Macro Definition Documentation

• #define SF_WIFI_NSAL_MAC_CHANGED (NX_LINK_USER_COMMAND + 1U) Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file.

10.4.3 Typedefs • typedef enum e_sf_wifi_nsal_zero_copy sf_wifi_nsal_zero_copy_t • typedef struct st_sf_wifi_nsal_cfg sf_wifi_nsal_cfg_t • typedef struct st_sf_wifi_nsal_callback_args sf_wifi_nsal_callback_args_t

Typedef Documentation

• typedef struct st_sf_wifi_nsal_callback_args sf_wifi_nsal_callback_args_t Define the NSAL callback arguments

• typedef struct st_sf_wifi_nsal_cfg sf_wifi_nsal_cfg_t Define the NSAL configuration parameters

• typedef enum e_sf_wifi_nsal_zero_copy sf_wifi_nsal_zero_copy_t Zero Copy Configuration Enumeration

10.4.4 Enumerations • enum e_sf_wifi_nsal_zero_copy { SF_WIFI_NSAL_ZERO_COPY_DISABLE,

SF_WIFI_NSAL_ZERO_COPY_ENABLE }

Enumeration Type Documentation

WiFi Framework 10. API References: WiFi Framework Interface

R11UM0050EU0108 Rev.1.08 Page 51 of 114 Jun 9, 2017

• enum e_sf_wifi_nsal_zero_copy Zero Copy Configuration Enumeration Enumerator:

SF_WIFI_NSAL_ZERO_COPY_DISABLE Zero copy is disabled.

SF_WIFI_NSAL_ZERO_COPY_ENABLE Zero copy is enabled.

Detailed Description RTOS-integrated SF WIFI NSAL Framework Interface.

Summary

This SSP Interface provides access to the ThreadX-aware SF WIFI NSAL Framework.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 52 of 114 Jun 9, 2017

11 API References: WiFi Framework On GT202

11.1 WiFi Framework on GT202

RTOS-integrated WiFi Framework example. Implementation of Atheros WiFi Driver. It implements the following interfaces:

11.1.1 Data Structures

• struct st_sf_wifi_on_gt202_cfg

11.1.2 Macros • #define SF_WIFI_GT202_CODE_VERSION_MAJOR (1U) • #define SF_WIFI_GT202_CODE_VERSION_MINOR (0U)

Macro Definition Documentation

• #define SF_WIFI_GT202_CODE_VERSION_MAJOR (1U) WiFi Interface. Major Version of code that implements the API defined in this file

• #define SF_WIFI_GT202_CODE_VERSION_MINOR (0U) Minor Version of code that implements the API defined in this file

11.1.3 Typedefs • typedef struct st_sf_wifi_on_gt202_cfg sf_wifi_on_gt202_cfg_t

Typedef Documentation

• typedef struct st_sf_wifi_on_gt202_cfg sf_wifi_on_gt202_cfg_t Extension structure for this Implementation. Each implementation can have its own extension structure. For example one implementation may use RSPI for communicating with the WiFi chip while another may use SDIO.

11.1.4 Functions • ssp_err_t SF_WIFI_GT202_Open (sf_wifi_ctrl_t *p_ctrl, sf_wifi_cfg_t const *const p_cfg)

Initialize WiFi module. • ssp_err_t SF_WIFI_GT202_Close (sf_wifi_ctrl_t *const p_ctrl)

Stop WiFi module functionality. • ssp_err_t SF_WIFI_GT202_ProvisioningSet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t

const *const p_wifi_provisioning) Provisions the WiFi module.

• ssp_err_t SF_WIFI_GT202_ProvisioningGet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t *const p_wifi_provisioning) Reads the current WiFi Provisioning information of the WiFi module.

• ssp_err_t SF_WIFI_GT202_MulticastListAdd (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Add MAC address in multicast list.

• ssp_err_t SF_WIFI_GT202_MulticastListDelete (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Delete MAC address from multicast list.

• ssp_err_t SF_WIFI_GT202_StatisticsGet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_stats_t *const p_wifi_device_stats)

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 53 of 114 Jun 9, 2017

Get the interface statistics. • ssp_err_t SF_WIFI_GT202_Transmit (sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_buf, uint32_t

length) Transmit data packets.

• ssp_err_t SF_WIFI_GT202_InfoGet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_info_t *const p_wifi_info) Get WiFi module information.

• ssp_err_t SF_WIFI_GT202_Scan (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_scan_t *const p_scan, uint8_t *const p_cnt) Scans for available APs.

• ssp_err_t SF_WIFI_GT202_ACLAdd (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Add MAC address from Access control list.

• ssp_err_t SF_WIFI_GT202_ACLDelete (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Delete MAC address from Access control list.

• ssp_err_t SF_WIFI_GT202_MACAddressSet (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Set MAC address of WiFi module.

• ssp_err_t SF_WIFI_GT202_MACAddressGet (sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_mac) Get MAC address of WiFi module.

• ssp_err_t SF_WIFI_GT202_VersionGet (ssp_version_t *const p_version) Set driver version based on compile time macros. Implements sf_wifi_api_t::versionGet.

Function Documentation

• ssp_err_t SF_WIFI_GT202_ACLAdd (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Add MAC address from Access control list. Implements sf_wifi_api_t::ACLAdd. Add specified mac address in access control list Return values:

SSP_ERR_UNSUPPORTED Functionality is not supported.

• ssp_err_t SF_WIFI_GT202_ACLDelete (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Delete MAC address from Access control list. Implements sf_wifi_api_t::ACLDelete Delete specified mac address from access control list Return values:

SSP_ERR_UNSUPPORTED Functionality is not supported.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 54 of 114 Jun 9, 2017

• ssp_err_t SF_WIFI_GT202_Close (sf_wifi_ctrl_t *const p_ctrl) Stop WiFi module functionality. Implements sf_wifi_api_t::close. This function performs the following tasks: Update global variables for future use. Disable the Interrupt and suspend the driver task thread. Return values:

SSP_SUCCESS Suspend the driver functionality.

SSP_ERR_NOT_OPEN Device is not opened.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to close

Disassociate or Stop Access Point Suspend the driver's main thread Disable the interrupt

• ssp_err_t SF_WIFI_GT202_InfoGet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_info_t *const p_wifi_info) Get WiFi module information. Implements sf_wifi_api_t::infoGet. Get WiFi module information like chipset/driver information, RSSI, noise level, link quality Return values:

SSP_SUCCESS Successfully get the WiFi information

SSP_ERR_NOT_OPEN Driver not opened.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_WIFI_FAILED Failed reading WiFi information

SSP_ERR_IN_USE Module in use

• ssp_err_t SF_WIFI_GT202_MACAddressGet (sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_mac) Get MAC address of WiFi module. Implements sf_wifi_api_t::getMACAddress Read configured MAC address of the WiFi module. Return values:

SSP_SUCCESS Successfully reads the mac address.

SSP_ERR_WIFI_FAILED Failed to read mac address

SSP_ERR_NOT_OPEN Driver not opened

SSP_ERR_IN_USE Module in use

Driver param structure for ioctl • ssp_err_t SF_WIFI_GT202_MACAddressSet (sf_wifi_ctrl_t *const p_ctrl, uint8_t const

*const p_mac) Set MAC address of WiFi module. Implements sf_wifi_api_t::setMACAddress. Configure MAC address of the WiFi module. Return values:

SSP_ERR_UNSUPPORTED Functionality is not supported.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 55 of 114 Jun 9, 2017

• ssp_err_t SF_WIFI_GT202_MulticastListAdd (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Add MAC address in multicast list. Implements sf_wifi_api_t::multicastListAdd. Adds specified MAC address in Multicast list Return values:

SSP_ERR_UNSUPPORTED Functionality is not supported by WiFi module

• ssp_err_t SF_WIFI_GT202_MulticastListDelete (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Delete MAC address from multicast list. Implements sf_wifi_api_t::multicastListDelete Deletes specified MAC Address from Multicast list Return values:

SSP_ERR_UNSUPPORTED Functionality is not supported

• ssp_err_t SF_WIFI_GT202_Open (sf_wifi_ctrl_t * p_ctrl, sf_wifi_cfg_t const *const p_cfg) Initialize WiFi module. Implements sf_wifi_api_t::open. This function performs the following tasks: Initializes WiFi module and Configure the parameters as per the p_cfg Update global variables for future use. Return values:

SSP_SUCCESS Module initialization successful

SSP_ERR_ALREADY_OPEN WiFi module is already opened

SSP_ERR_WIFI_CONFIG_FAILED WiFi module Configuration failed

SSP_ERR_WIFI_INIT_FAILED WiFi module initialization failed

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to initialize

SSP_ERR_UNSUPPORTED Unsupported Parameter configuration

SSP_ERR_INTERNAL Extended Configuration is NULL

• ssp_err_t SF_WIFI_GT202_ProvisioningGet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t *const p_wifi_provisioning) Reads the current WiFi Provisioning information of the WiFi module. Implements sf_wifi_api_t::provisioningGet. Reads the provisioning information Return values:

SSP_SUCCESS Successfully reads provisioning information

SSP_ERR_NOT_OPEN Device is not opened

SSP_ERR_WIFI_FAILED Failed to get provisioning information

SSP_ERR_ASSERTION Argument NULL is passed

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 56 of 114 Jun 9, 2017

• ssp_err_t SF_WIFI_GT202_ProvisioningSet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t const *const p_wifi_provisioning) Provisions the WiFi module. Implements sf_wifi_api_t::provisioningSet. This function performs the following tasks: Provisions the WiFi driver. Start WiFi interface in AP or STATION mode as provisioned. Return values:

SSP_SUCCESS Successfully provisioned the driver.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_NOT_OPEN Device is not opened

SSP_ERR_WIFI_FAILED Failed to set provisioning configuration.

SSP_ERR_INVALID_SIZE Invalid length of security key

SSP_ERR_INVALID_ARGUMENT Invalid encryption type for given security

SSP_ERR_IN_USE Module in use

SSP_ERR_INTERNAL Key setting failed

WiFi Security type if gt202_sec_cipher_mapping provisioning set success if is_opened

• ssp_err_t SF_WIFI_GT202_Scan (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_scan_t *const p_scan, uint8_t *const p_cnt) Scans for available APs. Implements sf_wifi_api_t::scan Scan for available AP's SSID and return the list to caller. Return values:

SSP_SUCCESS Successfully scan the network for available APs

SSP_ERR_NOT_OPEN Driver not opened

SSP_ERR_WIFI_FAILED Failed to scan

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

• ssp_err_t SF_WIFI_GT202_StatisticsGet (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_stats_t *const p_wifi_device_stats) Get the interface statistics. Implements sf_wifi_api_t::statisticsGet Collect the statistics information of WiFi interface Return values:

SSP_SUCCESS Successfully get the Statistics information.

SSP_ERR_UNSUPPORTED Functionality is not supported.

SSP_ERR_NOT_OPEN Device not opened

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed reading WiFi statistics

Statistics are not available in case of On chip Stack

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 57 of 114 Jun 9, 2017

• ssp_err_t SF_WIFI_GT202_Transmit (sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_buf, uint32_t length) Transmit data packets. Implements sf_wifi_api_t::transmit Adds packets in transmit Queue. Return values:

SSP_SUCCESS Successfully added the packet in transmit queue

SSP_ERR_NOT_OPEN WiFi driver is not opened

SSP_ERR_OUT_OF_MEMORY Memory allocation failed

SSP_ERR_WIFI_TRANSMIT_FAILED Transmission failed

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to transmit

• ssp_err_t SF_WIFI_GT202_VersionGet (ssp_version_t *const p_version) Set driver version based on compile time macros. Implements sf_wifi_api_t::versionGet. Return values:

SSP_SUCCESS Successful close.

SSP_ERR_ASSERTION The parameter p_version is NULL.

Detailed Description

RTOS-integrated WiFi Framework example. Implementation of Atheros WiFi Driver. It implements the following interfaces:

SF_WIFI Framework API on GT202.

• SF WIFI Framework Interface

11.2 WiFi On Chip Stack on GT202

RTOS-integrated WiFi On Chip Stack Framework example. Implementation of Atheros WiFi Driver. It implements the following interfaces:

11.2.1 Macros

• #define SF_WIFI_GT202_ONCHIP_STACK_CODE_MAJOR (1U) • #define SF_WIFI_GT202_ONCHIP_STACK_CODE_MINOR (0U)

Macro Definition Documentation

• #define SF_WIFI_GT202_ONCHIP_STACK_CODE_MAJOR (1U) WiFi Interface. Major Version of code that implements the API defined in this file

• #define SF_WIFI_GT202_ONCHIP_STACK_CODE_MINOR (0U) Minor Version of code that implements the API defined in this file

11.2.2 Functions

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_Open (sf_wifi_onchip_stack_ctrl_t *p_ctrl, sf_wifi_onchip_stack_cfg_t const *const p_cfg)

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 58 of 114 Jun 9, 2017

Open the WiFi Device driver to use the Onchip stack support. • ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_Close (sf_wifi_onchip_stack_ctrl_t *const p_ctrl)

Close the WiFi Device driver. • ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_IPAddressConfigure (sf_wifi_onchip_stack_ctrl_t

*const p_ctrl, sf_wifi_onchip_stack_ip_cfg_t *const p_cfg) Configures IP address of the interface.

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_DhcpServerStart (sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_ip_addr_t const *const p_start_ip, sf_wifi_ip_addr_t const *const p_end_ip) Starts DHCP server on the interface.

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_DhcpServerStop (sf_wifi_onchip_stack_ctrl_t *const p_ctrl) Stops DHCP server on the interface.

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_VersionGet (ssp_version_t *const p_version) Set driver version based on compile time macros. Implements sf_wifi_onchip_stack_api_t::versionGet.

Function Documentation

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_Close (sf_wifi_onchip_stack_ctrl_t *const p_ctrl) Close the WiFi Device driver. Implements sf_wifi_onchip_stack_api_t::close. Calls the low level WiFi device driver's Close API to close the WiFi Driver. Return values:

SSP_SUCCESS Suspend the driver functionality.

SSP_ERR_NOT_OPEN Device is not opened.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to close

SSP_ERR_INTERNAL Invalid argument

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_DhcpServerStart (sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_ip_addr_t const *const p_start_ip, sf_wifi_ip_addr_t const *const p_end_ip) Starts DHCP server on the interface. Implements sf_wifi_onchip_stack_api_t::dhcpServerStart. Starts DHCP server on the interface using on-chip networking stack. Cannot be used when using NSAL. Return values:

SSP_SUCCESS Successfully started DHCP server.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_UNSUPPORTED Functionality is not supported.

SSP_ERR_NOT_OPEN Device not opened.

SSP_ERR_INTERNAL Error occurred

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 59 of 114 Jun 9, 2017

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_DhcpServerStop (sf_wifi_onchip_stack_ctrl_t *const p_ctrl) Stops DHCP server on the interface. Implements sf_wifi_onchip_stack_api_t::dhcpServerStop. Stops DHCP server on the interface using on-chip networking stack. Cannot be used when using NSAL. Return values:

SSP_SUCCESS Successfully stopped DHCP server.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_NOT_OPEN Device not opened.

SSP_ERR_UNSUPPORTED Functionality is not supported.

SSP_ERR_INTERNAL Error occurred

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_IPAddressConfigure (sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_onchip_stack_ip_cfg_t *const p_cfg) Configures IP address of the interface. Implements sf_wifi_onchip_stack_api_t::ipAddressConfigure. Configures the IP address of the interface using on CHIP networking stack support. Cannot be used when using NSAL. Return values:

SSP_SUCCESS Successfully configured IP address.

Returns: SSP_ERR_INTERNAL Failed to Open WiFi Driver

Return values: SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_NOT_OPEN WiFi Driver in not open

SSP_ERR_UNSUPPORTED Functionality Unsupported

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_Open (sf_wifi_onchip_stack_ctrl_t * p_ctrl, sf_wifi_onchip_stack_cfg_t const *const p_cfg) Open the WiFi Device driver to use the Onchip stack support. Implements sf_wifi_onchip_stack_api_t::open Calls the low level WiFi device driver's Open API to Initialize the WiFi Device Driver, for using onchip stack. Return values:

SSP_SUCCESS Module initialization successful

SSP_ERR_ALREADY_OPEN WiFi module is already opened

SSP_ERR_WIFI_CONFIG_FAILED WiFi module Configuration failed

SSP_ERR_WIFI_INIT_FAILED WiFi module initialization failed

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to initialize

SSP_ERR_INTERNAL Invalid Argument

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 60 of 114 Jun 9, 2017

• ssp_err_t SF_WIFI_GT202_ONCHIP_STACK_VersionGet (ssp_version_t *const p_version) Set driver version based on compile time macros. Implements sf_wifi_onchip_stack_api_t::versionGet. Return values:

SSP_SUCCESS Successful.

SSP_ERR_ASSERTION Argument NULL is passed

Detailed Description

RTOS-integrated WiFi On Chip Stack Framework example. Implementation of Atheros WiFi Driver. It implements the following interfaces: SF_WIFI_ONCHIP_STACK Framework API on GT202.

• SF WIFI On-Chip Stack Interface

11.3 BSD Socket on GT202

Implementation of GT202 Socket layer over GT202 On-Chip stack.

11.3.1 Macros

• #define SF_WIFI_GT202_SOCKET_CODE_MAJOR (1U) • #define SF_WIFI_GT202_SOCKET_CODE_MINOR (0U) • #define AF_LOCAL (1)

Local Socket Family. • #define AF_INET (2)

IPV4 Socket Family. • #define AF_INET6 (10)

IPV6 Socket Family.

Macro Definition Documentation

• #define SF_WIFI_GT202_SOCKET_CODE_MAJOR (1U) WiFi Interface. Major Version of code that implements the API defined in this file

• #define SF_WIFI_GT202_SOCKET_CODE_MINOR (0U) Minor Version of code that implements the API defined in this file

11.3.2 Typedefs

• typedef enum e_wifi_socket_type sf_wifi_socket_type_t

Typedef Documentation

• typedef enum e_wifi_socket_type sf_wifi_socket_type_t Type of Socket

11.3.3 Enumerations • enum e_wifi_socket_type { SOCK_STREAM = 1, SOCK_DGRAM, SOCK_RAW }

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 61 of 114 Jun 9, 2017

Enumeration Type Documentation

• enum e_wifi_socket_type Type of Socket Enumerator:

SOCK_STREAM TCP Socket.

SOCK_DGRAM UDP Socket.

SOCK_RAW RAW Socket.

11.3.4 Functions • ssp_err_t SF_WIFI_GT202_SOCKET_Open (sf_socket_ctrl_t *p_ctrl, sf_socket_cfg_t const

*const p_cfg) Open the WiFi Device driver to use the Socket Layer on WiFi Driver On-Chip stack.

• ssp_err_t SF_WIFI_GT202_SOCKET_Close (sf_socket_ctrl_t *const p_ctrl) Close the WiFi Device driver.

• int socket (int domain, int type, int protocol) This creates socket for communication.

• int close (int socket_fd) This closes socket.

• int bind (int socket_fd, const struct sockaddr *p_local_sock_addr, socklen_t addrlen) This binds socket to IP address.

• int listen (int sockfd, int backlog) This listens for connection on socket.

• int connect (int sockfd, const struct sockaddr *p_serv_addr, socklen_t addrlen) This connects with remote socket(stream socket).

• int accept (int sockfd, struct sockaddr *p_cliaddr, socklen_t *p_addrlen) This accepts connection from remote socket.

• ssize_t send (int sockfd, const void *p_buf, size_t length, int flags) This sends data over STREAM socket.

• ssize_t recv (int sockfd, void *p_buf, size_t length, int flags) This receives data over STREAM socket.

• ssize_t sendto (int sockfd, const void *p_buf, size_t length, int flags, const struct sockaddr *p_dest_addr, socklen_t addrlen) This sends data over DGRAM socket.

• ssize_t recvfrom (int sockfd, void *p_buf, size_t length, int flags, struct sockaddr *p_src_addr, socklen_t *p_addrlen) This receives data over DGRAM socket.

• int setsockopt (int sockfd, int level, int optname, const void *p_optval, socklen_t optlen) This sets socket specific options.

• int getsockopt (int sockfd, int level, int optname, void *p_optval, socklen_t *p_optlen) This gets socket specific options.

• int select (int nfds, fd_set *p_readfds, fd_set *p_writefds, fd_set *p_exceptfds, struct timeval *p_timeout)

• This waits for any activity on socket.ssp_err_t SF_WIFI_GT202_SOCKET_VersionGet (ssp_version_t *const p_version) This function gets the version information of the underlying driver.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 62 of 114 Jun 9, 2017

Function Documentation

• ssp_err_t SF_WIFI_GT202_SOCKET_Close (sf_socket_ctrl_t *const p_ctrl) Close the WiFi Device driver. Implements sf_socket_api_t::close Call the low level WiFi device driver's Close API to close the WiFi Driver. Return values:

SSP_SUCCESS Suspend the driver functionality.

SSP_ERR_NOT_OPEN Device is not opened.

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to close

SSP_ERR_INTERNAL Internal Error occurred • ssp_err_t SF_WIFI_GT202_SOCKET_Open (sf_socket_ctrl_t * p_ctrl, sf_socket_cfg_t const

*const p_cfg) Open the WiFi Device driver to use the Socket Layer on WiFi Driver On-Chip stack. Implements sf_socket_api_t::open Call the low level WiFi device driver's Open API to Initialize the WiFi Device Driver, for using Socket Layer on On-Chip stack. Return values:

SSP_SUCCESS Module initialization successful

SSP_ERR_ALREADY_OPEN WiFi module is already opened

SSP_ERR_WIFI_CONFIG_FAILED WiFi module Configuration failed

SSP_ERR_WIFI_INIT_FAILED WiFi module initialization failed

SSP_ERR_ASSERTION Argument NULL is passed

SSP_ERR_IN_USE Module in use

SSP_ERR_WIFI_FAILED Failed to initialize

SSP_ERR_INTERNAL Internal Error occurred

Initialize global variables • ssp_err_t SF_WIFI_GT202_SOCKET_VersionGet (ssp_version_t *const p_version)

This function gets the version information of the underlying driver. Implements sf_socket_api_t::versionGet Return values:

SSP_SUCCESS Success

SSP_ERR_ASSERTION Argument NULL is passed

11.3.5 Variables • const sf_socket_api_t g_sf_socket_wifi_on_sf_socket_wifi_gt202

Socket API interface.

Detailed Description

Implementation of GT202 Socket layer over GT202 On-Chip stack.

11.4 SF WIFI NSAL on NetX

NetX NSAL interface implementation header file.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 63 of 114 Jun 9, 2017

11.4.1 Functions

• void nsal_netx_driver (NX_IP_DRIVER *driver, sf_wifi_instance_t const *p_wifi_instance, sf_wifi_nsal_cfg_t *p_wifi_nsal_cfg)

Function Documentation

• void nsal_netx_driver (NX_IP_DRIVER * driver, sf_wifi_instance_t const * p_wifi_instance, sf_wifi_nsal_cfg_t * p_wifi_nsal_cfg) Check if the link is up

Detailed Description

NetX NSAL interface implementation header file.

Summary

This SSP Interface provides access to the ThreadX-aware SF WIFI NSAL NX Framework.

11.5 Data Structure Documentation for WiFi Framework

• in_addr Struct Reference #include <sf_socket_api.h>

Data Fields

• unsigned long s_addr Load with inet_aton()

Detailed Description

Socket Internet Address structure

• sockaddr Struct Reference #include <sf_socket_api.h>

Data Fields

• unsigned short sin_port Port number.

• short sin_family Address family.

• struct in_addr sin_addr IP Address.

• char sin_zero [8] Zero this if you want to.

Detailed Description

Socket Internet Address structure with port and family

• sockaddr_in Struct Reference #include <sf_socket_api.h>

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 64 of 114 Jun 9, 2017

Data Fields

• uint16_t sin_port Address port (16 bits)

• uint16_t sin_family Internet Protocol (AF_INET)

• struct in_addr sin_addr Internet address (32 bits)

• int8_t sin_zero [8] Not used structure member.

Detailed Description

Socket address, Internet style.

• st_gt202_fw_version Struct Reference #include <sf_wifi_gt202_private.h>

Data Fields

• uint32_t host_ver Host version.

• uint32_t target_ver Target version.

• uint32_t wlan_ver WLAN version.

• uint32_t abi_ver ABI version.

Detailed Description

Firmware info structure

• st_sf_onchip_stack_wifi_api Struct Reference #include <sf_wifi_onchip_stack_api.h>

Data Fields

• ssp_err_t(* open )(sf_wifi_onchip_stack_ctrl_t *p_ctrl, sf_wifi_onchip_stack_cfg_t const *const p_cfg)

• ssp_err_t(* close )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl) • ssp_err_t(* ipAddressCfg )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl,

sf_wifi_onchip_stack_ip_cfg_t *const p_cfg) • ssp_err_t(* dhcpServerStart )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_ip_addr_t const

*const p_start_ip, sf_wifi_ip_addr_t const *const p_end_ip) • ssp_err_t(* dhcpServerStop )(sf_wifi_onchip_stack_ctrl_t *const p_ctrl) • ssp_err_t(* versionGet )(ssp_version_t *const p_version)

Detailed Description

Framework API structure. Implementations will use the following API.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 65 of 114 Jun 9, 2017

Field Documentation

• ssp_err_t(* st_sf_onchip_stack_wifi_api::close) (sf_wifi_onchip_stack_ctrl_t *const p_ctrl) Pointer to function which un-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt.

Parameters:

in,out p_ctrl Pointer to the control block

• ssp_err_t(* st_sf_onchip_stack_wifi_api::dhcpServerStart) (sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_ip_addr_t const *const p_start_ip, sf_wifi_ip_addr_t const *const p_end_ip) Starts DHCP server on the interface. Parameters:

in p_ctrl Pointer to the control block

in p_start_ip Pointer to start IP address

in p_end_ip Pointer to end IP address

• ssp_err_t(* st_sf_onchip_stack_wifi_api::dhcpServerStop) (sf_wifi_onchip_stack_ctrl_t *const p_ctrl) Stop DHCP server on the interface. Parameters:

in p_ctrl Pointer to the control block

• ssp_err_t(* st_sf_onchip_stack_wifi_api::ipAddressCfg) (sf_wifi_onchip_stack_ctrl_t *const p_ctrl, sf_wifi_onchip_stack_ip_cfg_t *const p_cfg) Configures IP address of the interface. Parameters:

in p_ctrl Pointer to the control block

in,out p_cfg Pointer to IP configuration structure.

• ssp_err_t(* st_sf_onchip_stack_wifi_api::open) (sf_wifi_onchip_stack_ctrl_t *p_ctrl, sf_wifi_onchip_stack_cfg_t const *const p_cfg) Pointer to function which initializes the network interface for data transfers Initial driver configuration, enable the driver link, enable interrupts and make device ready for data transfer. Parameters:

in,out p_ctrl Pointer to user-provided storage for the control block.

in p_cfg Pointer to configuration structure.

• ssp_err_t(* st_sf_onchip_stack_wifi_api::versionGet) (ssp_version_t *const p_version) Gets version and stores it in provided pointer p_version. Parameters:

out p_version pointer to memory location to return version number

• st_sf_socket_api Struct Reference #include <sf_socket_api.h>

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 66 of 114 Jun 9, 2017

Data Fields

• ssp_err_t(* open )(sf_socket_ctrl_t *p_ctrl, sf_socket_cfg_t const *const p_cfg) Pointer to function which initializes the network interface for data transfers Initial driver configuration, enable the driver link, enable interrupts and make device ready for data transfer.

• ssp_err_t(* close )(sf_socket_ctrl_t *const p_ctrl) Pointer to function which un-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt.

• ssp_err_t(* versionGet )(ssp_version_t *const p_version) Gets version and stores it in provided pointer p_version.

Detailed Description

Socket Interface API

Field Documentation

• ssp_err_t(* st_sf_socket_api::close) (sf_socket_ctrl_t *const p_ctrl) Pointer to function which un-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt. Parameters:

in,out p_ctrl Pointer to the control block

• ssp_err_t(* st_sf_socket_api::open) (sf_socket_ctrl_t *p_ctrl, sf_socket_cfg_t const *const p_cfg) Pointer to function which initializes the network interface for data transfers Initial driver configuration, enable the driver link, enable interrupts and make device ready for data transfer. Parameters:

in,out p_ctrl Pointer to user-provided storage for the control block.

in p_cfg Pointer to configuration structure.

• ssp_err_t(* st_sf_socket_api::versionGet) (ssp_version_t *const p_version) Gets version and stores it in provided pointer p_version. Parameters:

out p_version pointer to memory location to return version number

• st_sf_socket_cfg Struct Reference #include <sf_socket_api.h>

Data Fields

• sf_wifi_onchip_stack_instance_t * p_lower_lvl_onchip_wifi Pointer to SF on-chip stack instance.

• void * p_extend Extended configuration.

Detailed Description

Socket Interface configuration structure

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 67 of 114 Jun 9, 2017

• st_sf_socket_ctrl Struct Reference #include <sf_socket_api.h>

Data Fields

• sf_wifi_onchip_stack_instance_t * p_lower_lvl_onchip_wifi low level wifi interface

Detailed Description

Socket Interface control structure

• st_sf_socket_instance Struct Reference #include <sf_socket_api.h>

Data Fields

• sf_socket_ctrl_t * p_ctrl Pointer to the control structure for this instance.

• sf_socket_cfg_t const * p_cfg Pointer to the configuration structure for this instance.

• sf_socket_api_t const * p_api Pointer to the API structure for this instance.

Detailed Description

This structure encompasses everything that is needed to use an instance of this interface.

• st_sf_wifi_api Struct Reference #include <sf_wifi_api.h>

Data Fields

• ssp_err_t(* open )(sf_wifi_ctrl_t *p_ctrl, sf_wifi_cfg_t const *const p_cfg) Initializes the network interface for data transfers.

• ssp_err_t(* close )(sf_wifi_ctrl_t *const p_ctrl) De-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt.

• ssp_err_t(* multicastListAdd )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Add the given MAC address to the multicast filter list.

• ssp_err_t(* multicastListDelete )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) • ssp_err_t(* statisticsGet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_stats_t *const p_wifi_device_stats)

Get the interface statistics. • ssp_err_t(* transmit )(sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_buf, uint32_t length)

Transmit data packet. • ssp_err_t(* provisioningSet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t const *const

p_wifi_provisioning) Set WiFi module provisioning which will configure the module in AP or Client mode.

• ssp_err_t(* provisioningGet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t *const p_wifi_provisioning)

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 68 of 114 Jun 9, 2017

Get the provisioning information of WiFi module. • ssp_err_t(* infoGet )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_info_t *const p_wifi_info)

Get WiFi module information. • ssp_err_t(* scan )(sf_wifi_ctrl_t *const p_ctrl, sf_wifi_scan_t *const p_scan, uint8_t *const p_cnt)

Scan for WiFi SSIDs. • ssp_err_t(* ACLAdd )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac)

Adds a MAC address to the Access Control List. Valid in AP mode only. • ssp_err_t(* ACLDelete )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac)

Deletes a MAC address from Access Control List. Valid in AP mode only. • ssp_err_t(* macAddressGet )(sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_mac)

Get WiFi module MAC address. • ssp_err_t(* macAddressSet )(sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac)

Set WiFi module MAC address. • ssp_err_t(* versionGet )(ssp_version_t *const p_version)

Gets version and stores it in provided pointer p_version.

Detailed Description

Framework API structure. Implementations will use the following API.

Field Documentation

• ssp_err_t(* st_sf_wifi_api::ACLAdd) (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Adds a MAC address to the Access Control List. Valid in AP mode only. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_mac Pointer to MAC address

• ssp_err_t(* st_sf_wifi_api::ACLDelete) (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Deletes a MAC address from Access Control List. Valid in AP mode only. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_mac Pointer to MAC address

• ssp_err_t(* st_sf_wifi_api::close) (sf_wifi_ctrl_t *const p_ctrl) De-initialize the network interface and may put it in low power mode or power it off. Close the driver, disable the driver link, disable interrupt. Parameters:

in,out p_ctrl Pointer to the control block for the WiFi module.

• ssp_err_t(* st_sf_wifi_api::infoGet) (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_info_t *const p_wifi_info)

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 69 of 114 Jun 9, 2017

Get WiFi module information. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

out p_wifi_info Pointer to WiFi module information structure

• ssp_err_t(* st_sf_wifi_api::macAddressGet) (sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_mac) Get WiFi module MAC address. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

out p_mac Pointer to MAC address

• ssp_err_t(* st_sf_wifi_api::macAddressSet) (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac) Set WiFi module MAC address. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_mac Pointer to MAC address

• ssp_err_t(* st_sf_wifi_api::multicastListAdd) (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Add the given MAC address to the multicast filter list. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_mac_addr Pointer to the Mac address.

• ssp_err_t(* st_sf_wifi_api::multicastListDelete) (sf_wifi_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) Delete the given MAC address from the multicast filter list. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_mac_addr Pointer to the Mac address.

• ssp_err_t(* st_sf_wifi_api::open) (sf_wifi_ctrl_t *p_ctrl, sf_wifi_cfg_t const *const p_cfg) Initializes the network interface for data transfers. Initial driver configuration, enable the driver link, enable interrupts and make device ready for data transfer. Parameters:

in,out p_ctrl Pointer to user-provided storage for the control block.

in p_cfg Pointer to WiFi configuration structure.

• ssp_err_t(* st_sf_wifi_api::provisioningGet) (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t *const p_wifi_provisioning)

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 70 of 114 Jun 9, 2017

Get the provisioning information of WiFi module. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

out p_wifi_provisioning Pointer to WiFi provisioning structure

• ssp_err_t(* st_sf_wifi_api::provisioningSet) (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_provisioning_t const *const p_wifi_provisioning) Set WiFi module provisioning which will configure the module in AP or Client mode. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_wifi_provisioning Pointer to WiFi provisioning structure

• ssp_err_t(* st_sf_wifi_api::scan) (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_scan_t *const p_scan, uint8_t *const p_cnt) Scan for WiFi SSIDs. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

out p_scan Pointer to structure which will hold scan result. It is the responsibility of the caller to ensure that adequate space is available to hold scan results.

in,out p_cnt Pointer to variable, specifying maximum number of SSID's to scan and will be updated to number of actual SSIDs scanned by device

• ssp_err_t(* st_sf_wifi_api::statisticsGet) (sf_wifi_ctrl_t *const p_ctrl, sf_wifi_stats_t *const p_wifi_device_stats) Get the interface statistics. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

out p_wifi_device_stats Pointer to the WiFi module data statistics.

• ssp_err_t(* st_sf_wifi_api::transmit) (sf_wifi_ctrl_t *const p_ctrl, uint8_t *const p_buf, uint32_t length) Transmit data packet. Parameters:

in p_ctrl Pointer to the control block for the WiFi module.

in p_buf Pointer to transmit buffer

in length Transmit buffer length

• ssp_err_t(* st_sf_wifi_api::versionGet) (ssp_version_t *const p_version) Gets version and stores it in provided pointer p_version. Parameters:

out p_version pointer to memory location to return version number

• st_sf_wifi_callback_arg Struct Reference #include <sf_wifi_api.h>

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 71 of 114 Jun 9, 2017

Data Fields

• sf_wifi_event_t event Event code.

• uint8_t * p_data Packet data.

• uint32_t length Packet Data length.

• void const * p_context Context provided to user during callback.

Detailed Description

WiFi framework callback parameter definition

• st_sf_wifi_cfg Struct Reference #include <sf_wifi_api.h>

Data Fields

• uint8_t mac_addr [6] MAC address of WiFi Device.

• sf_wifi_interface_hw_mode_t hw_mode Modulation type: 11a/b/g/n.

• uint8_t tx_power Sets transmit power in dBm.

• sf_wifi_rts_t rts RTS/CTS handshake flag.

• uint16_t fragmentation Fragmentation threshold.

• uint8_t dtim Delivery traffic indication message interval.

• sf_wifi_high_throughput_t high_throughput High-throughput mode. Only valid for 802.11n.

• sf_wifi_preamble_t preamble Preamble type.

• sf_wifi_wmm_t wmm WiFi Multimedia Mode flag. If enabled, also requires.

• uint8_t max_stations Maximum permitted stations. Valid in AP mode only.

• sf_wifi_ssid_broadcast_t ssid_broadcast SSID broadcast flag. Valid in AP mode only.

• sf_wifi_access_control_t access_control Mode of access control MAC list.

• uint32_t beacon Beacon interval. Valid in AP mode only.

• uint32_t station_inactivity_timeout Station inactivity timeout value. Valid in AP mode only.

• sf_wifi_wds_t wds

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 72 of 114 Jun 9, 2017

WDS flag. Valid in AP mode only. • void * p_buffer_pool_rx

Pointer to Network stack Rx buffer pool. • sf_wifi_mandatory_high_throughput_t req_high_throughput

Only allow HT mode. Valid in AP mode only. • void(* p_callback )(sf_wifi_callback_args_t *p_args)

Pointer to callback function. • void const * p_context

User defined context passed into callback function. • void const * p_extend

Instance specific configuration.

Detailed Description

Define the WiFi configuration parameters

• st_sf_wifi_ctrl Struct Reference #include <sf_wifi_api.h>

Data Fields

• void * p_driver_handle

Detailed Description

WiFi Framework control structure

Field Documentation

• void* st_sf_wifi_ctrl::p_driver_handle Storage for information needed for each WiFi device driver in the system.

• st_sf_wifi_gt202_driver Struct Reference #include <sf_wifi_gt202_private.h>

Data Fields

• ENET_CONTEXT_STRUCT enet Atheros Driver control structure.

• ENET_PARAM_STRUCT enet_param Atheros Driver param structure.

• uint8_t init_done Driver Initialization status.

• uint8_t is_opened Driver Open status.

• sf_wifi_cfg_t wifi_cfg Backup of WiFi Configuration.

• sf_wifi_stats_t wifi_framework_statistics WiFi Framework Statistics information.

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 73 of 114 Jun 9, 2017

Detailed Description

Gt202 driver info structure

• st_sf_wifi_info Struct Reference #include <sf_wifi_api.h>

Data Fields

• uint8_t * p_chipset Pointer to sting showing WiFi chipset/driver information.

• uint16_t rssi Received signal strength indication.

• uint16_t noise_level Signal to noise ratio.

• uint16_t link_quality Signal strength / quality.

Detailed Description

Configuration about underlying device driver.

• st_sf_wifi_instance Struct Reference #include <sf_wifi_api.h>

Data Fields

• sf_wifi_ctrl_t * p_ctrl Pointer to the control structure for this instance.

• sf_wifi_cfg_t const * p_cfg Pointer to the configuration structure for this instance.

• sf_wifi_api_t const * p_api Pointer to the API structure for this instance.

Detailed Description

This structure encompasses everything that is needed to use an instance of this interface.

• st_sf_wifi_ip_addr Struct Reference #include <sf_wifi_api.h>

Data Fields

• sf_wifi_ip_addr_version_t version IP Address Version : v4 or v6. union {

uint32_t v4

uint32_t v6 [4]

} addr

IP address.

Detailed Description

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 74 of 114 Jun 9, 2017

IP address information

• st_sf_wifi_nsal_callback_args Struct Reference #include <sf_wifi_nsal_api.h>

Data Fields

• NX_IP * p_ip Pointer to NetX IP interface.

• sf_wifi_nsal_cfg_t * p_wifi_nsal_cfg pointer to NSAL configuration

Detailed Description

Define the NSAL callback arguments

• st_sf_wifi_nsal_cfg Struct Reference #include <sf_wifi_nsal_api.h>

Data Fields

• sf_wifi_nsal_zero_copy_t tx_zero_copy Transmit path zero copy support.

• sf_wifi_nsal_zero_copy_t rx_zero_copy Receive path zero copy support.

• uint8_t * p_tx_packet_buffer Pointer to Tx buffer used to consolidate data from chained NetX packets.

Detailed Description

Define the NSAL configuration parameters

• st_sf_wifi_on_gt202_cfg Struct Reference #include <sf_wifi_gt202.h>

Data Fields

• spi_instance_t const * p_lower_lvl_spi SPI Interface used for WiFi communications.

• external_irq_instance_t const * p_lower_lvl_icu ICU Interface used for WiFi communications.

• ioport_port_pin_t pin_reset Port pin used for resetting chipset.

• ioport_port_pin_t pin_slave_select Port pin used for SPI slave select.

• uint32_t driver_task_priority Driver task thread priority, should be high priority.

Detailed Description

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 75 of 114 Jun 9, 2017

Extension structure for this Implementation. Each implementation can have its own extension structure. For example one implementation may use RSPI for communicating with the WiFi chip while another may use SDIO.

• st_sf_wifi_onchip_stack_cfg Struct Reference #include <sf_wifi_onchip_stack_api.h>

Data Fields

• sf_wifi_instance_t const * p_lower_lvl_wifi Pointer to SF WiFi instance.

• void * p_extend Extended configuration.

Detailed Description

Define the WiFi configuration parameters

• st_sf_wifi_onchip_stack_ctrl Struct Reference #include <sf_wifi_onchip_stack_api.h>

Data Fields

• sf_wifi_instance_t * p_lower_lvl_wifi Pointer to SF WiFi instance.

Detailed Description

WiFi Framework control structure

Field Documentation

• sf_wifi_instance_t* st_sf_wifi_onchip_stack_ctrl::p_lower_lvl_wifi Pointer to SF WiFi instance. Storage for information needed for each WiFi device driver in the system.

• st_sf_wifi_onchip_stack_instance Struct Reference #include <sf_wifi_onchip_stack_api.h>

Data Fields

• sf_wifi_onchip_stack_ctrl_t * p_ctrl Pointer to the control structure for this instance.

• sf_wifi_onchip_stack_cfg_t const * p_cfg Pointer to the configuration structure for this instance.

• sf_wifi_onchip_stack_api_t const * p_api Pointer to the API structure for this instance.

Detailed Description

SF WiFi On Chip Stack Instance structure

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 76 of 114 Jun 9, 2017

• st_sf_wifi_onchip_stack_ip_cfg Struct Reference #include <sf_wifi_onchip_stack_api.h>

Data Fields

• sf_wifi_onchip_stack_ip_addr_mode_t ip_addr_mode Addressing mode.

• sf_wifi_ip_addr_t ip_addr Interface IP address.

• sf_wifi_ip_addr_t netmask Interface netmask.

• sf_wifi_ip_addr_t gateway Interface Gateway.

Detailed Description

Define IP Interface configuration information

• st_sf_wifi_provisioning Struct Reference #include <sf_wifi_api.h>

Data Fields

• sf_wifi_interface_mode_t mode Select AP or Client mode.

• uint8_t channel RF Channel number.

• uint8_t ssid [SF_WIFI_SSID_LENGTH] SSID.

• sf_wifi_security_type_t security Security type.

• sf_wifi_encryption_type_t encryption Encryption type.

• uint8_t key [SF_WIFI_SECURITY_KEY_LENGTH] Pre-shared key. void(* p_callback )(sf_wifi_callback_args_t *p_args) Pointer to AP Link UP/Down callback function.

Detailed Description

WiFi Provisioning parameters

• st_sf_wifi_scan Struct Reference #include <sf_wifi_api.h>

Data Fields

• sf_wifi_interface_hw_mode_t hw_mode Hardware mode 802.11a/b/g/n.

• uint8_t rssi

WiFi Framework 11. API References: WiFi Framework On GT202

R11UM0050EU0108 Rev.1.08 Page 77 of 114 Jun 9, 2017

Signal Strength. • uint8_t ssid [SF_WIFI_SSID_LENGTH]

SSID name. • uint8_t bssid [SF_WIFI_MAC_ADDR_LENGTH]

Basic Service Set Identification (i.e. MAC address of Access Point) • uint8_t channel

Radio channel that the AP beacon was received on. • sf_wifi_security_type_t security

Security type. • sf_wifi_encryption_type_t encryption

Encryption type. • sf_wifi_bss_type_t bss_type Network type.

Detailed Description

Define the structure to store the SSID scan information

• st_sf_wifi_stats Struct Reference #include <sf_wifi_api.h>

Data Fields

• uint32_t rx_pkts Packets received successfully.

• uint32_t tx_pkts Packets transmitted successfully.

• uint32_t tx_err Transmit errors.

Detailed Description

Define the statistic and error counters for this IP instance.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 78 of 114 Jun 9, 2017

12 Appendix

12.1 Atheros GT202

This section describes example of connections and configuration details used by Atheros GT202 WiFi module. One can connect Atheros GT202 module to same PMOD connector and do same configurations as specified below to make it work. Or one can refer to these and do required changes while interfacing with other PMOD connector.

12.1.1 Atheros GT202 on DK-S7G2

Figure 12.1 shows the orientation of the GT202 PMOD adapter board when connected to PMODA on the DK-S7G2 v3.1 board.

Figure 12.1 Orientation of the GT202 PMOD adapter when connected to PMODA on the DK-S7G2 v3.1 board

Make sure that 3.3 V is selected for PMODA.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 79 of 114 Jun 9, 2017

12.1.1.1 Thread pane setup and pin configurations

1. Create a new thread from the thread pane as shown in figure beloww

Figure 12.2 Thread pane view for SF_WiFi_GT202

2. Make sure to remove the DTC driver for transmission and reception.

Set the r_sci_spi properties as shown in figure below

Figure 12.3 Thread properties of GT202 for DK–S7G2 board – for r_sci_spi driver

3. Set Channel to 9 in properties for g_external_irq0.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 80 of 114 Jun 9, 2017

Figure 12.4 Thread properties of GT202 for DK–S7G2 board – for external IRQ

4. In g_sf_wifi0 properties, set the reset and slave select pins.

Figure 12.5 Thread properties of GT202 for DK–S7G2 board – for reset and slave select pins

5. Go to Pins tab.

6. Set up the SPI and IRQ pins:

A. For DK-S7G2 on PMODA, r_sci_spi is used. B. From the Pins tab, go to Pin Selection section. C. Go to Peripherals > Connectivity:SCI > SCI8. D. Set SCI8 up in "Simple SPI" operation mode. Set up PB_3, PB_4, and PB_5 for SCI use. See

figure below

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 81 of 114 Jun 9, 2017

Figure 12.6 Setup for SCI pins configuration for DK–S7G2 board

E. Set up the SCI chip-select as GPIO output PB_2 for DK-S7G2:

• From the Pins tab, go to Pin Selection section • Go to Ports > PB > PB02.

Figure 12.7 Setup for SCI chip-select pin configuration

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 82 of 114 Jun 9, 2017

F. Set up the IRQ pin P0_4 for DK-S7G2. This is IRQ-09.

• From the Pins tab, go to Pin Selection section • Go to Ports > P0 > P004.

Figure 12.8 Setup for IRQ pin configuration

G. Set up the WiFi Chipset Reset pin as GPIO output P9_11on DK-S7G2.

• From the Pins tab, go to Pin Selection section • Go to Ports > P9 > P911.

Figure 12.9 Setup for WiFi Chipset Reset pin configuration

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 83 of 114 Jun 9, 2017

12.1.2 Atheros GT202 on DK-S3A7

1. Connect the LongSys GT-202 module to the PMODC connector on the DK-S3A7 platform. The GT-202 module cannot be plugged into the PMODC connector. You need to connect it using jump wires. See table below for details. Also see step 2 below.

Table 12.1 GT202 connections to PMODC on DK-S3A7

GT-202 (J9) header pin # PMODC header pin # Description

1 1 Chip Select (Port 1 Pin 5 = SSLA1_A)

2 2 SPI MOSI (Port 1 Pin 1 = MOSIA_A)

3 3 SPI MISO (Port 1 pin 0 = MISOA_A)

4 4 SPI CLK (Port 1 Pin 2 = RSPCKA_A)VDD(3.3v)

5 5 GND

6 6 VCC

7 NC Not Connected

8 8 CHIP RESET (Port 6 Pin 2)

9 9 Not Connected

10 10 Not Connected

11 11 GND

12 12 VCC

Make sure that 3.3 volt is selected for PMODC. 2. Using a jump cable, connect pin 7 of GT202 header to pin P0_1 of port pin header J7 on DK-S3A7

board. For DK-S3A7 v2.0 board, interrupt pins are not available on any of the PMOD connectors. All PMOD based WiFi modules have to be wired using jump cables. The PMOD connector based modules cannot be directly plugged in to the board.

Figure 12.10 shows the GT202 module connected to the PMODC connector on DK-S3A7.

Figure 12.10 GT202 module connected to PMODC connector on DK-S3A7 v2.0 board

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 84 of 114 Jun 9, 2017

12.1.2.1 Thread pane setup and pin configurations

1. Create a new thread from the thread pane as shown in figure below

Figure 12.11 Thread pane view for SF_WiFi_GT202

2. Make sure to remove the DTC driver for transmission and reception. 3. Set up the SPI and IRQ pins:

A. For DK-S3A7 on PMODC, RSPI0 is used. B. From the Pins tab, go to Pin Selection section. C. Go to Peripherals > Connectivity:SPI > SPI0. D. Set SPI0 up in "custom" operation mode. Set up P100, P101, and P102 for SPI use.

Figure 12.12 Setup for SPI pins configuration for DK–S3A7 board

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 85 of 114 Jun 9, 2017

E. Set up the SPI chip-select as GPIO output P1_5 for DK-S3A7: From the Pins tab, go to Pin Selection section Go to Ports > P1 > P105.

Figure 12.13 Setup for SPI chip-select pin configuration for DK–S3A7 board

F. Set up the IRQ pin P0_1 for DK-S3A7, which is IRQ-7: • From the Pins tab, go to Pin Selection section • Go to Ports > P0 > P001.

Figure 12.14 Setup for IRQ pin configuration for DK–S3A7 board

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 86 of 114 Jun 9, 2017

G. Set up WiFi Chipset Reset pin as GPIO output P6_2 on DK-S3A7: • From the Pins tab, go to Pin Selection section • Go to Ports > P6 > P602.

Figure 12.15 Setup for WiFi Chipset Reset pin configuration for DK–S3A7 board

4. Set the r_spi0 properties as shown in figure below

Figure 12.16 Thread properties of GT202 for DK–S3A7 board – for r_spi0

5. Set Channel to 7 in properties for g_external_irq0.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 87 of 114 Jun 9, 2017

Figure 12.17 Thread properties of GT202 for DK – S3A7 board – For external IRQ

6. In g_sf_wifi0 properties set the reset and slave select pins.

Figure 12.18 Thread properties of GT202 for DK – S3A7 board – For the Reset and slave select pins

12.1.3 On chip stack configuration

Only the GT202 module includes support for on-chip networking stack. So, it also supports path 2 approach as explained in section 2.2

12.1.3.1 Thread pane setup

1. Create a new thread from the thread pane as shown in figure below

Figure 12.19 Thread pane view of on chip networking stack using SF_WiFi_GT202

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 88 of 114 Jun 9, 2017

2. To create Thread pane view as specified in Figure 12.19 first add BSD socket component as shown in Figure 12.20

Figure 12.20 Add BSD Socket component using GT202 on-chip networking stack

3. Enable On-chip stack support for sf_wifi_gt202 as shown in figure below

Figure 12.21 Enable on-chip stack support for sd_wifi_gt202

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 89 of 114 Jun 9, 2017

4. Figure 12.22 is the thread pane view after enabling on-chip stack support

Figure 12.22 Thread pane view after enabling on-chip networking stack support on sf_wifi_gt202

5. To configure sf_wifi_gt202 on DK-S7G2 please refer to 6. To configure sf_wifi_gt202 and below components on DK-S7G2 please refer to points #2 to #7

under section 12.1.1.1 7. To configure sf_wifi_gt202 and below components on DK-S7G2 please refer to points #2 to #6

under section 12.1.2.1

12.2 BCM43362

This section describes an example of connections and configuration details used by the BCM43362 WiFi module. One can connect a BCM43362 module to the same PMOD connector and do the same configurations as specified below to make it work. Alternatively, one can refer to these and do the required changes while interfacing with another PMOD connector.

12.2.1 BCM43362 on DK-S7G2

Figure 12.23 shows the orientation of the BCM43362 PMOD adapter board when connected to PMODA on the DK-S7G2 v3.1 board.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 90 of 114 Jun 9, 2017

Figure 12.23 Orientation of the BCM43362 PMOD adapter when connected to PMODA on the DK-S7G2 v3.1 board

Make sure that 3.3 V is selected for PMODA.

12.2.1.1 Thread Pane setup and pin configurations

1. Create a new thread from the thread pane as shown in Figure 12.24.

Figure 12.24 Thread pane view for SF_WiFi_BCM43362

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 91 of 114 Jun 9, 2017

2. Make sure to remove the DTC driver for transmission and reception. 3. BCM43362 requires NetX Source component to be added. 4. Make sure to add the NetX packet pool for RX operation and internal operation. Also make sure to

delete NetX Common components from below these packet pools. See Error! Reference source not found. and Error! Reference source not found..

Figure 12.25 NetX Packet pool for Rx operation on BCM43362

Figure 12.26 NetX Packet pool for internal operation on BCM43362

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 92 of 114 Jun 9, 2017

5. Change the Physical Header value in the Properties window for NetX Source to 44. This increases the physical header size in the NetX packet. This is required by the underlying BCM driver. See Figure 12.27.

Figure 12.27 Thread properties for DK–S7G2 board – specifying physical header size for NetX source

6. Set the r_sci_spi properties as in Figure 12.28.

Figure 12.28 Thread properties of BCM43362 for DK–S7G2 board – for r_sci_spi driver

7. Set Channel to 9 in properties for g_external_irq0.

Figure 12.29 Thread properties of BCM43362 for DK–S7G2 board – for external IRQ

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 93 of 114 Jun 9, 2017

8. In g_sf_wifi0 properties, set the reset and slave select pins as shown in figure below.

Figure 12.30 Thread properties of BCM43362 for DK–S7G2 board – for reset and slave select pins

9. Go to the Pins tab. 10. Set up the SPI and IRQ pins:

A. For DK-S7G2 on PMODA, r_sci_spi is used. B. From the Pins tab, go to Pin Selection section. C. Go to Peripherals > Connectivity:SCI > SCI8. D. Set SCI8 up in "Simple SPI" operation mode. Set up PB_3, PB_4, and PB_5 for SCI use.

Figure 12.31 Setup for SCI pins configuration for DK–S7G2 board

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 94 of 114 Jun 9, 2017

E. Set up the SCI chip-select as GPIO output PB_2 for DK-S7G2.

• From the Pins tab, go to Pin Selection section • Go to Ports > PB > PB02.

Figure 12.32 Setup for SCI chip-select pin configuration

F. Set up the IRQ pin P0_4 for DK-S7G2. This is IRQ-09.

• From the Pins tab, go to the Pin Selection section • Go to Ports > P0 > P004.

Figure 12.33 Setup for IRQ pin configuration

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 95 of 114 Jun 9, 2017

G. Set up WiFi Chipset Reset pin as GPIO output P9_11 on DK-S7G2.

• From the Pins tab, go to Pin Selection section • Go to Ports > P9 > P911.

Figure 12.34 Setup for WiFi Chipset Reset pin configuration

Broadcom binary images are placed in the ROM by default. For details on how to move them to the QSPI, see section Error! Reference source not found. of this document

12.2.2 BCM43362 on DK-S3A7

1. Connect BCM43362 module to PMODC connector on DK-S3A7. BCM43362 module cannot be plugged into PMODC connector. You need to connect it using jump wires. See Table below and step 2 below.

Table 12.2 BCM43362 connections to PMODC on DK-S3A7

BCM43362 header pin # PMODC header Pin # Description

1 1 Chip Select (Port 1 Pin 5 = SSLA1_A)

2 2 SPI MOSI (Port 1 Pin 1 = MOSIA_A)

3 3 SPI MISO (Port 1 pin 0 = MISOA_A)

4 4 SPI CLK (Port 1 Pin 2 = RSPCKA_A)VDD(3.3v)

5 5 GND

6 6 VCC

7 NC Not Connected to PMOD

8 8 CHIP RESET (Port 6 Pin 2)

9 9 Not Connected

10 10 Not Connected

11 11 GND

12 12 VCC

Make sure that 3.3V is selected for PMODC. 2. Using a jump cable, connect pin 7 of BCM43362 header to pin P0_1 of port pin header J7 on the

DK-S3A7 board. For the DK-S3A7 v2.0 board, interrupt pins are not available on any of the PMOD

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 96 of 114 Jun 9, 2017

connectors. All PMOD based WiFi modules have to be wired using jump cables. The PMOD connector based modules cannot be directly plugged to the board.

3. Figure 12.35 shows the BM43362 module connected to PMODC connector on DK-S3A7.

Figure 12.35 BCM43362 module connected to PMODC connector on DK-S3A7 v2.0 board

12.2.2.1 Thread pane setup and pin configurations

1. Create a new thread from the thread pane as seen in Figure 12.36.

Figure 12.36 Thread pane view for SF_WiFi_BCM43362

2. Make sure to remove the DTC driver for transmission and reception. 3. BCM43362 requires the NetX source component to be added.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 97 of 114 Jun 9, 2017

4. Make sure to add the NetX packet pool for RX operation and internal operation. Also make sure to delete NetX Common components from below these packet pools. See Error! Reference source not found. and Error! Reference source not found.

Figure 12.37 NetX packet pool for Rx operation on BCM43362

Figure 12.38 NetX Packet pool for internal operation on BCM43362

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 98 of 114 Jun 9, 2017

5. Change the Physical Header value in the Properties window for NetX Sources to 44. This increases the physical header size in NetX packet. This is required by the underlying BCM driver.

Figure 12.39 Thread properties for DK–S3A7 board – specifying physical header size for NetX source

6. Set up the SPI and IRQ pins as follows:

A. For DK-S3A7 on PMODC, RSPI0 is used. B. From the Pins tab, go to Pin Selection section. C. Go to Peripherals > Connectivity:SPI > SPI0. D. Set SPI0 up in "custom" operation mode. Set up P100, P101, and P102 for SPI use.

Figure 12.40 Setup for SPI pins configuration for DK–S3A7 board

E. Set up the SPI chip-select as GPIO output P1_5 for DK-S3A7:

From the Pins tab, go to the Pin Selection section Go to Ports > P1 > P105.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 99 of 114 Jun 9, 2017

Figure 12.41 Setup for SPI chip-select pin configuration for DK – S3A7 board

F. Set up the IRQ pin P0_1 for DK-S3A7. This is IRQ-7.

From the Pins tab, go to Pin Selection section Go to Ports > P0 > P001.

Figure 12.42 Setup for IRQ pin configuration for DK–S3A7 board

G. Set up WiFi Chipset Reset pin as GPIO output P6_2 on DK-S3A7.

From the Pins tab, go to Pin Selection section Go to Ports > P6 > P602.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 100 of 114 Jun 9, 2017

Figure 12.43 Setup for WiFi Chipset Reset pin configuration for DK – S3A7 Board

7. Set the r_spi0 properties as seen in Figure 12.44.

Figure 12.44 Thread properties of BCM43362 for DK – S3A7 board – for r_spi0

8. Set Channel to 7 in the properties for g_external_irq0.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 101 of 114 Jun 9, 2017

Figure 12.45 Thread properties of BCM43362 for DK – S3A7 board – for r_spi0

9. In g_sf_wifi0 properties, set the reset and slave select pins.

Figure 12.46 Thread properties of BCM43362 for DK – S3A7 board, for the reset and slave select pins

Broadcom binary images are placed in the ROM by default. For details on how to move them to QSPI, refer to section Error! Reference source not found. in this document.

12.3 BCM4343W

This section describes an example of connections and configuration details used by the BCM4343W WiFi module. One can connect BCM4343W module SDIO connector and do the same configurations as specified below to make it work.

12.3.1 BCM4343W on DK-S7G2

Figure 12.47 shows the orientation of the BCM4343W adapter board when connected through SDIO on the DK-S7G2 v3.1 board.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 102 of 114 Jun 9, 2017

Figure 12.47 Orientation of the BCM4343W adapter when connected through SDIO on the DK-S7G2 v3.1 board

12.3.1.1 BCM4343W adapter modification

1. Murata Type 1DX is a BCM434W based an SDIO module. 2. Use a Murata Type 1DX EVB board placed on a Murata i.MX Board. 3. Solder a jump wire from the WL REG ON test-point (as marked in Error! Reference source not

found.) and connect it to pin #12 (VCC) of PMODA. (For a test project, connect this to pin #8 of PMODA, that is, P0911, as it is internally driven by the application source code.)

Figure 12.48 Murata i.MX Interconnect Board Top View

Figure 12.49 Murata i.MX Interconnect Board Bottom View

4. Connect the SDIO connector to SDIO slot on the DK-S7G2 board.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 103 of 114 Jun 9, 2017

12.3.1.2 Thread Pane setup and pin configurations

1. Create a new thread from the thread pane as shown in Figure below

Figure 12.50 Thread pane view for SF_WiFi_BCM4343W

2. Make sure to add the transfer driver as DMAC for SDIO. 3. BCM4343W requires NetX Source component to be added. 4. Make sure to add the NetX packet pool for RX operation and internal operation. Also make sure to

delete NetX Common components from below these packet pools. See Error! Reference source not found. and Error! Reference source not found..

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 104 of 114 Jun 9, 2017

Figure 12.51 NetX Packet pool for Rx operation on BCM4343W

Figure 12.52 NetX Packet pool for internal operation on BCM4343W

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 105 of 114 Jun 9, 2017

5. Change the Physical Header value in the Properties window for NetX Source to 44. This increases the physical header size in NetX packet. This is required by the underlying BCM driver.

Figure 12.53 Thread properties for DK–S7G2 board – specifying physical header size for NetX source

6. Set the properties for r_sdmmc driver as in Figure below

Figure 12.54 Thread properties for DK–S7G2 board – for r_sdmmc driver

7. Set the properties for r_dmac as in Figure 12.55.

Figure 12.55 Thread properties for DK–S7G2 board – for r_dmac

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 106 of 114 Jun 9, 2017

8. Perform the appropriate pin settings: A. From the Pins tab, go to Pin Selection section. B. Go to Peripherals > Storage:SDHI > SDHI0.

Figure 12.56 Setup for SDHI0 pin configuration

Broadcom binary images are placed in the ROM by default. For details on how to move them to QSPI, see section Error! Reference source not found. in this document.

12.3.2 BCM4343W on DK-S3A7

Figure 12.57 shows the orientation of the BCM4343W adapter board when connected through SDIO on the DK-S3A7 board.

Figure 12.57 Orientation of BCM4343W adapter connected through SDIO on the DK-S3A7 board

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 107 of 114 Jun 9, 2017

12.3.2.1 BCM4343W adapter modifications

1. Murata Type 1DX is a BCM434W based on an SDIO module. 2. Use a Murata Type 1DX EVB board placed on a Murata i.MX Board. 3. Solder a jump wire from WL REG ON test-point (as marked in Error! Reference source not

found.) and connect it to pin #12 (VCC) of PMODA. (For a test project, connect this to pin #7 of PMODA, that is, P0700 as it is internally driven by application source code.)

Figure 12.58 Murata i.MX Interconnect Board Top View

Figure 12.59 Murata i.MX Interconnect Board Bottom View

4. Connect the SDIO connector to the SDIO slot on the DK-S3A7 board.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 108 of 114 Jun 9, 2017

12.3.2.2 Thread pane setup and pin configurations

1. Create a new thread from the thread pane as in Figure 12.60.

Figure 12.60 Thread pane view for SF_WiFi_BCM4343W

2. Make sure to add the transfer driver as DMAC for SDIO. 3. BCM4343W requires NetX Source component to be added. 4. Make sure to add the NetX packet pool for RX operation and internal operation. Also make sure to

delete NetX Common components from below these packet pools. See Error! Reference source not found. and Error! Reference source not found.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 109 of 114 Jun 9, 2017

Figure 12.61 NetX packet pool for Rx operation on BCM4343W

Figure 12.62 NetX packet pool for internal operation on BCM4343W

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 110 of 114 Jun 9, 2017

5. Change the Physical Header value in the Properties window for NetX Source to 44. This increases the physical header size in NetX packet. This is required by the underlying BCM driver.

Figure 12.63 Thread properties for DK – S3A7 board – specifying physical header size for NetX source

6. Set the properties for r_sdmmc driver as in Figure 12.64.

Figure 12.64 Thread Properties for DK – S3A7 board – For r_sdmmc driver

7. Set the properties for r_dmac in Figure 12.65.

Figure 12.65 Thread properties for DK – S3A7 board – for r_dmac

8. Perform the appropriate pin settings.

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 111 of 114 Jun 9, 2017

Figure 12.66 Setup for SDHI0 pin configuration

Broadcom binary images are placed in the ROM by default. For details on how to move them to QSPI, refer to section Error! Reference source not found. in this document.

12.4 Broadcom Chipset WiFi Firmware Image Location Settings

By default, the Broadcom chipset WiFi firmware images are placed in the ROM section. To move them to QSPI, use the following steps:

1. Open the linker descriptor file of the board located in script directory (S7G2.ld for S7G2 board and S3A7.ld for S3A7 board).

2. For BCM43362 WiFi module. A. Replace *(.rodata*) with *(EXCLUDE_FILE(*43362A2_bin.o) .rodata*) B. Replace

.qspi_flash :

{

__qspi_flash_start__ = .;

KEEP(*(.qspi_flash*))

__qspi_flash_end__ = .;

} > QSPI_FLASH

With .qspi_flash :

{

__qspi_flash_start__ = .;

KEEP(*(.qspi_flash*))

KEEP(*(.rodata.wifi_firmware_image))

KEEP(*(.rodata.wifi_firmware_image_data))

__qspi_flash_end__ = .;

} > QSPI_FLASH

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 112 of 114 Jun 9, 2017

3. For BCM4343W WiFi module A. Replace *(.rodata*) with *(EXCLUDE_FILE(*4343w1_bin.o) .rodata*) B. Replace

.qspi_flash :

{

__qspi_flash_start__ = .;

KEEP(*(.qspi_flash*))

__qspi_flash_end__ = .;

} > QSPI_FLASH

With

.qspi_flash :

{

__qspi_flash_start__ = .;

KEEP(*(.qspi_flash*))

KEEP(*(.rodata.wifi_firmware_image))

KEEP(*(.rodata.wifi_firmware_image_data))

__qspi_flash_end__ = .;

} > QSPI_FLASH

12.5 NetX Usage Note

The user/application thread should wait for the module to be initialized before it can call Synergy WiFi framework functions. NSAL layer initializes the module by calling the Synergy WiFi Framework open() function when it receives the appropriate event from NetX. The wait for module/NetX system can be exercised by the user thread by calling nx_system_initialize(). The snippet of this call is described as follows:

1. Call nx_system_initialize() and create() function for your NetX objects.

Examples: A. nx_packet_pool_create() B. nx_ip_create() C. nx_dhcp_create() D. nx_telnet_server_create().

2. Call the nx_ip_interface_status_check() function to wait for the NetX IP link to be enabled. This ensures that NetX has called the open(), which initializes the driver of the Synergy WiFi framework. An example call is shown below:

ULONG actual_status;

/** Wait for init to finish. */

err = nx_ip_interface_status_check(&ip, 0, NX_IP_LINK_ENABLED, &actual_status, NX_WAIT_FOREVER);

if (NX_SUCCESS != err)

{

//Handle error

}

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 113 of 114 Jun 9, 2017

3. Once the nx_ip_interface_status_check() function successfully returns, the WiFi provisioning can be set using the provisioningSet() function.

4. NetX calls can now be continued.

Examples: A. nx_dhcp_start() B. nx_telnet_server_start().

12.6 Security and Encryption details

Wifi framework supports multiple security and encryption types

Table 12.3 WiFi framework Security types

Security type Description SF_WIFI_SECURITY_TYPE_OPEN Open. No encryption used

SF_WIFI_SECURITY_TYPE_WEP 128-bit WEP OPEN ASCII

SF_WIFI_SECURITY_TYPE_WPA Wi-Fi Protected Access

SF_WIFI_SECURITY_TYPE_WPA2 Wi-Fi Protected Access v2

Table 12.4 WiFi framework Encryption types

Encryption type Description SF_WIFI_ENCRYPTION_TYPE_AUTO Automatic selection of encryption protocol

SF_WIFI_ENCRYPTION_TYPE_TKIP Temporal Key Integrity Protocol. Used by WPA

SF_WIFI_ENCRYPTION_TYPE_CCMP CTR mode with CBC-MAC Protocol. Used by WPA2

SF_WIFI_ENCRYPTION_TYPE_WEP WEP mode. Used by WEP

SF_WIFI_ENCRYPTION_TYPE_NONE No Encryption. Used by Open Security type

In station mode, if encryption type is set to AUTO the framework shall use TKIP as default for WPA and CCMP as default for WPA2. If connection to the AP fails then the framework shall switch to use CCMP for WPA and TKIP for WPA2 and reattempt to connect to the AP. Encryption type AUTO for WEP security will use WEP encryption and for OPEN security will use NONE.

WEP keys can be entered in either ASCII or HEX format. WEP keys can be configured to use either 40 or 104 bit keys. WEP key has 24-bit initialization vector in addition to the secret key. Due to this depending on the vendor 64-bit WEP keys can be referred as 40 bits and 128-bit WEP keys can be referred as 104 bits.

Min/Max key length of each WEP key are as described in the table below

Table 12.5 WiFi framework WEP key length

WEP key format Key type in bits Key length of one key (bytes) ASCII 40 (64) 5

104 (128) 13

HEX 40 (64) 10

104 (128) 26

WiFi Framework 12. Appendix

R11UM0050EU0108 Rev.1.08 Page 114 of 114 Jun 9, 2017

WiFi framework accepts 1 to 4 WEP keys of a specific format and type. In the Provisioning structure the user must fill the Security type as SF_WIFI_SECURITY_TYPE_WEP and at least one and maximum four WEP keys in the key buffer.

Sample 1: Below is the sample provisioning structure setting for WEP with one WEP key “1wert” in 40bit key in ASCII format.

Sample 2: Below is the sample provisioning structure setting for WEP with four WEP keys “1wert”, “2wert”, “3wert” and “4wert” each in 40bit key in ASCII format Socket APIs

12.7 WiFi Framework Error Codes

Table 12.6 lists the WiFi Framework specific error codes. These error codes are currently not part of ssp_err_t. These error codes can be found in sf_wifi_api.h.

Table 12.6 WiFi framework Encryption types

Error Codes Value SSP_ERR_WIFI_CONFIG_FAILED 4000

SSP_ERR_WIFI_INIT_FAILED 4001

SSP_ERR_WIFI_TRANSMIT_FAILED 4002

SSP_ERR_WIFI_INVALID_MODE 4003

SSP_ERR_WIFI_FAILED 4004

Revision History

Rev. Date

Description

Page Summary

Rev.1.01 Feb 8, 2017 - Update

Rev.1.02 Mar 3, 2017 - Restructuring, moved Module specific information to Appendix

Rev.1.03 Mar 7, 2017 - Updated Thread pane configuration diagrams

Rev.1.04 Mar 8, 2017 - Updated sample code snippets section, Atheros GT202 configuration for on-chip stack support

Rev.1.05 Apr 27, 2017 - Added security and encryption details to Appendix. Updated API names AccessControlListAdd to ACLAdd and AccessControlListDelete to ACLDelete

Rev.1.06 May 05, 2017 - Added API Reference sections. Added Error code details in Appendix. Added Link status details in Sample code snippet

Rev.1.08 Jun 8, 2017 - Formatting and editing

All trademarks and registered trademarks are the property of their respective owners.

WiFi Framework User’s Manual Publication Date: Rev.1.08 Jun 9, 2017 Published by: Renesas Electronics Corporation

http://www.renesas.comRefer to "http://www.renesas.com/" for the latest and detailed information.

Renesas Electronics America Inc.2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A.Tel: +1-408-588-6000, Fax: +1-408-588-6130Renesas Electronics Canada Limited9251 Yonge Street, Suite 8309 Richmond Hill, Ontario Canada L4C 9T3Tel: +1-905-237-2004Renesas Electronics Europe LimitedDukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.KTel: +44-1628-585-100, Fax: +44-1628-585-900Renesas Electronics Europe GmbHArcadiastrasse 10, 40472 Düsseldorf, GermanyTel: +49-211-6503-0, Fax: +49-211-6503-1327Renesas Electronics (China) Co., Ltd.Room 1709, Quantum Plaza, No.27 ZhiChunLu Haidian District, Beijing 100191, P.R.ChinaTel: +86-10-8235-1155, Fax: +86-10-8235-7679Renesas Electronics (Shanghai) Co., Ltd.Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, P. R. China 200333Tel: +86-21-2226-0888, Fax: +86-21-2226-0999Renesas Electronics Hong Kong LimitedUnit 1601-1611, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong KongTel: +852-2265-6688, Fax: +852 2886-9022Renesas Electronics Taiwan Co., Ltd.13F, No. 363, Fu Shing North Road, Taipei 10543, TaiwanTel: +886-2-8175-9600, Fax: +886 2-8175-9670Renesas Electronics Singapore Pte. Ltd.80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949Tel: +65-6213-0200, Fax: +65-6213-0300Renesas Electronics Malaysia Sdn.Bhd.Unit 1207, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, MalaysiaTel: +60-3-7955-9390, Fax: +60-3-7955-9510Renesas Electronics India Pvt. Ltd.No.777C, 100 Feet Road, HAL II Stage, Indiranagar, Bangalore, IndiaTel: +91-80-67208700, Fax: +91-80-67208777Renesas Electronics Korea Co., Ltd.12F., 234 Teheran-ro, Gangnam-Gu, Seoul, 135-080, KoreaTel: +82-2-558-3737, Fax: +82-2-558-5141

SALES OFFICES

© 2017 Renesas Electronics Corporation. All rights reserved.Colophon 4.1

Renesas Synergy™ Platform WiFi Framework

R11UM0050EU0108