Atmel 42566 ATWINC3400 WiFi BLE Network Controller Software Design Guide UserGuide
Atmel 42566 ATWINC3400 WiFi BLE Network Controller Software Design Guide UserGuide
User Guide
Introduction
Features
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
Table of Contents
2 ATWINC3400
2 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
7.4.1 Power Saving Modes .............................................................................................................. 19
7.4.1.1 M2M_PS_MANUAL ................................................................................................ 20
7.4.1.2 M2M_PS_AUTOMATIC .......................................................................................... 21
7.4.1.3 M2M_PS_H_AUTOMATIC ..................................................................................... 21
7.4.1.4 M2M_PS_DEEP_AUTOMATIC .............................................................................. 21
7.4.2 Configuring Listen Interval and DTIM Monitoring.................................................................... 21
12 Provisioning........................................................................................................ 51
12.1 BLE Provisioning ............................................................................................................................. 51
12.1.1 BLE Provisioning Code Example ............................................................................................ 53
12.2 HTTP Provisioning........................................................................................................................... 54
12.2.1 Introduction ............................................................................................................................. 54
12.2.2 Limitations .............................................................................................................................. 54
12.2.3 Basic Approach ...................................................................................................................... 54
12.2.4 Provisioning Control Flow ....................................................................................................... 55
12.2.5 HTTP Redirect Feature........................................................................................................... 56
12.2.6 HTTP Provisioning Code Example ......................................................................................... 56
12.3 Wi-Fi Protected Setup (WPS) .......................................................................................................... 57
12.3.1 WPS Configuration Methods .................................................................................................. 57
12.3.2 WPS Limitations ..................................................................................................................... 57
12.3.3 WPS Control Flow .................................................................................................................. 58
12.3.4 WPS Code Example ............................................................................................................... 59
4 ATWINC3400
4 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
15.3 Project Creation ............................................................................................................................... 69
15.4 Wi-Fi Software API Files .................................................................................................................. 69
15.5 Reading Temperature Sensor and Controlling LED Status ............................................................. 71
15.6 Step By Step Development ............................................................................................................. 72
Appendix C. How to Download the Certificate into the ATWINC ................. 141
C.1 Overview ....................................................................................................................................... 141
C.2 Certificate Downloading ................................................................................................................. 141
C.3 Adding New Certificate .................................................................................................................. 141
6 ATWINC3400
6 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1 Icon Key Identifiers
2 Glossary
BSD Berkeley Software Distribution
BSP Board Support Package
HIF Host Interface Layer
IoT Internet of Things
OTA Over The Air
OTP One Time Programmable
TLS Transport Layer Security
WINC Wi-Fi Network Controller
3 References
[R01] Atmel-42640-Getting-Started-Guide-for-ATWINC3400WiFi-using-SAMD21-Xplained-Pro_UserGuide.
[R02] Atmel-42639-Software-Programming-Guide-for-ATWINC3400-WiFi-using-SAMD21-Xplained-
Pro_UserGuide.
[R03] Atmel-42535-ATWINC3400-MR210-IEEE80211bgn-Link-Ctlr-with-Integrated-Low-Energy-
Bluetooth40_Datasheet
[R04] Atmel-42683-ATWINC3400-BLE-WiFi-Scan-and-Connect-Services-Guide_UserGuide
HOST MCU
IoT Application
ATWINC host driver software is a C library which provides the host MCU application with necessary APIs to
perform necessary WLAN, BLE, and socket operations. Figure 4-1 shows the architecture of the ATWINC host
driver software which runs on the host MCU. The components of the host driver are described in the following
sub-sections.
8 ATWINC3400
8 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4.3 Host Interface (HIF)
The Host Interface is responsible for handling the communication between the host driver and the WINC
firmware. This includes interrupt handling, DMA, and HIF command/response management. The host driver
communicates with the firmware in a form of commands and responses formatted by the HIF layer.
The interface is defined in the file: m2m_hif.h.
The detailed description of the HIF design is provided in Chapter 16: Host Interface Protocol.
WINC3400 SOC
BUS Interface
SPI FLASH
SPI Master/Slave I2C
APS3S-Cortus
Crypto Library
DNS SSL
Client/ SNTP Layer Security Protected
WINC RTOS
Resolver Manager
Server (TLS) Setup (WPS)
Memory Power
IEEE 802.11 MAC
Manager Management
Shared Radio
APS3-Cortus
Power Memory
Bluetooth V4.1 MAC
Management Manager
AT Bluetooth SmartConnect
Radio Wi-Fi cross Provisioning
Stack: SAP, SMT, ATT, GATT,
Coexistence comms App support
L2CAP
10 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
5.2 Non-volatile Storage
The SoC has an integrated 8Mb serial flash inside the WINC package (SIP). This stores both the WINC Wi-Fi
firmware image and the BLE firmware image. It also stores information used by WINC firmware in the run-time.
The detailed description of the serial flash is provided in Chapter 14: ATWINC Serial Flash Memory.
5.3 CPUs
The SoC contains two 32-bit CPUs:
An APS3S-Cortus 32-bit CPU running at 40MHz clock speed, which executes the embedded WINC Wi-
Fi firmware
An APS3-Cortus 32-bit CPU running at 26MHz clock speed, which executes the embedded WINC BLE
firmware
12 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
5.14 ATWINC IoT Library
The ATWINC IoT library provides a set of networking protocols in ATWINC firmware. It offloads the host MCU
from networking and transport layer protocols. The following sections describe the components of ATWINC IoT
library.
ATWINC TCP/IP STACK
The ATWINC TCP/IP is an IPv4.0 stack based on the µIP TCP/IP stack (pronounced micro-IP).
µIP is a low footprint TCP/IP stack which has the ability to run on a memory-constrained microcontroller
platform. It was originally developed by Adam Dunkels, licensed under a BSD style license, and further
developed by a wide group of developers. The ATWINC TCP/IP stack adds to the original µIP
implementation several enhancements to boost TCP and UDP throughput.
DHCP CLIENT/SERVER
A DHCP client is embedded in ATWINC firmware that can obtain an IP configuration automatically after
connecting to a Wi-Fi network.
ATWINC firmware provides an instance of a DHCP server that starts automatically when ATWINC AP
mode is enabled. When the host MCU application activates the AP mode, it is allowed to configure the
DHCP Server IP address pool range within the AP configuration parameters.
DNS RESOLVER
ATWINC firmware contains an instance of an embedded DNS resolver. This module can return an IP
address by resolving the host domain names supplied with the socket API call gethostbyname.
SNTP
The SNTP (Simple Network Time Protocol) module implements an SNTP client used to synchronize the
ATWINC internal clock to the UTC clock.
TRANSPORT LAYER SECURITY
For TLS implementation, see Chapter 10: Transport Layer Security (TLS) for details.
WI-FI PROTECTED SETUP
For WPS protocol implementation, see Section 12.3: Wi-Fi Protected Setup (WPS) for details.
CRYPTO LIBRARY
The Crypto Library contains a set of cryptographic algorithms used by common security protocols. This
library has an implementation of the following algorithms:
MD4 Hash algorithm (used only for MsChapv2.0 digest calculation)
MD5 Hash algorithm
SHA-1 Hash algorithm
SHA-256 Hash algorithm
DES Encryption (used only for MsChapv2.0 digest calculation)
MS-CHAPv2.0 (used as the EAP-TTLS inner authentication algorithm)
AES-128, AES-256 Encryption (used for securing WPS and TLS traffic)
BigInt module for large integer arithmetic (for Public Key Cryptographic computations)
RSA Public Key cryptography algorithms (includes RSA Signature and RSA Encryption algorithms)
Failure to complete any of the initialization steps will result in failure in ATWINC startup.
A Wi-Fi event handler is required for the correct operation of any ATWINC application.
1
Refer to ATWINC3400 datasheet [R02] for more information about ATWINC hardware reset sequence.
14 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
Host Interface Protocol. The HIF protocol defines how to serialize and de-serializes API requests and response
callbacks over the serial bus interface: I2C, UART, or SPI.
HOST MCU
Host MCU Application
WINC
WINC Firmware
WINC Hardware
ATWINC host driver API provides services to the host MCU applications that are mainly divided in two major
categories: Wi-Fi control services and Socket services. The Wi-Fi control services allow actions such as
channel scanning, network identification, connection, and disconnection. The Socket control services allow
application data transfer once a Wi-Fi connection has been established.
2 The callback is C function, which contains an application-defined logic. The callback is registered using the ATWINC host
driver registration API to handle the result of the requested service.
All the application-defined event callback functions registered with ATWINC driver run
in the context m2m_wifi_handle_events API.
The above HIF architecture allows the ATWINC host driver to be flexible to run in the following configurations:
Host MCU with no operating system configuration: In this configuration, the MCU main loop is
responsible to handle deferred work from interrupt handler.
Host MCU with operating system configuration: In this configuration, a dedicated task or thread is
required to call m2m_wifi_handle_events to handle deferred work from interrupt handler.
When host MCU is polling m2m_wifi_handle_events, the API checks for pending un-
handled interrupt from ATWINC. If no interrupt is pending, it returns immediately. If an
interrupt is pending, m2m_wifi_handle_events reads all the pending HIF messages
sequentially and dispatches the HIF message content to the respective registered
callback. If a callback is not registered to handle the type of message, the HIF mes-
sage content is discarded.
}
int main (void)
{
tstrWifiInitParam param;
nm_bsp_init();
m2m_memset((uint8*)¶m, 0, sizeof(param));
param.pfAppWifiCb = wifi_cb;
while(1){
/* Handle the app state machine plus the WINC event handler */
while(m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
}
}
}
16 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
7 ATWINC Configuration
ATWINC firmware has a set of configurable parameters that control its behavior. There is a set of APIs
provided to host MCU application to configure these parameters. The configuration APIs are categorized
according to their functionality into: device, network, and power saving parameters.
Any parameters left unset by the host MCU application shall use their default values assigned during the
initialization of the ATWINC firmware. A host MCU application needs to configure its parameters when coming
out of cold boot or when a specific configuration change is required.
If the HIF level of the current driver is not equal to the HIF level of the current ATWINC
firmware, the driver initialization will fail.
STA AP
IDLE
The supported API functions in this mode use the HIF command types: tenuM2mCon-
figCmd and tenuM2mStaCmd. See the full list of commands in the header file
m2m_types.h.
For more information about this mode, refer to Chapter 8: Wi-Fi Station Mode.
The supported API functions in this mode use the HIF command types:
tenuM2mApCmd and tenuM2mConfigCmd. See the full list of commands in the
header file m2m_types.h.
For more information about this mode, refer to Chapter 11: Wi-Fi AP Mode.
18 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
7.3 Network Parameters
For more details, refer to description of the following APIs in the WINC3400_IoT_SW_APIs.chm that was
supplied in the WINC3400_IoT_REL software package.
m2m_wifi_get_otp_mac_address
m2m_wifi_set_mac_address
m2m_wifi_get_mac_address
7.3.2 IP Address
ATWINC firmware uses the embedded DHCP client to obtain an IP configuration automatically after a
successful Wi-Fi connection. After the IP configuration is obtained, the host MCU application is notified by the
asynchronous event M2M_WIFI_RESP_IP_CONFIGURED.
Alternatively, the host MCU application can set a static IP configuration by calling the
m2m_wifi_set_static_ip API. Setting a static IP address will cancel any pending DHCP requests and
disable the DHCP client until the next Wi-Fi connection attempt to the same AP or any other AP.
7.4.1.1 M2M_PS_MANUAL
This is a fully host-driven power saving mode.
ATWINC sleeps when the host instructs it to do so using the m2m_wifi_request_sleep API. During
ATWINC sleep, the host MCU can decide to sleep also for extended durations.
ATWINC wakes up when the host MCU application requests services from ATWINC by calling any host
driver API function, e.g. Wi-Fi or socket operation
For an active Wi-Fi connection, the AP may decide to drop the connection if ATWINC is absent because it
sleeps for long time duration. If connection is dropped, ATWINC detects the disconnection on the next wake-up
cycle and notifies the host to reconnect to the AP again. In order to maintain an active Wi-Fi connection for
extended durations, the host MCU application should wake up the ATWINC periodically so that ATWINC can
send a keep-alive Wi-Fi frame to the AP. The host should choose the sleep period carefully to satisfy the
tradeoff between keeping the Wi-Fi connection uninterrupted and minimizing the system power consumption.
This mode is useful for applications which send notifications very rarely due to a certain trigger. It fits also
applications which send notifications periodically with a very long spacing between notifications. Careful power
planning is required when using this mode. If the host MCU decides to sleep for very long period, it may use
M2M_PS_MANUAL or may power off ATWINC3 completely. The advantage of this mode compared to powering off
ATWINC is that M2M_PS_MANUAL saves the time required for ATWINC firmware to boot since the firmware is
always loaded in ATWINC memory. The real pros and cons depend on the nature of the application. In some
applications, the sleep duration could be long enough to be a power-efficient decision to power off ATWINC
and power it on again and reconnect to the AP when host MCU wakes up. In other situations, a latency-
sensitive application may choose to use M2M_PS_MANUAL to avoid ATWINC firmware boot latency on the
expense of slightly increased power consumption.
During ATWINC sleep, ATWINC in M2M_PS_MANUAL mode saves more power than M2M_PS_DEEP_AUTOMATIC
mode since in the former mode ATWINC skips beacon monitoring while the latter it wakes up to receive
beacons. The comparison should also include the effect of host MCU sleep duration: If host MCU sleep period
is too long, the Wi-Fi connection may drop frequently and the power advantage of M2M_PS_MANUAL is lost due
to the power consumed in Wi-Fi reconnection. In contrast, M2M_PS_DEEP_AUTOMATIC can keep the Wi-Fi
connection for long durations at the expense of waking up ATWINC to monitor the AP beacon.
20 ATWINC3400
2 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
7.4.1.2 M2M_PS_AUTOMATIC
This mode is deprecated and kept for backward compatibility and development reasons. It should not be used
in new implementations.
7.4.1.3 M2M_PS_H_AUTOMATIC
This mode implements the Wi-Fi standard power saving method in which ATWINC will sleep and wake up
periodically to monitor AP beacons. In contrast to M2M_PS_MANUAL, this mode does not involve the host MCU
application.
In this mode, when ATWINC enters sleep state, it only turns off the IEEE 802.11 radio, MAC, and PHY. All
system clocks and the APS3S-Cortus CPU are on.
This mode is useful for a low-latency packet transmission because ATWINC clocks are on and ready to
transmit packets immediately, unlike the M2M_PS_DEEP_AUTOMATIC which may require time to wake up the
ATWINC to transmit a packet if ATWINC was sleep mode.
M2M_PS_H_AUTOMATIC mode is very similar to M2M_PS_DEEP_AUTOMATIC except that the former power
consumption is higher than the latter the since ATWINC system clock is on.
7.4.1.4 M2M_PS_DEEP_AUTOMATIC
Like M2M_PS_HS_AUTOMATIC, this mode implements the Wi-Fi standard power saving method. However, when
ATWINC enters sleep state, the system clock is turned off.
Before sleep, the ATWINC programs a hardware timer (running on an internal low-power oscillator) with a
sleep period determined by the ATWINC firmware power management module.
While sleeping, the ATWINC will wake up if one of the following events happens:
Expiry of the hardware sleep timer. ATWINC wakes up to receive the upcoming beacon from AP.
ATWINC wakes up4 when the host MCU application requests services from ATWINC by calling any host
driver API function, e.g. Wi-Fi or socket operation
4The wakeup sequence is handled internally in the ATWINC host driver in the hif_chip_wake API. Refer to the reference
Chapter 16 for more information.
22 ATWINC3400
2 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
Figure 8-1. Wi-Fi Scan Operation
m2m_wifi_request_scan(WiFi_Channel_ID)
wifi_cb(M2M_WIFI_RESP_SCAN_DONE,
tstrM2mScanDone* );
m2m_wifi_req_scan_result(0)
wifi_cb(M2M_WIFI_RESP_SCAN_RESULT,
tstrM2mWifiscanResult* );
m2m_wifi_req_scan_result(N - 1)
Using m2m_wifi_connect implies that the host MCU application has prior knowledge of
the connection parameters. For instance, connection parameters can be stored on non-
volatile storage attached to the host MCU.
m2m_wifi_connect(Sec_Type, SSID,SSID_Len,
Key,Key_Len ,Channel_ID(*));
wifi_cb(M2M_WIFI_REQ_CON_STATE_CHANGED,
tstrM2mWifiStateChanged* );
wifi_cb(M2M_WIFI_REQ_DHCP_CONF, uint8* );
A connection profile is cached in the serial flash if and only if the connection is success-
fully established with the target AP.
24 ATWINC3400
2 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
Figure 8-3. Wi-Fi Default Connection
m2m_wifi_default_connect();
wifi_cb(M2M_WIFI_REQ_CON_STATE_CHANGED,
tstrM2mWifiStateChanged* );
wifi_cb(M2M_WIFI_REQ_DHCP_CONF, uint8* );
nm_bsp_init();
m2m_memset((uint8*)¶m, 0, sizeof(param));
param.pfAppWifiCb = wifi_event_cb;
/* Connect to a WPA-Enterprise AP
*/
m2m_wifi_connect("DEMO_AP", sizeof("DEMO_AP"), M2M_WIFI_SEC_802_1X,
(uint8*)&gstrCred1x, M2M_WIFI_CH_ALL);
while(1)
{
/************************************************************************/
/* Handle the app state machine plus the WINC event handler */
/************************************************************************/
while(m2m_wifi_handle_events(NULL) != M2M_SUCCESS)
{
}
}
}
26 ATWINC3400
2 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
9 ATWINC Socket Programming
9.1 Overview
The ATWINC socket application programming interface (API) provides a method that allows host MCU
application to interact with intranet and remote internet hosts. The ATWINC sockets API is based on the BSD
(Berkeley) sockets. This chapter explains the ATWINC socket programming and how it differs from regular
BSD sockets.
This chapter assumes the reader to have a basic understanding of the BSD sockets,
TCP, UDP, and the Internet protocols. Follow the online references provided in link in
the name of each topic for more information.
Note that TCP port 53 and UDP port 53 represent two different sockets.
Remote socket address: Applicable only for TCP stream sockets. This is necessary since TCP is
connection oriented. Each connection is made to a specific IP address and port number requires a
separate socket. The remote socket address can be obtained in the socket event callback as discussed
later.
9.1.3 Limitations
The ATWINC sockets API support a maximum of seven TCP sockets and 4 for UDP sockets
The ATWINC sockets API support only IPv4. It does not support IPv6.
Figure 9-1 shows the ATWINC socket API connect to remote server host.
28 ATWINC3400
2 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
Figure 9-1. TCP Client API Call Sequence
9.2.3.5 bind
The bind function can be used for server operation for both UDP and TCP sockets. Its purpose is to associate
a socket with an address structure (port number and IP address).
The bind function call will result a SOCKET_MSG_BIND event sent to the socket callback handler with the bind
status. Calls to listen, send, sendto, recv, and recvfrom functions should not be issued until the bind
callback is received.
9.2.3.6 listen
The listen function is used for server operations with TCP stream sockets. After calling the listen API the
socket will accept a connection request from a remote host. The listen function causes a
SOCKET_MSG_LISTEN event notification to be sent to the host after the socket port is ready to indicate listen
operation success or failure.
When a remote peer establishes a connection, a SOCKET_MSG_ACCEPT event notification is sent to the
application.
9.2.3.7 accept
The accept function is deprecated and calling this API has no effect. It is kept only for backward compatibility.
The listen API will implicitly accepts accept connections from a TCP remote peer.
Although the accept function is deprecated, the SOCKET_MSG_ACCEPT event occurs whenever a remote host
connects to the ATWINC TCP server. The event message will contain the IP address and port number of the
connected remote host.
9.2.3.8 send
The send function is used by the application to send data to a remote host. The send function can be used to
send either UDP or TCP data depending on the type of socket. For a TCP socket a connection must be
established first. For a UDP socket, the target remote host must be specified as part of the address structure
during the bind function.
The send function will generate a SOCKET_MSG_SEND event callback after the data is transmitted to the remote
host. For TCP sockets, this event guarantees that the data has been delivered to the remote host TCP/IP stack
(the remote application must use the recv function to be able to read the data though). For UDP sockets it
means that the data has been transmitted but there are no guarantees that the data has arrived to the remote
host as per UDP protocol nature. The application is responsible to guarantee data delivery in the UDP sockets
case.
The SOCKET_MSG_SEND event callback will return the size of the data transmitted if the transmission in the
success case and zero or negative value in case of an error.
9.2.3.9 sendto
The sendto function is used by the application to send UDP data to a remote host. It can only be used with
UDP sockets. The IP address and port of the destination remote host is included as a parameter to the sendto
function.
The SOCKET_MSG_SENDTO event callback returns the size of the data transmitted in the success case and zero
or negative value in case of an error.
30 ATWINC3400
3 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
9.2.3.10 recv / recvfrom
The recv and recvfrom functions are used to read data from TCP and UDP sockets respectively. Their
operation is otherwise identical.
The host MCU application calls the recv or recvfrom function with a pre allocated buffer. When the
SOCKET_MSG_RECV or SOCKET_MSG_RECVFROM event callback arrives this buffer will contain the received data.
The received data size indicates the status:
Positive: Data received.
Zero: Socket connection is terminated.
Negative value: This indicates an error.
In the case of TCP sockets, it is recommended to call the recv function after each successful socket
connection (client or server). Otherwise, received data will be buffered in the ATWINC firmware wasting the
systems resources until the socket is explicitly closed using a close function call.
9.2.3.11 close
The close function is used to release the resources allocated to the socket and, for a TCP stream socket, also
terminate an open connection.
Each call to the socket function should be matched with a call to the close function. In addition, sockets that
have been accepted on a server socket port should also be closed using this function.
9.2.3.12 setsockopt
The setsockopt function may be used to set socket options to control the socket behavior.
The options supported are:
SO_SET_UDP_SEND_CALLBACK: Enables or disables the send /sendto event callbacks. The user might
want to disable the sendto event callback for UDP sockets to enhance the socket connection
throughput.
IP_ADD_MEMBERSHIP: Used to subscribe to IP Multicast addresses.
IP_DROP_MEMBERSHIP: Used to unsubscribe to IP Multicast addresses.
9.2.3.13 gethostbyname
The gethostbyname function is used to resolve a host name (e.g. URL) to a host IP address via the Domain
Name System (DNS). This is limited for IPv4 addresses only. Operation depends on having configured a DNS
server IP address and having access to the DNS hierarchy through the internet.
After gethostbyname has been called, a callback to the DNS resolver handler will be made. If the IP address
has been determined it will be returned. If it cannot be determined or if the DNS server is not accessible (30
second timeout) an IP address value of zero will be indicated.
A return IP value of zero indicates an error (e.g. the internet connection is down or DNS
is unavailable) and the host MCU application may try the function call gethostbyname
again later.
connect connect Asynchronous Client TCP Initialize a TCP connection request to a re-
mote server
listen listen Asynchronous Server TCP Allow a bound socket to listen to remote con-
nections for its local port
sendto sendto Asynchronous Both UDP Sends packet over UDP sockets
close close Synchronous Both Both Terminate TCP connection and release sys-
tem resources
gethostbyname gethostbyname Asynchronous Both Both Get IP address of certain host name
htons/ntohs _htons/_ntohs Synchronous Both Both Convert a 2-byte integer from the host repre-
sentation to the Network byte order represen-
tation (and vice versa)
htonl/ntohl _htonl/_ntohl Synchronous Both Both Convert a 4-byte integer from the host repre-
sentation to the Network byte order represen-
tation (and vice versa)
32 ATWINC3400
3 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
9.3 Socket Connection Flow
In the following sub-sections the TCP and UDP (client and server) operations are described in detail.
socketInit
registerSocketCallback
Socket
bind
socketInit
Bind event
callback
registerSocketCallback
listen
Client Operations
Socket
Listen event
callback
Accept event
connect Server Operations
callback
recv
send
Recv event
Send event callback
callback
Data Exchange
send
recv
recv
Recv event
close
callback
End Connection
close
HOST
APPLICATION WINC
DRIVER
socket(SOCK_STREAM)
clientSocketHdl
connect(clientSocketHdl)
SOCKET_CMD_CONNECT
TCP(SYN)
TCP(SYN,ACK)
SOCKET_CMD_CONNECT
SOCKET_MSG_CONNECT
send(clientSocketHdl, data)
SOCKET_CMD_SEND
recv(clientSocketHdl) TCP Packet
SOCKET_CMD_RECV
TCP Packet
SOCKET_CMD_RECV
SOCKET_MSG_RECV
close(clientSocketHdl)
SOCKET_CMD_CLOSE
TCP(FIN)
Notes: 1. The host application must register a socket notification callback function. The function must be of
type tpfAppSocketCb and must handle socket event notifications appropriately.
2. If the client knows the IP of the server, it may call connect directly as shown in Figure 9-4. If only
the server URL is known, then the application should resolve the server URL first calling the
gethostbyname API.
34 ATWINC3400
3 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
9.3.2 TCP Server Operation
HOST
APPLICATION WINC
DRIVER
socket(SOCK_STREAM)
listenSocketHdl
bind(listenSocketHdl,port)
SOCKET_CMD_BIND
SOCKET_CMD_BIND
SOCKET_MSG_BIND
listen(listenSocketHdl)
SOCKET_CMD_LISTEN
SOCKET_MSG_LISTEN SOCKET_CMD_LISTEN
TCP(SYN)
TCP(SYN,ACK)
SOCKET_CMD_ACCEPT
SOCKET_MSG_ACCEPT
close(acceptedSocketHdl)
SOCKET_CMD_CLOSE
close(listenSocketHdl) TCP(FIN)
SOCKET_CMD_CLOSE
Note: The host application must register a socket notification callback function. The function must be of type:
tpfAppSocketCb and must handle socket event notifications appropriately.
HOST
APPLICATION WINC
DRIVER
socket(SOCK_DGRAM)
clientSocketHdl
sendto(clientSocketHdl,data,addr)
SOCKET_CMD_SENDTO
recvfrom(clientSocketHdl) UDP Packet
SOCKET_CMD_RECVFROM
UDP Packet
SOCKET_CMD_RECVFROM
SOCKET_MSG_RECVFROM
close(clientSocketHdl)
SOCKET_CMD_CLOSE
Notes: 1. The first send message must be performed with the sendto API with the destination address
specified.
2. If further messages are to be sent to the same address, the send API can be used.
3. recv can be used instead of recvfrom.
36 ATWINC3400
3 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
9.3.4 UDP Server Operation
Figure 9-7 shows the message flow for transferring data after establishing a UDP server.
HOST
APPLICATION WINC
DRIVER
socket(SOCK_DGRAM)
serverSocketHdl
bind(serverSocketHdl,port)
SOCKET_CMD_BIND
SOCKET_CMD_BIND
SOCKET_MSG_BIND
recvfrom(serverSocketHdl)
SOCKET_CMD_RECVFROM
UDP Packet
SOCKET_CMD_RECVFROM
SOCKET_MSG_RECVFROM
sendto(serverSocketHdl, data)
SOCKET_CMD_SENDTO
UDP Packet
close(serverSocketHdl)
SOCKET_CMD_CLOSE
HOST
APPLICATION WINC
DRIVER
registerSocketCallback(dnsResolveCB)
gethostbyname(hostName)
SOCKET_CMD_DNS_RESOLVE
DNS_Resolver
formats a DNS
Query with the
given hostName
DNS Query
DNS Answer
DNS_Resolver
Extracts the
hostIP for
hostName from
the DNS Answer
SOCKET_CMD_DNS_RESOLVE
dnsResolveCB(hostName, hostIP)
Notes: 1. The host application requests to resolve hostname (e.g. www.foobar.com), by calling the function
gethostbyname.
2. Before calling the gethostbyname, the application must register a DNS response callback function
using the function registerSocketCallback.
3. After the ATWINC DNS_Resolver module obtains the IP address (hostIP) corresponding to the
given HostName, the dnsResolveCB will be called with the hostIP.
4. If an error occurs or if the DNS request encounters a timeout, the dnsResolveCB is called with IP
address value zero indicating a failure to resolve the domain name.
38 ATWINC3400
3 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
9.4 Example Code
This section provides code samples for different socket applications. For additional socket code example, refer
to [R03] ATWINC3400 Software Programming Guide.
// send data
send(clientSocketHdl, acSendBuffer, u16MsgSize, 0);
// Recv response from server.
recv(clientSocketHdl, rxBuffer, sizeof(rxBuffer), 0);
}
else
{
printf("TCP Connection Failed\n");
}
}
else if(u8Msg == SOCKET_MSG_RECV)
{
tstrSocketRecvMsg *pstrRecvMsg = (tstrSocketRecvMsg*)pvMsg;
if((pstrRecvMsg->pu8Buffer != NULL) && (pstrRecvMsg->s16BufferSize > 0))
{
// Process the received message.
if(u32ServerIP != 0)
{
clientSocketHdl = socket(AF_INET,SOCK_STREAM,u8Flags);
if(clientSocketHdl >= 0)
{
strAddr.sin_family = AF_INET;
strAddr.sin_port = _htons(443);
strAddr.sin_addr.s_addr = u32ServerIP;
/* This function needs to be called from main function. For the callbacks to be invoked correctly, the API
m2m_wifi_handle_events should be called continuously from main. */
void tcpConnect(char *pcServerURL)
{
// Initialize the socket layer.
socketInit();
40 ATWINC3400
4 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
recv(acceptedSocketHdl, rxBuffer, sizeof(rxBuffer), 0);
}
else
{
printf("Accept Failed\n");
}
}
else if(u8Msg == SOCKET_MSG_RECV)
{
tstrSocketRecvMsg *pstrRecvMsg = (tstrSocketRecvMsg*)pvMsg;
if((pstrRecvMsg->pu8Buffer != NULL) && (pstrRecvMsg->s16BufferSize > 0))
{
// Process the received message
// Perform data exchange
uint8 acSendBuffer[256];
uint16 u16MsgSize;
/* This function needs to be called from main function. For the callbacks to be invoked correctly, the API
m2m_wifi_handle_events should be called continuously from main. */
void tcpStartServer(uint16 u16ServerPort)
{
struct sockaddr_in strAddr;
/* This function needs to be called from main function. For the callbacks to be invoked correctly, the API
m2m_wifi_handle_events should be called continuously from main.
*/
void udpClientStart(char *pcServerIP)
{
struct sockaddr_in strAddr;
// Initialize the socket layer.
socketInit();
clientSocketHdl = socket(AF_INET,SOCK_STREAM,u8Flags);
if(clientSocketHdl >= 0)
{
uint16 len;
strAddr.sin_family = AF_INET;
strAddr.sin_port = _htons(1234);
strAddr.sin_addr.s_addr = nmi_inet_addr(pcServerIP);
// Format some message in the acSendBuffer and put its length in len
sendto(clientSocketHdl, acSendBuffer, len, 0, (struct sockaddr*)&strAddr,
sizeof(struct sockaddr_in));
42 ATWINC3400
4 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
9.4.4 UDP Server Example Code
SOCKET serverSocketHdl;
uint8 rxBuffer[256];
// call Recv
recvfrom(serverSocketHdl, rxBuffer, sizeof(rxBuffer), 0);
/* This function needs to be called from main function. For the callbacks to be invoked correctly, the API
m2m_wifi_handle_events should be called continuously from main.
*/
void udpStartServer(uint16 u16ServerPort)
{
struct sockaddr_in strAddr;
// Initialize the socket layer.
socketInit();
44 ATWINC3400
4 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
10 Transport Layer Security (TLS)
The Transport Layer Security layer sits on top of TCP and provides security services including privacy,
authenticity, and message integrity. Various security methods are available with TLS in ATWINC firmware.
ATWINC implements the Transport Layer Security protocol TLS v1.0, client mode.
Do not miss both the SOCKET_FLAGS_SSL flag and the correct port number in your TLS
application. For instance an HTTP client application shall use no flags when calling
socket API function and connect to port 80. The same application source code be-
comes an HTTPS client application if you use the flag SOCKET_FLAGS_SSL and change
the port number to connect to port 433.
HOST
APPLICATION WINC
DRIVER
socket(SOCK_FLAGS_SSL)
sslSocketHdl
connect(sslSocketHdl)
SOCKET_CMD_SSL_CONNECT
TLS Handshake
SOCKET_CMD_SSL_CONNECT
SOCKET_MSG_CONNECT
close(sslSocketHdl)
SOCKET_CMD_SSL_CLOSE
Refer to Appendix C for more information on how to download X509 certificates on ATWINC serial flash.
46 ATWINC3400
4 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
10.4 SSL Client Code Example
SOCKET sslSocketHdl;
uint8 rxBuffer[256];
if(u32ServerIP != 0)
{
sslSocketHdl = socket(AF_INET,SOCK_STREAM,u8Flags);
if(sslSocketHdl >= 0)
/* This function needs to be called from main function. For the callbacks to be invoked correctly, the API
m2m_wifi_handle_events should be called continuously from main.
*/
void SSL_Connect(char *pcServerURL)
{
// Initialize the socket layer.
socketInit();
48 ATWINC3400
4 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
11 Wi-Fi AP Mode
11.1 Overview
This chapter provides an overview of ATWINC Access Point (AP) mode and describes how to set up this mode
and configure its parameters.
11.3 Limitations
AP mode supports OPEN and WEP security only
The AP can only support a single associated station. Further connection attempts will be rejected.
Concurrency (simultaneous STA/P2P and AP mode) is not supported. Before activating the AP mode,
host MCU application should disable the mode currently running.
param.pfAppWifiCb = wifi_event_cb;
if (!m2m_wifi_init(¶m))
{
tstrM2MAPConfig apConfig;
strcpy(apConfig.au8SSID, "WINC_SSID"); // Set SSID
apConfig.u8SsidHide = SSID_MODE_VISIBLE; // Set SSID to be broadcasted
apConfig.u8ListenChannel = 1; // Set Channel
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[3] = 1;
// Start AP mode
m2m_wifi_enable_ap(&apConfig);
while(1)
{
m2m_wifi_handle_events(NULL);
}
}
}
50 ATWINC3400
5 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
12 Provisioning
For normal operation the ATWINC device needs certain parameters to be loaded. In particular, when operating
in station mode, it needs to know the identity (SSID) and credentials of the access point to which it will connect.
The entry of this information is facilitated through the following provisioning steps.
The ATWINC3400 software supports three methods of provisioning:
BLE based in which a SmartPhone detects the ATWINC and uses an APP to transfer the information
from the user to the ATWINC3400
HTTP-based (browser) provisioning while ATWINC is in AP mode
Wi-Fi Protected Setup (WPS)
When the user selects a product and clicks the ‘>’ symbol, the Access Points visible to the IoT device will be
shown on the screen:
HOST
APPLICATION WINC USER DEVICE
DRIVER
m2m_wifi_start_ble_provision_mode
M2M_WIFI_REQ_START_BLE_PROVISION_MODE
M2M_WIFI_RESP_PROVISION_INFO
M2M_WIFI_RESP_PROVISION_INFO
Wi-Fi Connection
Procedure
Figure 12-1 shows the provisioning operation for an ATWINC device. The detailed steps are described in the
code example below.
52 ATWINC3400
5 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
12.1.1 BLE Provisioning Code Example
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
if(u8WiFiEvent == M2M_WIFI_RESP_PROVISION_INFO)
{
tstrM2MProvisionInfo *provInfo = (tstrM2MProvisionInfo*)pvMsg;
if(provInfo->u8Status == M2M_SUCCESS)
{
// connect to the provisioned AP.
m2m_wifi_connect((char*)provInfo->au8SSID, strlen(provInfo ->au8SSID),
provInfo->u8SecType, provInfo->au8Password, M2M_WIFI_CH_ALL);
printf("PROV SSID : %s\n", provInfo->au8SSID);
printf("PROV PSK : %s\n", provInfo->au8Password);
}
else
{
printf("(ERR) Provisioning Failed\n");
}
}
}
int main()
{
tstrWifiInitParam param;
// Driver initialization.
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(¶m))
{
m2m_wifi_start_ble_provision_mode();
while(1)
{
m2m_wifi_handle_events(NULL);
}
}
}
12.2.1 Introduction
In this method, the ATWINC is placed in AP mode and another device with a browser capability (mobile phone,
tablet, PC, etc.) is instructed to connect to the ATWINC HTTP server. Once connected, the desired
configuration can be entered.
12.2.2 Limitations
The current implementation of the HTTP Provisioning has the following limitations:
ATWINC AP limitations apply in provisioning mode. See Section 11.3: Limitations for a list of AP mode
limitations.
Provisioning uses AP mode with open security. No Wi-Fi security nor application level security (e.g. TLS)
is used and therefore the AP credentials entered by the user are sent on the clear and can be seen by
eavesdroppers.
The ATWINC Provisioning home page is a static HTML page. No server-side scripting allowed in the
ATWINC HTTP server.
Only APs with WPA-personal security (passphrase based) and no security (Open network) can be
provisioned. WEP and WPA-Enterprise APs cannot be provisioned.
The Provisioning is responsible to deliver the connection parameters to the application, the connection
procedure and the connection parameters validity its application responsibility
54 ATWINC3400
5 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
12.2.4 Provisioning Control Flow
HOST
APPLICATION WINC USER DEVICE
DRIVER
m2m_wifi_start_provision_mode
M2M_WIFI_REQ_START_PROVISION_MODE
M2M_WIFI_RESP_PROVISION_INFO
M2M_WIFI_RESP_PROVISION_INFO
Wi-Fi Connection
Procedure
Figure 12-3 shows the provisioning operation for an ATWINC device. The detailed steps are described as
follows:
1. The ATWINC device starts the HTTP Provisioning mode.
2. A user with a smart phone finds the ATWINC AP SSID in the Wi-Fi search list.
3. The user connects to the ATWINC AP.
4. The user launches the web browser and writes the ATWINC home page in the address bar.
5. If the HTTP redirect is enabled at the ATWINC, any web address the ATWINC home page will load
automatically (like connecting to a public Wi-Fi hotspot). Some phones will display a notification
message “sign in to Wi-Fi networks?” which, when accepted, will load the ATWINC home pages load
automatically. The ATWINC home page (shown in Figure 12-2) will appear on the browser.
6. To discover the list of Wi-Fi APs in the area, the user can press “Refresh”.
7. The desired AP is then selected from the search list (by one click or one touch) and its name will appear
automatically in the “Network Name” text box.
8. Then the user must enter the correct AP passphrase (for WPA/WPA2 personal security) in the “Pass
Phrase” text box. If the AP is not secured (Open network) the field should be left empty.
9. An ATWINC device name may be optionally configured if desired by the user in the “Device Name” text
box.
int main()
{
tstrWifiInitParam param;
// Driver initialization.
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(¶m))
{
tstrM2MAPConfig apConfig;
uint8 bEnableRedirect = 1;
strcpy(apConfig.au8SSID, "WINC_AP");
apConfig.u8ListenChannel = 1;
apConfig.u8SecType = M2M_WIFI_SEC_OPEN;
apConfig.u8SsidHide = 0;
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
56 ATWINC3400
5 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[0] = 1;
while(1)
{
m2m_wifi_handle_events(NULL);
}
}
}
HOST
APPLICATION WINC
DRIVER
m2m_wifi_wps
M2M_WIFI_REQ_WPS
WPS Button
Pressed on AP
WPS Registration
Protocol
M2M_WIFI_REQ_WPS
M2M_WIFI_REQ_WPS
Wi-Fi Connection
Procedure
58 ATWINC3400
5 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
12.3.4 WPS Code Example
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
if(u8WiFiEvent == M2M_WIFI_REQ_WPS)
{
tstrM2MWPSInfo *pstrWPS = (tstrM2MWPSInfo*)pvMsg;
if(pstrWPS->u8AuthType != 0)
{
printf("WPS SSID : %s\n",pstrWPS->au8SSID);
printf("WPS PSK : %s\n",pstrWPS->au8PSK);
printf("WPS SSID Auth Type : %s\n",
pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN ? "OPEN" : "WPA/WPA2");
printf("WPS Channel : %d\n",pstrWPS->u8Ch + 1);
int main()
{
tstrWifiInitParam param;
// Driver initialization.
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(¶m))
{
// Trigger WPS in Push button mode.
m2m_wifi_wps(WPS_PBC_TRIGGER, NULL);
while(1)
{
m2m_wifi_handle_events(NULL);
}
}
}
13.1 Overview
The purpose of the multicast filters is to provide the ability to send/receive messages to/from multicast
addresses. This feature is useful for one-to-many communication over networks, whether it is intended to send
Internet Protocol (IP) datagrams to a group of interested receivers in a single transmission, participate in a
zero-configuration networking or listening to a multicast stream or any other application.
60 ATWINC3400
6 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
if(MDNS_ParseQuery(&pu8RxBuffer[0], &strDnsHdr,&strDnsQuery))
MDNS_SendResp (sock,pu8IPAddr, u16Port,&strDnsHdr,&strDnsQuery );
}
else
{
MDNS_INFO("DnsServer_RecvfromCB Error !\n");
}
}
if(MDNS_ParseQuery(&pu8RxBuffer[0], &strDnsHdr,&strDnsQuery))
MDNS_SendResp (sock,pu8IPAddr, u16Port,&strDnsHdr,&strDnsQuery );
}
else
{
MDNS_INFO("DnsServer_RecvfromCB Error !\n");
}
}
62 ATWINC3400
6 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
Send mDNS Response:
void MDNS_SendResp (signed char sock,unsigned char * pu8IPAddr,
unsigned short u16Port,tstrDnsHdr *pstrDnsHdr,strdnsquery *pstrDnsQuery)
{
unsigned short u16index=0;
tstrSockAddr strclientAddr ;
unsigned char * pu8sendBuf;
char * serviceName2 = (char*)malloc(sizeof(serviceName)+1);
unsigned int MULTICAST_IP = 0xFB0000E0;
pu8sendBuf= gPu8Buf;
memcpy(&strclientAddr.u32IPAddr,&MULTICAST_IP,IPV4_DATA_LENGTH);
strclientAddr.u16Port=u16Port;
MDNS_INFO("%s \n",pstrDnsQuery->query);
MDNS_INFO("Query Size = %d \n",pstrDnsQuery->u16size);
MDNS_INFO("class = %.4x \n",pstrDnsQuery->u16class);
MDNS_INFO("type = %.4x \n",pstrDnsQuery->u16type);
MDNS_INFO("PREPARING DNS ANSWER BEFORE SENDING\n");
/*########################Answers#########################*/
/*------------------------------Name---------------------------------*/
pu8sendBuf [u16index++]= 0xC0 ; //pointer to query name location
pu8sendBuf [u16index++]= 0x0C ; // instead of writing the whole query name again
/*-----------------------------Type----------------------------------*/
pu8sendBuf [u16index++] =MDNS_TYPE>>8; //Type 12 PTR (domain name Pointer).
pu8sendBuf [u16index++] =(MDNS_TYPE&0xFF);
/*------------------------------Class-----------------------------------*/
pu8sendBuf [u16index++] =0x00;//MDNS_CLASS; //Class IN, Internet.
pu8sendBuf [u16index++] =0x01;// (MDNS_CLASS & 0xFF);
/*-----------------------------TTL----------------------------------*/
pu8sendBuf [u16index++] =(TIME_TO_LIVE >>24);
pu8sendBuf [u16index++] =(TIME_TO_LIVE >>16);
pu8sendBuf [u16index++] =(TIME_TO_LIVE >>8);
pu8sendBuf [u16index++] =(TIME_TO_LIVE );
/*---------------------------Date Length----------------------------------*/
pu8sendBuf [u16index++] =(sizeof(serviceName)+2)>>8;//added 2 bytes for the pointer
pu8sendBuf [u16index++] =(sizeof(serviceName)+2);
/*-----------------------------DATA--------------------------------*/
convertServiceName(serviceName,sizeof(serviceName),serviceName2);
memcpy(&pu8sendBuf[u16index],serviceName2,sizeof(serviceName)+1);
u16index+=sizeof(serviceName);
pu8sendBuf [u16index++] =0xC0;//Pointer to .local (from name)
pu8sendBuf [u16index++] =gu8pos;//23
/*###########################################################*/
strclientAddr.u16Port=HTONS(MDNS_SERVER_PORT);
// MultiCast RESPONSE
sendto( sock, pu8sendBuf,(uint16)u16index,0,(struct
sockaddr*)&strclientAddr,sizeof(strclientAddr));
strclientAddr.u16Port=u16Port;
memcpy(&strclientAddr.u32IPAddr,pu8IPAddr,IPV4_DATA_LENGTH);
}
Service Name
static char gpacDnsServerCache[DNS_SERVER_CACHE_SIZE][MDNS_HOSTNAME_SIZE] =
{
"_services._dns-sd._udp.local","_workstation._tcp.local","_http._tcp.local"
};
unsigned char gPu8Buf [MDNS_BUF_SIZE];
unsigned char gu8pos ;
signed char dns_server_sock ;
64 ATWINC3400
6 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
14 ATWINC Serial Flash Memory
WINC
Host MCU I2C, SPI, UART Wi-Fi ASIC SPI Master Serial Flash
int main()
66 ATWINC3400
6 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
{
uint8 au8FlashContent[FLASH_SECTOR_SZ] = {0};
uint32u32FlashTotalSize = 0, u32FlashOffset = 0;
ret = m2m_wifi_download_mode();
if(M2M_SUCCESS != ret)
{
printf("Unable to enter download mode\r\n");
}
else
{
u32FlashTotalSize = spi_flash_get_size();
}
if(M2M_SUCCESS == ret)
{
printf("Successful operations\r\n");
}
else
{
printf("Failed operations\r\n");
}
while(1);
return M2M_SUCCESS;
}
15.1 Prerequisites
Hardware Prerequisites
– Atmel SAMD21-XPRO Evaluation kit
– Atmel I/O1 Xplained ATIO1-XPRO board
– Atmel ATWINC3400 Xplained Pro Extension board
– Micro-USB Cable (Micro-A / Micro-B)
– Android Phone
Software Prerequisites
– Atmel Studio 6.2 (build 1153) or higher
– Atmel Software Frameworks 3.15.0
– Wi-Fi Network Controller demo for SAM D21
– Android apk AtmelWirelessConnect application
To develop and run this project you need to start with the downloaded empty Wi-Fi example project.
68 ATWINC3400
6 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
If you cannot use an Android phone to test the solution, you can still use Wireshark to
see the traffic generated by the IoT sensor application.
ATWINC3400 Wi-Fi extension and I/O1 extension should be plugged into SAM D21
Xplained Pro EXT1 and EXT2 respectively.
In order to add Wi-Fi connectivity into an existing user example project, the complete “wifi_nmi” folder should
be added to the user project.
70 ATWINC3400
7 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
15.5 Reading Temperature Sensor and Controlling LED Status
The empty Wi-Fi example Project comes with a specific driver for the AT30TSE temperature sensor, located on
the I/O1 extension.
#include “asf.h”
at30tse_init();
The empty Wi-Fi example Project already includes the peripheral dependencies for the
temperature sensor.
The temperature sensor configuration file “conf_at30tse75x.h” is already configured to
use the peripheral on EXT2.
The demo_start() function is the application main loop which implements the routines for connecting to the
network and sending temperature reports using the Wi-Fi Software API.
Implement the following steps to implement the IoT temperature sensor application.
72 ATWINC3400
7 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
1. Reset the ATWINC3400 Module.
To do so, we need to call nm_bsp_init(), which initializes the CHIP_EN and RESET_N GPIOs.
void demo_start(void)
{
/* Reset network controller */
nm_bsp_init();
while (1) {
/* TODO: Implement IOT feature here. */
}
}
tstrWifiInitParam param;
sint8 ret;
ret = m2m_wifi_init(¶m);
if (M2M_SUCCESS != ret) {
puts("demo_start: nm_drv_init call error!");
while (1)
;
}
/* Initialize Socket module */
socketInit();
registerSocketCallback(m2m_wifi_socket_handler, NULL);
When m2m_wifi_socket_handler() is called, it indicates a specific asynchronous socket operation has been
done for a specified SOCKET sock. The completed socket operation type is indicated in u8Msg parameter and
any message payload (e.g. received data) is provided in the last parameter pvMsg.
Example of non-blocking asynchronous socket operations completions are: SOCKET_MSG_BIND,
SOCKET_MSG_LISTEN, SOCKET_MSG_ACCEPT, SOCKET_MSG_CONNECT, SOCKET_MSG_RECV,
SOCKET_MSG_SEND, SOCKET_MSG_SENDTO, and SOCKET_MSG_RECVFROM to indicate completion of bind(),
listen(), accept(), connect(), recv(), send(), sendto(), recvfrom() respectively.
74 ATWINC3400
7 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
Upon completion of this step, the code should look like the following:
/**
* \brief Demo main routine.
*/
void demo_start(void)
{
tstrWifiInitParam param;
sint8 ret;
while (1) {
/* TODO: Implement IOT feature here. */
}
}
The initialization stage is done. Now, connect to the network and open the required
communication sockets.
while (1) {
/* Handle pending events from network controller. */
m2m_wifi_handle_events(NULL);
}
Since the demo application does not use operating system, m2m_wifi_han-
dle_events() is called in the application main loop. If the application used an operat-
ing system, it is required to create a dedicated task to call m2m_wifi_han-
dle_events(). The task shall sleep until an interrupt on IRQN line, then it handles the
deferred work by ISR and calls m2m_wifi_handle_events().
8. Start association.
The SSID and passphrase of the router are defined in the demo.h file, using the following defines;
DEMO_WLAN_SSID and DEMO_WLAN_PSK. These should be updated with your local SSID and passphrase.
The m2m_wifi_connect() function request the ATWINC3400 Wi-Fi module to start association with the
local SSID.
/* Connect to router. */
m2m_wifi_connect((char *)DEMO_WLAN_SSID, sizeof(DEMO_WLAN_SSID),
DEMO_WLAN_AUTH, (char *)DEMO_WLAN_PSK, M2M_WIFI_CH_ALL);
The parameter DEMO_WLAN_AUTH specifies the local AP security type which can be either: OPEN, WEP,
WPA/WPA2, or enterprise security. The last parameter M2M_WIFI_CH_ALL forces the ATWINC3400 to
scan for the local AP on all channels.
The ATWINC3400 firmware contains a “fast boot feature” which optimizes the asso-
ciation time across power cycles. Firmware stores the channel on which the last suc-
cessful association occurred. During next association attempt, firmware probes if the
local AP is still on the same channel (which is most likely to happen since AP does not
change channels frequently).
If local AP is not found, then firmware will trigger a new scan.
76 ATWINC3400
7 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
/** Wi-Fi status variable. */
static volatile uint8 wifi_connected = 0;
...
...
...
When association succeeds, M2M_WIFI_CONNECTED event is received. This implies the start of the DHCP
client to obtain IP address by calling m2m_wifi_request_dhcp_client(). If association fails or a
disconnection happens, M2M_WIFI_DISCONNECTED is received and the demo app will attempt to reconnect
again using m2m_wifi_connect().
10. Obtaining DHCP configuration.
When DHCP client in ATWINC3400 Firmware obtains IP address from local AP, the demo app receives
information about the obtained IP address. m2m_wifi_state() callback is invoked with
M2M_WIFI_REQ_DHCP_CONF event type.
Add the following code to m2m_wifi_state() to handle M2M_WIFI_REQ_DHCP_CONF.
break;
}
Upon completion of this step, the code should look like the following:
/**
* \brief Demo main routine.
*/
void demo_start(void)
{
tstrWifiInitParam param;
sint8 ret;
78 ATWINC3400
7 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
The association stage is done. In next section we will open sockets and start sending
and receiving data.
To get started with transmit and receive, add the following code to the demo application:
if (wifi_connected == M2M_WIFI_CONNECTED) {
/* Open server socket. */
if (rx_socket < 0) {
if ((rx_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
puts("demo_start: failed to create RX UDP client socket error!");
continue;
}
bind(rx_socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
}
The above code open two sockets and attempts to bind on the UDP server socket. When bind is
complete, m2m_wifi_socket_handler() is called with an u8Msg = SOCKET_MSG_BIND success
indication. We need to add a handler for SOCKET_MSG_BIND inside m2m_wifi_socket_handler().
After successful bind, the demo app will start receiving data from the UDP server. The demo app allocates a
static buffer gau8SocketTestBuffer to receive incoming data.
80 ATWINC3400
8 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
Notice that recvfrom() is called after successful bind() callback.
The call to recvfrom() is non-blocking and execution will return again to application main loop. When data is
received, m2m_wifi_socket_handler() is called with an u8Msg = SOCKET_MSG_RECVFROM and pvMsg is a
pointer to tstrSocketRecvMsg structure.
The structure tstrSocketRecvMsg provides information about the RX buffer pointer for current socket as well
as the received size. As explained previously, the received message contains a t_msg_temp_report structure
which contains LED on/off command to a specific device. The device changes the LED status only when the
received t_msg_temp_report .name[9] field matches its DEMO_PRODUCT_NAME.
void demo_start(void)
{
while (1) {
/* Handle pending events from network controller. */
m2m_wifi_handle_events(NULL);
if (wifi_connected == M2M_WIFI_CONNECTED
&& (ms_ticks - delay > DEMO_REPORT_INTERVAL)) {
if (ret == M2M_SUCCESS) {
puts("demo_start: sensor report sent");
} else {
puts("demo_start: failed to send status report error!");
}
}
}
}
The IoT temperature sensor application is now complete and you are ready to pro-
gram the SAM D21 Xplained Pro board. Your final code should be like the following
listing:
82 ATWINC3400
8 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
/**
*
* \file
*
* \brief Wi-Fi NMI temperature sensor demo.
*
* Copyright (c) 2014 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "asf.h"
#include "demo.h"
#include "bsp/include/nm_bsp.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
#include "conf_wifi_m2m.h"
/**
* \brief Callback to get the Data from socket.
*
* \param[in] sock socket handler.
* \param[in] u8Msg socket event type. Possible values are:
* - SOCKET_MSG_BIND
* - SOCKET_MSG_LISTEN
* - SOCKET_MSG_ACCEPT
* - SOCKET_MSG_CONNECT
* - SOCKET_MSG_RECV
* - SOCKET_MSG_SEND
* - SOCKET_MSG_SENDTO
* - SOCKET_MSG_RECVFROM
* \param[in] pvMsg is a pointer to message structure. Existing types are:
* - tstrSocketBindMsg
* - tstrSocketListenMsg
* - tstrSocketAcceptMsg
* - tstrSocketConnectMsg
* - tstrSocketRecvMsg
*/
static void m2m_wifi_socket_handler(SOCKET sock, uint8 u8Msg, void *pvMsg)
{
/* Check for socket event on RX socket. */
if (sock == rx_socket) {
if (u8Msg == SOCKET_MSG_BIND) {
tstrSocketBindMsg *pstrBind = (tstrSocketBindMsg *)pvMsg;
if (pstrBind && pstrBind->status == 0) {
/* Prepare next buffer reception. */
recvfrom(sock, gau8SocketTestBuffer, TEST_BUFFER_SIZE, 0);
}
else {
puts("m2m_wifi_socket_handler: bind error!");
}
}
else if (u8Msg == SOCKET_MSG_RECVFROM) {
tstrSocketRecvMsg *pstrRx = (tstrSocketRecvMsg *)pvMsg;
84 ATWINC3400
8 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
if (pstrRx->pu8Buffer && pstrRx->s16BufferSize) {
/**
* \brief Callback to get the Wi-Fi status update.
*
* \param[in] u8MsgType type of Wi-Fi notification. Possible types are:
* - [M2M_WIFI_RESP_CURRENT_RSSI](@ref M2M_WIFI_RESP_CURRENT_RSSI)
* - [M2M_WIFI_RESP_CON_STATE_CHANGED](@ref M2M_WIFI_RESP_CON_STATE_CHANGED)
* - [M2M_WIFI_RESP_CONNTION_STATE](@ref M2M_WIFI_RESP_CONNTION_STATE)
* - [M2M_WIFI_RESP_SCAN_DONE](@ref M2M_WIFI_RESP_SCAN_DONE)
* - [M2M_WIFI_RESP_SCAN_RESULT](@ref M2M_WIFI_RESP_SCAN_RESULT)
* - [M2M_WIFI_REQ_WPS](@ref M2M_WIFI_REQ_WPS)
* - [M2M_WIFI_RESP_IP_CONFIGURED](@ref M2M_WIFI_RESP_IP_CONFIGURED)
* - [M2M_WIFI_RESP_IP_CONFLICT](@ref M2M_WIFI_RESP_IP_CONFLICT)
* - [M2M_WIFI_RESP_P2P](@ref M2M_WIFI_RESP_P2P)
* - [M2M_WIFI_RESP_AP](@ref M2M_WIFI_RESP_AP)
* - [M2M_WIFI_RESP_CLIENT_INFO](@ref M2M_WIFI_RESP_CLIENT_INFO)
* \param[in] pvMsg A pointer to a buffer containing the notification parameters
* (if any). It should be casted to the correct data type corresponding to the
* notification type. Existing types are:
* - tstrM2mWifiStateChanged
* - tstrM2MWPSInfo
* - tstrM2MP2pResp
* - tstrM2MAPResp
* - tstrM2mScanDone
* - tstrM2mWifiscanResult
*/
static void m2m_wifi_state(uint8 u8MsgType, void *pvMsg)
{
switch (u8MsgType) {
case M2M_WIFI_RESP_CON_STATE_CHANGED: {
tstrM2mWifiStateChanged *pstrWifiState = (tstrM2mWifiStateChanged*) pvMsg;
if (pstrWifiState->u8CurrState == M2M_WIFI_CONNECTED) {
puts("m2m_wifi_state: M2M_WIFI_RESP_CON_STATE_CHANGED: CONNECTED");
m2m_wifi_request_dhcp_client();
}
else if(pstrWifiState->u8CurrState == M2M_WIFI_DISCONNECTED) {
puts("m2m_wifi_state: M2M_WIFI_RESP_CON_STATE_CHANGED: DISCONNECTED");
wifi_connected = 0;
m2m_wifi_connect((char *)DEMO_WLAN_SSID, sizeof(DEMO_WLAN_SSID),
DEMO_WLAN_AUTH, (char *)DEMO_WLAN_PSK, M2M_WIFI_CH_ALL);
}
break;
}
case M2M_WIFI_REQ_DHCP_CONF: {
uint8 *pu8IPAddress = (uint8*) pvMsg;
wifi_connected = 1;
/* Turn LED0 on to declare that IP address received. */
port_pin_set_output_level(LED_0_PIN, false);
/**
* \brief Sensor thread entry.
*
* \param[in] params unused parameter.
*/
void demo_start(void)
{
tstrWifiInitParam param;
struct sockaddr_in addr;
sint8 ret;
/* Connect to router. */
m2m_wifi_connect((char *)DEMO_WLAN_SSID, sizeof(DEMO_WLAN_SSID),
DEMO_WLAN_AUTH, (char *)DEMO_WLAN_PSK, M2M_WIFI_CH_ALL);
while (1) {
/* Handle pending events from network controller. */
m2m_wifi_handle_events(NULL);
86 ATWINC3400
8 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
puts("demo_start: failed to create TX UDP client socket error!");
continue;
}
}
if (ret == M2M_SUCCESS) {
puts("demo_start: sensor report sent");
} else {
puts("demo_start: failed to send status report error!");
}
}
}
}
Connect the ATWINC3400 Wi-Fi extension and the I/O1 extension to the SAM D21 Xplained Pro as
displayed:
Connect the SAM D21 Xplained Pro board to your PC using DEBUG USB connector
Program the application by clicking on the Start Debugging and Break icon:
The application will be programmed in the SAM D21 embedded flash and breaks at main function. Click
You may be asked to upgrade your EDBG firmware. If so, click on Upgrade:
Upgrade operation may take a few minutes, wait for the operation to complete.
88 ATWINC3400
8 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
The IoT sensor application is now programmed and running.
Open the EDBG DEBUG USB serial COM port, with the following settings: 115200 bauds, 8-bit data, no parity,
one stop bit and no flow control.
Connect the Android device to the same SSID network than the ATWINC3400 Wi-Fi module
Open the Temperature sensor application on the Android device
Hit the “Start Scan” button
A “TempSensor” device (as defined in the DEMO_PRODUCT_NAME macro in demo.h file) appears
Dealing with HIF messages in host MCU application is an advanced topic. For most
applications, it is recommended to use Wi-Fi and socket layers. Both layers hide the
complexity of the HIF APIs.
After the application sends request, the Host Driver (Wi-Fi/Socket layer) formats the request and sends it to the
HIF layer which then interrupts the ATWINC device announcing that a new request will be posted. Upon
receipt, the ATWINC firmware parses the request and starts the required operation.
HOST MCU
Host Applicaton
Host Driver
Wi-Fi Socket
HIF
Bus
The Host Interface Layer is responsible for handling communication between the host MCU and the ATWINC
device. This includes Interrupt handling, DMA control, and management of communication logic between
firmware driver at host and ATWINC firmware.
The Request/Response sequence between the Host and the ATWINC chip is shown in Figure 16-2.
90 ATWINC3400
9 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
Figure 16-2. The Request/Response Sequence Diagram
WINC
DRIVER WINC
Application Wi-Fi/Socket Host FIRMWARE
Layer Interface
Request
Format Request
Interrupt WINC
Write RQ to Memory
Tx Done Interrupt
Process
Request
Write
Response
to
Memory
Interrupt Host
Call appropriate handler
Send Response to
Application Callback
function Rx Done
Interrupt
Fail to allocate
memory
(error state)
Step Description
Step (1) Wake up the ATWINC device Wakeup the device to be able to receive Host requests
Step (2) Check for Interrupt Monitor BIT[0] of WIFI_HOST_RCV_CTRL_0 register.
Disable the host from receiving interrupts (until this one has been pro-
cessed).
Step (3) Clear interrupt Write zero to BIT[0] of WIFI_HOST_RCV_CTRL_0 register
Step (4) Read Data Get the address of the data block from WIFI_HOST_RCV_CTRL_1 regis-
ter.
Read Data block with size obtained from WIFI_HOST_RCV_CTRL_0 reg-
ister BIT[13] <->BIT[2].
92 ATWINC3400
9 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
Step Description
Step (5) Process Request Parse the HIF header at the start of the Data and forward the Data to the
appropriate registered Callback function
Step (6) HOST RX Done Raise an interrupt for the chip to free the memory holding the data by set-
ting BIT[1] of WIFI_HOST_RCV_CTRL_0 register.
Enable Host interrupt reception again.
Step (7) Allow ATWINC device to sleep Allow the ATWINC device to enter sleep mode again (if it wishes).
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
Group ID Op Code
Payload Length
Payload
...
...
...
The Group ID (8-bits): A group ID is the category of the message. Valid categories are
M2M_REQ_GRP_WIFI, M2M_REQ_GRP_IP, M2M_REQ_GRP_HIF, M2M_REQ_GRP_OTA corresponding to Wi-Fi,
Socket, HIF, and OTA respectively. A group ID can be assigned one of the values enumerated in
tenuM2mReqGrp.
Op Code: (8-bit): A command number. Valid command number is a value enumerated in:
tenuM2mConfigCmd and tenuM2mStaCmd, tenuM2mApCmd, and tenuM2mP2pCmd corresponding to
configuration, STA mode, AP mode, and P2P mode commands. See the full list of commands in the
header file m2m_types.h.
Payload Length (16-bits): The payload length in bytes (does not include header).
The Host driver Wi-Fi layer formats the request and forward it to HIF (Host Interface) layer
sint8 m2m_wifi_request_scan(uint8 ch)
{
tstrM2MScan strtmp;
sint8 s8Ret = M2M_ERR_SCAN_IN_PROGRESS;
strtmp.u8ChNum = ch;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SCAN, (uint8*)&strtmp,
sizeof(tstrM2MScan),NULL, 0,0);
return s8Ret;
}
94 ATWINC3400
9 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
{
sint8 ret = M2M_ERR_SEND;
volatile tstrHifHdr strHif;
strHif.u8Opcode = u8Opcode&(~NBIT7);
strHif.u8Gid = u8Gid;
strHif.u16Length = M2M_HIF_HDR_OFFSET;
if(pu8DataBuf != NULL)
{
strHif.u16Length += u16DataOffset + u16DataSize;
}
else
{
strHif.u16Length += u16CtrlBufSize;
}
/* TX STEP (1) */
ret = hif_chip_wake();
if(ret == M2M_SUCCESS)
{
volatile uint32 reg, dma_addr = 0;
volatile uint16 cnt = 0;
reg = 0UL;
reg |= (uint32)u8Gid;
reg |= ((uint32)u8Opcode<<8);
reg |= ((uint32)strHif.u16Length<<16);
ret = nm_write_reg(NMI_STATE_REG,reg);
if(M2M_SUCCESS != ret) goto ERR1;
reg = 0;
/* TX STEP (2) */
reg |= (1<<1);
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_2, reg);
if(M2M_SUCCESS != ret) goto ERR1;
dma_addr = 0;
for(cnt = 0; cnt < 1000; cnt ++)
{
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_2,(uint32 *)®);
if(ret != M2M_SUCCESS) break;
if (!(reg & 0x2))
{
/* TX STEP (3) */
ret = nm_read_reg_with_ret(0x150400,(uint32 *)&dma_addr);
if(ret != M2M_SUCCESS) {
/*in case of read error clear the dma address and return error*/
dma_addr = 0;
}
/*in case of success break */
break;
}
}
if (dma_addr != 0)
{
volatile uint32 u32CurrAddr;
u32CurrAddr = dma_addr;
strHif.u16Length=NM_BSP_B_L_16(strHif.u16Length);
/* TX STEP (4) */
ret = nm_write_block(u32CurrAddr, (uint8*)&strHif, M2M_HIF_HDR_OFFSET);
The ATWINC chip processes the request and interrupts the host after finishing the operation
The HIF layer then receives the response
static sint8 hif_isr(void)
{
sint8 ret = M2M_ERR_BUS_FAIL;
uint32 reg;
volatile tstrHifHdr strHif;
/* RX STEP (1) */
ret = hif_chip_wake();
if(ret == M2M_SUCCESS)
{
/* RX STEP (2) */
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0, ®);
if(M2M_SUCCESS == ret)
{
/* New interrupt has been received */
if(reg & 0x1)
{
96 ATWINC3400
9 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
6
uint16 size;
nm_bsp_interrupt_ctrl(0);
/*Clearing RX interrupt*/
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0,®);
if(ret != M2M_SUCCESS)goto ERR1;
reg &= ~(1<<0);
/* RX STEP (3) */
ret=nm_write_reg(WIFI_HOST_RCV_CTRL_0,reg);
if(ret != M2M_SUCCESS)goto ERR1;
/* read the rx size */
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0, ®);
if(M2M_SUCCESS != ret)
{
M2M_ERR("(hif) WIFI_HOST_RCV_CTRL_0 bus fail\n");
nm_bsp_interrupt_ctrl(1);
goto ERR1;
}
gu8HifSizeDone = 0;
size = (uint16)((reg >> 2) & 0xfff);
if (size > 0) {
uint32 address = 0;
/**
start bus transfer
**/
/* RX STEP (4) */
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_1, &address);
if(M2M_SUCCESS != ret)
{
M2M_ERR("(hif) WIFI_HOST_RCV_CTRL_1 bus fail\n");
nm_bsp_interrupt_ctrl(1);
goto ERR1;
}
ret = nm_read_block(address, (uint8*)&strHif, sizeof(tstrHifHdr));
strHif.u16Length = NM_BSP_B_L_16(strHif.u16Length);
if(M2M_SUCCESS != ret)
{
M2M_ERR("(hif) address bus fail\n");
nm_bsp_interrupt_ctrl(1);
goto ERR1;
}
if(strHif.u16Length != size)
{
if((size - strHif.u16Length) > 4)
{
M2M_ERR("(hif) Corrupted packet Size = %u <L = %u, G = %u, OP
= %02X>\n",
size, strHif.u16Length, strHif.u8Gid, strHif.u8Opcode);
nm_bsp_interrupt_ctrl(1);
ret = M2M_ERR_BUS_FAIL;
goto ERR1;
}
}
/* RX STEP (5) */
if(M2M_REQ_GRP_WIFI == strHif.u8Gid)
{
if(pfWifiCb)
pfWifiCb(strHif.u8Opcode,strHif.u16Length - M2M_HIF_HDR_OFFSET,
address + M2M_HIF_HDR_OFFSET);
}
else if(M2M_REQ_GRP_IP == strHif.u8Gid)
{
if(pfIpCb)
98 ATWINC3400
9 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
8
}
}
// …code eliminated…
}
The Wi-Fi layer sends the response to the application through its callback function
if (u8MsgType == M2M_WIFI_RESP_SCAN_DONE)
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*) pvMsg;
if( (gu8IsWiFiConnected == M2M_WIFI_DISCONNECTED) &&
(gu8WPS == WPS_DISABLED) && (gu8Prov == PROV_DISABLED) )
{
gu8Index = 0;
gu8Sleep = PS_WAKE;
if (pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(gu8Index);
gu8Index++;
}
else
{
m2m_wifi_request_scan(M2M_WIFI_CH_ALL);
}
}
}
Host MCU
Application •App Logic
Host MCU
Raw SPI Bus •SPI read/write
17.1 Introduction
The ATWINC SPI Protocol is implemented as a command-response transaction and assumes that one party is
the master and the other is the slave. The roles correspond to the master and slave devices on the SPI bus.
Each message has an identifier in the first byte indicating the type of message:
Command
Response
Data
In the case of Command and Data messages, the last byte is used as data integrity check.
100 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
0
The format of Command and Response and Data frames is described in the following sections. The following
points apply:
There is a response for each command
Transmitted/received data is divided into packets with fixed size
For a write transaction (Slave is receiving data packets), the slave should reply by a response for each
data packet
For an RD transaction (Master is receiving data packets), the master doesn’t send response. If there is
an error, the master should request retransmission on the lost data packet.
Protection of commands and data packets by CRC is optional
10 Byte (max)
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 101 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
1
Type A commands include:
DMA single-word RD
internal register RD
Transaction termination command
Repeat Data PKT command
Soft reset command
Type B commands include:
DMA RD Transaction
DMA WR Transaction
Type C commands include:
DMA Extended RD transaction
DMA Extended WR transaction
Internal register WR
Type D commands include:
DMA single-word WR
Full details of the frame format fields are provided in the following table:
Field Size Description
CMD Start 4 bits Command Start: 4’b1100
CMD Type 4 bits Command type:
4’b0001: DMA write transaction
4’b0010: DMA read transaction
4’b0011: Internal register write
4’b0100: Internal register read
4’b0101: Transaction termination
4’b0110: Repeat data Packet command
4’b0111: DMA extended write transaction
4’b1000: DMA extended read transaction
4’b1001: DMA single-word write
4’b1010: DMA single-word read
4’b1111: soft reset command
102 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
2
Payload A: 3 The Payload field may be of Type A, B, C, or D
B: 5 Type A (length 3)
C: 6 1- DMA single-word RD
D: 7
Param: Read Address:
Payload bytes:
B0: ADDRESS[23:16]
B1: ADDRESS[15:8]
B2: ADDRESS[7:0]
2- internal register RD
Param: Offset address (two bytes):
Payload bytes:
B0: OFFSET-ADDR[15:8]
B1: OFFSET-ADDR[7:0]
B2: 0
3- Transaction termination command
Param: none
Payload bytes:
B0: 0
B1: 0
B2: 0
4- Repeat Data PKT command
Param: none
Payload bytes:
B0: 0
B1: 0
B2: 0
5- Soft reset command
Param: none
Payload bytes:
B0: 0xFF
B1: 0xFF
B2: 0xFF
Type B (length 5)
1- DMA RD Transaction
Params:
DMA Start Address: 3 bytes
DMA count: 2 bytes
Payload bytes:
B0: ADDRESS[23:16]
B1: ADDRESS[15:8]
B2: ADDRESS[7:0]
B3: COUNT[15:8]
B4: COUNT[7:0]
2- DMA WR Transaction
Params:
DMA Start Address: 3 bytes
DMA count: 2 bytes
Payload bytes:
B0: ADDRESS[23:16]
B1: ADDRESS[15:8]
B2: ADDRESS[7:0]
B3: COUNT[15:8]
B4: COUNT[7:0]
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 103 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
3
Field Size Description
Type C (length 6)
1- DMA Extended RD transaction
Params:
DMA Start Address: 3 bytes
DMA extended count: 3 bytes
Payload bytes:
B0: ADDRESS[23:16]
B1: ADDRESS[15:8]
B2: ADDRESS[7:0]
B3: COUNT[23:16]
B4: COUNT[15:8]
B5: COUNT[7:0]
2- DMA Extended WR transaction
Params:
DMA Start Address: 3 bytes
DMA extended count: 3 bytes
Payload bytes:
B0: ADDRESS[23:16]
B1: ADDRESS[15:8]
B2: ADDRESS[7:0]
B3: COUNT[23:16]
B4: COUNT[15:8]
B5: COUNT[7:0]
3- Internal register WR*
Params:
Offset address: 3 bytes
Write Data: 3 bytes
* “clocked or clockless registers”
Payload bytes:
B0: OFFSET-ADDR[15:8]
B1: OFFSET-ADDR [7:0]
B2: DATA[31:24]
B3: DATA [23:16]
B4: DATA [15:8]
B5: DATA [7:0]
Type D (length 7)
1- DMA single-word WR
Params:
Address: 3 bytes
DMA Data: 4 bytes
Payload bytes:
B0: ADDRESS[23:16]
B1: ADDRESS[15:8]
B2: ADDRESS[7:0]
B3: DATA[31:24]
B4: DATA [23:16]
B5: DATA [15:8]
B6: DATA [7:0]
CRC7 1 byte Optional data integrity field comprising two subfields:
bit 0: fixed value ‘1’
bits 1-7: 7 bit CRC value computed using polynomial G(x)
= X^7 + X^3 + 1 with seed value: 0x7F
104 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
4
The following table summarizes the different commands according to the payload type (DMA address = 3-
bytes):
Command packet size
Payload type Payload size Commands
“with CRC”
Type A 3-Bytes 5-Bytes 1- DMA Single-Word Read
2- Internal Register Read
3- Transaction Termination
4- Repeat Data Packet
5- Soft Reset
Type B 5-Bytes 7-Bytes 1- DMA Read
2- DMA Write
Type C 6-Bytes 8-Bytes 1- DMA Extended Read
2- DMA Extended Write
3- Internal Register Write
Type D 7-Bytes 9-Bytes 1- DMA Single-Word Write
2 Byte
The first byte contains two 4-bit fields which identify the response message and the response type.
The second byte indicates the status of the ATWINC after receiving and, where possible, executing the
command/data. This byte contains two sub fields:
B0-B3: Error state
B4-B7: DMA state
States that may be indicated are:
DMA state:
– DMA ready for any transaction
– DMA engine is busy
Error state:
– No error
– Unsupported command
– Receiving unexpected data packet
– Command CRC7 error
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 105 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
5
Field Size Description
Res Start 4 bits Response Start : 4’b1100
Response Type 4 bits If the response packet is for Command:
Contains of copy of the Command Type field in the
Command.
If the response packet is for received Data Packet:
4’b0001: first data packet is received
4’b0010: Receiving data packets
4’b0011: last data packet is received
4’b1111: Reserved value
State 1 byte This field is divided into two subfields:
State
4 Bits 4 bits
DMA State :
4’b0000: DMA ready for any transaction
4’b0001: DMA engine is busy
Error State:
4’b0000: No error
4’b0001: Unsupported command
4’b0010: Receiving unexpected data packet
4’b0011: Command CRC7 error
4’b0100: Data CRC16 error
4’b0101: Internal general error
4 Bits 4 Bits
1 Byte DATA_PACKET_SIZE 2 Byte
To support DMA hardware a large data transfer may be fragmented into multiple smaller Data Packets. This is
controlled by the value of DATA_PACKET_SIZE which is agreed between the master and slave in software
and is a fixed value such as 256B, 512B, 1KB (default), 2KB, 4KB, or 8KB. If a transfer has a length m which
exceeds DATA_PACKET_SIZE the sender must split into n frames where frames 1..n-1 will be length
DATA_PACKET_SIZE and frame n will be length:
(m – (n-1)* DATA_PACKET_SIZE).This is shown diagrammatically below:
If DMA count <= DATA_PACKET_SIZE
The data packet is “DATA_Header + DMA count +optional CRC16“, i.e. no padding.
DATA
Header
Remaining data CRC
106 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
6
If DMA count > DATA_PACKET_SIZE
DMA Count
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 107 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
7
Error type Recovery mechanism
TX/RX Data count error Retransmit the command
No response to soft reset Transmit all ones till master receives a response of all ones from the slave
command
Then deactivate the output data line
Slave:
Unsupported command Send response with error
Returns to command monitor state
Receive command CRC Send response with error
error
waits for command retransmission
Received data CRC error Send response with error
wait for retransmission of the data packet
Internal general error The master should soft reset the slave
TX/RX Data count error Only the master can detect this error
Slave operates with the data count received till the count finishes or the master
terminates the transaction
In both cases the master should retry the command from the beginning
No response to soft reset 1. First received 4’b1001, it decides data start.
command
2. Then received packet order 4’b1111 that is reserved value.
3. Then monitors for 7 bytes all ones to decide Soft Reset action.
4. The slave should activate the output data line.
5. Waits for deactivation for the received line.
6. The slave then deactivates the output data line and returns to the CMD/DATA start
monitor state.
General NOTE The slave should monitor the received line for command reception in any time
When a CMD start is detected, the slave will receive eight bytes, then return again
to the command reception state
When the slave is transmitting data, it should also monitor for command reception
When the slave is receiving data, it will monitor for command reception between the
data packets
Therefore issuing a soft reset command, should be detected in all cases
108 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
8
For clock-less register read: - according to the interface, the protocol slave may not send CRC16. One or two
byte padding depends on three or four byte DMA addresses.
Offset_addr[15] Offset_addr[14:0] One or two
8'hC3 { CRC7,1'b1 }
‘0’ =1'b1 = clkless_addr byte padding ‘0’
1 Byte 2 Byte 1 or 2 Byte 1 Byte
Clk-less
Response Data Hdr
‘0’ reg data ‘0’
2 Byte 1 Byte
CMD_RES Period
1 byte 4 bytes
Cmd Hdr:
Address / CRC
‘0’ Read Single Word ‘0’
1 byte 1 byte 1 byte 4 bytes
‘0’ Rsp Hdr STATE DATA Start DATA ‘0’
CMD_RES Period
1 byte 2 bytes 2 bytes
Cmd Hdr:
Offset Addr 16‘d0
‘0’ Read Internal Register ‘0’
1 byte 1 byte 1 byte 4 bytes
‘0’ Rsp Hdr STATE DATA Start DATA ‘0’
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 109 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
0
9
17.2.3 Read Block
Normal transaction:
Master: Issues a DMA read transaction and waits for a response.
Slave: Sends a response after CMD_RES_PERIOD.
Master: Waits for a data packet start.
Slave: Sends the data packets, separated by DATA_DATA_PERIOD 5 where DATA_DATA_PERIOD is
controlled by software and has one of these values:
NO_DELAY (default), 4_BYTE_PERIOD, 8_BYTE_PERIOD, and 16_BYTE_PERIOD.
Slave: Continues sending till the count ends.
Master: Receive data packets. No response is sent for data packets but a termination/retransmit command
may be sent if there is an error.
The message sequence for this case is shown below:
CMD_RES Period
DATA_DATA Period
1 byte 6 bytes
Cmd Hdr:
‘0’ Data Read
Address, Count, crc ‘0’
1 byte 1 byte 1 byte Fixed size 2 byte 1 byte Fixed size 2 byte
‘0’ Rsp Hdr STATE DATA Hdr DATA ‘0’ CRC16 ‘0’ DAT Header DATA ‘0’ CRC16 ‘0’
5
Actually the period between data packets is “DATA_DATA_PERIOD + DMA access time.” The master should monitor for DATA_START
directly after DATA_DATA_PERIOD
110 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
0
Repeat command is issued:
1. Master: Can issue a repeat command at any time during the transaction.
2. Master: Should monitor for RES_START after CMD_RESP_PERIOD.
3. Slave: Should cut off the current running data packet, if any.
4. Slave: Should respond to the repeat command after CMD_RESP_PERIOD from the end of the repeat
command packet.
5. Slave: Resends the data packet that has an error then continues the transaction as normal.
CMD_RES Period
1 byte 8 bytes
Cmd Hdr:
‘0’ Single Word Write
Address, Data, CRC ‘0’
Response
‘0’ Hdr
STATE ‘0’
CMD_RES Period
1 byte 7 bytes
Cmd Hdr:
‘0’ Internal Word Write
Offset Addr, Data, CRC ‘0’
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 111 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
1
17.2.6 Write Block
Case 1: Master waits for a command response:
1. Master: Issues a DMA write command and waits for a response.
2. Slave: Sends response after CMD_RES_PERIOD.
3. Master: Sends the data packets after receiving response.
4. Slave: Sends a response packet for each data packet received after DATA_RES_PERIOD.
5. Master: Does not wait for the data response before sending the following data packet notes:
CMD_RES_PERIOD is controlled by SW taking one of the values:
NO_DELAY (default), 1_BYTE_PERIOD, 2_BYTE_PERIOD and 3_BYTE_PERIOD
1 byte Fixed size 2 byte 1 byte Fixed size 2 byte 1 byte Fixed size 2 byte
Cmd Hdr:
‘0’ Write Command
AddresS, Count, CRC
‘0’ DATA Hdr DATA CRC16 DATA Hdr DATA CRC16 DATA Hdr DATA CRC16 ‘0’
‘0’ Rsp Hdr STATE ‘0’ Rsp Hdr STATE ‘0’ Rsp Hdr STATE ‘0’
1 byte Fixed size 2 byte 1 byte Fixed size 2 byte 1 byte Fixed size 2 byte
Cmd Hdr:
‘0’ Write Command
Address, count, CRC DATA Hdr DATA CRC16 DATA Hdr DATA CRC16 DATA Hdr DATA CRC16 ‘0’
112 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
2
17.3.1 TX (Send Request)
First step in hif_send() API is to wake up the chip:
sint8 nm_clkless_wake(void)
{
ret = nm_read_reg_with_ret(0x1, ®);
/* Set bit 1 */
ret = nm_write_reg(0x1, reg | (1 << 1));
// Check the clock status
ret = nm_read_reg_with_ret(clk_status_reg_adr, &clk_status_reg);
// Tell Firmware that Host waked up the chip
ret = nm_write_reg(WAKE_REG, WAKE_VALUE);
return ret;
}
ATWINC acknowledges the command by sending three bytes [C4] [0] [F3].
Then the ATWINC chip sends the value of the register 0x01 which equals 0x01.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 113 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
3
Command CMD_INTERNAL_WRITE: C3 /* internal register write */
BYTE [0] = CMD_INTERNAL_WRITE
BYTE [1] = address >> 8; /* address = 0x01 */
BYTE [1] |= (1 << 7); /* clockless register */
BYTE [2] = address;
BYTE [3] = u32data >> 24; /* Data = 0x03 */
BYTE [4] = u32data >> 16;
BYTE [5] = u32data >> 8;
BYTE [6] = u32data;
ATWINC acknowledges the command by sending three bytes [C4] [0] [F3].
114 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
4
Then ATWINC chip sends the value of the register 0x01 which equals 0x07.
The chip acknowledges the command by sending two bytes [C9] [0].
At this point, HIF finishes executing the clockless wakeup of the ATWINC chip.
The HIF layer Prepares and Sets the HIF layer header to NMI_STATE_REG register (4 | 8 Byte header
describing the packet to be sent).
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 115 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
5
Set BIT [1] of WIFI_HOST_RCV_CTRL_2 register to raise an interrupt to the chip.
sint8 hif_send(uint8 u8Gid,uint8 u8Opcode,uint8 *pu8CtrlBuf,uint16 u16CtrlBufSize,
uint8 *pu8DataBuf,uint16 u16DataSize, uint16 u16DataOffset)
{
volatile tstrHifHdr strHif;
volatile uint32 reg;
strHif.u8Opcode = u8Opcode&(~NBIT7);
strHif.u8Gid = u8Gid;
strHif.u16Length = M2M_HIF_HDR_OFFSET;
strHif.u16Length += u16CtrlBufSize;
ret = nm_clkless_wake();
reg = 0UL;
reg |= (uint32)u8Gid;
reg |= ((uint32)u8Opcode<<8);
reg |= ((uint32)strHif.u16Length<<16);
ret = nm_write_reg(NMI_STATE_REG,reg);
reg = 0;
reg |= (1<<1);
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_2, reg);
116 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
6
Command CMD_SINGLE_WRITE:0XC9 /* single word write */
BYTE [0] = CMD_SINGLE_WRITE
BYTE [1] = address >> 16; /* WIFI_HOST_RCV_CTRL_2address = 0x1087*/
BYTE [2] = address >> 8;
BYTE [3] = address;
BYTE [4] = u32data >> 24; /* Data = 0x02 */
BYTE [5] = u32data >> 16;
BYTE [6] = u32data >> 8;
BYTE [7] = u32data;
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 117 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
7
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip send the value of the register 0x1078 which equals 0x00.
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
118 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
8
Then the ATWINC chip send the value of the register 0x1504 which equals 0x037AA0.
ATWINC acknowledges the command by sending three bytes [C7] [0] [F3].
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 119 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
1
9
The HIF layer writes the Data.
HIF writes the Control Buffer data (part of the framing of the request).
if (pu8CtrlBuf != NULL)
{
ret = nm_write_block(u32CurrAddr, pu8CtrlBuf, u16CtrlBufSize);
if(M2M_SUCCESS != ret) goto ERR1;
u32CurrAddr += u16CtrlBufSize;
}
120 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
0
ATWINC acknowledges the command by sending three bytes [C7] [0] [F3].
Finally, HIF finished writing the request data to memory and is going to interrupt the chip announcing that host
TX is done.
reg = dma_addr << 2;
reg |= (1 << 1);
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_3, reg);
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 121 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
1
ATWINC acknowledges the command by sending two bytes [C9] [0].
122 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
2
ATWINC acknowledges the command by sending two bytes [C9] [0].
ATWINC acknowledges the command by sending three bytes [C4] [0] [F3].
Then the ATWINC chip sends the value of the register 0x01 which equals 0x03.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 123 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
3
BYTE [3] = u32data >> 24; /* Data = 0x01 */
BYTE [4] = u32data >> 16;
BYTE [5] = u32data >> 8;
BYTE [6] = u32data;
The ATWINC chip acknowledges the command by sending two bytes [C3] [0].
At this point, the HIF layer has finished posting the scan Wi-Fi request to the ATWINC chip and the request is
being processed by the chip.
124 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
4
BYTE [3] = 0x00;
ATWINC acknowledges the command by sending three bytes [C4] [0] [F3].
Then the ATWINC chip sends the value of the register 0x01 which equals 0x01.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 125 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
5
Command CMD_INTERNAL_READ: 0xC4 /* internal register read */
BYTE [0] = CMD_INTERNAL_READ
BYTE [1] = address >> 8; /* address = 0x0F
*/
BYTE [1] |= (1 << 7); /* clockless register */
BYTE [2] = address;
BYTE [3] = 0x00;
ATWINC acknowledges the command by sending three bytes [C4] [0] [F3].
Then the ATWINC chip sends the value of the register 0x01 which equals 0x07.
126 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
6
The chip acknowledges the command by sending two bytes [C9] [0].
Read register WIFI_HOST_RCV_CTRL_0 to check if there is new interrupt, and if so, clear it (as it will be
handled now).
static sint8 hif_isr(void)
{
sint8 ret ;
uint32 reg;
volatile tstrHifHdr strHif;
ret = hif_chip_wake();
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0, ®);
if(reg & 0x1) /* New interrupt has been received */
{
uint16 size;
/*Clearing RX interrupt*/
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0,®);
reg &= ~(1<<0);
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_0,reg);
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 127 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
7
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip sends the value of the register 0x1070 which equals 0x31.
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
128 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
8
Then the ATWINC chip sends the value of the register 0x1070 which equals 0x31.
The chip acknowledges the command by sending two bytes [C9] [0].
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 129 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
2
9
Command CMD_SINGLE_READ: 0xCA /* single word (4 bytes) read */
BYTE [0] = CMD_SINGLE_READ
BYTE [1] = address >> 16; /* WIFI_HOST_RCV_CTRL_0 address = 0x1070 */
BYTE [2] = address >> 8;
BYTE [3] = address;
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip sends the value of the register 0x1070 which equals 0x30.
130 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
0
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip sends the value of the register 0x1078 which equals 0x037AB0.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 131 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
1
ATWINC acknowledges the command by sending three bytes [C8] [0] [F3].
HIF then calls the appropriate handler according to the hif header received which tries to receive the Response
data payload. (Note that hif_receive ( ) obtains some data again for checks.)
sint8 hif_receive(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz, uint8 isDone)
{
uint32 address, reg;
uint16 size;
sint8 ret = M2M_SUCCESS;
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0,®);
size = (uint16)((reg >> 2) & 0xfff);
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_1,&address);
/* Receive the payload */
ret = nm_read_block(u32Addr, pu8Buf, u16Sz);
132 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
2
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip sends the value of the register 0x1070 which equals 0x30.
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip sends the value of the register 0x1078 which equals 0x037AB0.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 133 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
3
Command CMD_DMA_EXT_READ: C8 /* dma extended read */
BYTE [0] = CMD_DMA_EXT_READ
BYTE [1] = address >> 16; /* address = 0x037AB8*/
BYTE [2] = address >> 8;
BYTE [3] = address;
BYTE [4] = size >> 16;
BYTE [5] = size >>;
BYTE [6] = size;
ATWINC acknowledges the command by sending three bytes [C8] [0] [F3].
134 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
4
Now, after HIF layer received the response, it interrupts the chip to announce host RX is done.
static sint8 hif_set_rx_done(void)
{
uint32 reg;
sint8 ret = M2M_SUCCESS;
ret = nm_read_reg_with_ret(WIFI_HOST_RCV_CTRL_0,®);
/* Set RX Done */
reg |= (1<<1);
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_0,reg);
}
ATWINC acknowledges the command by sending three bytes [CA] [0] [F3].
Then the ATWINC chip sends the value of the register 0x1070 which equals 0x30.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 135 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
5
The chip acknowledges the command by sending two bytes [C9] [0].
The HIF layer allows the chip to enter sleep mode again.
sint8 hif_chip_sleep(void)
{
sint8 ret = M2M_SUCCESS;
uint32 reg = 0;
ret = nm_write_reg(WAKE_REG, SLEEP_VALUE);
/* Clear bit 1 */
ret = nm_read_reg_with_ret(0x1, ®);
if(reg&0x2)
{
reg &=~(1 << 1);
ret = nm_write_reg(0x1, reg);
}
}
136 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
6
ATWINC acknowledges the command by sending two bytes [C9] [0].
ATWINC acknowledges the command by sending three bytes [C4] [0] [F3].
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 137 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
7
Then the ATWINC chip sends the value of the register 0x01 which equals 0x03.
The ATWINC chip acknowledges the command by sending two bytes [C3] [0].
Scan Wi-Fi request has been sent to the ATWINC chip and the response is sent to the host successfully.
138 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
8
Appendix A. How to Generate Certificates
A.1 Introduction
This chapter explains the required procedures to create and sign custom certificates using OpenSSL, to use
this guide you must install OpenSSL to your machine.
OpenSSL is an open-source implementation of the SSL and TLS protocols. The core library, written in the C
programming language, implements basic cryptographic functions and provides various utility functions.
OpenSSL can be found here: https://www.openssl.org
A.2 Steps
After installing OpenSSL, open a CMD prompt and navigate to the directory where OpenSSL was installed
(e.g.: C:\OpenSSL-Win64\bin).
First you need to generate a key for our The CA (certification authority). To generate a 4096-bit long
RSA (will create a new file CA_KEY.key to store the random key):
CMD: openssl genrsa -out CA_KEY.key 4096
Next, create your self-signed root CA certificate CA_CERT.crt; you’ll need to provide some data for your
Root certificate.
CMD: openssl req -new -x509 -days 1826 -key CA_KEY.key -out CA_CERT.crt
Next step is to create the custom certificate which will be signed by the CA root certificate created earlier.
First, generate the key:
CMD: openssl genrsa -out Custom.key 4096
Using the key generated above, you should generate a certificate request file (csr):
CMD: openssl req -new -key Custom.key -out CertReq.csr
Finally: process the request for the certificate and get it signed by the root CA.
CMD: openssl x509 -req -days 730 -in CertReq.csr -CA CA_CERT.crt -CAkey
CA_KEY.key -set_serial 01 -out CustomCert.crt
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 139 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
3
9
Appendix B. X.509 Certificate Format and Conversion
B.1 Introduction
The most known encodings for the X.509 digital certificates are PEM and DER formats.
The PEM format is base64 encoding of the DER enclosed with between
"-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----".
140 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
0
Appendix C. How to Download the Certificate into the ATWINC
C.1 Overview
The ATWINC save the certificate inside the SPI flash in 4K sector (so the maximum size of all certificates in
flash should be less than 4K).
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 141 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
1
Appendix D. Firmware Image Downloader
The Firmware Downloader script use the EDBG SAMD21/W25 UART as the main interface.
1. Downloads the serial bridge application on the SAMD21/W25 using the Atmel atprogram.exe.
2. After downloading, the application will initialize the ATWINC in download mode and start listen on EDBG
UART for UART commands.
3. The application will convert the UART commands to SPI commands.
4. The script will wait a couple of seconds until the application initialization finishes, then executes the
firmware downloader, and the gain builder given the UART argument and the firmware/gain sheets path
argument.
142 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
2
2. From the list on the left hand side, select (click on) “Device Manager”. The “View” will change to
something very similar to the following image:
3. In the Right Hand Panel, select (double click) Ports (COM and LPT). The “View” will change to
something like the following (actual info shown depends on your PC).
In the below image, the boards are connected and using COM15, and COM26:
Make sure the EDBG port is not in use at Atmel Studio or with any other serial monitor
before downloading. Also make sure that the firmware bin file is located at “./firm-
ware/m2m_aio.bin” and gain files are located at “./Tools/gain_builder/gain_sheets/”.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 143 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
3
144 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
4
Appendix E. Gain Settings Builder
E.1 Introduction
Gain setting values, are those values used by RF with different rates to configure transmission power.
This appendix helps to calculate these values and store them in Flash to use them otherwise default values will
be used.
E.3.1 Method 1
Replace the data of samd21_gain_setting.csv file in the project’s folder with the new data where the file’s
location is the default (./Tools/gain_builder/gain_sheets/)
Then run your application. It will calculate and store you data in Flash.
E.3.2 Method 2
If you have a different file with data in a different path, then open “gain_build_and_download.bat” patch
file and update it with the new path and file like:
-fw_path ../gain_sheets/samd21_gain_setting.csv → -fw_path c:/gain_values.csv
Then run your application by double click on modified patch file
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 145 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
5
– The .csv file must be sorted based on gain rates like the templates
– There are two different buses to run your app I2C or UART
– Your file must have 15 columns and 21 Rows for all channels such as the following
template:
ch 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1
2
5.5
11
6
9
12
18 Insert your values here
24
36
48
54
mcs0
mcs1
mcs2
mcs3
mcs4
mcs5
mcs6
mcs7
146 ATWINC3400
1 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
6
Appendix F. Revision History
Doc Rev. Date Comments
42566A 04/2016 Initial document release.
ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE] 147 1
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
7
Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 │ www.atmel.com
Atmel®, Atmel logo and combinations thereof, AVR®, Enabling Unlimited Possibilities®, and others are registered trademarks or trademarks of Atmel Corporation in
U.S. and other countries. ARM®, ARM Connected® logo, and others are the registered trademarks or trademarks of ARM Ltd. Windows® is a registered trademark of
Microsoft Corporation in U.S. and or other countries. Other terms and product names may be trademarks of others.
DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellect ual property right
is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL T ERMS AND CONDITIONS OF SALES LOCATED ON THE
ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNE SS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT
SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LI MITATION, DAMAGES
FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accurac y or completeness of the contents of this
document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information
contained herein. Unless specifically provided otherwise, Atmel products a re not suitable for, and shall not be used in, automotive applications. Atmel products are not intended,
authorized, or warranted for use as components in applications intended to support or sustain life.
SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where
the failure of such products would reasonably be expected to result in significant personal injury or death (“Safety -Critical Applications”) without an Atmel officer's specific written consent.
Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation o f nuclear facilities and weapons systems. Atmel
148 ATWINC3400 Wi-Fi/BLE Network Controller Software Design Guide [USER GUIDE]
products are not designed nor intended for use in military or aerospace applications or environments unless specifically designated by Atmel as mil itary-grade. Atmel products are not
1
designed nor intended for use in automotive applications unless specifically designated by Atme l as automotive-grade.
Atmel-42566A-ATWINC3400-WiFi-BLE-Network-Controller-Software-Design-Guide_UserGuide_042016
4
8