WIFI_API_20150524e

Files at this revision

API Documentation at this revision

Comitter:
Marcomissyou
Date:
Tue Jun 09 06:04:13 2015 +0000
Commit message:
update to WIFI_API_20150524e

Changed in this revision

EthernetInterface/EthernetInterface.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/Endpoint.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/Socket.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/TCPSocketConnection.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/TCPSocketServer.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/UDPSocket.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/endpoint.o Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/socket.o Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/tcpsocketconnection.o Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/tcpsocketserver.o Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/Socket/udpsocket.o Show annotated file Show diff for this revision Revisions of this file
EthernetInterface/ethernetinterface.o Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
WIFIDevice.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/cyntec_dns.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/cyntec_dns.o Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_config.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_spi.o Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_type.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_wifi_adapter.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_wifi_adapter.o Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_wlan.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_wlan.o Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/nmi_wlan_if.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/socket_internal.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/socket_nmc.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/socket_nmc.o Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nmc/strc.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/boards.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/nrf_ecb.c Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/nrf_ecb.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/nrf_gpio.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/pca10001.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/simple_uart.c Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/simple_uart.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/spi_flash.c Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/spi_flash.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/spi_master.c Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/spi_master.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/nordic/spi_master_config.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/wifi_api.h Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/wifi_api.o Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/wifi_core.c Show annotated file Show diff for this revision Revisions of this file
WIFI_Driver/wifi_core.h Show annotated file Show diff for this revision Revisions of this file
wifidevice.o Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface/EthernetInterface.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,98 @@
+/* EthernetInterface.h */
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ 
+#ifndef ETHERNETINTERFACE_H_
+#define ETHERNETINTERFACE_H_
+/*Tsungta
+#if !defined(TARGET_LPC1768) && !defined(TARGET_LPC4088) && !defined(TARGET_K64F) && !defined(TARGET_RZ_A1H)
+#error The Ethernet Interface library is not supported on this target
+#endif
+
+#include "rtos.h"
+#include "lwip/netif.h"
+*/
+ /** Interface using Ethernet to connect to an IP-based network
+ *
+ */
+class EthernetInterface {
+public:
+  /** Initialize the interface with DHCP.
+  * Initialize the interface and configure it to use DHCP (no connection at this point).
+  * \return 0 on success, a negative number on failure
+  */
+  static int init(); //With DHCP
+
+  /** Initialize the interface with a static IP address.
+  * Initialize the interface and configure it with the following static configuration (no connection at this point).
+  * \param ip the IP address to use
+  * \param mask the IP address mask
+  * \param gateway the gateway to use
+  * \return 0 on success, a negative number on failure
+  */
+  static int init(const char* ip, const char* mask, const char* gateway);
+
+  /** Connect
+  * Bring the interface up, start DHCP if needed.
+  * \param   timeout_ms  timeout in ms (default: (15)s).
+  * \return 0 on success, a negative number on failure
+  */
+  static int connect(unsigned int timeout_ms=35000);
+  
+  /** Disconnect
+  * Bring the interface down
+  * \return 0 on success, a negative number on failure
+  */
+  static int disconnect();
+  
+  /** Get the MAC address of your Ethernet interface
+   * \return a pointer to a string containing the MAC address
+   */
+  static char* getMACAddress();
+  
+  /** Get the IP address of your Ethernet interface
+   * \return a pointer to a string containing the IP address
+   */
+  static char* getIPAddress();
+
+  /** Get the Gateway address of your Ethernet interface
+   * \return a pointer to a string containing the Gateway address
+   */
+  static char* getGateway();
+
+  /** Get the Network mask of your Ethernet interface
+   * \return a pointer to a string containing the Network mask
+   */
+  static char* getNetworkMask();
+};
+
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+
+#include "Endpoint.h"
+#include "UDPSocket.h"
+
+// following are added by Tsungta
+#include "stdint.h"
+#include "string.h"
+typedef struct ip_addr ip_addr_t;
+struct ip_addr {
+  uint32_t addr;
+};
+
+#endif /* ETHERNETINTERFACE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface/Socket/Endpoint.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,84 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef ENDPOINT_H
+#define ENDPOINT_H
+
+//following are added by Tsungta
+#include "stdint.h"
+/* For compatibility with BSD code */
+struct in_addr {
+  uint32_t s_addr;
+};
+
+struct sockaddr_in {
+  uint8_t sin_len;
+  uint8_t sin_family;
+  uint16_t sin_port;
+  struct in_addr sin_addr;
+  char sin_zero[8];
+};
+//Tsungta
+class UDPSocket;
+
+/*
+IP Endpoint (address, port)
+*/
+class Endpoint {
+    friend class UDPSocket;
+
+private:
+    char UDP_host[15];
+    int UDP_port;
+
+public:
+    /* IP Endpoint (address, port)
+     */
+    Endpoint(void);
+    
+    ~Endpoint(void);
+    
+    /* Reset the address of this endpoint
+     */
+    void reset_address(void);
+    
+    /* Set the address of this endpoint
+    \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
+    \param port The endpoint port
+    \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
+     */
+    int  set_address(const char* host, const int port);
+    
+    /* Get the IP address of this endpoint
+    \return The IP address of this endpoint.
+     */
+    char* get_address(void);
+    
+    /* Get the port of this endpoint
+    \return The port of this endpoint
+     */
+    int get_port(void);
+
+protected:
+    char _ipAddress[17];
+    struct sockaddr_in _remoteHost;
+
+};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface/Socket/Socket.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,118 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef SOCKET_H_
+#define SOCKET_H_
+
+//#include "lwip/sockets.h"
+//#include "lwip/netdb.h"
+
+//following are added by Tsungta
+#include <stddef.h> /* for size_t */ 
+#include "stdint.h"
+#define socklen_t uint32_t
+//Tsungta
+
+struct timeval {
+  long    tv_sec;         /* seconds */
+  long    tv_usec;        /* and microseconds */
+};
+
+//DNS
+inline struct hostent *gethostbyname(const char *name) {
+//  return lwip_gethostbyname(name);
+        return 0;
+}
+
+inline int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) {
+//  return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
+        return 0;
+    
+}
+
+class TimeInterval;
+
+/** Socket file descriptor and select wrapper
+  */
+class Socket {
+public:
+    /** Socket
+     */
+    Socket();
+    
+    /** Set blocking or non-blocking mode of the socket and a timeout on
+        blocking socket operations
+    \param blocking  true for blocking mode, false for non-blocking mode.
+    \param timeout   timeout in ms [Default: (1500)ms].
+    */
+    void set_blocking(bool blocking, unsigned int timeout=1500);
+    
+//    /** Set socket options
+//    \param level     stack level (see: lwip/sockets.h)
+//    \param optname   option ID
+//    \param optval    option value
+//    \param socklen_t length of the option value
+//    \return 0 on success, -1 on failure
+//    */
+//    int set_option(int level, int optname, const void *optval, socklen_t optlen);
+//    
+//    /** Get socket options
+//        \param level     stack level (see: lwip/sockets.h)
+//        \param optname   option ID
+//        \param optval    buffer pointer where to write the option value
+//        \param socklen_t length of the option value
+//        \return 0 on success, -1 on failure
+//        */
+//    int get_option(int level, int optname, void *optval, socklen_t *optlen);
+    
+    /** Close the socket
+        \param shutdown   free the left-over data in message queues
+     */
+    int close(bool shutdown=true);
+    
+    ~Socket();
+    
+protected:
+    int _sock_fd;
+    int init_socket(int type);
+    
+    int wait_readable(TimeInterval& timeout);
+    int wait_writable(TimeInterval& timeout);
+    
+    bool _blocking;
+    unsigned int _timeout;
+    
+private:
+    int select(struct timeval *timeout, bool read, bool write);
+};
+
+/** Time interval class used to specify timeouts
+ */
+class TimeInterval {
+    friend class Socket;
+
+public:
+    /** Time Interval
+     \param ms time interval expressed in milliseconds
+      */
+    TimeInterval(unsigned int ms);
+    
+private:
+    struct timeval _time;
+};
+
+#endif /* SOCKET_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface/Socket/TCPSocketConnection.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,81 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TCPSOCKET_H
+#define TCPSOCKET_H
+
+#include "Socket.h"
+#include "Endpoint.h"
+
+/**
+TCP socket connection
+*/
+class TCPSocketConnection : public Socket, public Endpoint {
+    friend class TCPSocketServer;
+    
+public:
+    /** TCP socket connection
+    */
+    TCPSocketConnection();
+    
+    /** Connects this TCP socket to the server
+    \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
+    \param port The host's port to connect to.
+    \return 0 on success, -1 on failure.
+    */
+    int connect(const char* host, const int port);
+    
+    /** Check if the socket is connected
+    \return true if connected, false otherwise.
+    */
+    bool is_connected(void);
+    
+    /** Send data to the remote host.
+    \param data The buffer to send to the host.
+    \param length The length of the buffer to send.
+    \return the number of written bytes on success (>=0) or -1 on failure
+     */
+    int send(char* data, int length);
+    
+    /** Send all the data to the remote host.
+    \param data The buffer to send to the host.
+    \param length The length of the buffer to send.
+    \return the number of written bytes on success (>=0) or -1 on failure
+    */
+    int send_all(char* data, int length);
+    
+    /** Receive data from the remote host.
+    \param data The buffer in which to store the data received from the host.
+    \param length The maximum length of the buffer.
+    \return the number of received bytes on success (>=0) or -1 on failure
+     */
+    int receive(char* data, int length);
+    
+    /** Receive all the data from the remote host.
+    \param data The buffer in which to store the data received from the host.
+    \param length The maximum length of the buffer.
+    \return the number of received bytes on success (>=0) or -1 on failure
+    */
+    int receive_all(char* data, int length);
+
+private:
+    bool _is_connected;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface/Socket/TCPSocketServer.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,52 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef TCPSOCKETSERVER_H
+#define TCPSOCKETSERVER_H
+
+#include "Socket.h"
+#include "TCPSocketConnection.h"
+
+/** TCP Server.
+  */
+class TCPSocketServer : public Socket {
+  public:
+    /** Instantiate a TCP Server.
+    */
+    TCPSocketServer();
+    
+    /** Bind a socket to a specific port.
+    \param port The port to listen for incoming connections on.
+    \return 0 on success, -1 on failure.
+    */
+    int bind(int port);
+    
+    /** Start listening for incoming connections.
+    \param backlog number of pending connections that can be queued up at any
+                   one time [Default: 1].
+    \return 0 on success, -1 on failure.
+    */
+    int listen(int backlog=1);
+    
+    /** Accept a new connection.
+    \param connection A TCPSocketConnection instance that will handle the incoming connection.
+    \return 0 on success, -1 on failure.
+    */
+    int accept(TCPSocketConnection& connection);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface/Socket/UDPSocket.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef UDPSOCKET_H
+#define UDPSOCKET_H
+
+#include "Socket.h"
+#include "Endpoint.h"
+
+/**
+UDP Socket
+*/
+class UDPSocket : public Socket {
+
+public:
+    /** Instantiate an UDP Socket.
+    */
+    UDPSocket();
+    
+    /** Init the UDP Client Socket without binding it to any specific port
+    \return 0 on success, -1 on failure.
+    */
+    int init(void);
+    
+    /** Bind a UDP Server Socket to a specific port
+    \param port The port to listen for incoming connections on
+    \return 0 on success, -1 on failure.
+    */
+    int bind(int port);
+    
+//    /** Join the multicast group at the given address
+//    \param address  The address of the multicast group
+//    \return 0 on success, -1 on failure.
+//    */
+//    int join_multicast_group(const char* address);
+    
+    /** Set the socket in broadcasting mode
+    \return 0 on success, -1 on failure.
+    */
+    int set_broadcasting(bool broadcast=true);
+    
+    /** Send a packet to a remote endpoint
+    \param remote   The remote endpoint
+    \param packet   The packet to be sent
+    \param length   The length of the packet to be sent
+    \return the number of written bytes on success (>=0) or -1 on failure
+    */
+    int sendTo(Endpoint &remote, char *packet, int length);
+    
+    /** Receive a packet from a remote endpoint
+    \param remote   The remote endpoint
+    \param buffer   The buffer for storing the incoming packet data. If a packet
+           is too long to fit in the supplied buffer, excess bytes are discarded
+    \param length   The length of the buffer
+    \return the number of received bytes on success (>=0) or -1 on failure
+    */
+    int receiveFrom(Endpoint &remote, char *buffer, int length);
+};
+
+#endif
Binary file EthernetInterface/Socket/endpoint.o has changed
Binary file EthernetInterface/Socket/socket.o has changed
Binary file EthernetInterface/Socket/tcpsocketconnection.o has changed
Binary file EthernetInterface/Socket/tcpsocketserver.o has changed
Binary file EthernetInterface/Socket/udpsocket.o has changed
Binary file EthernetInterface/ethernetinterface.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,42 @@
+# NNN40 WI-FI SDK version 20150524, release at 2015/5/24
+This is the export repo for the WIFI_API provided by Delta Electronics, Inc.
+
+# Fixed bug in previous version
+* Fix wifi inti fail (timing issue) issue
+* Change type of ap_ssid and ap_pw to char*
+* Command getNetworkMask() and getGateway()  
+* Bug fix: is_connect() return 0 when close() function is called
+* Bug fix: listen() return 0
+* Change TCP ERROR retry to 3 times
+* WIFI SPI interface change to SPI0
+* WIFI MAC Address readout from Flash
+* UART conflict bug fix 
+* Fix is_connect return error when ethernet is disconnected
+* Set TCP maximum payload to 512 bytes
+* Set UDP maximum payload to 256 bytes
+* Fix UDP send_to length issue
+* Fix send_to return error when client socket is colsed
+* Set IP 255.255.255.255 as reserved
+* Fix Switch return error when ethernet is init
+* Fix bug in spi_flash.c for data access
+* Fix bind return error 
+
+# Fixed bug in this version
+* Support DNS client for TCP/UDP
+* Fast AP re-connection is performed automatically, user can call EthernetInterface.disconnect() to have lowest power consumption of 4uA, then call init and connected to previous AP for less than 4 sec
+
+# Supported functionalities 
+Currently supported  functionalities include:
+* IEEE 802.11 b/g/n connectivity
+* Station (STA) infrastructure mode
+* WEP/WPA/WPA2 security
+* DHCP Client and Static IPv4 addressing
+* TCP Server/Client
+* UDP Server/Client
+
+# Getting Started 
+This WIFI API is meant to be used on Delta NNN40 EVB. 
+A good starting point are these pages:
+* [WI-FI SDK User Guide](document come with WI-FI SDK deliver) for system overview, APIs summary and sample code
+* [EthernetInterface - Handbook](http://developer.mbed.org/handbook/Ethernet-Interface) a simple API that you will need to connect to the internet.
+* [Socket - Handbook](http://developer.mbed.org/handbook/Socket) a simple and consistent way to communicate using bsd-like TCP and UDP sockets over WI-FI 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFIDevice.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,73 @@
+#ifndef WIFIDEVICE_H_
+#define WIFIDEVICE_H_
+
+#include "nmi_wlan_if.h"
+#include "nmi_wlan.h"
+
+ /** Interface using WI-FI to connect to Ethernet
+ *
+ */
+class WIFIDevice {
+public:
+
+  /** Set WIFI in sleep mode.
+  * Disable WIFI and set into sleep mode to conserve energy (no WIFI function is available at this point).
+  * \return 0 on success, a negative number on failure
+  */
+  int sleep(void);
+
+  /** Set the position of embedded RF switch.
+  * Set the position of RF switch between WIFI and BLE.
+  * \param position set 1 on WIFI to use, set 0 on BLE to use.
+  * \return 0 on success, a negative number on failure
+  */
+  int setSwitch(int position);
+  
+  /** Get the position of embedded RF switch.
+  * Get the current position of RF switch
+  * \return get 1 on WIFI to use, get 0 on BLE to use
+  */
+  int getSwitch(void);
+    
+//  /** Perform one time WIFI scan.
+//  * Scan for available access point on all channels.
+//  * \return number of scanned WIFI access point
+//  */
+//  int oneTimeScan(void);
+//
+//  /** Get the scanned access point information.
+//  * Get the scanned associated access point information table on least oneTimeScan.
+//  * \param index query the information of result table in index number [0~19]
+//  * \param SSID access point SSID name on query index
+//  * \param RSSI access point RSSI (Received Signal Strength Indicator) on query index
+//  * \param security access point security type on query index, get 0 on no security, 1 on WEP, 2 on WPA, 3 on WPA2 
+//  * \return 0 on success, a negative number on failure when empty
+//  */
+//  int getScanResult(uint8_t index, uint8_t* SSID, int* RSSI, uint8_t security);
+    
+  /** Set network connection in priority.
+  * Set SSID, password and priority to connect.
+  * \param SSID name of access point to connect
+  * \param PW password of the given SSID
+  * \param priority range from 0 to 2, set 0 for the highest priority
+  */
+  void setNetwork(char* SSID, char* PW, uint8_t priority);
+
+//  /** Get the status of embedded WIFI chipset.
+//  * Get the current status of embedded WIFI chipset
+//  * \return get 1 on WIFI to use, get 0 on BLE to use
+//  */
+//  int getStatus(void);
+  
+//  /** Set WIFI output power.
+//  * Set WIFI output power level 
+//  * \param output power level
+//  * \return 0 on success, a negative number on failure
+//  */
+//  int setTxPower(uint8_t powerIndex);
+  
+};
+
+//#include "EthernetInterface.h"
+
+#endif /* WIFIDEVICE_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/cyntec_dns.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,150 @@
+#ifndef CYNTEC_DNS_H
+#define CYNTEC_DNS_H
+
+#include <stdint.h>
+
+class DnsClient
+{
+private:
+
+//    class Hander {
+//    private:
+
+//        uint16_t *handerMsg = 0;
+//        uint16_t *transactionId = 0;  //A 16 bit identifier assigned by the program that generates any kind of query.
+//        uint16_t *handerSecondRow = 0;
+//        uint16_t *qdCount = 0;
+//        uint16_t *anCount = 0;
+//        uint16_t *nsCount = 0;
+//        uint16_t *arCount = 0;
+
+//    public:
+//        Hander();
+//        Hander(uint16_t *msg);
+//        uint16_t getTransactionId();
+//        uint8_t getQueryOrRespone();
+//        uint8_t getOpCode();
+//        uint8_t getAuthoritativeAnswer();
+//        uint8_t getTrunCation();
+//        uint8_t getRecursionDesired();
+//        uint8_t getRecursionAvailable();
+//        uint8_t getZ();
+//        uint8_t getResponseCode();
+//        uint16_t *getQdCountget();
+//        uint16_t *getAnCount();
+//        uint16_t *getNsCount();
+//        uint16_t *getArCount();
+//    };
+
+//    class Question {
+//    private:
+//        Question(char *msg);
+//        char *questionMsg = 0;
+//        char *QName = 0; // a domain name represented as a sequence of labels.
+//        char *QType[2]; //a two octet code which specifies the type of the query.
+//        char *QClass[2]; //a two octet code that specifies the class of the query.
+//    public:
+//        const char* getQName();
+//        const char* getQType();
+//        const char* getQClass();
+//    };
+
+//    class RRecord{
+//    private:
+//        RRecord(char *msg);
+//        char *rRecordMsg;
+//        char *RRName; // a domain name to which this resource record pertains.
+//        char *RRType[2]; //two octets containing one of the RR type codes
+//        char *RRClass[2]; //two octets which specify the class of the data in the RDATA field.
+//        char *RRTll[4]; // a domain name represented as a sequence of labels.
+//        char *RdLength[2]; //an unsigned 16 bit integer that specifies the length in octets of the RDATA field.
+//        char *RData[2]; //a variable length string of octets that describes the resource.
+//    public:
+//        const char* getRRName();
+//        const char* getRRType();
+//        const char* getRRClass();
+//        const char* getRRTll();
+//        const char* getRdLength();
+//        const char* getRData();
+//    };
+
+    const char *queryMsg;
+    char *queryEcMsg;
+    short queryId;
+    int querySize;
+
+    char *answerMsg;
+    short answerId;
+    int iPCounters;
+    char **answerIPs;
+//    Hander *ptrHander = 0;
+//    Question *ptrQuestion = 0;
+//    RRecord *ptrRRcoed = 0;
+
+    /**
+     *		QR (1 bit)
+     * 	query (0), or a response (1).
+     *
+     *		OpCode (4 bits)
+     *	0 a standard query (QUERY)
+     *	1 an inverse query (IQUERY)
+     *	2 a server status request (STATUS)
+     *	3-15 reserved for future use
+     *
+     * 		Authoritative Answer (1 bit)
+     * 	this bit is valid in responses,
+     * 	and specifies that the responding name server is an
+     * 	authority for the domain name in question section.
+     *
+     *		TrunCation (1 bit)
+     *	specifies that this message was truncated
+     * 	due to length greater than that permitted on the
+     * 	transmission channel.
+     *
+     *		Recursion Desired (1 bit)
+     *	this bit may be set in a query and is copied into the response.
+     *
+     * 		Recursion Available (1 bit)
+     * 	this be is set or cleared in a
+     * 	response, and denotes whether recursive query support is
+     * 	available in the name server.
+     *
+     * 		Z (3 bits)
+     * 	 Reserved for future use.
+     *
+     *	Response code (4 bits)
+     * 	this 4 bit field is set as part of responses.
+     */
+
+    char *queryEncode();
+    void queryAddHeader(char *startChar);
+    void queryAddQuestion(char *startChar);
+//    void queryAddRRFrom(char *dst);
+
+    short parseAnswerId(char *answerMsg);
+    char **parseAnswerIPs(char *answerMsg);
+
+
+public:
+    DnsClient(const char *msg);
+    ~DnsClient();
+
+    int getQuerySize();
+    char *getQueryEncode();
+    short getQueryID();
+
+    void *answerDecode(char *msg);
+    short getAnswerId();
+    int getIpCounters();
+    const char** getAnswerIPs();
+
+//    void *responseDecode();
+//    Hander *getHander();
+//    Question *getQuestion();
+//    RRecord *getRRecord();
+
+};
+
+#endif // CYNTEC_DNS_H
+
+
Binary file WIFI_Driver/nmc/cyntec_dns.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/nmi_config.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,16 @@
+#ifndef __NMI_CONFIG_H__
+#define __NMI_CONFIG_H__
+
+
+#define NMI_WLAN_DRIVER_DBG
+#define NMI_WLAN_MGMT_DBG
+
+
+typedef struct{
+	uint8_t	*au8Ssid;
+	uint8_t	*pu8AuthCred;	
+	uint8_t	u8AuthType;		
+} tstrM2mAp;
+
+
+#endif /* __NMI_CONFIG_H__ */
Binary file WIFI_Driver/nmc/nmi_spi.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/nmi_type.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) Newport Media Inc.  All rights reserved.
+//
+// Module Name:  nmi_type.h
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef NMI_TYPE_H
+#define NMI_TYPE_H
+
+/********************************************
+
+	Type Defines
+
+********************************************/
+
+#if defined(_LINUX_)
+
+#include <asm/types.h>
+
+#else
+
+typedef unsigned char u8;
+typedef signed char s8;
+typedef unsigned short u16;
+typedef short s16;
+typedef unsigned int u32;
+typedef int s32;
+
+
+#endif 
+
+
+#include <stdint.h>//Ryan
+#include <stdio.h>//Ryan
+#include <stdarg.h>//Ryan
+#include <string.h>//Ryan
+#include <stdlib.h>//Ryan
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/nmi_wifi_adapter.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,638 @@
+/*
+ * wpa_supplicant/hostapd / OS specific functions
+ * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#ifndef __NMI_WIFI_ADAPER_H__
+#define __NMI_WIFI_ADAPER_H__
+
+#include <stddef.h>
+#include <stdarg.h>
+
+//#include "os_api.h"
+
+//#include "wifisupp_api.h"   //ksong 2012.8.28
+
+#include <stdbool.h>
+#include <stdint.h>
+    /* exact-width signed integer types */
+typedef   signed          char int8;
+typedef   signed short     int int16;
+typedef   signed           int int32;
+typedef   signed       __int64 int64;
+
+typedef   signed          char sint8;
+typedef   signed short     int sint16;
+typedef   signed           int sint32;
+typedef   signed       __int64 sint64;
+
+    /* exact-width unsigned integer types */
+typedef unsigned          char uint8;
+typedef unsigned short     int uint16;
+typedef unsigned           int uint32;
+typedef unsigned       __int64 uint64;
+
+//#include "nmi_wlan_if.h"	command by Tsungta
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************/
+//#define GPIO_WIFI_IRQ_ID 0
+
+
+#define NMI_INVALID_THREAD_ID    SCI_INVALID_BLOCK_ID
+
+
+/********************************************
+
+	Debug Flags
+
+********************************************/
+#define NMI_INIT			0x00000001
+#define NMI_ERR			0x00000002
+#define NMI_TX			0x00000004
+#define NMI_INTR 		0x00000008
+#define NMI_RX			0x00000010
+#define NMI_SCAN		0x00000020
+#define NMI_JOIN			0x00000040
+#define NMI_STATUS		0x00000080
+#define NMI_POLL		0x00000100
+#define NMI_IF			0x00000200
+#define NMI_ALL			0xffffffff
+
+/*******************************************************************************/
+
+typedef unsigned char BOOLEAN;
+typedef long os_time_t;
+typedef unsigned long       NMI_TCPIP_IP_ADDR_T; 
+typedef unsigned long       NMI_TCPIP_NET_ID_T; 
+typedef unsigned char	    NMI_BOOLEAN_T;
+typedef unsigned long		NMI_BLOCK_ID;
+typedef void *  NMI_SCI_EVENT_GROUP_PTR;
+typedef void *  NMI_SCI_MUTEX_PTR;
+typedef void *  NMI_SCI_SEMAPHORE_PTR;
+
+#if 0//Ryan
+typedef enum
+{
+	NMI_MESSAGE_START = WIFISUPP_SIG_CUSTOM_START,
+	NMI_MESSAGE_RESTART_MAC,
+	NMI_MESSAGE_POWER_SAVE,
+	NMI_MESSAGE_SLEEP,
+	NMI_MESSAGE_MAX = WIFISUPP_SIG_CUSTOM_END
+}NMI_MESSAGE_E;
+#endif
+
+//#define CFLWCHAR        unsigned short    // uni-code char
+#define SFS_MAX_PATH    255
+
+// EAPOL data receive upcall function
+typedef void (*NMI_TCPIP_EAPOL_RX_CALLBACK_FPTR)( 
+    const unsigned char*    data_ptr,       /* EAPOL data pointer */
+    unsigned int            data_len,       /* EAPOL data length */
+    const unsigned char*    src_mac_ptr,    /* source mac address pointer */
+    unsigned int            src_mac_len,    /* source mac length, unit: byte for ethernet, it should be 6 */
+    NMI_TCPIP_NET_ID_T      net_id );       /* net interface ID */
+
+
+// TCPIP interface error enum
+typedef enum
+{
+	NMI_TCPIP_ERROR_OK = 0,     /* no error */
+	NMI_TCPIP_ERROR_INVALPARAM, /* invalid parameter */
+	NMI_TCPIP_ERROR_INVALNETID, /* invalid net id */
+	NMI_TCPIP_ERROR_MEMALLOC,   /* memory alloc fail */
+	NMI_TCPIP_ERROR_LOGICAL,    /* calling or running logical error */
+	NMI_TCPIP_ERROR_TIMEOUT,    /* time out */
+	NMI_TCPIP_ERROR_MAX
+} NMI_TCPIP_ERROR_E;
+
+
+typedef enum
+{
+	NMI_TCPIP_PKTTYPE_NULL = 0,
+	NMI_TCPIP_PKTTYPE_IP,       /* packet is encapsulated as IP */
+	NMI_TCPIP_PKTTYPE_ETHER,    /* packet is encapsulated as Ethernet */
+	NMI_TCPIP_PKTTYPE_MAX
+} NMI_TCPIP_PACKET_TYPE_E;
+
+
+// TCPIP net interface IP addresses
+// NOTES : IP addresses should be in Big-Ending
+typedef struct _netif_ipaddr_tag
+{
+	NMI_TCPIP_IP_ADDR_T  ipaddr;     /* host IP */
+	NMI_TCPIP_IP_ADDR_T  snmask;     /* subnet mask */
+	NMI_TCPIP_IP_ADDR_T  gateway;    /* gateway */
+	NMI_TCPIP_IP_ADDR_T  dns1;       /* primary DNS */
+	NMI_TCPIP_IP_ADDR_T  dns2;       /* secondary DNS */
+} NMI_TCPIP_NETIF_IPADDR_T;
+
+// TCPIP net interface hardware address
+typedef struct _netif_haddr_tag
+{
+	unsigned char*  addr_ptr;           /* hard address pointer */
+	unsigned int    addr_len;           /* hard address length, unit: byte */
+} NMI_TCPIP_NETIF_HADDR_T;
+
+
+// TCPIP packet info struct
+typedef struct _packet_info_tag
+{
+	unsigned char*      data_ptr;   /* data pointer */
+	unsigned int        data_len;   /* data length - full packet encapsulation length */
+	NMI_TCPIP_NET_ID_T  net_id;     /* net interface ID */
+} NMI_TCPIP_PACKET_INFO_T;
+
+
+typedef unsigned int (*NMI_TCPIP_TX_REQ_FPTR)( 
+    const NMI_TCPIP_PACKET_INFO_T*  pkt_info_ptr );
+
+// TCPIP receive flow control setting function 
+typedef void (*NMI_TCPIP_RX_FLCTRL_FPTR)(
+    NMI_BOOLEAN_T         is_set,     /* flow control flag: TRUE - set; FALSE - not set */
+    NMI_TCPIP_NET_ID_T   net_id );   /* net interface ID */
+
+
+
+// TCPIP net interface configuration struct
+typedef struct _netif_cfg_tag
+{
+	NMI_TCPIP_PACKET_TYPE_E     pkt_type;       /* packet type between tcpip and low layer */
+	NMI_TCPIP_TX_REQ_FPTR       tx_req_fptr;    /* tx function pointer for data sending from tcpip to low layer */
+	NMI_BOOLEAN_T               is_async_tx;    /* tx mode: TRUE - async send; FALSE - sync send */
+	NMI_TCPIP_NETIF_IPADDR_T    saddr;          /* soft (IP) address */
+	NMI_TCPIP_NETIF_HADDR_T     haddr;          /* hard (MAC) address */
+	unsigned int                mtu;            /* MTU of the low layer */
+	unsigned int                tx_rate;        /* max tx send rate - it's useful in tx flow control */
+	NMI_TCPIP_RX_FLCTRL_FPTR    rx_flctrl_fptr; /* rx flow control function pointer, this is optional, can be NULL */
+	char*                       netif_name_ptr; /* net interface name, given by low layer, it can be NULL, but we recommend caller set one for better debug */
+} NMI_TCPIP_NETIF_CFG_T;
+
+
+/*******************************************************************************/
+
+/**--------------------------------------------------------------------------*
+ **                         MACRO DEFINITION                                 *
+ **--------------------------------------------------------------------------*/
+#define NMI_WIFISUPP_BSSID_LEN              6               //the length of BSSID in bytes
+#define NMI_WIFISUPP_SSID_MAX_LEN           32              //the MAX length of SSID in bytes
+#define NMI_WIFISUPP_WEP_IV_LEN             3               //the length of IV in WEP
+#define NMI_WIFISUPP_WEP_64BITS_KEY_LEN     8               //the length of 64bits WEP key
+#define NMI_WIFISUPP_WEP_128BITS_KEY_LEN    16              //the length of 128bits WEP key
+#define NMI_WIFISUPP_WPA_PSK_LEN            64              //the length of WPA PSK
+#ifdef WLAN_SUPPORT
+#define NMI_WIFISUPP_WAPI_PSK_LEN           64              //the length of WAPI PSK
+#endif
+#define NMI_WIFISUPP_MAX_FILE_PATH_LEN      SFS_MAX_PATH    //the MAX file path supported
+#define NMI_WIFISUPP_WEP_KEY_ID_MAX         4               //the max WEP key ID
+
+#define NMI_WIFISUPP_MAX_USERNAME_LEN       32
+#define NMI_WIFISUPP_MAX_PSW_LEN            32
+/**--------------------------------------------------------------------------*
+ **                         typedef                                          *
+ **--------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/*                          Enum                                             */
+/*---------------------------------------------------------------------------*/
+typedef enum
+{
+	NMI_WIFISUPP_NETWORK_MODE_INFRASTRUCTURE,   //infrastructure
+	NMI_WIFISUPP_NETWORK_MODE_ADHOC,            //ad-hoc
+	NMI_WIFISUPP_NETWORK_MODE_MAX
+} NMI_WIFISUPP_NETWORK_MODE_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_RESULT_SUCC,           //success
+	NMI_WIFISUPP_RESULT_FAIL,           //fail
+	NMI_WIFISUPP_RESULT_NOT_FOUND,      //the AP is not found
+	NMI_WIFISUPP_RESULT_TIMEOUT,        //operation time out
+	NMI_WIFISUPP_RESULT_RESTRICTED,     //connection is restricted
+	NMI_WIFISUPP_WRONG_PASSPHRASE,
+	NMI_WIFISUPP_RESULT_MAX
+} NMI_WIFISUPP_RESULT_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_OPENSYS,   //open system
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_WEP,       //WEP
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_WPA,       //WPA
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_WPA2,      //WPA2
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_WAPI,      //WAPI
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_MAX
+}NMI_WIFISUPP_ENCRYP_PROTOCOL_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_CIPHER_TKIP,	    //TKIP
+	NMI_WIFISUPP_CIPHER_CCMP,		//CCMP
+	NMI_WIFISUPP_CIPHER_WEP,        //wep
+	NMI_WIFISUPP_CIPHER_SMS4,        //WAPI SMS4
+	NMI_WIFISUPP_CIPHER_MAX
+}NMI_WIFISUPP_CIPHER_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_WEP_KEY_TYPE_64BITS,       //64bits_type WEP Key
+	NMI_WIFISUPP_WEP_KEY_TYPE_128BITS,      //128bits_type WEP Key
+	NMI_WIFISUPP_WEP_KEY_TYPE_MAX
+}NMI_WIFISUPP_WEP_KEY_TYPE_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_WPA_CREDENTIAL_TYPE_PSK,   //WPA using PSK
+	NMI_WIFISUPP_WPA_CREDENTIAL_TYPE_EAP,   //WPA using EAP   802.1X
+	NMI_WIFISUPP_WPA_CREDENTIAL_TYPE_MAX
+}NMI_WIFISUPP_WPA_CREDENTIAL_TYPE_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_WAPI_CREDENTIAL_TYPE_PSK,   //WAPI using PSK
+	NMI_WIFISUPP_WAPI_CREDENTIAL_TYPE_CER,   //WAPI using certificate
+	NMI_WIFISUPP_WAPI_CREDENTIAL_TYPE_MAX
+}NMI_WIFISUPP_WAPI_CREDENTIAL_TYPE_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_CREDENTIAL_TYPE_PSK,
+	NMI_WIFISUPP_CREDENTIAL_TYPE_RADIUS,
+	NMI_WIFISUPP_CREDENTIAL_TYPE_CER,
+	NMI_WIFISUPP_CREDENTIAL_TYPE_MAX
+}NMI_WIFISUPP_CREDENTIAL_TYPE_E;
+
+
+typedef enum
+{
+	NMI_WIFISUPP_WPA_EAP_TYPE_TLS,          //EAP using TLS
+	NMI_WIFISUPP_WPA_EAP_TYPE_TTLS,         //EAP using TTLS
+	NMI_WIFISUPP_WPA_EAP_TYPE_PEAP,         //EAP using PEAP
+	NMI_WIFISUPP_WPA_EAP_TYPE_LEAP,         //EAP using LEAP
+	NMI_WIFISUPP_WPA_EAP_TYPE_SIM,          //EAP using SIM
+	NMI_WIFISUPP_WPA_EAP_TYPE_AKA,          //EAP using AKA
+	NMI_WIFISUPP_WPA_EAP_TYPE_FAST,         //EAP using FAST
+	NMI_WIFISUPP_WPA_EAP_TYPE_MAX
+} NMI_WIFISUPP_WPA_EAP_TYPE_E;
+
+typedef enum
+{
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_CHAP,        //CHAP credential
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_PAP,         //PAP credential
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_MSCHAP,      //MSCHAP credential
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_MSCHAP_V2,   //MACHAP_V2 credential
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_GTC,         //GTC credential
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_MAX
+} NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_E;
+
+//bruce add for coexistence: DHCP notice
+typedef enum
+{
+	NMI_WIFISUPP_DHCP_NOTICE_START,		//APP begin to do dhcp
+	NMI_WIFISUPP_DHCP_NOTICE_END,			//APP end dhcp
+	NMI_WIFISUPP_DHCP_NOTICE_MAX
+}NMI_WIFISUPP_DHCP_NOTICE_E;
+
+/*---------------------------------------------------------------------------*/
+/*                          Struct                                           */
+/*---------------------------------------------------------------------------*/
+typedef struct
+{
+	unsigned char ssid[NMI_WIFISUPP_SSID_MAX_LEN];
+	unsigned char ssid_len;
+} NMI_WIFISUPP_SSID_T;  //SSID
+
+typedef struct
+{
+	unsigned char bssid[NMI_WIFISUPP_BSSID_LEN];
+} NMI_WIFISUPP_BSSID_T; //BSSID
+
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T             ssid;
+	NMI_WIFISUPP_BSSID_T            bssid_info;
+	signed int                      signal_qua;         //signal quality: RSSI
+	unsigned int                    noise;              //SNR: signal noise ratio
+	unsigned int                    beacon_interval;    //the BEACON interval
+	unsigned int                    channel;            //the channel using
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_E  encryp_protocol;    //the protocol used by encryption    
+	unsigned int                    rate;               //the rate
+	NMI_WIFISUPP_NETWORK_MODE_E     network_mode;       //network mode
+
+	NMI_WIFISUPP_CIPHER_E           pairwise_cipher;
+	NMI_WIFISUPP_CIPHER_E		    group_cipher;
+
+	NMI_WIFISUPP_CREDENTIAL_TYPE_E      credential_type;    //AKM type
+} NMI_WIFISUPP_SCAN_AP_INFO_T;  //the AP info scanned
+
+
+typedef struct
+{
+	unsigned char   psk[NMI_WIFISUPP_WPA_PSK_LEN];
+}NMI_WIFISUPP_WPA_PSK_T;    //WPA Pre_shared Key
+
+typedef struct
+{
+	BOOLEAN         is_use_file;
+	unsigned short  certificate_file_path[NMI_WIFISUPP_MAX_FILE_PATH_LEN];  //the tls certificate file path, this MAY NOT available when using buffer
+	unsigned char   *certificate_buf_ptr;   //the tls certificate buffer, this MAY NOT available when using file
+	unsigned int    certificate_buf_len;    //the tls certificate buffer length, this MAY NOT available when using file
+} NMI_WIFISUPP_WPA_EAP_TLS_T;   //EAP_TLS information
+
+typedef struct
+{
+	NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_E    inner_credential_type;
+	char                                    username_arr[NMI_WIFISUPP_MAX_USERNAME_LEN+1];
+	char                                    psw_arr[NMI_WIFISUPP_MAX_PSW_LEN+1];
+} NMI_WIFISUPP_WPA_EAP_TTLS_PEAP_T; //EAP_TTLS/EAP_PEAP information
+
+typedef struct
+{
+	char    username_arr[NMI_WIFISUPP_MAX_USERNAME_LEN+1];
+	char    psw_arr[NMI_WIFISUPP_MAX_PSW_LEN+1];
+}NMI_WIFISUPP_WPA_EAP_LEAP_T;   //EAP_LEAP information
+
+typedef struct
+{
+	BOOLEAN         is_use_file;
+	unsigned short  pac_file_path[NMI_WIFISUPP_MAX_FILE_PATH_LEN];//the FAST PAC file path, this MAY NOT available when using buffer
+	unsigned char   *pac_buf_ptr;   //the FAST PAC buffer, this MAY NOT available when using file
+	unsigned int    pac_buf_len;    //the FAST PAC buffer length, this MAY NOT available when using file
+	char            username_arr[NMI_WIFISUPP_MAX_USERNAME_LEN+1];
+	char            psw_arr[NMI_WIFISUPP_MAX_PSW_LEN+1];
+}NMI_WIFISUPP_WPA_EAP_FAST_T;   //EAP_FAST information
+
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T     ssid;
+}NMI_WIFISUPP_DISCONNECT_REQ_INFO_T;    //information in the request for disconnecting a connection
+
+typedef struct
+{
+	NMI_WIFISUPP_WPA_EAP_TYPE_E eap_type;
+	union
+	{
+		NMI_WIFISUPP_WPA_EAP_TLS_T          tls_info;
+		NMI_WIFISUPP_WPA_EAP_TTLS_PEAP_T    ttls_info;
+		NMI_WIFISUPP_WPA_EAP_TTLS_PEAP_T    peap_info;
+		NMI_WIFISUPP_WPA_EAP_LEAP_T         leap_info;
+		NMI_WIFISUPP_WPA_EAP_FAST_T         fast_info;
+	}eap_info;
+} NMI_WIFISUPP_WPA_EAP_T; //WPA EAP information
+
+#ifdef WLAN_SUPPORT
+typedef struct
+{
+	unsigned char   psk[NMI_WIFISUPP_WAPI_PSK_LEN];
+}NMI_WIFISUPP_WAPI_PSK_T;
+
+typedef struct
+{
+	unsigned char    *as_certificate_buf_ptr;
+	unsigned int    as_certificate_buf_len; 
+	unsigned char    *asue_certificate_buf_ptr;
+	unsigned int    asue_certificate_buf_len; 
+}NMI_WIFISUPP_WAPI_CER_T;
+
+typedef struct
+{
+	NMI_WIFISUPP_WAPI_CREDENTIAL_TYPE_E  credential_type;
+	union
+	{
+		NMI_WIFISUPP_WAPI_PSK_T  wapi_psk_info;
+		NMI_WIFISUPP_WAPI_CER_T  wapi_cer_info;
+	}credential_info;
+}NMI_WIFISUPP_WAPI_CREDENTIAL_T;
+#endif
+
+typedef struct
+{
+	NMI_WIFISUPP_WPA_CREDENTIAL_TYPE_E  credential_type;
+	union
+	{
+		NMI_WIFISUPP_WPA_PSK_T  wpa_psk_info;
+		NMI_WIFISUPP_WPA_EAP_T  wpa_eap_info;
+	}credential_info;
+} NMI_WIFISUPP_WPA_CREDENTIAL_T;    //WPA credential information
+
+typedef struct
+{
+	NMI_WIFISUPP_WEP_KEY_TYPE_E key_type;
+	BOOLEAN					    is_open_mode;
+	unsigned int		        key_in_use;
+	union
+	{   
+		unsigned char   key_64bits_arr[NMI_WIFISUPP_WEP_KEY_ID_MAX][NMI_WIFISUPP_WEP_64BITS_KEY_LEN - NMI_WIFISUPP_WEP_IV_LEN];
+		unsigned char   key_128bits_arr[NMI_WIFISUPP_WEP_KEY_ID_MAX][NMI_WIFISUPP_WEP_128BITS_KEY_LEN - NMI_WIFISUPP_WEP_IV_LEN];
+	}key;
+} NMI_WIFISUPP_WEP_CREDENTIAL_T;    //WEP credential information
+
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T             ssid;
+	NMI_WIFISUPP_BSSID_T            bssid_info;
+	NMI_WIFISUPP_NETWORK_MODE_E     network_mode;
+	NMI_WIFISUPP_ENCRYP_PROTOCOL_E  encryp_protocol;
+	unsigned int                    channel;
+	union
+	{
+		NMI_WIFISUPP_WEP_CREDENTIAL_T   wep_credential;
+		NMI_WIFISUPP_WPA_CREDENTIAL_T   wpa_credential;
+	#ifdef WLAN_SUPPORT
+		NMI_WIFISUPP_WAPI_CREDENTIAL_T   wapi_credential;
+	#endif
+	}credential;
+
+	NMI_WIFISUPP_CIPHER_E           pairwise_cipher;
+	NMI_WIFISUPP_CIPHER_E           group_cipher;
+} NMI_WIFISUPP_SSID_CONFIG_T;   //the config of a SSID
+
+typedef struct
+{
+	NMI_WIFISUPP_RESULT_E   result;
+	NMI_WIFISUPP_SSID_T     ssid;
+	NMI_WIFISUPP_BSSID_T    bssid_info;
+	unsigned int            channel;
+	signed int              rssi;
+} NMI_WIFISUPP_CONNECT_RESULT_T;    //connect result
+
+typedef struct 
+{
+	NMI_WIFISUPP_RESULT_E   result;
+	NMI_WIFISUPP_SSID_T     ssid;
+} NMI_WIFISUPP_DISCONNECT_RESULT_T; //disconnect result
+
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T     ssid;
+} NMI_WIFISUPP_DISCONNECT_INFO_T;   //disconnect information
+
+typedef struct
+{
+   // _ATH_SIGNAL_VARS
+   	NMI_WIFISUPP_DISCONNECT_INFO_T      disc_info;
+} NMI_WIFISUPP_DISCONNECT_IND_T;    //disconnect indication
+
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T     ssid;
+	NMI_WIFISUPP_BSSID_T    new_bssid_info;
+	unsigned int            channel;            //the channel using
+} NMI_WIFISUPP_BSSID_CHANGED_INFO_T;    //new bssid information
+
+typedef struct
+{
+	//_ATH_SIGNAL_VARS
+	NMI_WIFISUPP_BSSID_CHANGED_INFO_T   bssid_changed_info;
+} NMI_WIFISUPP_BSSID_CHANGED_IND_T; //BSSID changed indication
+
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T     ssid;
+	NMI_WIFISUPP_BSSID_T    bssid_info;
+	signed int            new_signal_qua;
+} NMI_WIFISUPP_RSSI_CHANGED_INFO_T; //RSSI information
+
+typedef struct
+{
+    //_ATH_SIGNAL_VARS
+	NMI_WIFISUPP_RSSI_CHANGED_INFO_T    rssi_changed_info;
+} NMI_WIFISUPP_RSSI_CHANGED_IND_T;  //RSSI changed indication
+
+typedef struct
+{
+	NMI_WIFISUPP_RESULT_E   wifi_on_result;
+	unsigned int            net_id;             //the net id got from TCP/IP
+	BOOLEAN                 is_support_roam;    //wether support roam
+	BOOLEAN                 is_support_protocol[NMI_WIFISUPP_ENCRYP_PROTOCOL_MAX];  //the encrypt protocol supported
+	BOOLEAN                 is_support_eap[NMI_WIFISUPP_WPA_EAP_TYPE_MAX];          //the EAP methods supported
+	BOOLEAN                 is_support_inner_eap[NMI_WIFISUPP_INNER_CREDENTIAL_TYPE_MAX];   //the inner eap methos supported
+} NMI_WIFISUPP_ON_RESULT_T; // wifi on result
+
+typedef struct 
+{
+	NMI_WIFISUPP_RESULT_E   wifi_off_result;
+} NMI_WIFISUPP_OFF_RESULT_T;    //wifi off result
+
+#ifdef WLAN_SUPPORT
+typedef struct
+{
+	NMI_WIFISUPP_SSID_T     ssid;
+} NMI_WIFISUPP_SCAN_REQ_INFO_T;
+
+typedef struct
+{
+	unsigned int is_enter;
+	unsigned int threshold; 
+}NMI_WIFISUPP_DEEPSLEEP_CMD_INFO_T;
+
+typedef struct
+{
+	unsigned int is_enable;
+	unsigned int interval;
+}NMI_WIFISUPP_AUTOSCAN_REQ_INFO_T;
+
+typedef struct
+{
+	NMI_WIFISUPP_RESULT_E   wifi_autoscan_result;
+} NMI_WIFISUPP_AUTOSCAN_RESULT_T;    
+
+typedef struct
+{
+	//_ATH_SIGNAL_VARS
+	NMI_WIFISUPP_AUTOSCAN_RESULT_T  autoscan_result;
+} NMI_WIFISUPP_AUTOSCAN_CNF_T;   
+
+typedef struct
+{
+   // _ATH_SIGNAL_VARS
+} NMI_WIFISUPP_SCAN_BEGIN_IND_T;   
+
+#else
+typedef struct NMI_WIFISUPP_SCAN_REQ_INFO_tag
+{
+	NMI_WIFISUPP_SSID_T     ssid;
+} NMI_WIFISUPP_SCAN_REQ_INFO_T;
+#endif
+
+#if 0//Ryan
+typedef struct
+{
+    _SIGNAL_VARS
+    void    *msg_body;
+} NMI_WIFISUPP_CUST_MSG_T;    
+#endif
+
+typedef enum{
+	NMI_DISCONNECTTED = 0,
+	NMI_CONNECTTING = 1,
+	NMI_CONNECTTED = 2,
+	NMI_DISCONNECTTING = 3,
+	NMI_MAX
+}NMI_STATE_T;
+/*---------------------------------------------------------------------------*/
+unsigned char ath_set_eut_mode(uint8 is_enter);
+int ath_set_eut_rxtx_channel(int channel);
+int ath_set_eut_tx_rate(int ratio);
+int ath_set_eut_tx_pwr(int pwr);
+unsigned char ath_eut_set_TX_para(unsigned char on_off, int tx_packet_mode);
+unsigned char ath_eut_set_RX_para(int rx_command);
+unsigned char ath_eut_get_RX_packets(unsigned long *tatal_packets_ptr, unsigned long *err_packets_ptr);
+unsigned char ath_eut_set_crystallcap(unsigned char CrystalcapIn,unsigned char CrystalcapOut);
+
+unsigned char ath_eut_get_cal_data(char* pBuf, unsigned int len);
+unsigned char ath_eut_update_cal_data(const char* pBuf, unsigned int len);
+
+
+void nmi_os_trace(char *log);
+void nmi_TraceLow(const char * x_format,...);
+
+unsigned int nmi_os_get_ms(void);
+
+unsigned int nmi_os_getSystemTickCount(void);
+
+void nmi_os_sleep_ms(unsigned int msecs);
+
+int nmi_spi_interface_init(void* spi_dma_isr);
+
+
+uint32 nmi_spi_interface_read( uint8 * buf_ptr, uint32 lenght);
+
+
+uint32 nmi_spi_interface_write( uint8 * buf_ptr, uint32 lenght);
+
+
+uint32 nmi_spi_interface_deinit(void* spi_dma_isr);
+
+#ifdef SPI_RW_SEPARATE
+uint32 nmi_spi_interface_writeread(uint8 * out_buf_ptr, uint32 out_buf_len, uint8 * in_buf_ptr, uint32 in_buf_len);  //kyu
+#else
+uint32 nmi_spi_interface_writeread(uint8 * out_buf_ptr, uint8 * in_buf_ptr, uint32 length);  //ksong 2012.7.12
+#endif
+
+
+BOOLEAN nmc1000_wifi_on(void); 
+BOOLEAN nmc1000_wifi_off(void); 
+
+void wifi_handle_event(uint8_t * event);//added by Tsungta
+void ap_disconnect();//added by Tsungta
+void nmc1000_pmk_info_callback(unsigned int ptr, unsigned int len);
+void nmc1000_set_pmk_cache_info(uint8_t reset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* __NMC1000_WIFI_ADAPER_H__ */
+
+
Binary file WIFI_Driver/nmc/nmi_wifi_adapter.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/nmi_wlan.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,635 @@
+#ifndef NMI_WLAN_H
+#define NMI_WLAN_H
+
+#include "nmi_type.h"
+
+/********************************************
+
+	Endian Conversion 
+
+********************************************/
+
+#define BYTE_SWAP(val) ((((val) & 0x000000FF) << 24) + \
+                                   		(((val) & 0x0000FF00) << 8)  + \
+                                   		(((val) & 0x00FF0000) >> 8)   + \
+                                   		(((val) & 0xFF000000) >> 24))
+
+
+/********************************************
+
+	Macro Defines 
+
+********************************************/
+#define SINGLE_TX_QUEUE 
+#define HOST_PS
+#define STATIC_TX_BUFFER
+
+/********************************************
+
+	Register Defines
+
+********************************************/
+#define NMI_PERIPH_REG_BASE 0x1000
+#define NMI_CHIPID	(NMI_PERIPH_REG_BASE)
+#define NMI_GLB_RESET_0 (NMI_PERIPH_REG_BASE + 0x400)
+#define NMI_PIN_MUX_0 (NMI_PERIPH_REG_BASE + 0x408)
+#define NMI_MISC	(NMI_PERIPH_REG_BASE+0x428)
+#define NMI_INTR_REG_BASE (NMI_PERIPH_REG_BASE+0xa00)
+#define NMI_INTR_ENABLE (NMI_INTR_REG_BASE)
+#define NMI_INTR_POLARITY (NMI_INTR_REG_BASE+0x10)
+#define NMI_INTR_TYPE (NMI_INTR_REG_BASE+0x20)
+#define NMI_INTR_CLEAR (NMI_INTR_REG_BASE+0x30)
+#define NMI_INTR_STATUS (NMI_INTR_REG_BASE+0x40)
+
+#define NMI_VMM_TBL_SIZE 64
+#define NMI_VMM_TX_TBL_BASE (0x150400)
+#define NMI_VMM_RX_TBL_BASE (0x150500)
+
+#define NMI_VMM_BASE 0x150000
+#define NMI_VMM_CORE_CTL (NMI_VMM_BASE)
+#define NMI_VMM_TBL_CTL (NMI_VMM_BASE+0x4)
+#define NMI_VMM_TBL_ENTRY (NMI_VMM_BASE+0x8)
+#define NMI_VMM_TBL0_SIZE (NMI_VMM_BASE+0xc)
+#define NMI_VMM_TO_HOST_SIZE (NMI_VMM_BASE+0x10)
+#define NMI_VMM_CORE_CFG (NMI_VMM_BASE+0x14)
+#define NMI_VMM_TBL_ACTIVE (NMI_VMM_BASE+040)
+#define NMI_VMM_TBL_STATUS (NMI_VMM_BASE+0x44)
+
+#define NMI_SPI_REG_BASE 0xe800
+#define NMI_SPI_CTL (NMI_SPI_REG_BASE)
+#define NMI_SPI_MASTER_DMA_ADDR (NMI_SPI_REG_BASE+0x4)
+#define NMI_SPI_MASTER_DMA_COUNT (NMI_SPI_REG_BASE+0x8)
+#define NMI_SPI_SLAVE_DMA_ADDR (NMI_SPI_REG_BASE+0xc)
+#define NMI_SPI_SLAVE_DMA_COUNT (NMI_SPI_REG_BASE+0x10)
+#define NMI_SPI_TX_MODE (NMI_SPI_REG_BASE+0x20)
+#define NMI_SPI_PROTOCOL_CONFIG (NMI_SPI_REG_BASE+0x24)
+#define NMI_SPI_INTR_CTL (NMI_SPI_REG_BASE+0x2c)
+
+#define NMI_SPI_PROTOCOL_OFFSET (NMI_SPI_PROTOCOL_CONFIG-NMI_SPI_REG_BASE)
+
+#define NMI_AHB_DATA_MEM_BASE 0x30000
+#define NMI_AHB_SHARE_MEM_BASE 0xd0000
+#define NMI_AHB_DMA_ADDR (NMI_AHB_DATA_MEM_BASE + 0xe000)
+
+#define NMI_CLR_RX_INTR_REG		(NMI_PERIPH_REG_BASE+0xc8)
+#define NMI_TX_SET_INTR_REG		(NMI_PERIPH_REG_BASE+0x78)  /*0xa8*/
+
+#define NMI_SDIO_INTR_TYPE_REG	(NMI_PERIPH_REG_BASE+0x8c)
+
+/********************************************
+
+	FW State Defines
+
+********************************************/
+
+#define FW_TX_OK				0x1
+#define FW_SYNC 				0x2
+#define FW_SLEEP				0x4
+/********************************************
+
+	Size
+
+********************************************/
+
+#define CFG_MSG_HDR_LEN 4
+#define N_MAX_TX_SIZE (2*1024)//(8*1024)
+#define N_HDR_SIZE 4
+#define N_ALIGN_SIZE 4
+#define N_GRP_HDR_SIZE 4
+
+/********************************************
+
+	List Helper
+
+********************************************/
+
+struct wl_list {	
+	struct wl_list *prev;	
+	struct wl_list *next;
+};
+
+#define wl_get_list_entry(ptr, type, member) \
+	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+
+#define wl_list_for_each(pos, head) \
+	for (pos = (head)->next; pos != (head); pos = pos->next)
+
+#define wl_list_for_each_prev(pos, head) \
+	for (pos = (head)->prev; pos != (head); pos = pos->prev)
+
+#define wl_list_for_each_safe(pos, n, head) \
+	for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
+
+#if defined(_LINUX_) 
+static inline void wl_init_list_head(struct wl_list *list)
+{	
+	list->next = list;	
+	list->prev = list;
+}
+
+static inline void wl_list_add(struct wl_list *ne, struct wl_list *prev, struct wl_list *next)
+{	
+	next->prev = ne;	
+	ne->next = next;	
+	ne->prev = prev;	
+	prev->next = ne;
+}
+
+static inline void wl_list_add_head(struct wl_list *ne, struct wl_list *head)
+{	
+	wl_list_add(ne, head, head->next);
+}
+
+static inline void wl_list_add_tail(struct wl_list *ne, struct wl_list *head)
+{	
+	wl_list_add(ne, head->prev, head);
+}
+
+static inline void wl_list_del(struct wl_list *entry)
+{	
+	struct wl_list *prev = entry->prev;
+	struct wl_list *next = entry->next;
+
+	next->prev = prev;	
+	prev->next = next;
+}
+
+static inline int wl_list_empty(const struct wl_list *head)
+{	
+	return head->next == head;
+}
+
+#else
+static void wl_init_list_head(struct wl_list *list);
+static void wl_list_add(struct wl_list *ne, struct wl_list *prev, struct wl_list *next);
+static void wl_list_add_head(struct wl_list *ne, struct wl_list *head);
+static void wl_list_add_tail(struct wl_list *ne, struct wl_list *head);
+static void wl_list_del(struct wl_list *entry);
+static int wl_list_empty(const struct wl_list *head);
+
+
+#endif
+/********************************************
+
+	Mac State Defines
+
+********************************************/
+
+typedef enum {
+	MAC_DISCONNECTED = 1, //0,  /* ksong 2013.5.9 */
+	MAC_CONNECTED,
+	MAC_ALIVE, //MAC_UPDATE_PLL,
+	MAC_UPDATE_PLL_DONE,
+	MAC_SLEEP,
+	MAC_WAKE,
+	MAC_READY,
+	MAC_TX_DONE,
+	MAC_TX_STOP,
+} MAC_STATUS_T;
+
+typedef enum {
+	MLME_SCAN_RSP   = 0,
+	MLME_START_RSP  = 1,
+	MLME_JOIN_RSP   = 2,
+	MLME_AUTH_RSP   = 3,
+	MLME_ASOC_RSP   = 4,
+	MLME_EAPOL_RSP	= 5,		/* Atmel: 1-15-2015 */	
+	MLME_UNEXPECT_RSP = 6,  /* ksong 2013-8-9 */
+} MLME_RSP_TYPE_T;
+
+/********************************************
+
+	Comamnd Parameters
+
+********************************************/
+
+typedef enum {
+	B_ONLY_MODE = 0,				/* basic rate: 1, 2 Mbps, otherwise: 5, 11 Mbps */
+	G_ONLY_MODE,					/* basic rate: 6, 12, 24 Mbps, otherwise: 9, 18, 36, 48, 54 Mbps */
+	G_MIXED_11B_1_MODE,		/* basic rate: 1, 2, 5.5, 11 Mbps, otherwise: all on */
+	G_MIXED_11B_2_MODE,		/* basic rate: 1, 2, 5, 11, 6, 12, 24 Mbps, otherwise: all on */
+} G_OPERATING_MODE_T;
+
+typedef enum{
+	RATE_AUTO = 0,
+	RATE_1MB = 1,
+	RATE_2MB = 2,
+	RATE_5MB = 5,
+	RATE_6MB = 6,
+	RATE_9MB = 9,
+	RATE_11MB = 11,
+	RATE_12MB = 12,
+	RATE_18MB = 18,
+	RATE_24MB = 24,
+	RATE_26MB = 36,
+	RATE_48MB = 48,
+	RATE_54MB = 54
+} TX_RATE_T;
+
+typedef enum {
+	G_SHORT_PREAMBLE = 0, 	/* Short Preamble          */
+    G_LONG_PREAMBLE  = 1, 		/* Long Preamble           */
+    G_AUTO_PREAMBLE  = 2, 		/* Auto Preamble Selection */
+} G_PREAMBLE_T;
+
+typedef enum {
+	AUTO_PROT = 0,	/* Auto */
+	NO_PROT, 			/* Do not use any protection       */
+	ERP_PROT, 			/* Protect all ERP frame exchanges */
+	HT_PROT,  			/* Protect all HT frame exchanges  */
+	GF_PROT,  			/* Protect all GF frame exchanges  */
+} N_PROTECTION_MODE_T;
+
+typedef enum {
+	SITE_SURVEY_1CH    = 0,
+	SITE_SURVEY_ALL_CH = 1,
+	SITE_SURVEY_OFF    = 2
+} SITE_SURVEY_T;
+
+typedef enum {
+	NORMAL_ACK = 0,
+    NO_ACK,
+} ACK_POLICY_T;
+
+typedef enum {
+	G_SELF_CTS_PROT,
+    G_RTS_CTS_PROT,
+} G_PROTECTION_MODE_T;
+
+typedef enum {
+	HT_MIXED_MODE = 1,
+	HT_ONLY_20MHZ_MODE,
+	HT_ONLY_20_40MHZ_MODE,
+} N_OPERATING_MODE_T;
+
+/********************************************
+
+	Command ID Defines
+
+********************************************/
+
+typedef enum {
+	WID_CHAR     = 0,
+	WID_SHORT    = 1,
+	WID_INT      = 2,
+	WID_STR      = 3,
+	WID_BIN = 4
+} WID_TYPE_T;
+
+typedef enum {
+WID_NIL                            = -1,
+
+	/* Character WID list */
+	WID_BSS_TYPE                       = 0x0000,
+	WID_CURRENT_TX_RATE                = 0x0001,
+	WID_CURRENT_CHANNEL                = 0x0002,
+	WID_PREAMBLE                       = 0x0003,
+	WID_11G_OPERATING_MODE             = 0x0004,
+	WID_STATUS                         = 0x0005,
+	WID_SCAN_TYPE                      = 0x0007,
+	WID_PRIVACY_INVOKED                = 0x0008,
+	WID_KEY_ID                         = 0x0009,
+	WID_QOS_ENABLE                     = 0x000A,
+	WID_POWER_MANAGEMENT               = 0x000B,
+	WID_11I_MODE                       = 0x000C,
+	WID_AUTH_TYPE                      = 0x000D,
+	WID_SITE_SURVEY                    = 0x000E,
+	WID_LISTEN_INTERVAL                = 0x000F,
+	WID_DTIM_PERIOD                    = 0x0010,
+	WID_ACK_POLICY                     = 0x0011,
+	WID_RESET                          = 0x0012,
+	WID_BCAST_SSID                     = 0x0015,
+	WID_DISCONNECT                     = 0x0016,
+	WID_READ_ADDR_SDRAM                = 0x0017,
+	WID_TX_POWER_LEVEL_11A             = 0x0018,
+	WID_REKEY_POLICY                   = 0x0019,
+	WID_SHORT_SLOT_ALLOWED             = 0x001A,
+	WID_PHY_ACTIVE_REG                 = 0x001B,
+	WID_TX_POWER_LEVEL_11B             = 0x001D,
+	WID_START_SCAN_REQ                 = 0x001E,
+	WID_RSSI                           = 0x001F,
+	WID_JOIN_REQ                       = 0x0020,
+#ifdef MAC_ANTENNA_DIVERSITY_FEATURE
+	WID_ANTENNA_SELECTION              = 0x0021,
+#endif /* MAC_ANTENNA_DIVERSITY_FEATURE */
+	WID_USER_CONTROL_ON_TX_POWER       = 0x0027,
+	WID_MEMORY_ACCESS_8BIT             = 0x0029,
+	WID_UAPSD_SUPPORT_AP               = 0x002A,
+	WID_CURRENT_MAC_STATUS             = 0x0031,
+	WID_AUTO_RX_SENSITIVITY            = 0x0032,
+	WID_DATAFLOW_CONTROL               = 0x0033,
+	WID_SCAN_FILTER                    = 0x0036,
+	WID_LINK_LOSS_THRESHOLD            = 0x0037,
+	WID_AUTORATE_TYPE                  = 0x0038,
+	WID_802_11H_DFS_MODE               = 0x003B,
+	WID_802_11H_TPC_MODE               = 0x003C,
+
+	/* Character WID list */
+	WID_11N_PROT_MECH                  = 0x0080,
+	WID_11N_ERP_PROT_TYPE              = 0x0081,
+	WID_11N_ENABLE                     = 0x0082,
+	WID_11N_OPERATING_MODE             = 0x0083,
+	WID_11N_OBSS_NONHT_DETECTION       = 0x0084,
+	WID_11N_HT_PROT_TYPE               = 0x0085,
+	WID_11N_RIFS_PROT_ENABLE           = 0x0086,
+	WID_11N_SMPS_MODE                  = 0x0087,
+	WID_11N_CURRENT_TX_MCS             = 0x0088,
+	WID_11N_PRINT_STATS                = 0x0089,
+	WID_HUT_FCS_CORRUPT_MODE           = 0x008A,
+	WID_HUT_RESTART                    = 0x008B,
+	WID_HUT_TX_FORMAT                  = 0x008C,
+	WID_11N_SHORT_GI_ENABLE            = 0x008D,
+	WID_HUT_BANDWIDTH                  = 0x008E,
+	WID_HUT_OP_BAND                    = 0x008F,
+	WID_HUT_STBC                       = 0x0090,
+	WID_HUT_ESS                        = 0x0091,
+	WID_HUT_ANTSET                     = 0x0092,
+	WID_HUT_HT_OP_MODE                 = 0x0093,
+	WID_RIFS_MODE                      = 0x0094,
+	WID_HUT_SMOOTHING_REC              = 0x0095,
+	WID_HUT_SOUNDING_PKT               = 0x0096,
+	WID_HUT_HT_CODING                  = 0x0097,
+	WID_HUT_TEST_DIR                   = 0x0098,
+	WID_HUT_PHY_TEST_MODE              = 0x009A,
+	WID_HUT_PHY_TEST_RATE_HI           = 0x009B,
+	WID_HUT_PHY_TEST_RATE_LO           = 0x009C,
+	WID_HUT_DISABLE_RXQ_REPLENISH      = 0x009D,
+	WID_HUT_KEY_ORIGIN                 = 0x009E,
+	WID_HUT_BCST_PERCENT               = 0x009F,
+	WID_HUT_GROUP_CIPHER_TYPE          = 0x00A0,
+	WID_TX_ABORT_CONFIG                = 0x00A1,
+	WID_HOST_DATA_IF_TYPE              = 0x00A2,
+	WID_HOST_CONFIG_IF_TYPE            = 0x00A3,
+	WID_HUT_TSF_TEST_MODE              = 0x00A4,
+	WID_HUT_PKT_TSSI_VALUE             = 0x00A5,
+	WID_REG_TSSI_11B_VALUE             = 0x00A6,
+	WID_REG_TSSI_11G_VALUE             = 0x00A7,
+	WID_REG_TSSI_11N_VALUE             = 0x00A8,
+	WID_TX_CALIBRATION                 = 0x00A9,
+	WID_DSCR_TSSI_11B_VALUE            = 0x00AA,
+	WID_DSCR_TSSI_11G_VALUE            = 0x00AB,
+	WID_DSCR_TSSI_11N_VALUE            = 0x00AC,
+	WID_HUT_RSSI_EX                    = 0x00AD,
+	WID_HUT_ADJ_RSSI_EX                = 0x00AE,
+	WID_11N_IMMEDIATE_BA_ENABLED       = 0x00AF,
+	WID_11N_TXOP_PROT_DISABLE          = 0x00B0,
+	WID_TX_POWER_LEVEL_11N             = 0x00B1,
+	WID_USER_SEC_CHANNEL_OFFSET        = 0x00C0,
+	WID_2040_COEXISTENCE               = 0x00C1,
+	WID_HUT_FC_TXOP_MOD                = 0x00C2,
+	WID_HUT_FC_PROT_TYPE               = 0x00C3,
+	WID_HUT_SEC_CCA_ASSERT             = 0x00C4,
+	WID_2040_ENABLE                    = 0x00C5,
+	WID_2040_CURR_CHANNEL_OFFSET       = 0x00C6,
+	WID_2040_40MHZ_INTOLERANT          = 0x00C7,
+	WID_HOST_PLATFORM					         = 0x00C8,		/* ykk */
+	WID_MLME_RSP					         = 0x00C9,		/* ykk */
+	WID_RX_TEST						= 0x00CA,     /* ksong 2013-7-16 */
+	WID_DOZE_TIME                          = 0x00CB,	    /* ksong 2013-7-22 */
+  /* Character WID list */
+
+  /* Short WID list */
+  WID_RTS_THRESHOLD                  = 0x1000,
+  WID_FRAG_THRESHOLD                 = 0x1001,
+  WID_SHORT_RETRY_LIMIT              = 0x1002,
+  WID_LONG_RETRY_LIMIT               = 0x1003,
+  WID_BEACON_INTERVAL                = 0x1006,
+  WID_MEMORY_ACCESS_16BIT            = 0x1008,
+  WID_RX_SENSE                       = 0x100B,
+  WID_ACTIVE_SCAN_TIME               = 0x100C,
+  WID_PASSIVE_SCAN_TIME              = 0x100D,
+  WID_SITE_SURVEY_SCAN_TIME          = 0x100E,
+  WID_JOIN_START_TIMEOUT             = 0x100F,
+  WID_AUTH_TIMEOUT                   = 0x1010,
+  WID_ASOC_TIMEOUT                   = 0x1011,
+  WID_11I_PROTOCOL_TIMEOUT           = 0x1012,
+  WID_EAPOL_RESPONSE_TIMEOUT         = 0x1013,
+
+  /* Short WID list */
+  WID_11N_RF_REG_VAL                 = 0x1080,
+  WID_HUT_FRAME_LEN                  = 0x1081,
+  WID_HUT_TXOP_LIMIT                 = 0x1082,
+  WID_HUT_SIG_QUAL_AVG               = 0x1083,
+  WID_HUT_SIG_QUAL_AVG_CNT           = 0x1084,
+  WID_11N_SIG_QUAL_VAL               = 0x1085,
+  WID_HUT_RSSI_EX_COUNT              = 0x1086,
+  WID_CCA_THRESHOLD                  = 0x1087,
+  WID_CLK_26M_SETTLE_TIME			= 0x1088,    /* ksong */
+
+  /* Short WID list */
+
+	/* Integer WID list */
+	WID_FAILED_COUNT                   = 0x2000,
+	WID_RETRY_COUNT                    = 0x2001,
+	WID_MULTIPLE_RETRY_COUNT           = 0x2002,
+	WID_FRAME_DUPLICATE_COUNT          = 0x2003,
+	WID_ACK_FAILURE_COUNT              = 0x2004,
+	WID_RECEIVED_FRAGMENT_COUNT        = 0x2005,
+	WID_MCAST_RECEIVED_FRAME_COUNT     = 0x2006,
+	WID_FCS_ERROR_COUNT                = 0x2007,
+	WID_SUCCESS_FRAME_COUNT            = 0x2008,
+	WID_HUT_TX_COUNT                   = 0x200A,
+	WID_TX_FRAGMENT_COUNT              = 0x200B,
+	WID_TX_MULTICAST_FRAME_COUNT       = 0x200C,
+	WID_RTS_SUCCESS_COUNT              = 0x200D,
+	WID_RTS_FAILURE_COUNT              = 0x200E,
+	WID_WEP_UNDECRYPTABLE_COUNT        = 0x200F,
+	WID_REKEY_PERIOD                   = 0x2010,
+	WID_REKEY_PACKET_COUNT             = 0x2011,
+	WID_1X_SERV_ADDR                   = 0x2012,
+	WID_STACK_IP_ADDR                  = 0x2013,
+	WID_STACK_NETMASK_ADDR             = 0x2014,
+	WID_HW_RX_COUNT                    = 0x2015,
+	WID_MEMORY_ADDRESS                 = 0x201E,
+	WID_MEMORY_ACCESS_32BIT            = 0x201F,
+	WID_RF_REG_VAL                     = 0x2021,
+
+	/* Integer WID list */
+	WID_11N_PHY_ACTIVE_REG_VAL         = 0x2080,
+	WID_HUT_NUM_TX_PKTS                = 0x2081,
+	WID_HUT_TX_TIME_TAKEN              = 0x2082,
+	WID_HUT_TX_TEST_TIME               = 0x2083,
+
+	/* Integer WID list */
+  WID_FW_DEBUG_FLAG               		= 0x2084,
+
+	/* String WID list */
+	WID_SSID                           = 0x3000,
+	WID_FIRMWARE_VERSION               = 0x3001,
+	WID_OPERATIONAL_RATE_SET           = 0x3002,
+	WID_BSSID                          = 0x3003,
+	WID_WEP_KEY_VALUE                  = 0x3004,
+	WID_11I_PSK                        = 0x3008,
+	WID_11E_P_ACTION_REQ               = 0x3009,
+	WID_1X_KEY                         = 0x300A,
+	WID_HARDWARE_VERSION               = 0x300B,
+	WID_MAC_ADDR                       = 0x300C,
+	WID_HUT_DEST_ADDR                  = 0x300D,
+	WID_MISC_TEST_MODES                = 0x300E,
+	WID_PHY_VERSION                    = 0x300F,
+	WID_SUPP_USERNAME                  = 0x3010,
+	WID_SUPP_PASSWORD                  = 0x3011,
+	WID_SITE_SURVEY_RESULTS            = 0x3012,	
+	WID_RX_POWER_LEVEL                 = 0x3013,
+	WID_ADD_WEP_KEY                    = 0x3019,
+	WID_REMOVE_WEP_KEY                 = 0x301A,
+	WID_ADD_PTK                        = 0x301B,
+	WID_ADD_RX_GTK                     = 0x301C,
+	WID_ADD_TX_GTK                     = 0x301D,
+	WID_REMOVE_KEY                     = 0x301E,
+	WID_ASSOC_REQ_INFO                 = 0x301F,
+	WID_ASSOC_RES_INFO                 = 0x3020,
+	WID_UPDATE_RF_SUPPORTED_INFO       = 0x3021,
+
+  /* String WID list */
+  WID_11N_P_ACTION_REQ               = 0x3080,
+  WID_HUT_TEST_ID                    = 0x3081,
+  WID_PMKID_INFO                     = 0x3082,
+  WID_FIRMWARE_INFO                  = 0x3083,
+  WID_HOST_SCAN_SSID                  		= 0x3084,
+
+  /* String WID list */
+  WID_FIXED_IP_ADDR					 = 0x3090,//Ryan
+
+  /* Binary WID list */
+  WID_UAPSD_CONFIG                   = 0x4001,
+  WID_UAPSD_STATUS                   = 0x4002,
+  WID_WMM_AP_AC_PARAMS               = 0x4003,
+  WID_WMM_STA_AC_PARAMS              = 0x4004,
+  WID_NETWORK_INFO                   = 0x4005,
+  WID_STA_JOIN_INFO                  = 0x4006,
+  WID_CONNECTED_STA_LIST             = 0x4007,
+	WID_SCAN_BSS_INFO 												= 0x4008,
+
+  /* Binary WID list */
+  WID_11N_AUTORATE_TABLE             = 0x4080,
+  WID_HUT_TX_PATTERN                 = 0x4081,
+  WID_HUT_STATS                      = 0x4082,
+  WID_HUT_LOG_STATS                  = 0x4083,
+
+	WID_HOST_PROBE_IE									= 0x4084,
+	WID_HOST_SCAN_CHANNEL							= 0x4085,	
+ 
+ 	/* Atmel, 1-15-2015*/ 
+  WID_PMK_CACHE_INFO             		= 0x4088,
+
+ 
+ /* Miscellaneous WIDs */
+  WID_ALL                            = 0x7FFE,
+  WID_MAX                            = 0xFFFF
+} WID_T;
+
+/********************************************
+
+	Tx/Rx Queue Structure
+
+********************************************/
+
+#ifdef SINGLE_TX_QUEUE
+typedef enum {
+	CFG_W = 1,
+	CFG_Q,
+	NET_D,
+} TX_PACKET_ID_T;
+#endif
+
+typedef struct que_h {
+	int bytes_in_queue;	
+	int count;
+	LOCK_ID_T lock_id;
+	struct wl_list list;
+} que_hdr_t;
+
+typedef struct que_e {
+	u8 *buffer;	
+	u32 buffer_size;	
+	struct wl_list list;
+} que_e_common_t;
+
+#ifdef SINGLE_TX_QUEUE
+typedef struct tx_que_common {
+	u8 *buffer;	
+	u32 buffer_size;
+	struct wl_list list;
+	TX_PACKET_ID_T id;
+} tx_que_common_t;
+#endif
+
+typedef struct txq_e {
+	u8 *buffer;	
+	u32 buffer_size;
+	struct wl_list list;
+#ifdef SINGLE_TX_QUEUE
+	TX_PACKET_ID_T id;
+#endif
+	void *priv;
+	free_txb_cb_fun_t free_txb_cb;	
+} txq_e_t;
+
+typedef struct rxq_e {
+	u8 *buffer;	
+	u32 buffer_size;	
+	struct wl_list list;
+} rxq_e_t;
+
+typedef struct set_cfg_e {	
+	u8 *buffer;	
+	u32 buffer_size;	
+	struct wl_list list;
+#ifdef SINGLE_TX_QUEUE
+	TX_PACKET_ID_T id;
+#endif
+} cfg_w_e_t;
+
+typedef struct query_cfg_e {
+	u8 *buffer;	
+	u32 buffer_size;
+	struct wl_list list;
+#ifdef SINGLE_TX_QUEUE
+	TX_PACKET_ID_T id;
+#endif
+} cfg_q_e_t;
+
+/* Atmel: 1-15-2015
+		Move to nmi_wlan_if.h
+*/
+//typedef void (*query_cb_fun_t)(u32, u32);
+
+typedef struct query_rsp_e {
+	u16 wid;	
+	query_cb_fun_t query_cb;
+	struct wl_list list;
+} cfg_q_rsp_e_t;
+
+typedef struct {
+	u8 	type;
+	u8 	id;
+	u16 	len;
+} cfg_msg_hdr_t; 
+
+
+typedef struct {
+	int (*read_reg)(u32, u32 *);
+	int (*write_reg)(u32, u32);
+	int (*block_rx)(u32, u8 *, u32);
+	int (*block_tx)(u32, u8 *, u32);	
+	int (*hw_cfg)(void);
+	int (*clear_intr)(void);	
+} nmi_wl_if_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int nmi_hif_init(nmi_wl_io_t *, nmi_wl_if_t *);
+extern void DPRINT(u32, char *fmt, ...);
+extern void DPRINT_HEX(u32 grp, char *title, u8 *buf, u32 len);
+void set_FW_TX_OK(void);//Tsungta
+void get_FW_TX_OK(void);//Tsungta
+u32 FW_TX_is_OK(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
Binary file WIFI_Driver/nmc/nmi_wlan.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/nmi_wlan_if.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,428 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) Newport Media Inc.  All rights reserved.
+//
+// Module Name:  nmi_wlan_if.h
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef NMI_WLAN_IF_H
+#define NMI_WLAN_IF_H
+
+#if defined(_LINUX_)
+
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <asm/gpio.h>
+#include <linux/kthread.h>
+#include <linux/firmware.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+#include <linux/version.h>
+#include <linux/semaphore.h>
+
+#else
+
+#define SPI_RW_SEPARATE//Ryan
+//#include "os_api.h"
+//#include "IN_Message.h"
+//#include "tcpip_types.h"
+//#include "tcpip_api.h"
+//#include "app_tcp_if.h"
+//#include "wifisupp_api.h"
+#include "nmi_wifi_adapter.h"
+//#include "wifi_drv.h"
+//#include "nmi_os.h"
+//#include "nmi_config.h"//command by Tsungta
+
+#endif
+
+#include "nmi_type.h"
+
+#ifdef __SC6800H__
+#define BIG_ENDIAN
+#endif
+
+/********************************************
+
+	Debug Flags
+
+********************************************/
+
+#define N_INIT		0x00000001
+#define N_ERR			0x00000002
+#define N_TXQ			0x00000004
+#define N_INTR 		0x00000008
+#define N_RXQ			0x00000010
+#define N_TRACE		0x00000020
+#define N_LIST		0x00000040
+#define N_SCAN		0x00000080
+#define N_JOIN		0x00000100
+#define N_WARN		0x00000200
+#define N_HIF			0x00000400
+#define N_BUS			0x00000800
+#define N_FW_STATE	0x00001000
+#define N_ALL			0xffffffff
+
+
+/********************************************
+
+	Host SDIO Bus Interface Defines
+
+********************************************/
+
+#define N_SDIO 0
+/**
+	Note:
+		Set the SDIO block size here. The max is 2k.
+**/
+#define NMI_SDIO_BLOCK_SIZE 			512	
+
+typedef struct {
+	u32 read_write:1;
+	u32 function:3;
+	u32 raw:1;
+	u32 address:17;
+	u32 data:8;
+} sdio_cmd52_t;
+
+typedef struct {
+	struct {
+		u32 read_write:1;
+		u32 function:3;
+		u32 block_mode:1;
+		u32 increment:1;
+		u32 address:17;
+		u32 count:9;
+	} bit;
+	u8 *buffer;
+	u32 block_size;
+} sdio_cmd53_t;
+
+/********************************************
+
+	Host SPI Bus Interface Defines
+
+********************************************/
+
+//#define SPI_RW_SEPARATE
+#define N_SPI 1
+#define SPI_DATA_PKT_SZ_256 			256
+#define SPI_DATA_PKT_SZ_512				512
+#define SPI_DATA_PKT_SZ_1K				1024
+#define SPI_DATA_PKT_SZ_2K				(2 * 1024)
+#define SPI_DATA_PKT_SZ_4K				(4 * 1024)
+#define SPI_DATA_PKT_SZ_8K				(8 * 1024)
+/**
+	
+	Note:
+		Set the SPI transfer size here. See above
+**/
+#define SPI_DATA_PKT_SZ					SPI_DATA_PKT_SZ_4K//SPI_DATA_PKT_SZ_8K	
+
+/********************************************
+
+	Wlan Interfaces Defines 
+
+********************************************/
+
+#define MAX_SSID_LEN            33
+
+typedef enum {
+	NO_SECURITY = 0,
+	WEP_40 = 0x3,
+	WEP_104 = 0x7,
+	WPA_AES = 0x29,
+	WPA_TKIP = 0x49,
+	WPA_AES_TKIP = 0x69,		/* Aes or Tkip */
+	WPA2_AES = 0x31,
+	WPA2_TKIP = 0x51,
+	WPA2_AES_TKIP = 0x71,	/* Aes or Tkip */
+	WP2_WPA_AES = 0x39,     /* ksong add 2013.5.21 it is a wired value */
+	WPA2_WPA_AES_TKIP = 0x79, /* ksong add 2013.5.13 */
+} SECURITY_T; 
+
+typedef enum {
+	INFRASTRUCTURE  = 1,
+	INDEPENDENT     = 2,
+	ANY_BSS         = 3
+} BSSTYPE_T;
+
+typedef enum{
+	PASSIVE_SCAN = 0,
+	ACTIVE_SCAN  = 1,
+	NUM_SCANTYPE
+} SCANTYPE_T;
+
+typedef enum{
+	OPEN_SYSTEM = 1,
+	SHARED_KEY = 2,
+	ANY	= 3
+} AUTHTYPE_T;
+
+typedef enum {
+	NO_POWERSAVE     = 0,
+	MIN_FAST_PS      = 1,
+	MAX_FAST_PS      = 2,
+	MIN_PSPOLL_PS    = 3,
+	MAX_PSPOLL_PS    = 4
+} USER_PS_MODE_T;
+
+typedef enum{
+	SUCCESS_MLMESTATUS  = 0,
+	INVALID_MLMESTATUS  = 1,
+	TIMEOUT             = 2,
+	REFUSED             = 3,
+	TOMANY_REQ          = 4,
+	ALREADY_BSS         = 5
+} MLMESTATUS_T;
+
+typedef struct {
+	int status;
+	u8 bssid[6];
+	u16 asoc_req_len;	
+	u8 *asoc_req;
+	u16 asoc_rsp_len;	
+	u8 *asoc_rsp;
+} nmi_wl_join_rsp_t;
+
+typedef struct {
+	int chan_no;
+	u8 bssid[6];
+	//u16 ssid_len;
+	u8 ssid[33];
+	BSSTYPE_T bss_type;
+	AUTHTYPE_T auth_type;
+	SECURITY_T sec_type;
+	u8 *key;
+	u8 key_len, key_idx;
+	u16 beacon_period;
+	void *priv;
+	void (*join_callback_fun)(void *, nmi_wl_join_rsp_t *);
+	void (*disconnect_callback_fun)(void *);
+} nmi_wl_join_t;
+
+typedef struct
+{
+	u32 bss_type;
+	u32   chan_no;
+	u32  beacon_period;
+	u32  cap_info;
+	u8  bssid[8];
+	u8  ssid[36];
+	s32     rssi;
+	u32  dot11i_info;
+	u32  ht_capable;
+	u32 max_rate;
+	//u8 *ie;
+	//u16 ie_len;
+} nmi_wl_bss_t;
+
+typedef struct {
+	void *priv;
+	SCANTYPE_T scan_type;
+	BSSTYPE_T bss_type;
+	u32 ssid_len;
+	u8 ssid[32];
+	u16 n_channel;
+	u8 channel[14];
+	u32 active_scan_time;
+	u32 passive_scan_time;
+	unsigned char *ie;
+	u32 ie_len;
+	void (*scan_callback_fun)(void *, nmi_wl_bss_t *, int, int);
+} nmi_wl_scan_t;
+
+typedef struct {
+	SECURITY_T sec_type;
+	u8 bssid[6];
+	u8 key_index;
+	int seq_len;
+	u8 *seq;
+	int key_len;
+	u8 *key;
+	int grp;
+
+} nmi_add_key_t;
+
+/* Atmel: 1-15-2015 */
+typedef struct {
+	u8 password[64];
+	u8 ssid[MAX_SSID_LEN];
+	u8 psk[40];	
+} pmk_cache_info_t;
+
+/********************************************
+
+	Platform Interface Defines
+
+********************************************/
+
+#define HOST_ID_ANDROID 0
+#define HOST_ID_RTOS 1
+
+typedef enum {
+	TXQ_LOCK = 1,
+	RXQ_LOCK,
+	CFQ_LOCK,
+	QRQ_LOCK,
+	QSQ_LOCK,
+	IO_LOCK,
+} LOCK_ID_T;
+
+typedef enum {
+	HIF_WAIT = 1,
+	RXQ_WAIT,
+	SYNC_WAIT,
+} WAIT_ID_T;
+
+typedef struct {
+	int type;
+	union {
+		struct {
+			int external_intr_pin;
+			int (*sdio_cmd52)(sdio_cmd52_t *);
+			int (*sdio_cmd53)(sdio_cmd53_t *);
+		} sdio;
+		struct {
+#ifdef SPI_RW_SEPARATE
+			int (*spi_io)(u8 *, u32, u8 *, u32);
+#else
+			int (*spi_io)(u8 *, u8 *, u32);
+#endif
+		} spi;
+	} u;
+} nmi_wl_io_t;
+
+typedef struct {
+	void (*print)(char *);
+	void (*msleep)(u32);
+	void *(*malloc)(u32);
+	void (*free)(void *);
+	void (*lock)(void *, LOCK_ID_T);
+	void (*unlock)(void *, LOCK_ID_T);
+	int (*wait)(void *, WAIT_ID_T, u32);
+	void (*signal)(void *, WAIT_ID_T);
+	u32 (*net_rx)(void *, u8 *, u32);
+	void (*net_enable_irq)(void *);
+	void (*net_tx_resume)(void *);
+	void (*net_tx_stop)(void *);
+	void (*net_link_up)(void *);
+	void (*net_link_down)(void *);
+	void (*power_up)(void *);
+	void (*power_down)(void *);
+	void (*rssi_fun)(s8);  
+} nmi_wl_plat_func_t;
+
+typedef struct {
+	void *priv;
+	u32 dbgflag;	
+	u32 host_id;
+	nmi_wl_plat_func_t fun;
+	nmi_wl_io_t io;
+} nmi_wl_platform_t;
+
+typedef void (*free_txb_cb_fun_t)(void *, u8 *, u32);
+/* Atmel: 1-15-2015 */
+typedef void (*query_cb_fun_t)(u32, u32);
+
+typedef struct {
+//	int (*firmware_download)(u8 *, u32);
+	int (*firmware_download)(const u8 *, u32);//Ryan
+	int (*hw_start)(void);
+	void (*hw_stop)(void);
+	void (*host_trans)(void);
+	void (*host_indicate_rx_isr)(void);
+	void (*host_rx_trans)(void);
+	void (*host_tx_trans)(void);
+	int (*net_que_tx_frame)(void *, u8 *, u32, free_txb_cb_fun_t);
+	void (*net_disp_rx_frame)(void);
+	int (*wl_scan)(nmi_wl_scan_t *);
+	int (*wl_join)(nmi_wl_join_t *);
+	int (*wl_leave)(void);
+	int (*wl_add_key)(nmi_add_key_t *);
+	int (*wl_del_key)(nmi_add_key_t *);
+	int (*wl_get_mac_addr)(void *);
+	int (*wl_power_save_enable)(int);
+	void (*wl_clean)(void); /* ksong add 2013.5.9 */
+	void (*wl_sleep)(u32);	 /* ksong add 2013-6-26 */
+	void (*wl_wakeup)(void); /* ksong add 2013-6-26 */
+} nmi_wl_core_func_t;
+
+#if 1//Ryan
+typedef uint32 TCPIP_NETID_T;//Ryan
+
+struct nmi_wl_adp_t {
+	
+//	void *hif_event;
+//	void *rxq_event;
+//	void *sync_event;
+
+	nmi_wl_core_func_t core;
+
+	uint8 mac_address[6];
+
+	TCPIP_NETID_T  net_id;
+
+	int quit;
+
+	uint32 hif_thread_id;
+	uint32 rxq_thread_id ;
+
+	uint8 disconnect_req; /* disconnect request */
+	uint8 already_on;	  /*avoid re-enter the init and deinit function. */
+	uint8 not_inform_app;  /* sometimes we do not need to inform app that connection is fail */
+	NMI_WIFISUPP_SSID_CONFIG_T connect_info; /* Store the connect info */
+	NMI_STATE_T state;  /* record the state */
+	void *poll_dhcp_timer;	/* dhcp poll timer */
+};
+#endif
+
+extern int nmi_wl_core_init(nmi_wl_platform_t *, nmi_wl_core_func_t *, u8 *);
+
+/* Definitions for error constants. */
+
+#define ERR_OK          0    /* No error, everything OK. */
+#define ERR_MEM        -1    /* Out of memory error.     */
+#define ERR_BUF        -2    /* Buffer error.            */
+#define ERR_TIMEOUT    -3    /* Timeout.                 */
+#define ERR_RTE        -4    /* Routing problem.         */
+#define ERR_INPROGRESS -5    /* Operation in progress    */
+#define ERR_VAL        -6    /* Illegal value.           */
+#define ERR_WOULDBLOCK -7    /* Operation would block.   */
+#define ERR_USE        -8    /* Address in use.          */
+#define ERR_ISCONN     -9    /* Already connected.       */
+
+#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN)
+
+#define ERR_ABRT       -10   /* Connection aborted.      */
+#define ERR_RST        -11   /* Connection reset.        */
+#define ERR_CLSD       -12   /* Connection closed.       */
+#define ERR_CONN       -13   /* Not connected.           */
+
+#define ERR_ARG        -14   /* Illegal argument.        */
+
+#define ERR_IF         -15   /* Low-level netif error    */
+
+#define NMI_PRINTF(...) DPRINT(N_ERR, __VA_ARGS__);//vDebugPrintf("\r\n"); vDebugPrintf(__VA_ARGS__); vDebugPrintf("\r\n");// vTaskDelay( 5 / portTICK_RATE_MS );//printk(__VA_ARGS__)
+
+typedef enum{
+	WIFI_SCAN_DONE	= 1,
+	WIFI_CONNECTED,
+	WIFI_MAC_READY,
+	WIFI_DISCONNECTED,//Tsungta		
+}tenuWiFiEventType;//Ryan
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/socket_internal.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,226 @@
+/*
+@file	
+	socket_internal.h
+
+@brief	
+*/
+#ifndef __SOCKET_INTERNAL_H__
+#define __SOCKET_INTERNAL_H__
+
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+INCLUDES
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+#include "socket_nmc.h"
+
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+MACROS
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+#define SOCKET_CMD_INVALID				0x00
+/*< Invlaid Socket command value.
+*/
+#define SOCKET_CMD_BIND					0x41
+/*< Socket Binding command value.
+*/
+#define SOCKET_CMD_LISTEN				0x42
+/*< Socket Listening command value.
+*/
+#define SOCKET_CMD_ACCEPT				0x43
+/*< Socket Accepting command value.
+*/
+#define SOCKET_CMD_CONNECT				0x44
+/*< Socket Connecting command value.
+*/
+#define SOCKET_CMD_SEND					0x45
+/*< Socket send command value.
+*/
+#define SOCKET_CMD_RECV					0x46
+/*< Socket Recieve command value.
+*/
+#define SOCKET_CMD_SENDTO				0x47
+/*< Socket sendTo command value.
+*/
+#define SOCKET_CMD_RECVFROM				0x48
+/*< Socket RecieveFrom command value.
+*/
+#define SOCKET_CMD_CLOSE				0x49
+/*< Socket Close command value.
+*/
+#define SOCKET_CMD_DNS_RESOLVE			0x4A
+/*< Socket DNS Resolve command value.
+*/
+#define SOCKET_CMD_SSL_CONNECT			0x4B
+/*< SSL-Socket Connect command value.
+*/
+#define SOCKET_CMD_SSL_SEND				0x4C	
+/*< SSL-Socket Send command value.
+*/	
+#define SOCKET_CMD_SSL_RECV				0x4D
+/*< SSL-Socket Recieve command value.
+*/
+#define SOCKET_CMD_SSL_CLOSE			0x4E
+/*< SSL-Socket Close command value.
+*/
+#define SOCKET_CMD_DHCP_CLIENT			0x4F
+/*< DHCP Client command value.
+*/
+#define SOCKET_CMD_TCP_ERROR            0x50
+/*!< TCP Error command value.
+*/
+
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+DATA TYPES
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+/*
+*  @brief	
+*/
+typedef struct{	
+	uint16		u16Family;
+	uint16		u16Port;
+	uint32		u32IPAddr;
+}tstrSockAddr;
+
+
+
+/*
+@struct	\
+	tstrDnsReply
+	
+@brief
+	DNS Reply, contains hostName and HostIP.
+*/
+typedef struct{
+	char	acHostName[HOSTNAME_MAX_SIZE];
+	uint32	u32HostIP;
+}tstrDnsReply;
+
+
+/*
+@struct	\
+	tstrDhcpClientReply
+
+@brief
+	DHCP Client Reply, contains OfferIP.
+*/
+typedef struct{
+	uint32	u32OfferIP;
+	uint32	u32GatewayIP;
+}tstrDhcpClientReply;
+
+/*
+@struct	\
+	tstrConnectReply
+	
+@brief
+	Connect Reply, contains sock number and error value
+*/
+typedef struct{
+	SOCKET		sock;
+	sint8		s8Error;
+	uint16		u16Void;
+}tstrConnectReply;
+
+
+/*
+@struct \
+    tstrTCPErrorReply
+ 
+@brief
+    Connect Reply, contains sock number and error value
+*/
+typedef struct{
+    SOCKET      sock;
+    sint8       s8Error;
+    uint16      u16Void;
+}tstrTCPErrorReply;
+ 
+/*
+*  @brief
+*/
+typedef struct{
+	tstrSockAddr	strAddr;
+	SOCKET			sListenSock;
+	SOCKET			sConnectedSock;
+	uint16			u16Void;
+}tstrAcceptReply;
+
+
+/*
+@brief
+*/
+typedef struct{
+	SOCKET		sock;
+	sint8		s8Status;
+	uint16		u16Void;
+}tstrBindReply;
+
+
+/*
+@struct	\
+	tstrSocketRecvMsg
+	
+@brief	Socket recv status. 
+
+	It is passed to the APPSocketEventHandler with SOCKET_MSG_RECV or SOCKET_MSG_RECVFROM message type 
+	in a response to a user call to the recv or recvfrom.
+	If the received data from the remote peer is larger than the USER Buffer size (given at recv call), the data is 
+	delivered to the user in a number of consecutive chunks according to the USER Buffer size.
+*/
+typedef struct{
+	SOCKET		sock;
+	sint8		s8Status;
+	uint16		u16Void;
+}tstrListenReply;
+
+
+/*
+@struct	\
+	tstrSendReply
+	
+@brief
+	Send Reply, contains socket number and number of sent bytes.
+*/
+typedef struct{
+	SOCKET		sock;
+	uint8		u8Void;
+	sint16		s16SentBytes;
+}tstrSendReply;
+
+
+/*
+@struct
+@brief
+*/
+typedef struct{
+	tstrSockAddr	strRemoteAddr;
+	sint16			s16RecvStatus;
+	uint16			u16DataOffset;
+	SOCKET			sock;
+	uint8			u8Void;
+	uint16			u16Void;
+}tstrRecvReply;
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+FUNCTION PROTOTYPES
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+NMI_API void Socket_ReadSocketData(SOCKET sock, tstrSocketRecvMsg *pstrRecv,uint8 u8SocketMsg,
+								  uint32 u32StartAddress,uint16 u16ReadCount, uint8 u8Skip);
+
+#ifdef  __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __SOCKET_H__ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/socket_nmc.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,759 @@
+/*
+@file	
+	socket.h
+
+@brief	Socket Interface APIs
+
+	The file defines APIs and types of socket layer for the NMC1500 IoT solution. 	The APIs 	are very similar 
+	to the standard POSIX sockets APIs. The socket layer operates in asynchronus mode which means socket 
+	functions are non-blocking functions, requiring the result of a socket operation (eg. bind) is delivered later
+	in a callback function [APPSocketEventHandler](@ref APPSocketEventHandler).
+*/
+#ifndef __SOCKET_NMC_H__
+#define __SOCKET_NMC_H__
+
+#include "nmi_wlan_if.h"
+#include "nmi_wlan.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+INCLUDES
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+//#include "common\include\nm_common.h"
+
+#define NMI_API
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+MACROS
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+#define HOSTNAME_MAX_SIZE									64
+/*< Maximum allowed size for a host domain name.
+*/
+
+
+	
+#define SOCKET_BUFFER_MAX_LENGTH							1400
+/*< Maximum allowed size for a socket Data buffer.
+*/
+
+
+#define  AF_INET											2
+/*< Supported socket family. 
+*/
+
+
+#define  SOCK_STREAM										1
+/*< This is the identifier of TCP socket type.
+*/
+
+
+#define  SOCK_DGRAM											2
+/*< This is the identifier of UDP socket type.
+*/
+
+
+#define SOCKET_FLAGS_SSL									0x01
+/*< This flag shall be passed to the 
+	socket API for SSL session.
+*/
+
+
+#define TCP_SOCK_MAX										2//(7)
+/*< Maximum number of simultaneous TCP sockets.
+*/
+
+
+#define UDP_SOCK_MAX										2//4
+/*< Maximum number of simultaneous UDP sockets.
+*/
+
+
+#define MAX_SOCKET											(TCP_SOCK_MAX + UDP_SOCK_MAX)
+/*< Maximum number of Sockets.
+*/
+
+
+/**************
+Socket Errors
+**************/
+
+#define SOCK_ERR_NO_ERROR									0
+/*< Every thing is OK.
+*/
+
+
+#define SOCK_ERR_INVALID_ADDRESS							-1
+/*< Socket address is invalid. The socket operation cannot
+	be completed without address is specified. For example,
+	Bind is called without specifying a port number.
+*/
+
+
+#define SOCK_ERR_ADDR_ALREADY_IN_USE						-2
+/*< Cannot bind on the given address. It is already bound
+	by another opened socket.
+*/
+
+
+#define SOCK_ERR_MAX_TCP_SOCK								-3
+/*< The maximum number of TCP sockets is reached. Socket
+	creation failed.
+*/
+
+
+#define SOCK_ERR_MAX_UDP_SOCK								-4
+/*< The maximum number of UDP sockets is reached. Socket
+	creation failed.
+*/
+
+
+#define SOCK_ERR_INVALID_ARG								-6
+/*< An invalid arguement is passed to a function.
+*/
+
+
+#define SOCK_ERR_MAX_LISTEN_SOCK							-7
+/*< The maximum number of TCP passive listening sockets is
+	reached. Listen function fails.
+*/
+
+
+#define SOCK_ERR_INVALID									-9
+/*< The requested socket operation is not valid in the 
+	current socket state. For Example, accept is called on a
+	TCP socket before bind or listen.
+*/
+
+
+#define SOCK_ERR_ADDR_IS_REQUIRED							-11
+/*< The socket address is required for the operation to 
+	be completed. It is generated from sendto when there is
+	no valid address found to send the data to.
+*/
+
+
+#define SOCK_ERR_CONN_ABORTED								-12
+/*< The socket is closed by the peer. The local socket is 
+	closed also.
+*/
+
+
+#define SOCK_ERR_TIMEOUT									-13
+/*< The socket pending operation has been timedout. 
+*/
+
+
+#define SOCK_ERR_BUFFER_FULL								-14
+/*< The send operation could not be performed before the 
+	transmission buffer corresponding to this socket is busy.
+*/
+
+#ifndef _NM_BSP_BIG_END
+
+#define _htonl(m)				(m)	
+#define _htons(A)				(A)
+
+#else
+
+#define _htonl(m)		\
+	(uint32)(((uint32)(m << 24)) | ((uint32)((m & 0x0000FF00) << 8)) | ((uint32)((m & 0x00FF0000) >> 8)) | ((uint32)(m >> 24)))
+/*< Convert a 4-byte integer from the host representation to the Network byte order representation.
+*/
+
+
+#define _htons(A)   	(uint16)((((uint16) (A)) << 8) | (((uint16) (A)) >> 8))
+/*< Convert a 2-byte integer (short) from the host representation to the Network byte order representation.
+*/
+
+
+#endif
+
+
+#define _ntohl      		_htonl
+/*< Convert a 4-byte integer from the Network byte order representation to the host representation .
+*/
+
+
+#define _ntohs      		_htons
+/*< Convert a 2-byte integer from the Network byte order representation to the host representation .
+*/
+
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+DATA TYPES
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+/*
+@typedef	\	
+	SOCKET
+	
+@brief
+	Data type definition for socket handlers.
+*/
+typedef sint8  SOCKET;
+
+
+/*
+@struct	\
+	in_addr
+	
+@brief
+	IPv4 address representation.
+*/
+typedef struct{
+	uint32		s_addr;   
+	/*< Network Byte Order representation of the IPv4 address.
+	*/
+}in_addr_nmc;//Tsungta
+
+
+/*
+@struct	\
+	sockaddr
+	
+@brief
+	Generic socket address structure.
+*/
+struct sockaddr{
+    uint16		sa_family;
+    uint8		sa_data[14];
+};
+
+
+/*
+@struct	\
+	sockaddr_in
+	
+@brief
+	Socket address structure for IPV4 addresses.
+*/
+struct sockaddr_in_nmc{//Tsungta
+	uint16			sin_family;            
+	/*< The only supported value for this is AF_INET.
+	*/
+	uint16   		sin_port;              
+	/*< Port number of the socket address. It must be set in the 
+	Network Byte Order format (e.g. _htons(80)).
+	*/
+	in_addr_nmc			sin_addr;       //Tsungta
+	/*< IP Address [in_addr].
+	*/
+	uint8			sin_zero[8];          
+	/*< Dummy bytes.
+	*/
+};
+
+
+/*******************************************
+Specific Definitions for Asynchronous implementation
+*******************************************/
+
+/*
+@enum	\
+	tenuSocketCallbackMsgType
+	
+@brief
+	Socket message types for socket callback notifications.
+*/
+typedef enum{
+	SOCKET_MSG_BIND	= 1,
+	SOCKET_MSG_LISTEN,
+	SOCKET_MSG_DNS_RESOLVE,
+	SOCKET_MSG_ACCEPT,
+	SOCKET_MSG_CONNECT,
+	SOCKET_MSG_RECV,
+	SOCKET_MSG_SEND,
+	SOCKET_MSG_SENDTO,
+	SOCKET_MSG_RECVFROM,
+	SOCKET_MSG_DHCP_OFFER,
+	SOCKET_MSG_TCPERROR
+}tenuSocketCallbackMsgType;
+
+/*
+@struct	\
+	tstrSocketBindMsg
+	
+@brief	Socket bind status. 
+
+	It is passed to the APPSocketEventHandler with SOCKET_MSG_BIND message type 
+	in a response to a user call to bind.
+*/
+typedef struct{
+	sint8		status;
+	/*< The result of the bind operation.
+	*/
+}tstrSocketBindMsg;
+
+
+/*
+@struct	\
+	tstrSocketListenMsg
+	
+@brief	Socket listen status. 
+
+	It is passed to the APPSocketEventHandler with SOCKET_MSG_LISTEN message type 
+	in a response to a user call to listen.
+*/
+typedef struct{
+	sint8		status;
+	/*< Result of the listen operation.
+	*/
+}tstrSocketListenMsg;
+
+
+
+/*
+@struct	\
+	tstrSocketAcceptMsg
+	
+@brief	Socket accept status. 
+
+	It is passed to the APPSocketEventHandler with SOCKET_MSG_ACCEPT message type 
+	in a response to a user call to accept.
+*/
+typedef struct{
+	SOCKET		sock;
+	/*< Socket ID for the accepted connection with a remote peer. If it is a negative value, it refers to 
+	an accept error (accept failed).
+	*/
+	struct		sockaddr_in_nmc	strAddr;//Tsungta
+	/*< Socket address structure for the remote peer.
+	*/
+}tstrSocketAcceptMsg;
+
+
+/*
+@struct	\
+	tstrSocketConnectMsg
+	
+@brief	Socket connect status. 
+
+	It is passed to the APPSocketEventHandler with SOCKET_MSG_CONNECT message type 
+	in a response	to a user call to connect.
+*/
+typedef struct{
+	SOCKET	sock;
+	/*< Socket ID referring to the socket passed to the connect function call.
+	*/
+	sint8		s8Error;
+	/*< Connect error code. It shall be ZERO for successful connect and a negative number otherwise.
+	*/
+}tstrSocketConnectMsg;
+
+
+/*
+@struct	\
+    tstrSocketTCPErrorMsg
+    
+@brief  Socket connect status. 
+ 
+    It is passed to the APPSocketEventHandler with SOCKET_MSG_TCPERROR message type 
+    in a response   for TCP socket error.
+*/
+typedef struct{
+    SOCKET  sock;
+    /*< Socket ID referring to the socket passed to the TCP socket control function call.
+    */
+    sint8       s8Error;
+    /*< Connect error code. TCP socket handling errors.
+    */
+}tstrSocketTCPErrorMsg;
+ 
+/*
+@struct \
+
+	tstrSocketRecvMsg
+	
+@brief	Socket recv status. 
+
+	It is passed to the APPSocketEventHandler with SOCKET_MSG_RECV or SOCKET_MSG_RECVFROM message type 
+	in a response to a user call to the recv or recvfrom.
+	If the received data from the remote peer is larger than the USER Buffer size (given at recv call), the data is 
+	delivered to the user in a number of consecutive chunks according to the USER Buffer size.
+*/
+typedef struct{
+	uint8				*pu8Buffer;
+	/*< Pointer to the USER buffer (passed to recv or recvfrom) containing a received data chunk.
+	*/
+	sint16				s16BufferSize;
+	/*< The recevied data chunk size. It will be negative value if there is a recv error.
+	*/
+	uint16				u16RemainingSize;
+	/*< The number of bytes remaining in the current recv operation.
+	*/
+	struct sockaddr_in_nmc		strRemoteAddr;//Tsungta
+	/*< Socket address structure for the remote peer.
+	*/
+}tstrSocketRecvMsg;
+
+
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
+FUNCTION PROTOTYPES
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+/*
+@fn	\			
+	NMI_API void socketInit(void);
+
+@brief	Socket Layer Initialization
+
+	The function performs the necessary initializations for the socket library. 
+	It must be invoked before any socket operation is performed.
+*/
+NMI_API void socketInit(void);
+
+
+/*
+@fn	\			
+	NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags);
+
+@brief	
+	Creates a socket with a given type.
+
+@param [in]	u16Domain
+				Socket family. The only allowed value is AF_INET for TCP/UDP sockets.
+
+@param [in] u8Type
+				Socket type. Allowed values are:
+				- [SOCK_STREAM](@ref SOCK_STREAM)
+				- [SOCK_DGRAM](@ref SOCK_DGRAM)
+
+@param [in] u8Flags
+				Used to specify the socket creation flags. It shall be set to zero for normal TCP/UDP sockets.
+				If could be SOCKET_FLAGS_SSL if the socket is used for SSL session. The use of the flag
+				[SOCKET_FLAGS_SSL](@ref SOCKET_FLAGS_SSL) has no meaning in case of UDP sockets.
+
+@return		
+	The function shall return a negative value for socket creation failed and a nonnegative value
+	representing the socket ID otherwise.
+*/
+NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags);
+
+
+/*
+@fn	\			
+	NMI_API sint8 bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
+
+@brief	
+	Binds a socket on a local port.
+
+@param [in]	sock
+				Socket ID.
+
+@param [in] pstrAddr
+				Socket address for the address to be bound.
+
+@param [in] u8AddrLen
+				Size of the given address in bytes.
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint8 bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
+
+
+/*
+@fn	\			
+	NMI_API sint8 listen(SOCKET sock, uint8 backlog);
+
+@brief	
+	Start listening on a passive socket for incoming connections. The socket must be bound on a local port
+	or the listen fails. The listen function must be called at receiving [SOCKET_MSG_BIND](@ref SOCKET_MSG_BIND)
+	in the socket callback.
+
+@param [in]	sock
+				Socket ID.
+
+@param [in] backlog
+				Number of maximum allowed connections that will be accepted on the given socket.
+				It is not used by the current implementation.
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint8 listen(SOCKET sock, uint8 backlog);
+
+
+/*
+@fn	\			
+	NMI_API sint8 accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen);
+
+@brief	
+	Retrieve a successful connection .
+
+@param [in]	sock
+				Socket ID.
+
+@param [in] addr
+				It is not used in the current implementation.
+
+@param [in] addrlen
+				It is not used in the current implementation.
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint8 accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen);
+
+
+/*
+@fn	\	
+	NMI_API sint8 connect(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
+
+@brief	
+	Establishes a TCP connection with a remote server.
+
+@param [in]	sock
+				Socket ID.
+
+@param [in]	pstrAddr
+				Address of the remote server.
+
+@param [in]	u8AddrLen
+				Address length in  bytes.
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint8 connect(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
+
+
+/*
+@fn	\		
+	NMI_API sint16 recv(SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, uint32 u32TimeoutSeconds);
+
+@brief		
+	Recieves data from a TCP Scoket.
+
+@param [in]	sock
+				Socket handler.
+
+@param [in]	pvRecvBuf
+				Pointer to a buffer that will hold the received data. The buffer shall be used 
+				in the recv callback to deliver the received data to the caller. The buffer must
+				be resident in memory (heap or global buffer). 
+
+@param [in]	u16BufLen
+				The buffer size in bytes.
+
+@param [in]	u32Timeoutmsec
+				Timeout for the recv function in milli-seconds. If the value is set to ZERO, the timeout
+				will be set to infinite (the recv function waits forever). If the timeout period is
+				elapsed with no data received, the socket will get a timeout error in the function
+				[APPSocketEventHandler](@ref APPSocketEventHandler).
+
+@return		
+	- [SOCK_ERR_NO_ERROR](@ref SOCK_ERR_NO_ERROR)
+	- [SOCK_ERR_INVALID_ARG](@ref SOCK_ERR_INVALID_ARG)
+*/
+NMI_API sint16 recv(SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, uint32 u32Timeoutmsec);
+
+
+/*
+@fn	\	
+	NMI_API sint16 recvfrom(SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, uint32 u32TimeoutSeconds);
+
+@brief		
+	Recieves data from a UDP Scoket.
+
+@param [in]	sock
+				Socket handler.
+
+@param [in]	pvRecvBuf
+				Pointer to a buffer that will hold the received data. The buffer shall be used 
+				in the recv callback to deliver the received data to the caller. The buffer must
+				be resident in memory (heap or global buffer). 
+
+@param [in]	u16BufLen
+				The buffer size in bytes.
+
+@param [in]	u32TimeoutSeconds
+				Timeout for the recv function in milli-seconds. If the value is set to ZERO, the timeout
+				will be set to infinite (the recv function waits forever).
+
+@return		
+	- [SOCK_ERR_NO_ERROR](@ref SOCK_ERR_NO_ERROR)		
+	- [SOCK_ERR_INVALID_ARG](@ref SOCK_ERR_INVALID_ARG)
+*/
+NMI_API sint16 recvfrom(SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, uint32 u32Timeoutmsec);
+
+
+/*
+@fn	\		
+	NMI_API sint16 send(SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 u16Flags);
+
+@brief		
+	Sends data on a TCP Scoket.
+
+@param [in]	sock
+				Socket handler.
+
+@param [in]	pvSendBuffer
+				Pointer to a buffer that holding data to be transmitted. 
+
+@param [in]	u16SendLength
+				The buffer size in bytes. It must not exceed [SOCKET_BUFFER_MAX_LENGTH](@ref SOCKET_BUFFER_MAX_LENGTH).
+
+@param [in]	u16Flags
+				It is not used in the current implementation
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint16 send_nmc(SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 u16Flags);
+
+
+/*
+@fn	\		
+	NMI_API sint16 sendto(SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 flags, struct sockaddr *pstrDestAddr, uint8 u8AddrLen);
+
+@brief		
+	Sends data on a UDP Scoket.
+
+@param [in]	sock
+				Socket handler.
+
+@param [in]	pvSendBuffer
+				Pointer to a buffer that holding data to be transmitted. 
+
+@param [in]	u16SendLength
+				The buffer size in bytes. It must not exceed [SOCKET_BUFFER_MAX_LENGTH](@ref SOCKET_BUFFER_MAX_LENGTH).
+
+@param [in]	flags
+				It is not used in the current implementation
+
+@param [in]	pstrDestAddr
+				The destination address.
+
+@param [in]	u8AddrLen
+				Destination address length in bytes.
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint16 sendto(SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 flags, struct sockaddr *pstrDestAddr, uint8 u8AddrLen);
+
+
+/*
+@fn	\		
+	NMI_API sint8 close(SOCKET sock);
+
+@brief		
+	Closes a socket.
+
+@param [in]	sock
+				Socket handler.
+
+@return		
+	The function shall return ZERO for successful operation and a negative value otherwise. 
+*/
+NMI_API sint8 close_nmc(SOCKET sock);
+
+
+/*
+@fn	\		
+	NMI_API sint8 gethostbyname(uint8 * pcHostName);
+
+@brief		
+	Use DNS to resolve a domain name into the corresponding IP Address.
+
+@param [in]	pcHostName
+				NULL terminated string containing the domain name for the remote host.
+				Its size must not exceed [HOSTNAME_MAX_SIZE](@ref HOSTNAME_MAX_SIZE).
+
+@return		
+	- [SOCK_ERR_NO_ERROR](@ref SOCK_ERR_NO_ERROR)
+	- [SOCK_ERR_INVALID_ARG](@ref SOCK_ERR_INVALID_ARG)
+*/
+NMI_API sint8 gethostbyname(uint8 * pcHostName);
+
+
+/*
+@fn	\		
+	NMI_API uint32 nmi_inet_addr(char *pcIpAddr);
+
+@brief		
+	Convert the IPv4 from the dotted decimal notation to an integer represented in Network Byte Order.
+
+@param [in]	pcIpAddr
+				NULL terminated string containing the dotted decimal notation for an IP "a.b.c.d".
+
+@return		
+	The integer representation of the IPv4 address in network byte order.
+*/
+NMI_API uint32 nmi_inet_addr(char *pcIpAddr);
+
+
+/*
+@fn	\		
+	NMI_API void APPSocketEventHandler(SOCKET sock, uint8 u8Msg, void * pvMsg);
+
+@brief	Socket Callback Function
+
+	A function used by the socket layer to convey a socket operation callback to the user. This function MUST be
+	implemeneted by the application developer.
+	
+@param [in]	sock
+				Socket ID.
+
+@param [in]	u8Msg
+				Socket message type [tenuSocketCallbackMsgType](@ref tenuSocketCallbackMsgType).
+
+@param [in]	pvMsg
+				Msg parameters corresponding to the message type.	
+
+@sa			tstrSocketBindMsg
+			tstrSocketListenMsg
+			tstrSocketAcceptMsg
+			tstrSocketConnectMsg
+			tstrSocketRecvMsg
+*/
+NMI_API void APPSocketEventHandler(SOCKET sock, uint8 u8Msg, void * pvMsg);
+
+
+/*
+@fn	\		
+	NMI_API void AppServerCb(uint8* pu8DomainName, uint32 u32ServerIP);
+
+@brief		
+	DNS host name resolution callback.
+
+@param [in]	pu8DomainName
+				NULL terminated string containing the Domain name of a host (eg. "www.Google.com").
+
+@param [in]	u32ServerIP
+				IP Address corresponding to the domain name. It is formatted in network byte order.
+*/
+NMI_API void AppServerCb(uint8* pu8DomainName, uint32 u32ServerIP);
+
+//Ryan
+typedef void (*tf_APPSocketEventHandler)(SOCKET sock, uint8 u8Msg, void * pvMsg);
+
+NMI_API void m2m_set_app(tf_APPSocketEventHandler str);
+
+#define M2M_HIF_HDR_OFFSET (sizeof(tstrHifHdr))
+
+/*
+*	@struct		tstrHifHdr
+*	@brief		Structure to hold HIF header
+*	@author		Mahfouz Sheref
+*	@version	1.0
+*/ 
+typedef struct 
+{
+    uint8   u8Gid;		/*< Group ID */
+    uint8   u8Opcode;	/*< OP code */
+    uint16  u16Length;	/*< Payload length */
+}tstrHifHdr;
+
+#ifdef  __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __SOCKET_H__ */
Binary file WIFI_Driver/nmc/socket_nmc.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nmc/strc.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,70 @@
+#include "nmi_wlan.h"
+#include "nmi_wlan_if.h"
+
+#ifndef __STRC_H__
+ #define __STRC_H__
+ 
+typedef struct {
+	void *priv;
+	void (*scan_callback)(void *, nmi_wl_bss_t *, int, int);
+} scan_session_t;
+
+typedef struct {
+	int bss_type;
+	int connect;
+	void *priv;
+	u8 sa[6];
+	u8 bssid[6];
+	void (*join_callback)(void *, nmi_wl_join_rsp_t *);
+	void (*disconnect_callback)(void *);
+	int dhcp_check;
+
+} join_session_t;
+
+typedef struct wlan_t {
+
+	u32 chipid;
+	u32 fw_state;
+
+	/**
+	**/
+	nmi_wl_platform_t plat;
+	nmi_wl_if_t hif;	
+
+	/**
+		TX queue
+	**/
+	que_hdr_t txq_h;
+
+	/**
+		RX queue
+	**/
+	que_hdr_t rxq_h;
+
+	/**
+		CFG queue
+	**/
+	que_hdr_t cfg_w_h;
+	que_hdr_t cfg_q_h;
+	que_hdr_t cfg_q_rsp_h;
+	u32 cfg_id;
+
+	scan_session_t scan_sess;	
+	join_session_t join_sess;
+	
+	int rx_isr;
+ 	int sleep;
+	int fw_en_sleep;
+
+	u8 mac_addr[6];   /* ksong add 2013.5.16 */
+
+	u32 scan_cmd_cnt;	/* ksong 2013-8-9 */
+	u32 join_cmd_cnt;	/* ksong 2013-8-9 */
+	
+#ifdef STATIC_TX_BUFFER
+	u8 tx_buffer[600];//[8*1024];
+#endif
+
+} nmi_wlan_t;
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/boards.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,29 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+#ifndef BOARDS_H
+#define BOARDS_H
+
+#define BOARD_PCA10001//Tsungta
+
+#if defined(BOARD_NRF6310)
+  #include "boards/nrf6310.h"
+#elif defined(BOARD_PCA10000)
+  #include "boards/pca10000.h"
+#elif defined(BOARD_PCA10001)
+  #include "pca10001.h"//Tsungta
+#elif defined(BOARD_PCA10003)
+  #include "boards/pca10003.h"
+#else
+#error "Board is not defined"
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/nrf_ecb.c	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,73 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+*
+* The information contained herein is property of Nordic Semiconductor ASA.
+* Terms and conditions of usage are described in detail in NORDIC
+* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 
+*
+* Licensees are granted free, non-transferable use of the information. NO
+* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+* the file.
+*
+* $LastChangedRevision: 25419 $
+*/ 
+
+/** 
+ * @file
+ * @brief Implementation of AES ECB driver
+ */
+
+
+//lint -e438
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include "nrf51.h" // Tsungta
+#include "nrf_ecb.h"
+
+static uint8_t  ecb_data[48];   ///< ECB data structure for RNG peripheral to access.
+static uint8_t* ecb_key;        ///< Key:        Starts at ecb_data 
+static uint8_t* ecb_cleartext;  ///< Cleartext:  Starts at ecb_data + 16 bytes.
+static uint8_t* ecb_ciphertext; ///< Ciphertext: Starts at ecb_data + 32 bytes.
+
+bool nrf_ecb_init(void)
+{
+  ecb_key = ecb_data;
+  ecb_cleartext  = ecb_data + 16;
+  ecb_ciphertext = ecb_data + 32;
+
+  NRF_ECB->ECBDATAPTR = (uint32_t)ecb_data;
+  return true;
+}
+
+
+bool nrf_ecb_crypt(uint8_t * dest_buf, const uint8_t * src_buf)
+{
+   uint32_t counter = 0x1000000;
+   if(src_buf != ecb_cleartext)
+   {
+     memcpy(ecb_cleartext,src_buf,16);
+   }
+   NRF_ECB->EVENTS_ENDECB = 0;
+   NRF_ECB->TASKS_STARTECB = 1;
+   while(NRF_ECB->EVENTS_ENDECB == 0)
+   {
+    counter--;
+    if(counter == 0)
+    {
+      return false;
+    }
+   }
+   NRF_ECB->EVENTS_ENDECB = 0;
+   if(dest_buf != ecb_ciphertext)
+   {
+     memcpy(dest_buf,ecb_ciphertext,16);
+   }
+   return true;
+}
+
+void nrf_ecb_set_key(const uint8_t * key)
+{
+  memcpy(ecb_key,key,16);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/nrf_ecb.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,66 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is confidential property of Nordic 
+ * Semiconductor ASA.Terms and conditions of usage are described in detail 
+ * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *              
+ * $LastChangedRevision: 13999 $
+ */
+
+/**
+ * @file
+ * @brief ECB driver API.
+ */
+
+#ifndef NRF_ECB_H__
+#define NRF_ECB_H__
+
+/**
+ * @defgroup nrf_ecb AES ECB encryption
+ * @{
+ * @ingroup nrf_drivers
+ * @brief Driver for the nRF51 AES Electronic Code Book (ECB) peripheral.
+ *
+ * In order to encrypt and decrypt data the peripheral must be powered on
+ * using nrf_ecb_init() and then the key set using nrf_ecb_set_key.
+ */
+
+#include <stdint.h>
+
+/**
+ * Initialize and power on the ECB peripheral.
+ *
+ * Allocates memory for the ECBDATAPTR.
+ * @retval true Initialization was successful.
+ * @retval false Powering up failed.
+ */
+bool nrf_ecb_init(void);
+
+/**
+ * Encrypt/decrypt 16-byte data using current key.
+ *
+ * The function avoids unnecessary copying of data if the point to the 
+ * correct locations in the ECB data structure.
+ *
+ * @param dst Result of encryption/decryption. 16 bytes will be written. 
+ * @param src Source with 16-byte data to be encrypted/decrypted.
+ *
+ * @retval true  If the encryption operation completed.
+ * @retval false If the encryption operation did not complete.
+ */
+bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src);
+//
+/**
+ * Set the key to be used for encryption/decryption.
+ *
+ * @param key Pointer to key. 16 bytes will be read.
+ */
+void nrf_ecb_set_key(const uint8_t * key);
+
+#endif  // NRF_ECB_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/nrf_gpio.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,422 @@
+#ifndef NRF_GPIO_H__
+#define NRF_GPIO_H__
+
+#include "nrf51.h"
+#include "nrf51_bitfields.h"
+
+/**
+ * @defgroup nrf_gpio GPIO abstraction
+ * @{
+ * @ingroup nrf_drivers
+ * @brief GPIO pin abstraction and port abstraction for reading and writing byte-wise to GPIO ports.
+ *
+ * Here, the GPIO ports are defined as follows:
+ * - Port 0 -> pin 0-7
+ * - Port 1 -> pin 8-15
+ * - Port 2 -> pin 16-23
+ * - Port 3 -> pin 24-31
+ */
+
+/**
+ * @enum nrf_gpio_port_dir_t
+ * @brief Enumerator used for setting the direction of a GPIO port.
+ */
+typedef enum
+{
+    NRF_GPIO_PORT_DIR_OUTPUT,       ///<  Output
+    NRF_GPIO_PORT_DIR_INPUT         ///<  Input
+} nrf_gpio_port_dir_t;
+
+/**
+ * @enum nrf_gpio_pin_dir_t
+ * Pin direction definitions.
+ */
+typedef enum
+{
+    NRF_GPIO_PIN_DIR_INPUT,   ///< Input
+    NRF_GPIO_PIN_DIR_OUTPUT   ///< Output
+} nrf_gpio_pin_dir_t;
+
+/**
+ * @enum nrf_gpio_port_select_t
+ * @brief Enumerator used for selecting between port 0 - 3.
+ */
+typedef enum
+{
+    NRF_GPIO_PORT_SELECT_PORT0 = 0,           ///<  Port 0 (GPIO pin 0-7)
+    NRF_GPIO_PORT_SELECT_PORT1,               ///<  Port 1 (GPIO pin 8-15)
+    NRF_GPIO_PORT_SELECT_PORT2,               ///<  Port 2 (GPIO pin 16-23)
+    NRF_GPIO_PORT_SELECT_PORT3,               ///<  Port 3 (GPIO pin 24-31)
+} nrf_gpio_port_select_t;
+
+/**
+ * @enum nrf_gpio_pin_pull_t
+ * @brief Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration
+ */
+typedef enum
+{
+    NRF_GPIO_PIN_NOPULL   = GPIO_PIN_CNF_PULL_Disabled,                 ///<  Pin pullup resistor disabled
+    NRF_GPIO_PIN_PULLDOWN = GPIO_PIN_CNF_PULL_Pulldown,                 ///<  Pin pulldown resistor enabled
+    NRF_GPIO_PIN_PULLUP   = GPIO_PIN_CNF_PULL_Pullup,                   ///<  Pin pullup resistor enabled
+} nrf_gpio_pin_pull_t;
+
+/**
+ * @enum nrf_gpio_pin_sense_t
+ * @brief Enumerator used for selecting the pin to sense high or low level on the pin input.
+ */
+typedef enum
+{
+    NRF_GPIO_PIN_NOSENSE    = GPIO_PIN_CNF_SENSE_Disabled,              ///<  Pin sense level disabled.
+    NRF_GPIO_PIN_SENSE_LOW  = GPIO_PIN_CNF_SENSE_Low,                   ///<  Pin sense low level.
+    NRF_GPIO_PIN_SENSE_HIGH = GPIO_PIN_CNF_SENSE_High,                  ///<  Pin sense high level.
+} nrf_gpio_pin_sense_t;
+
+/**
+ * @brief Function for configuring the GPIO pin range as outputs with normal drive strength.
+ *        This function can be used to configure pin range as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
+ *
+ * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
+ *
+ * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
+ *
+ * @note For configuring only one pin as output use @ref nrf_gpio_cfg_output
+ *       Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output.
+ */
+static __INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end)
+{
+    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
+    for (; pin_range_start <= pin_range_end; pin_range_start++)
+    {
+        NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                                        | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                                        | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
+                                        | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
+                                        | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
+    }
+}
+
+/**
+ * @brief Function for configuring the GPIO pin range as inputs with given initial value set, hiding inner details.
+ *        This function can be used to configure pin range as simple input.
+ *
+ * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
+ *
+ * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
+ *
+ * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high)
+ *
+ * @note  For configuring only one pin as input use @ref nrf_gpio_cfg_input
+ *        Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable
+ */
+static __INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start, uint32_t pin_range_end, nrf_gpio_pin_pull_t pull_config)
+{
+    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
+    for (; pin_range_start <= pin_range_end; pin_range_start++)
+    {
+        NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                                        | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                                        | (pull_config << GPIO_PIN_CNF_PULL_Pos)
+                                        | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                                        | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
+    }
+}
+
+/**
+ * @brief Function for configuring the given GPIO pin number as output with given initial value set, hiding inner details.
+ *        This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
+ *
+ * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30)
+ *
+ * @note  Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output.
+ */
+static __INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
+{
+    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
+    NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                                            | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                                            | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
+                                            | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
+                                            | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
+}
+
+/**
+ * @brief Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details.
+ *        This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
+ *
+ * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30)
+ *
+ * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high)
+ *
+ * @note  Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable
+ */
+static __INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config)
+{
+    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
+    NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                                        | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                                        | (pull_config << GPIO_PIN_CNF_PULL_Pos)
+                                        | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                                        | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
+}
+
+/**
+ * @brief Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details.
+ *        This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
+ *        Sense capability on the pin is configurable, and input is connected to buffer so that the GPIO->IN register is readable.
+ *
+ * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30).
+ *
+ * @param pull_config state of the pin pull resistor (no pull, pulled down or pulled high).
+ *
+ * @param sense_config sense level of the pin (no sense, sense low or sense high).
+ */
+static __INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config, nrf_gpio_pin_sense_t sense_config)
+{
+    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
+    NRF_GPIO->PIN_CNF[pin_number] = (sense_config << GPIO_PIN_CNF_SENSE_Pos)
+                                        | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                                        | (pull_config << GPIO_PIN_CNF_PULL_Pos)
+                                        | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                                        | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
+}
+
+/**
+ * @brief Function for setting the direction for a GPIO pin.
+ *
+ * @param pin_number specifies the pin number [0:31] for which to
+ * set the direction.
+ *
+ * @param direction specifies the direction
+ */
+static __INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction)
+{
+    if(direction == NRF_GPIO_PIN_DIR_INPUT)
+    {
+        NRF_GPIO->PIN_CNF[pin_number] =
+          (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+        | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+        | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
+        | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+        | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
+    }
+    else
+    {
+        NRF_GPIO->DIRSET = (1UL << pin_number);
+    }
+}
+
+/**
+ * @brief Function for setting a GPIO pin.
+ *
+ * Note that the pin must be configured as an output for this
+ * function to have any effect.
+ *
+ * @param pin_number specifies the pin number [0:31] to
+ * set.
+ */
+static __INLINE void nrf_gpio_pin_set(uint32_t pin_number)
+{
+    NRF_GPIO->OUTSET = (1UL << pin_number);
+}
+
+/**
+ * @brief Function for clearing a GPIO pin.
+ *
+ * Note that the pin must be configured as an output for this
+ * function to have any effect.
+ *
+ * @param pin_number specifies the pin number [0:31] to
+ * clear.
+ */
+static __INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
+{
+    NRF_GPIO->OUTCLR = (1UL << pin_number);
+}
+
+/**
+ * @brief Function for toggling a GPIO pin.
+ *
+ * Note that the pin must be configured as an output for this
+ * function to have any effect.
+ *
+ * @param pin_number specifies the pin number [0:31] to
+ * toggle.
+ */
+static __INLINE void nrf_gpio_pin_toggle(uint32_t pin_number)
+{
+    const uint32_t pin_bit   = 1UL << pin_number;
+    const uint32_t pin_state = ((NRF_GPIO->OUT >> pin_number) & 1UL);
+    
+    if (pin_state == 0)
+    {
+        // Current state low, set high.
+        NRF_GPIO->OUTSET = pin_bit;        
+    }
+    else
+    {
+        // Current state high, set low.    
+        NRF_GPIO->OUTCLR = pin_bit;       
+    }
+}
+
+/**
+ * @brief Function for writing a value to a GPIO pin.
+ *
+ * Note that the pin must be configured as an output for this
+ * function to have any effect.
+ *
+ * @param pin_number specifies the pin number [0:31] to
+ * write.
+ *
+ * @param value specifies the value to be written to the pin.
+ * @arg 0 clears the pin
+ * @arg >=1 sets the pin.
+ */
+static __INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value)
+{
+    if (value == 0)
+    {
+        nrf_gpio_pin_clear(pin_number);
+    }
+    else
+    {
+        nrf_gpio_pin_set(pin_number);
+    }
+}
+
+/**
+ * @brief Function for reading the input level of a GPIO pin.
+ *
+ * Note that the pin must have input connected for the value
+ * returned from this function to be valid.
+ *
+ * @param pin_number specifies the pin number [0:31] to
+ * read.
+ *
+ * @return
+ * @retval 0 if the pin input level is low.
+ * @retval 1 if the pin input level is high.
+ * @retval > 1 should never occur.
+ */
+static __INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number)
+{
+    return  ((NRF_GPIO->IN >> pin_number) & 1UL);
+}
+
+/**
+ * @brief Generic function for writing a single byte of a 32 bit word at a given
+ * address.
+ *
+ * This function should not be called from outside the nrf_gpio
+ * abstraction layer.
+ *
+ * @param word_address is the address of the word to be written.
+ *
+ * @param byte_no is the the word byte number (0-3) to be written.
+ *
+ * @param value is the value to be written to byte "byte_no" of word
+ * at address "word_address"
+ */
+static __INLINE void nrf_gpio_word_byte_write(volatile uint32_t * word_address, uint8_t byte_no, uint8_t value)
+{
+    *((volatile uint8_t*)(word_address) + byte_no) = value;
+}
+
+/**
+ * @brief Generic function for reading a single byte of a 32 bit word at a given
+ * address.
+ *
+ * This function should not be called from outside the nrf_gpio
+ * abstraction layer.
+ *
+ * @param word_address is the address of the word to be read.
+ *
+ * @param byte_no is the the byte number (0-3) of the word to be read.
+ *
+ * @return byte "byte_no" of word at address "word_address".
+ */
+static __INLINE uint8_t nrf_gpio_word_byte_read(const volatile uint32_t* word_address, uint8_t byte_no)
+{
+    return (*((const volatile uint8_t*)(word_address) + byte_no));
+}
+
+/**
+ * @brief Function for setting the direction of a port.
+ *
+ * @param port is the port for which to set the direction.
+ *
+ * @param dir direction to be set for this port.
+ */
+static __INLINE void nrf_gpio_port_dir_set(nrf_gpio_port_select_t port, nrf_gpio_port_dir_t dir)
+{
+    if (dir == NRF_GPIO_PORT_DIR_OUTPUT)
+    {
+        nrf_gpio_word_byte_write(&NRF_GPIO->DIRSET, port, 0xFF);
+    }
+    else
+    {
+        nrf_gpio_range_cfg_input(port*8, (port+1)*8-1, NRF_GPIO_PIN_NOPULL);
+    }
+}
+
+/**
+ * @brief Function for reading a GPIO port.
+ *
+ * @param port is the port to read.
+ *
+ * @return the input value on this port.
+ */
+static __INLINE uint8_t nrf_gpio_port_read(nrf_gpio_port_select_t port)
+{
+    return nrf_gpio_word_byte_read(&NRF_GPIO->IN, port);
+}
+
+/**
+ * @brief Function for writing to a GPIO port.
+ *
+ * @param port is the port to write.
+ *
+ * @param value is the value to write to this port.
+ *
+ * @sa nrf_gpio_port_dir_set()
+ */
+static __INLINE void nrf_gpio_port_write(nrf_gpio_port_select_t port, uint8_t value)
+{
+    nrf_gpio_word_byte_write(&NRF_GPIO->OUT, port, value);
+}
+
+/**
+ * @brief Function for setting individual pins on GPIO port.
+ *
+ * @param port is the port for which to set the pins.
+ *
+ * @param set_mask is a mask specifying which pins to set. A bit
+ * set to 1 indicates that the corresponding port pin shall be
+ * set.
+ *
+ * @sa nrf_gpio_port_dir_set()
+ */
+static __INLINE void nrf_gpio_port_set(nrf_gpio_port_select_t port, uint8_t set_mask)
+{
+    nrf_gpio_word_byte_write(&NRF_GPIO->OUTSET, port, set_mask);
+}
+
+/**
+ * @brief Function for clearing individual pins on GPIO port.
+ *
+ * @param port is the port for which to clear the pins.
+ *
+ * @param clr_mask is a mask specifying which pins to clear. A bit
+ * set to 1 indicates that the corresponding port pin shall be
+ * cleared.
+ *
+ * @sa nrf_gpio_port_dir_set()
+ */
+static __INLINE void nrf_gpio_port_clear(nrf_gpio_port_select_t port, uint8_t clr_mask)
+{
+    nrf_gpio_word_byte_write(&NRF_GPIO->OUTCLR, port, clr_mask);
+}
+
+/** @} */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/pca10001.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,69 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ *//* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+#ifndef PCA10001_H
+#define PCA10001_H
+
+#include "nrf_gpio.h"
+
+#define LED_START      18
+#define LED_0          18
+#define LED_1          19
+#define LED_STOP       19
+
+#define BUTTON_START   16
+#define BUTTON_0       16
+#define BUTTON_1       17
+#define BUTTON_STOP    17
+#define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
+
+#define RX_PIN_NUMBER  23//22//0//11	// modified by Tsungta
+#define TX_PIN_NUMBER  25//2//9	// modified by Tsungta
+#define CTS_PIN_NUMBER 10
+#define RTS_PIN_NUMBER 8
+#define HWFC           false//true
+
+#endif
+
+#ifndef PCA10001_H
+#define PCA10001_H
+
+#define LED_START      18
+#define LED0           18
+#define LED_STOP       19
+#define LED1           19
+#define LED_PORT       NRF_GPIO_PORT_SELECT_PORT2
+#define LED_OFFSET     2
+
+#define BUTTON_START   16
+#define BUTTON0        16
+#define BUTTON_STOP    17
+#define BUTTON1        17
+
+#define RX_PIN_NUMBER  11
+#define TX_PIN_NUMBER  9
+#define CTS_PIN_NUMBER 10
+#define RTS_PIN_NUMBER 8
+#define HWFC           false
+
+#define BLINKY_STATE_MASK   0x01
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/simple_uart.c	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,112 @@
+/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#include <stdint.h>
+
+//#include "nrf.h"  //command by Tsungta @12/12 when trying to porting on mbed online compilier
+#include "simple_uart.h"
+//#include "nrf_delay.h"
+#include "nrf_gpio.h"
+
+extern uint8_t rx_isr;
+extern uint8_t hif;
+extern uint8_t udp_client_test;
+uint8_t simple_uart_get(void)
+{
+  while (NRF_UART0->EVENTS_RXDRDY != 1 && rx_isr == 0 && hif == 0 && udp_client_test == 0)
+  {
+    // Wait for RXD data to be received
+  }
+  
+  NRF_UART0->EVENTS_RXDRDY = 0;
+  return (uint8_t)NRF_UART0->RXD;
+}
+
+//bool simple_uart_get_with_timeout(int32_t timeout_ms, uint8_t *rx_data)
+//{
+//  bool ret = true;
+//  
+//  while (NRF_UART0->EVENTS_RXDRDY != 1)
+//  {
+//    if (timeout_ms-- >= 0)
+//    {
+//      // wait in 1ms chunk before checking for status
+//      nrf_delay_us(1000);
+//    }
+//    else
+//    {
+//      ret = false;
+//      break;
+//    }
+//  }  // Wait for RXD data to be received
+//
+//  if (timeout_ms >= 0)
+//  {
+//    // clear the event and set rx_data with received byte
+//      NRF_UART0->EVENTS_RXDRDY = 0;
+//      *rx_data = (uint8_t)NRF_UART0->RXD;
+//  }
+//
+//  return ret;
+//}
+
+void simple_uart_put(uint8_t cr)
+{
+  NRF_UART0->TXD = (uint8_t)cr;
+
+  while (NRF_UART0->EVENTS_TXDRDY!=1)
+  {
+    // Wait for TXD data to be sent
+  }
+
+  NRF_UART0->EVENTS_TXDRDY=0;
+}
+
+void simple_uart_putstring(const uint8_t *str)
+{
+  uint_fast8_t i = 0;
+  uint8_t ch = str[i++];
+  while (ch != '\0')
+  {
+    simple_uart_put(ch);
+    ch = str[i++];
+  }
+}
+
+void simple_uart_config(  uint8_t rts_pin_number,
+                          uint8_t txd_pin_number,
+                          uint8_t cts_pin_number,
+                          uint8_t rxd_pin_number,
+                          bool hwfc)
+{
+  nrf_gpio_cfg_output(txd_pin_number);
+  nrf_gpio_cfg_input(rxd_pin_number, NRF_GPIO_PIN_NOPULL);  
+
+  NRF_UART0->PSELTXD = txd_pin_number;
+  NRF_UART0->PSELRXD = rxd_pin_number;
+
+  if (hwfc)
+  {
+    nrf_gpio_cfg_output(rts_pin_number);
+    nrf_gpio_cfg_input(cts_pin_number, NRF_GPIO_PIN_NOPULL);
+    NRF_UART0->PSELCTS = cts_pin_number;
+    NRF_UART0->PSELRTS = rts_pin_number;
+    NRF_UART0->CONFIG  = (UART_CONFIG_HWFC_Enabled << UART_CONFIG_HWFC_Pos);
+  }
+
+//  NRF_UART0->BAUDRATE         = (UART_BAUDRATE_BAUDRATE_Baud38400 << UART_BAUDRATE_BAUDRATE_Pos);
+  NRF_UART0->BAUDRATE         = (UART_BAUDRATE_BAUDRATE_Baud115200 << UART_BAUDRATE_BAUDRATE_Pos);
+  NRF_UART0->ENABLE           = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
+  NRF_UART0->TASKS_STARTTX    = 1;
+  NRF_UART0->TASKS_STARTRX    = 1;
+  NRF_UART0->EVENTS_RXDRDY    = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/simple_uart.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,72 @@
+ /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#ifndef SIMPLE_UART_H
+#define SIMPLE_UART_H
+
+/*lint ++flb "Enter library region" */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/* @file
+* @brief Simple UART driver
+*
+*
+* @defgroup nrf_drivers_simple_uart Simple UART driver
+* @{
+* @ingroup nrf_drivers
+* @brief Simple UART driver
+*/
+
+/** Reads a character from UART.
+Execution is blocked until UART peripheral detects character has been received.
+\return cr Received character.
+*/
+uint8_t simple_uart_get(void);
+
+/** Reads a character from UART with timeout on how long to wait for the byte to be received
+Execution is blocked until UART peripheral detects character has been received or until the timeout expires, which even occurs first
+\return bool True, if byte is received before timeout, else returns False.
+@param timeout_ms maximum time to wait for the data.
+@param rx_data pointer to the memory where the received data is stored.
+*/
+bool simple_uart_get_with_timeout(int32_t timeout_ms, uint8_t *rx_data);
+
+/** Sends a character to UART.
+Execution is blocked until UART peripheral reports character to have been send.
+@param cr Character to send.
+*/
+void simple_uart_put(uint8_t cr);
+
+/** Sends a string to UART.
+Execution is blocked until UART peripheral reports all characters to have been send.
+Maximum string length is 254 characters including null character in the end.
+@param str Null terminated string to send.
+*/
+void simple_uart_putstring(const uint8_t *str);
+
+/** Configures UART to use 38400 baud rate.
+@param rts_pin_number Chip pin number to be used for UART RTS
+@param txd_pin_number Chip pin number to be used for UART TXD
+@param cts_pin_number Chip pin number to be used for UART CTS
+@param rxd_pin_number Chip pin number to be used for UART RXD
+@param hwfc Enable hardware flow control
+*/
+void simple_uart_config(uint8_t rts_pin_number, uint8_t txd_pin_number, uint8_t cts_pin_number, uint8_t rxd_pin_number, bool hwfc);
+
+/**
+ *@}
+ **/
+
+/*lint --flb "Leave library region" */
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/spi_flash.c	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,462 @@
+/* 
+ *	Generated for windbond flash
+ */
+
+#include <string.h>
+#include <spi_flash.h>
+//#include "nrf_delay.h"
+#include "nrf_gpio.h"
+//#include "common.h"
+#include "spi_master_config.h" // This file must be in the application folder
+
+#include "simple_uart.h"
+
+#include "spi_master.h"
+
+#include "wait_api.h"
+
+#if 1	//marcus add for flash read/write
+#define MFG_ID_WINBOND (0xEF)
+#define DEVICE_ID_WINBOND_8M (0x5014)
+
+#define CMD_POWER_UP (0xAB)
+#define CMD_JEDEC_ID	(0x9F)
+#define CMD_POWER_DOWN	(0xB9)
+#define CMD_READ_STATUS	(0x05)
+#define CMD_WRITE_ENABLE (0x06)
+#define CMD_PAGE_PROG (0x02)
+#define CMD_READ_DATA (0x03)
+#define CMD_ERASE_4K (0x20)
+#define CMD_ERASE_64K (0xD8)
+#define CMD_DUMMY	(0xFF)
+
+// added by Tsungta
+#define CMD_READ_UNIQUE_ID (0x4B)
+#define CMD_ERASE_SECU (0x44)
+#define CMD_PAGE_PROG_SECU (0x42)
+#define CMD_READ_SECU (0x48)
+
+#define	THREE_BYTE_LENGTH	3
+#define WIFIDRI_LENGTH (136568)
+#define ERASEWIFI_LENGTH (2696)
+#define DEVICE_PAGE_SIZE (256)
+#define DEVICE_SECTOR_SIZE (4096)
+#define DEVICE_BLOCK_SIZE (65536)
+#ifdef WIFI_BOOT_NORDIC
+extern const unsigned char wifi_firmware[];
+#endif
+#endif
+
+#if 1	//marcus add for flash read/write
+static bool spi_flash_writeOneByte(uint32_t *spi_base_address, uint8_t DataBuffer)
+{
+		uint8_t rx_data;
+		uint32_t counter = 0;
+    /*lint -e{826} //Are too small pointer conversion */
+    NRF_SPI_Type *spi_base = (NRF_SPI_Type *)spi_base_address;
+
+		spi_base->TXD = (uint32_t) DataBuffer;
+	
+    /* Wait for the transaction complete or timeout (about 10ms - 20 ms) */
+    while ((spi_base->EVENTS_READY == 0U) && (counter < TIMEOUT_COUNTER))
+    {
+				counter++;
+    }
+
+    if (counter == TIMEOUT_COUNTER)
+		{
+				/* timed out, disable slave (slave select active low) and return with error */
+        return false;
+    }	else {
+				/* clear the event to be ready to receive next messages */
+        spi_base->EVENTS_READY = 0U;
+		}
+		
+		/* Marcus, need to move RXD to get the next transaction*/
+		rx_data = (uint8_t)spi_base->RXD;
+		
+		return true;
+}
+
+static uint8_t spi_flash_readOneByte(uint32_t *spi_base_address)
+{
+		uint32_t counter = 0;
+    /*lint -e{826} //Are too small pointer conversion */
+    NRF_SPI_Type *spi_base = (NRF_SPI_Type *)spi_base_address;
+		
+		spi_base->TXD = 0xFF; //put dont case data
+	
+    /* Wait for the transaction complete or timeout (about 10ms - 20 ms) */
+    while ((spi_base->EVENTS_READY == 0U) && (counter < TIMEOUT_COUNTER))
+    {
+				counter++;
+    }
+
+    if (counter == TIMEOUT_COUNTER)
+		{
+        return 0;
+    }	else {
+				/* clear the event to be ready to receive next messages */
+        spi_base->EVENTS_READY = 0U;
+		}	
+	
+		return (uint8_t)spi_base->RXD;
+}
+
+//#if !defined(TARGET_DELTA_DFCM_NNN40)
+bool spi_flash_init(void)
+{
+		uint8_t mfgId;
+		uint16_t deviceID;
+	
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return false;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+    spi_flash_writeOneByte(p_spi_base_address, CMD_POWER_UP);
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);
+		
+		//wait for wake up
+		wait_us(30);//nrf_delay_us(30);
+		
+		nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+		spi_flash_writeOneByte(p_spi_base_address, CMD_JEDEC_ID);
+		
+		mfgId = spi_flash_readOneByte(p_spi_base_address);
+		deviceID = (uint16_t)(spi_flash_readOneByte(p_spi_base_address) << 8);
+		deviceID |= spi_flash_readOneByte(p_spi_base_address);
+		
+		nrf_gpio_pin_set(SPI_PSELSS1_flash);
+		
+		if (mfgId != MFG_ID_WINBOND || deviceID != DEVICE_ID_WINBOND_8M) {
+				return false;
+		}
+		
+		return true;
+}
+
+bool spi_flash_powerDown(void)
+{			
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return false;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+    spi_flash_writeOneByte(p_spi_base_address, CMD_POWER_DOWN);
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);
+		
+		//wait for sleep
+		wait_us(3);//nrf_delay_us(3);
+		
+		return true;
+}
+//#endif
+
+bool spi_flash_waitBusy(void)
+{
+		uint8_t status;
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return false;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+    spi_flash_writeOneByte(p_spi_base_address, CMD_READ_STATUS);
+		status = spi_flash_readOneByte(p_spi_base_address);
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);
+		
+		if ( (status & 0x01) == 0x01 )
+		{
+				return true;
+		} else {
+				return false;
+		}
+}
+
+void spi_flash_setWEL(void)
+{
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+    spi_flash_writeOneByte(p_spi_base_address, CMD_WRITE_ENABLE);
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);	
+}
+
+void spi_flash_writePage(uint32_t address, const uint8_t *data, uint16_t len)
+{
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+		
+		//setWEL
+		spi_flash_setWEL();
+
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }
+			
+		nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, CMD_PAGE_PROG);
+		
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 16) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 8) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, (address & 0xFF));
+		
+		/* write data */
+		while(len--) {
+			spi_flash_writeOneByte(p_spi_base_address, *data++);
+		}			
+		
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);
+		
+		return;
+}
+
+void spi_flash_eraseCmd(uint8_t command, uint32_t address)
+{
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }	
+	
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, command);
+		
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 16) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 8) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, (address & 0xFF));
+    
+		nrf_gpio_pin_set(SPI_PSELSS1_flash);	
+}
+
+void spi_flash_erase(void)
+{
+		uint32_t address = 0;
+		uint32_t totalLength = WIFIDRI_LENGTH + ERASEWIFI_LENGTH;	//To map SECTOR size
+
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+
+		//setWEL
+		spi_flash_setWEL();			
+
+		// handle any full blocks
+		while(totalLength >= DEVICE_BLOCK_SIZE) {
+			spi_flash_eraseCmd(CMD_ERASE_64K, address);
+			address += DEVICE_BLOCK_SIZE;
+			totalLength -= DEVICE_BLOCK_SIZE;
+		}	
+
+		// finally handle any trailing partial blocks
+		while(totalLength) {
+			spi_flash_eraseCmd(CMD_ERASE_4K, address);
+			address += DEVICE_SECTOR_SIZE;
+			totalLength -= DEVICE_SECTOR_SIZE;
+		}
+
+		return;
+}
+
+static bool m_spi_result = true;
+
+void spi_flash_readpage(uint32_t address, uint8_t *data, uint16_t len)
+{
+
+		uint16_t i = 0;	
+	
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+			
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+				m_spi_result = false;
+        return;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, CMD_READ_DATA);
+		
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 16) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 8) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, (address & 0xFF));
+		
+		/* read data */
+		
+		for (i=0; i < len; i++){	// only totalLength bytes (<4096) left 
+				*data++ = spi_flash_readOneByte(p_spi_base_address);
+		}		
+		
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);	
+}
+	#ifdef WIFI_BOOT_NORDIC
+void spi_flash_write(void)
+{
+	uint32_t totalLength = WIFIDRI_LENGTH;
+	uint32_t address = 0;
+	uint16_t len = DEVICE_PAGE_SIZE;
+
+	const uint8_t *data = wifi_firmware;
+
+
+  while(totalLength) {
+    spi_flash_writePage(address, data, len);
+    totalLength -= len;
+    address += len;
+    data += len;
+    len = (totalLength>DEVICE_PAGE_SIZE)? DEVICE_PAGE_SIZE : totalLength;
+  }	
+}
+#endif
+#endif
+
+// added by Tsungta
+void spi_flash_read_uniqueID(uint8_t *data)
+{
+		uint8_t dummy_len = 4;
+		uint8_t id_len = 8;
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+			
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, CMD_READ_UNIQUE_ID);
+		while(dummy_len--)
+			spi_flash_readOneByte(p_spi_base_address);		// there is four dummy bytes before real data
+		/* id data */
+		while(id_len--) 
+			*data++ = spi_flash_readOneByte(p_spi_base_address);			
+
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);		
+}
+
+// added by Tsungta
+void spi_flash_erase_security(uint32_t address)
+{
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+
+		//setWEL
+		spi_flash_setWEL();
+			
+		uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }	
+	
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, CMD_ERASE_SECU);
+		
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 16) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 8) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, (address & 0xFF));
+    
+		nrf_gpio_pin_set(SPI_PSELSS1_flash);	
+}
+
+// added by Tsungta
+void spi_flash_writePage_security(uint32_t address, const uint8_t *data, uint16_t len)
+{
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+		
+		//setWEL
+		spi_flash_setWEL();
+
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }
+			
+		nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, CMD_PAGE_PROG_SECU);
+		
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 16) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 8) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, (address & 0xFF));
+		
+		/* write data */
+		while(len--) {
+			spi_flash_writeOneByte(p_spi_base_address, *data++);
+		}			
+		
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);
+		
+		return;
+}
+
+// added by Tsungta
+void spi_flash_read_security(uint32_t address, uint8_t *data, uint16_t len)
+{
+
+#ifdef FLASHDEBUG
+		uint8_t data = 0;
+		uint8_t i = 1;	
+#endif
+	
+		//wait busy
+		while(spi_flash_waitBusy()) {};
+		
+//		//setWEL
+//		spi_flash_setWEL();
+			
+    uint32_t * p_spi_base_address = spi_master_init(SPI0, SPI_MODE0, false);
+    if (p_spi_base_address == NULL)
+    {
+        return;
+    }
+		
+    nrf_gpio_pin_clear(SPI_PSELSS1_flash);
+		
+    spi_flash_writeOneByte(p_spi_base_address, CMD_READ_SECU);
+		
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 16) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, ((address >> 8) & 0xFF));
+		spi_flash_writeOneByte(p_spi_base_address, (address & 0xFF));
+		
+		spi_flash_readOneByte(p_spi_base_address);		// there is a dummy byte before real data
+		/* read data */
+		while(len--) {
+#ifdef FLASHDEBUG			
+			data = spi_flash_readOneByte(p_spi_base_address);
+		  uint8_t buf[30];
+		  sprintf(buf,"0x%02X ",data);
+		  simple_uart_putstring(buf);
+			if(i == 11)
+			{
+				simple_uart_put('\n');
+				i = 0;
+			}
+			i++;
+#else
+			*data++ = spi_flash_readOneByte(p_spi_base_address);
+#endif			
+		}
+    nrf_gpio_pin_set(SPI_PSELSS1_flash);		
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/spi_flash.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,35 @@
+ /* 
+ *	Generated for windbond flash
+ */
+
+#ifndef SPI_FLASH_H
+#define SPI_FLASH_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+
+#if 1 //marcus
+
+//#if !defined(TARGET_DELTA_DFCM_NNN40)
+bool spi_flash_init(void);
+bool spi_flash_powerDown(void);
+//#endif
+
+void spi_flash_erase(void);
+void spi_flash_readpage(uint32_t address, uint8_t *data, uint16_t len);
+void spi_flash_write(void);
+
+void spi_flash_eraseCmd(uint8_t command, uint32_t address);
+void spi_flash_writePage(uint32_t address, const uint8_t *data, uint16_t len);
+
+bool spi_flash_waitBusy(void);
+void spi_flash_setWEL(void);
+
+// added by Tsungta
+void spi_flash_read_uniqueID(uint8_t *data);
+void spi_flash_erase_security(uint32_t address);
+void spi_flash_writePage_security(uint32_t address, const uint8_t *data, uint16_t len);
+void spi_flash_read_security(uint32_t address, uint8_t *data, uint16_t len);
+#endif
+#endif /* SPI_MASTER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/spi_master.c	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,183 @@
+/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#include <spi_master.h>
+//#include "nrf_delay.h"
+#include "nrf_gpio.h"
+//#include "common.h"
+#include "spi_master_config.h" // This file must be in the application folder
+
+uint32_t* spi_master_init(SPIModuleNumber module_number, SPIMode mode, bool lsb_first)
+{
+    uint32_t config_mode;
+
+    NRF_SPI_Type *spi_base_address = (SPI0 == module_number)? NRF_SPI0 : (NRF_SPI_Type *)NRF_SPI1;
+
+    if(SPI0 == module_number)
+    {
+        /* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI0 */
+        nrf_gpio_cfg_output(SPI_PSELSCK0);
+        nrf_gpio_cfg_output(SPI_PSELMOSI0);
+        nrf_gpio_cfg_input(SPI_PSELMISO0, NRF_GPIO_PIN_PULLUP);
+        nrf_gpio_cfg_output(SPI_PSELSS0);
+				nrf_gpio_cfg_output(SPI_PSELSS1_flash);	//added by Tsungta
+				
+        /* Configure pins, frequency and mode */
+        spi_base_address->PSELSCK  = SPI_PSELSCK0;
+        spi_base_address->PSELMOSI = SPI_PSELMOSI0;
+        spi_base_address->PSELMISO = SPI_PSELMISO0;
+        nrf_gpio_pin_set(SPI_PSELSS0); /* disable Set slave select (inactive high) */
+			  nrf_gpio_pin_set(SPI_PSELSS1_flash);	//added by Tsungta        
+    }
+    else
+    {
+        /* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI1*/
+        nrf_gpio_cfg_output(SPI_PSELSCK1);
+        nrf_gpio_cfg_output(SPI_PSELMOSI1);
+        nrf_gpio_cfg_input(SPI_PSELMISO1, NRF_GPIO_PIN_PULLUP);
+        nrf_gpio_cfg_output(SPI_PSELSS1);
+				nrf_gpio_cfg_output(SPI_PSELSS1_flash);	//added by Tsungta
+			
+        /* Configure pins, frequency and mode */
+        spi_base_address->PSELSCK  = SPI_PSELSCK1;
+        spi_base_address->PSELMOSI = SPI_PSELMOSI1;
+        spi_base_address->PSELMISO = SPI_PSELMISO1;
+        nrf_gpio_pin_set(SPI_PSELSS1);         /* disable Set slave select (inactive high) */
+			  nrf_gpio_pin_set(SPI_PSELSS1_flash);	//added by Tsungta
+    }
+    spi_base_address->FREQUENCY = (uint32_t) SPI_OPERATING_FREQUENCY_4M;	//modified by Tsungta, 4MHz is max. speed for 1.8V
+
+    /*lint -e845 -save // A zero has been given as right argument to operator '!'" */
+    /** @snippet [SPI Select mode] */
+    switch (mode )
+    {
+       
+        case SPI_MODE0:
+            config_mode = (SPI_CONFIG_CPHA_Leading << SPI_CONFIG_CPHA_Pos) | (SPI_CONFIG_CPOL_ActiveHigh << SPI_CONFIG_CPOL_Pos);
+            break;
+        case SPI_MODE1:
+            config_mode = (SPI_CONFIG_CPHA_Trailing << SPI_CONFIG_CPHA_Pos) | (SPI_CONFIG_CPOL_ActiveHigh << SPI_CONFIG_CPOL_Pos);
+            break;
+        case SPI_MODE2:
+            config_mode = (SPI_CONFIG_CPHA_Leading << SPI_CONFIG_CPHA_Pos) | (SPI_CONFIG_CPOL_ActiveLow << SPI_CONFIG_CPOL_Pos);
+            break;
+        case SPI_MODE3:
+            config_mode = (SPI_CONFIG_CPHA_Trailing << SPI_CONFIG_CPHA_Pos) | (SPI_CONFIG_CPOL_ActiveLow << SPI_CONFIG_CPOL_Pos);
+            break;
+        default:
+            config_mode = 0;
+            break;
+    
+    }
+    /** @snippet [SPI Select mode] */
+    /*lint -restore */
+
+    /*lint -e845 -save // A zero has been given as right argument to operator '!'" */
+    /** @snippet [SPI Select endianess] */
+    if (lsb_first)
+    {
+        spi_base_address->CONFIG = (config_mode | (SPI_CONFIG_ORDER_LsbFirst << SPI_CONFIG_ORDER_Pos));
+    }
+    else
+    {
+        spi_base_address->CONFIG = (config_mode | (SPI_CONFIG_ORDER_MsbFirst << SPI_CONFIG_ORDER_Pos));
+    }
+    /** @snippet [SPI Select endianess] */
+    /*lint -restore */
+
+    spi_base_address->EVENTS_READY = 0U;
+#if 1
+
+    /* Enable */
+    if(SPI0 == module_number)
+    spi_base_address->ENABLE = (SPI_ENABLE_ENABLE_Enabled << SPI_ENABLE_ENABLE_Pos);
+#endif
+    return (uint32_t *)spi_base_address;
+}
+
+//bool spi_master_tx_rx(uint32_t *spi_base_address, uint16_t transfer_size, const uint8_t *tx_data, uint8_t *rx_data)
+bool spi_master_tx_rx(SPIModuleNumber module_number, uint16_t transfer_size, const uint8_t *tx_data, uint8_t *rx_data)
+{
+    uint32_t counter = 0;
+    uint16_t number_of_txd_bytes = 0;
+    uint32_t SEL_SS_PINOUT;
+    /*lint -e{826} //Are too small pointer conversion */
+//    NRF_SPI_Type *spi_base = (NRF_SPI_Type *)spi_base_address;
+    NRF_SPI_Type *spi_base = (SPI0 == module_number)? NRF_SPI0 : (NRF_SPI_Type *)NRF_SPI1;
+    volatile uint32_t dummyread;
+
+    if(NRF_SPI0 == spi_base)
+    spi_base->ENABLE = (SPI_ENABLE_ENABLE_Enabled << SPI_ENABLE_ENABLE_Pos);
+// 	  nrf_delay_ms(10);
+
+//    if( (uint32_t *)NRF_SPI0 == spi_base_address)
+    if(NRF_SPI0 == spi_base)
+    {
+        SEL_SS_PINOUT = SPI_PSELSS0;
+    }
+    else
+    {
+        SEL_SS_PINOUT = SPI_PSELSS1;
+    }
+
+    /* enable slave (slave select active low) */
+	if (SEL_SS_PINOUT == SPI_PSELSS0)
+    nrf_gpio_pin_clear(SEL_SS_PINOUT);
+
+    while(number_of_txd_bytes < transfer_size)
+    {
+			counter = 0;//Tsungta; FIXED for 4MHz issue
+	    if(tx_data == 0)
+	    {
+	        spi_base->TXD = 0x0;//0xFF;
+	    }
+		else
+        spi_base->TXD = (uint32_t)(tx_data[number_of_txd_bytes]);
+
+        /* Wait for the transaction complete or timeout (about 10ms - 20 ms) */
+        while ((spi_base->EVENTS_READY == 0U) && (counter < TIMEOUT_COUNTER))
+        {
+            counter++;
+        }
+
+        if (counter == TIMEOUT_COUNTER)
+        {
+            /* timed out, disable slave (slave select active low) and return with error */
+	if (SEL_SS_PINOUT == SPI_PSELSS0)
+            nrf_gpio_pin_set(SEL_SS_PINOUT);
+            return false;
+        }
+        else
+        {   /* clear the event to be ready to receive next messages */
+            spi_base->EVENTS_READY = 0U;
+        }
+
+	    if(rx_data == 0)
+	    {
+	        dummyread = spi_base->RXD;
+	    }
+		else
+        rx_data[number_of_txd_bytes] = (uint8_t)spi_base->RXD;
+        number_of_txd_bytes++;
+    };
+
+    /* disable slave (slave select active low) */
+	if (SEL_SS_PINOUT == SPI_PSELSS0)
+    nrf_gpio_pin_set(SEL_SS_PINOUT);
+
+    if(NRF_SPI0 == spi_base)
+    spi_base->ENABLE = (SPI_ENABLE_ENABLE_Disabled << SPI_ENABLE_ENABLE_Pos);
+// 	  nrf_delay_ms(10);
+
+    return true;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/spi_master.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,110 @@
+ /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#ifndef SPI_MASTER_H
+#define SPI_MASTER_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/* @file
+* @brief Software controlled SPI Master driver.
+*
+*
+* @defgroup lib_driver_spi_master Software controlled SPI Master driver
+* @{
+* @ingroup nrf_drivers
+* @brief Software controlled SPI Master driver.
+*
+* Supported features:
+* - Operate two SPI masters independently or in parallel.
+* - Transmit and Receive given size of data through SPI.
+* - configure each SPI module separately through @ref spi_master_init.
+*/
+
+/**
+ *  SPI master operating frequency
+ */
+typedef enum
+{
+    Freq_125Kbps = 0,        /*!< drive SClk with frequency 125Kbps */
+    Freq_250Kbps,            /*!< drive SClk with frequency 250Kbps */
+    Freq_500Kbps,            /*!< drive SClk with frequency 500Kbps */
+    Freq_1Mbps,              /*!< drive SClk with frequency 1Mbps */
+    Freq_2Mbps,              /*!< drive SClk with frequency 2Mbps */
+    Freq_4Mbps,              /*!< drive SClk with frequency 4Mbps */
+    Freq_8Mbps               /*!< drive SClk with frequency 8Mbps */
+} SPIFrequency_t;
+
+/**
+ *  SPI master module number
+ */
+typedef enum
+{
+    SPI0 = 0,               /*!< SPI module 0 */
+    SPI1                    /*!< SPI module 1 */
+} SPIModuleNumber;
+
+/**
+ *  SPI mode
+ */
+typedef enum
+{
+    //------------------------Clock polarity 0, Clock starts with level 0-------------------------------------------
+    SPI_MODE0 = 0,          /*!< Sample data at rising edge of clock and shift serial data at falling edge */
+    SPI_MODE1,              /*!< sample data at falling edge of clock and shift serial data at rising edge */
+    //------------------------Clock polarity 1, Clock starts with level 1-------------------------------------------
+    SPI_MODE2,              /*!< sample data at falling edge of clock and shift serial data at rising edge */
+    SPI_MODE3               /*!< Sample data at rising edge of clock and shift serial data at falling edge */
+} SPIMode;
+
+
+/**
+ * @brief Function for initializing given SPI master with given configuration.
+ *
+ * After initializing the given SPI master with given configuration, this function also test if the
+ * SPI slave is responding with the configurations by transmitting few test bytes. If the slave did not
+ * respond then error is returned and contents of the rx_data are invalid.
+ *
+ * @param module_number SPI master number (SPIModuleNumber) to initialize.
+ * @param mode SPI master mode (mode 0, 1, 2 or 3 from SPIMode)
+ * @param lsb_first true if lsb is first bit to shift in/out as serial data on MISO/MOSI pins.
+ * @return
+ * @retval pointer to direct physical address of the requested SPI module if init was successful
+ * @retval 0, if either init failed or slave did not respond to the test transfer
+ */
+uint32_t* spi_master_init(SPIModuleNumber module_number, SPIMode mode, bool lsb_first);
+
+/**
+ * @brief Function for transferring/receiving data over SPI bus.
+ *
+ * If TWI master detects even one NACK from the slave or timeout occurs, STOP condition is issued
+ * and the function returns false.
+ *
+ * @note Make sure at least transfer_size number of bytes is allocated in tx_data/rx_data.
+ *
+ * @param spi_base_address  register base address of the selected SPI master module
+ * @param transfer_size  number of bytes to transmit/receive over SPI master
+ * @param tx_data pointer to the data that needs to be transmitted
+ * @param rx_data pointer to the data that needs to be received
+ * @return
+ * @retval true if transmit/reveive of transfer_size were completed.
+ * @retval false if transmit/reveive of transfer_size were not complete and tx_data/rx_data points to invalid data.
+ */
+//bool spi_master_tx_rx(uint32_t *spi_base_address, uint16_t transfer_size, const uint8_t *tx_data, uint8_t *rx_data);
+bool spi_master_tx_rx(SPIModuleNumber module_number, uint16_t transfer_size, const uint8_t *tx_data, uint8_t *rx_data);
+
+/**
+ *@}
+ **/
+ 
+#endif /* SPI_MASTER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/nordic/spi_master_config.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,59 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+#ifndef SPI_MASTER_CONFIG_H
+#define SPI_MASTER_CONFIG_H
+
+#define SPI_OPERATING_FREQUENCY_8M  ( 0x02000000UL << (uint32_t)Freq_8Mbps )  /*!< Slave clock frequency. */
+#define SPI_OPERATING_FREQUENCY_4M  ( 0x02000000UL << (uint32_t)Freq_4Mbps )  /*!< Slave clock frequency. */
+#define SPI_OPERATING_FREQUENCY_1M  ( 0x02000000UL << (uint32_t)Freq_1Mbps )  /*!< Slave clock frequency. */
+
+/*  SPI0 */ 
+																	//modified by Tsungta, SCK/MOSI/MISO are shared
+#define SPI_PSELSCK0              11//25//31   /*!< GPIO pin number for SPI clock (note that setting this to 31 will only work for loopback purposes as it not connected to a pin) */
+#define SPI_PSELMOSI0             15//24//20   /*!< GPIO pin number for Master Out Slave In    */
+#define SPI_PSELMISO0             9//29//22   /*!< GPIO pin number for Master In Slave Out    */
+#define SPI_PSELSS0               12//30   /*!< GPIO pin number for Slave Select           */
+
+/*  SPI1 */
+#define SPI_PSELSCK1              11//29   /*!< GPIO pin number for SPI clock              */
+#define SPI_PSELMOSI1             15//21   /*!< GPIO pin number for Master Out Slave In    */
+#define SPI_PSELMISO1             9//23   /*!< GPIO pin number for Master In Slave Out    */
+#define SPI_PSELSS1               28//28   /*!< GPIO pin number for Slave Select           */
+#define SPI_PSELSS1_flash					28			// added by Tsungta
+//#define DEBUG
+#ifdef DEBUG
+#define DEBUG_EVENT_READY_PIN0    10    /*!< when DEBUG is enabled, this GPIO pin is toggled everytime READY_EVENT is set for SPI0, no toggling means something has gone wrong */
+#define DEBUG_EVENT_READY_PIN1    11    /*!< when DEBUG is enabled, this GPIO pin is toggled everytime READY_EVENT is set for SPI1, no toggling means something has gone wrong */
+#endif
+
+#define NUMBER_OF_TEST_BYTES     2    /*!< number of bytes to send to slave to test if Initialization was successful */
+#define TEST_BYTE                0xBB /*!< Randomly chosen test byte to transmit to spi slave */
+#define TIMEOUT_COUNTER          0x3000UL  /*!< timeout for getting rx bytes from slave */
+
+/** @def  TX_RX_MSG_LENGTH
+ * number of bytes to transmit and receive. This amount of bytes will also be tested to see that
+ * the received bytes from slave are the same as the transmitted bytes from the master */
+#define TX_RX_MSG_LENGTH   100
+
+/** @def ERROR_PIN_SPI0
+ * This pin is set active high when there is an error either in TX/RX for SPI0 or if the received bytes does not totally match the transmitted bytes.
+ * This functionality can be tested by temporarily disconnecting the MISO pin while running this example.
+ */
+#define ERROR_PIN_SPI0   8UL
+
+/** @def ERROR_PIN_SPI1
+ * This pin is set active high when there is an error either in TX/RX for SPI1 or if the received bytes does not totally match the transmitted bytes.
+ * This functionality can be tested by temporarily disconnecting the MISO pin while running this example.
+ */
+#define ERROR_PIN_SPI1   9UL
+
+#endif /* SPI_MASTER_CONFIG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/wifi_api.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,64 @@
+
+
+#ifndef WIFI_API_H
+#define WIFI_API_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/* @file
+* @brief Wi-Fi Connection API for NNN40.
+*
+*
+* @defgroup lib_driver_spi_master Software controlled SPI Master driver
+* @{
+* @ingroup nrf_drivers
+* @brief Software controlled SPI Master driver.
+*
+* Supported features:
+* - Operate two SPI masters independently or in parallel.
+* - Transmit and Receive given size of data through SPI.
+* - configure each SPI module separately through @ref spi_master_init.
+*/
+
+#define SSID_MAX_LENGTH 32
+#define SCAN_SSID_MAX_NUM 20
+
+#define ticker_internal 20
+#define wait_ms_internal 1
+
+/**
+ *  Wi-Fi Init
+ */
+int wifi_init(void); 
+int wifi_apConnect(void);
+void wifi_ssid_pw_set(uint8_t* SSID, uint8_t* PW, uint8_t priority);
+uint8_t wifi_scan(void);
+int wifi_connect(unsigned int timeout_ms);
+int wifi_static_ip_set(const char * ip, const char * netmask, const char * gateway);
+int wifi_disconnect(void);
+
+int wifi_UDP_server_init(const int port);
+int wifi_TCP_server_init(const int port);
+int wifi_UDP_client_init(void);
+int wifi_TCP_client_init(const char *ipv4_addr, const int port, bool new_socket);
+int wifi_send_UDP(char *data, int length, uint8_t cid, const char *ipv4_addr, const int port);
+int wifi_send_TCP(char *data, uint8_t cid);
+
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void start_socket_routine(void);    
+int wifi_receive_UDP_callback(uint8_t *data, uint8_t cid);  
+int wifi_receive_TCP_callback(uint8_t *data, uint8_t cid);
+void Socket_Close_All(void);
+int wifi_ipconfig(unsigned int timeout_ms);
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Binary file WIFI_Driver/wifi_api.o has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/wifi_core.c	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,132 @@
+/* Copyright (c) Cyntec Inc. All Rights Reserved.
+ *
+ *
+ */
+
+#include "wait_api.h"
+
+#if WIFI_API_DEBUG_LOG
+#include "simple_uart.h"
+#endif
+
+#include "nrf_gpio.h"
+#include "boards.h"
+#include "nmi_wlan_if.h"
+#include "nmi_wlan.h"//Ryan
+
+#include "spi_flash.h"			//added by Tsungta
+#include "wifi_core.h"
+
+extern u8 wifi_event;//Ryan
+extern uint8_t nmi_macaddress[6];
+extern bool start_routine;
+
+
+		
+void wifi_pin_CFG(void)
+{
+ //followings are added by Tsungta	
+ nrf_gpio_cfg_output(19);	// SWIO	
+ nrf_gpio_cfg_output(18);	//WLAN_Wake
+ nrf_gpio_cfg_output(8);	//Chip_En
+ nrf_gpio_cfg_output(10);	//Reset_n	
+ nrf_gpio_pin_set(19);
+ nrf_gpio_pin_set(18);	
+ nrf_gpio_pin_set(8);
+ nrf_gpio_pin_clear(10);		
+ wait_ms(1);
+ nrf_gpio_pin_set(10);
+}
+
+extern u8 hif;//Ryan
+uint8_t rx_isr = 0;//Ryan
+extern struct nmi_wl_adp_t adp;//Ryan
+extern u8 bCfgScanning;//Ryan
+extern u8 mac_ready;//Ryan
+extern u8 scan_done;//Ryan
+u8 MacStatus;//Ryan
+
+void notify_Connect_Status(MAC_STATUS_T connect_status) {
+	MacStatus = connect_status;
+	if (connect_status == MAC_CONNECTED)
+	wifi_event = WIFI_CONNECTED;
+	else if (connect_status == MAC_DISCONNECTED)
+	wifi_event = WIFI_DISCONNECTED;
+	DPRINT(N_ERR, "notify_Connect_Status: %d\r\n", connect_status);
+}
+
+void check_rx_int(void)
+{
+   	if (rx_isr)// == 1)
+	{
+		rx_isr--;//= 0;
+//		adp.core.host_indicate_rx_isr();
+		adp.core.host_rx_trans();
+	}
+}
+
+u8 get_rx_int(void)
+{
+	return rx_isr+2;
+}
+
+
+extern u8 scanned_match_index;
+
+int wifi_core_start(void)
+{
+
+  uint8_t i;
+  MacStatus = MAC_DISCONNECTED;//Ryan
+
+if (!start_routine) {
+	start_routine = true;
+
+#if WIFI_API_DEBUG_LOG	
+  simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);
+#endif
+	
+	spi_flash_init();
+	spi_flash_read_security(0x002000, nmi_macaddress, 6);
+}  	
+
+
+	
+	wifi_pin_CFG();
+	
+  nmc1000_wifi_reset();
+  nmc1000_wifi_on();
+
+
+
+}
+
+int wait_wifi_event(void)
+{
+	DPRINT(N_ERR, "wait_wifi_event!!\n");
+   while(!wifi_event)
+   {
+   	if (rx_isr)// == 1)
+	{
+		rx_isr--;// = 0;
+//		adp.core.host_indicate_rx_isr();
+		adp.core.host_rx_trans();
+		continue;
+	}
+   	if (hif == 1)
+	{
+		hif = 0;
+		adp.core.host_trans();
+		continue;
+	}
+	//wifi_handle_event
+   }	
+}
+
+void nmi_os_trace(char *log)
+{
+#if WIFI_API_DEBUG_LOG	
+	simple_uart_putstring((const uint8_t *)log);
+#endif	
+//	SCI_TraceLow("%s", log);	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIFI_Driver/wifi_core.h	Tue Jun 09 06:04:13 2015 +0000
@@ -0,0 +1,15 @@
+#define WIFI_API_DEBUG_LOG 1
+
+#ifndef WIFI_CORE_H
+#define WIFI_CORE_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+
+int wifi_core_start(void); 
+int wait_wifi_event(void);
+void GPIOTE_IRQHandler_Ext(void);
+
+void check_rx_int(void);
+#endif
Binary file wifidevice.o has changed