summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-10-25 16:39:27 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-10-25 16:39:27 -0600
commit3b5bd753e1b55a2d7bb956003e1e03c184dd0727 (patch)
tree7f74f2f5634b188d9b49c561604d5d149bca0f4f
parent50e6a51affdf062828972b100f21b80f8cf84bee (diff)
downloadpx4-nuttx-3b5bd753e1b55a2d7bb956003e1e03c184dd0727.tar.gz
px4-nuttx-3b5bd753e1b55a2d7bb956003e1e03c184dd0727.tar.bz2
px4-nuttx-3b5bd753e1b55a2d7bb956003e1e03c184dd0727.zip
CC3000 driver update from David Sidrane (part 2 of 2)
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/include/nuttx/wireless/cc3000.h107
-rw-r--r--nuttx/include/nuttx/wireless/cc3000/cc3000_common.h4
-rw-r--r--nuttx/include/nuttx/wireless/cc3000/evnt_handler.h225
-rw-r--r--nuttx/include/nuttx/wireless/cc3000/include/cc3000_upif.h2
-rw-r--r--nuttx/include/nuttx/wireless/cc3000/include/sys/socket.h351
-rw-r--r--nuttx/include/nuttx/wireless/cc3000/wlan.h29
7 files changed, 296 insertions, 424 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 879d1ac70..59c53bb20 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5884,4 +5884,6 @@
(2015-10-25).
* configs/spark: Spark configuration updated by David Sidrane
(2013-10-25).
+ * drivers/wireless/cc3000 and include/nuttx/wireless/cc3000:
+ CC3000 driver update from David Sidrane (2013-10-25).
diff --git a/nuttx/include/nuttx/wireless/cc3000.h b/nuttx/include/nuttx/wireless/cc3000.h
index d899770ba..f12ceb01a 100644
--- a/nuttx/include/nuttx/wireless/cc3000.h
+++ b/nuttx/include/nuttx/wireless/cc3000.h
@@ -54,16 +54,20 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
-#define DEV_FORMAT "/dev/wireless%d"
-#define DEV_NAMELEN 16
-#define QUEUE_FORMAT "wlq%d"
-#define QUEUE_NAMELEN 6
+
+#define DEV_FORMAT "/dev/wireless%d" /* The device Name*/
+#define DEV_NAMELEN 17 /* The buffer size to hold formatted string*/
+
+#define QUEUE_FORMAT "wlq%d" /* The Queue name */
+#define QUEUE_NAMELEN 8 /* The buffer size to hold formatted string*/
+
+#define SEM_FORMAT "wls%d" /* The Spi Resume Senaphore name*/
+#define SEM_NAMELEN 8 /* The buffer size to hold formatted string*/
/* IOCTL commands */
-#define CC3000IOC_GETQUEID _WLIOC_USER(0x0001) /* arg: Address of int for number*/
-#define CC3000IOC_COMPLETE _WLIOC_USER(0x0002) /* arg: none resumes the Event WL Asynchronous events */
+#define CC3000IOC_GETQUESEMID _WLIOC_USER(0x0001) /* arg: Address of int for number*/
/****************************************************************************
* Public Types
@@ -88,57 +92,54 @@ extern "C" {
#define EXTERN extern
#endif
-EXTERN void wlan_init( tWlanCB sWlanCB,
+ /*****************************************************************************
+ *
+ * CC3000_wlan_init
+ *
+ * @param sWlanCB Asynchronous events callback.
+ * 0 no event call back.
+ * -call back parameters:
+ * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event,
+ * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event,
+ * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done,
+ * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report,
+ * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR
+ * HCI_EVNT_WLAN_KEEPALIVE keepalive.
+ * 2) data: pointer to extra data that received by the event
+ * (NULL no data).
+ * 3) length: data length.
+ * -Events with extra data:
+ * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask,
+ * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes
+ * for DNS server.
+ * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent,
+ * 4 bytes Packets received, 4 bytes Min round time,
+ * 4 bytes Max round time and 4 bytes for Avg round time.
+ *
+ * @param sFWPatches 0 no patch or pointer to FW patches
+ * @param sDriverPatches 0 no patch or pointer to driver patches
+ * @param sBootLoaderPatches 0 no patch or pointer to bootloader patches
+ *
+ * @return none
+ *
+ * @sa wlan_set_event_mask , wlan_start , wlan_stop
+ *
+ * @brief Initialize wlan driver
+ *
+ * @warning This function must be called before ANY other wlan driver function
+ *
+ ****************************************************************************/
+
+void wlan_init( tWlanCB sWlanCB,
tFWPatches sFWPatches,
tDriverPatches sDriverPatches,
- tBootLoaderPatches sBootLoaderPatches,
- tWlanReadInteruptPin sReadWlanInterruptPin,
- tWlanInterruptEnable sWlanInterruptEnable,
- tWlanInterruptDisable sWlanInterruptDisable,
- tWriteWlanPin sWriteWlanPin);
+ tBootLoaderPatches sBootLoaderPatches);
-/*****************************************************************************
- *
- * CC3000_wlan_init
- *
- * @param sWlanCB Asynchronous events callback.
- * 0 no event call back.
- * -call back parameters:
- * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event,
- * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event,
- * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done,
- * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report,
- * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR
- * HCI_EVNT_WLAN_KEEPALIVE keepalive.
- * 2) data: pointer to extra data that received by the event
- * (NULL no data).
- * 3) length: data length.
- * -Events with extra data:
- * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask,
- * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes
- * for DNS server.
- * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent,
- * 4 bytes Packets received, 4 bytes Min round time,
- * 4 bytes Max round time and 4 bytes for Avg round time.
- *
- * @param sFWPatches 0 no patch or pointer to FW patches
- * @param sDriverPatches 0 no patch or pointer to driver patches
- * @param sBootLoaderPatches 0 no patch or pointer to bootloader patches
- *
- * @return none
- *
- * @sa wlan_set_event_mask , wlan_start , wlan_stop
- *
- * @brief Initialize wlan driver
- *
- * @warning This function must be called before ANY other wlan driver function
- *
- ****************************************************************************/
-EXTERN void CC3000_wlan_init(tWlanCB sWlanCB,
- tFWPatches sFWPatches,
- tDriverPatches sDriverPatches,
- tBootLoaderPatches sBootLoaderPatches);
+void cc3000_wlan_init(tWlanCB sWlanCB,
+ tFWPatches sFWPatches,
+ tDriverPatches sDriverPatches,
+ tBootLoaderPatches sBootLoaderPatches);
/************************************************************************************
diff --git a/nuttx/include/nuttx/wireless/cc3000/cc3000_common.h b/nuttx/include/nuttx/wireless/cc3000/cc3000_common.h
index 5a8e05a68..4eca40852 100644
--- a/nuttx/include/nuttx/wireless/cc3000/cc3000_common.h
+++ b/nuttx/include/nuttx/wireless/cc3000/cc3000_common.h
@@ -230,10 +230,6 @@ typedef struct
tDriverPatches sDriverPatches;
tBootLoaderPatches sBootLoaderPatches;
tWlanCB sWlanCB;
- tWlanReadInteruptPin ReadWlanInterruptPin;
- tWlanInterruptEnable WlanInterruptEnable;
- tWlanInterruptDisable WlanInterruptDisable;
- tWriteWlanPin WriteWlanPin;
signed long slTransmitDataError;
uint16_t usNumberOfFreeBuffers;
diff --git a/nuttx/include/nuttx/wireless/cc3000/evnt_handler.h b/nuttx/include/nuttx/wireless/cc3000/evnt_handler.h
index 7e16547ef..a67fef891 100644
--- a/nuttx/include/nuttx/wireless/cc3000/evnt_handler.h
+++ b/nuttx/include/nuttx/wireless/cc3000/evnt_handler.h
@@ -12,156 +12,169 @@
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
+* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
-#ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
-#define _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
+
+#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
+#define __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
#include <nuttx/wireless/cc3000/hci.h>
-#include <nuttx/wireless/cc3000/include/sys/socket.h>
-
-//*****************************************************************************
-//
-// If building with a C++ compiler, make all of the definitions in this header
-// have a C binding.
-//
-//*****************************************************************************
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <sys/socket.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
-//*****************************************************************************
-//
-// Prototypes for the APIs.
-//
-//*****************************************************************************
-
-//*****************************************************************************
-//
-//! hci_event_handler
-//!
-//! @param pRetParams incoming data buffer
-//! @param from from information (in case of data received)
-//! @param fromlen from information length (in case of data received)
-//!
-//! @return none
-//!
-//! @brief Parse the incoming events packets and issues corresponding
-//! event handler from global array of handlers pointers
-//
-//*****************************************************************************
-extern uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen);
-
-//*****************************************************************************
-//
-//! hci_unsol_event_handler
-//!
-//! @param event_hdr event header
-//!
-//! @return 1 if event supported and handled
-//! 0 if event is not supported
-//!
-//! @brief Handle unsolicited events
-//
-//*****************************************************************************
-extern long hci_unsol_event_handler(char *event_hdr);
-
-//*****************************************************************************
-//
-//! hci_unsolicited_event_handler
-//!
-//! @param None
-//!
-//! @return ESUCCESS if successful, EFAIL if an error occurred
-//!
-//! @brief Parse the incoming unsolicited event packets and issues
-//! corresponding event handler.
-//
-//*****************************************************************************
-extern long hci_unsolicited_event_handler(void);
-
-#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
+#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)\
+ ((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
#define SOCKET_STATUS_ACTIVE 0
#define SOCKET_STATUS_INACTIVE 1
-/* Init socket_active_status = 'all ones': init all sockets with SOCKET_STATUS_INACTIVE.
- Will be changed by 'set_socket_active_status' upon 'connect' and 'accept' calls */
+
+/* Init socket_active_status = 'all ones': init all sockets with
+ * SOCKET_STATUS_INACTIVE. Will be changed by 'set_socket_active_status' upon
+ * 'connect' and 'accept' calls
+ */
+
#define SOCKET_STATUS_INIT_VAL 0xFFFF
#define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7))
-#define M_IS_VALID_STATUS(status) (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
+#define M_IS_VALID_STATUS(status) \
+ (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
-extern unsigned long socket_active_status;
+#define BSD_RECV_FROM_FROMLEN_OFFSET (4)
+#define BSD_RECV_FROM_FROM_OFFSET (16)
-extern void set_socket_active_status(long Sd, long Status);
-extern long get_socket_active_status(long Sd);
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
typedef struct _bsd_accept_return_t
{
- long iSocketDescriptor;
- long iStatus;
- sockaddr tSocketAddress;
-
+ long iSocketDescriptor;
+ long iStatus;
+ struct sockaddr tSocketAddress;
} tBsdReturnParams;
-
typedef struct _bsd_read_return_t
{
- long iSocketDescriptor;
- long iNumberOfBytes;
- unsigned long uiFlags;
+ long iSocketDescriptor;
+ long iNumberOfBytes;
+ unsigned long uiFlags;
} tBsdReadReturnParams;
-#define BSD_RECV_FROM_FROMLEN_OFFSET (4)
-#define BSD_RECV_FROM_FROM_OFFSET (16)
-
-
typedef struct _bsd_select_return_t
{
- long iStatus;
- unsigned long uiRdfd;
- unsigned long uiWrfd;
- unsigned long uiExfd;
+ long iStatus;
+ unsigned long uiRdfd;
+ unsigned long uiWrfd;
+ unsigned long uiExfd;
} tBsdSelectRecvParams;
-
typedef struct _bsd_getsockopt_return_t
{
- uint8_t ucOptValue[4];
- char iStatus;
+ uint8_t ucOptValue[4];
+ char iStatus;
} tBsdGetSockOptReturnParams;
typedef struct _bsd_gethostbyname_return_t
{
- long retVal;
- long outputAddress;
+ long retVal;
+ long outputAddress;
} tBsdGethostbynameParams;
-//*****************************************************************************
-//
-// Mark the end of the C bindings section for C++ compilers.
-//
-//*****************************************************************************
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern unsigned long socket_active_status;
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: hci_event_handler
+ *
+ * Description:
+ * Parse the incoming events packets and issues corresponding event
+ * handler from global array of handlers pointers
+ *
+ * Input Parameters:
+ * pRetParams incoming data buffer
+ * from from information (in case of data received)
+ * fromlen from information length (in case of data received)
+ *
+ * Returned Values:
+ * None
+ *
+ ****************************************************************************/
+
+uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen);
+
+/****************************************************************************
+ * Name: hci_unsol_event_handler
+ *
+ * Description:
+ * Handle unsolicited events
+ *
+ * Input Parameters:
+ * event_hdr event header
+ *
+ * Returned Values:
+ * 1 if event supported and handled; 0 if event is not supported
+ *
+ ****************************************************************************/
+
+long hci_unsol_event_handler(char *event_hdr);
+
+/****************************************************************************
+ * Name: hci_unsolicited_event_handler
+ *
+ * Description:
+ * Parse the incoming unsolicited event packets and issues corresponding
+ * event handler.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Values:
+ * ESUCCESS if successful, EFAIL if an error occurred
+ *
+ ****************************************************************************/
+
+long hci_unsolicited_event_handler(void);
+
+void set_socket_active_status(long Sd, long Status);
+long get_socket_active_status(long Sd);
+
#ifdef __cplusplus
}
#endif // __cplusplus
-#endif // _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
-
+#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
diff --git a/nuttx/include/nuttx/wireless/cc3000/include/cc3000_upif.h b/nuttx/include/nuttx/wireless/cc3000/include/cc3000_upif.h
index d121203a6..5b7e7ebd7 100644
--- a/nuttx/include/nuttx/wireless/cc3000/include/cc3000_upif.h
+++ b/nuttx/include/nuttx/wireless/cc3000/include/cc3000_upif.h
@@ -141,7 +141,7 @@ struct cc3000_config_s
void (*irq_enable)(FAR struct cc3000_config_s *state, bool enable);
void (*irq_clear)(FAR struct cc3000_config_s *state);
void (*power_enable)(FAR struct cc3000_config_s *state,bool enable);
- void (*chip_select)(FAR struct cc3000_config_s *state,bool enable);
+ void (*chip_chip_select)(FAR struct cc3000_config_s *state,bool enable);
bool (*irq_read)(FAR struct cc3000_config_s *state);
bool (*probe)(FAR struct cc3000_config_s *state, int n, bool s);
};
diff --git a/nuttx/include/nuttx/wireless/cc3000/include/sys/socket.h b/nuttx/include/nuttx/wireless/cc3000/include/sys/socket.h
index 9ba965513..0704a8a05 100644
--- a/nuttx/include/nuttx/wireless/cc3000/include/sys/socket.h
+++ b/nuttx/include/nuttx/wireless/cc3000/include/sys/socket.h
@@ -35,171 +35,37 @@
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_SYS_SOCKET_H
#define __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_SYS_SOCKET_H
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sys/types.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+
/*****************************************************************************
* Pre-processor Definitions
*****************************************************************************/
-#define CC3000_SOCKETS /* Indicate using CC3000 sockets */
-#define CC3000_SOCKETS_ST /* Indicate single threaded version */
-
-#define HOSTNAME_MAX_LENGTH (230) /* 230 bytes + header shouldn't exceed 8
- * bit value */
-
-/*--------- Address Families --------*/
-
-#define AF_INET 2
-#define AF_INET6 23
-
-#define PF_INET AF_INET /* IPv4 Internet protocols */
-#define PF_INET6 AF_INET6 /* IPv6 Internet protocols */
-
-
-/*------------ Socket Types ------------*/
-
-#define SOCK_STREAM 1
-#define SOCK_DGRAM 2
-#define SOCK_RAW 3 /* Raw sockets allow new IPv4
- * protocols to be implemented in
- * user space. A raw socket receives
- * or sends the raw datagram not
- * including link level headers */
-#define SOCK_RDM 4
-#define SOCK_SEQPACKET 5
-
-/*----------- Socket Protocol ----------*/
-
-#define IPPROTO_IP 0 /* Dummy for IP */
-#define IPPROTO_ICMP 1 /* Control message protocol */
-#define IPPROTO_IPV4 IPPROTO_IP /* IP inside IP */
-#define IPPROTO_TCP 6 /* TCP */
-#define IPPROTO_UDP 17 /* User datagram protocol */
-#define IPPROTO_IPV6 41 /* IPv6 in IPv6 */
-#define IPPROTO_NONE 59 /* No next header */
-#define IPPROTO_RAW 255 /* Raw IP packet */
-#define IPPROTO_MAX 256
-
-/*----------- Socket retunr codes -----------*/
-
-#define SOC_ERROR (-1) /* Error */
-#define SOC_IN_PROGRESS (-2) /* Socket in progress */
-
-/*----------- Socket Options -----------*/
-#define SOL_SOCKET 0xffff /* Socket level */
-#define SOCKOPT_RECV_NONBLOCK 0 /* recv non block mode, set SOCK_ON or
- * SOCK_OFF (default block mode) */
-#define SOCKOPT_RECV_TIMEOUT 1 /* optname to configure recv and recvfromtimeout */
-#define SOCKOPT_ACCEPT_NONBLOCK 2 /* accept non block mode, set SOCK_ON or SOCK_OFF
- * (default block mode) */
-#define SOCK_ON 0 /* socket non-blocking mode is enabled */
-#define SOCK_OFF 1 /* socket blocking mode is enabled */
-
-#define TCP_NODELAY 0x0001
-#define TCP_BSDURGENT 0x7000
-
-#define MAX_PACKET_SIZE 1500
-#define MAX_LISTEN_QUEUE 4
-
-#define IOCTL_SOCKET_EVENTMASK
-
-#define __FD_SETSIZE 32
-
-#define ASIC_ADDR_LEN 8
-
-#define NO_QUERY_RECIVED -3
-
-/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
-
-#define __NFDBITS (8 * sizeof (__fd_mask))
-#define __FDELT(d) ((d) / __NFDBITS)
-#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
-
-#define __FDS_BITS(set) ((set)->fds_bits)
-
-/* We don't use `memset' because this would require a prototype and
- * the array isn't too big.
- */
-
-#define __FD_ZERO(set) \
- do { \
- unsigned int __i; \
- TICC3000fd_set *__arr = (set); \
- for (__i = 0; __i < sizeof (TICC3000fd_set) / sizeof (__fd_mask); ++__i) \
- __FDS_BITS (__arr)[__i] = 0; \
- } while (0)
-#define __FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
-#define __FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
-#define __FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
-
-/* Access macros for 'TICC3000fd_set' */
-
-#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
-#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
-#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
-#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
-
-/* Use in case of Big Endian only */
-
-#define htonl(A) ((((unsigned long)(A) & 0xff000000) >> 24) | \
- (((unsigned long)(A) & 0x00ff0000) >> 8) | \
- (((unsigned long)(A) & 0x0000ff00) << 8) | \
- (((unsigned long)(A) & 0x000000ff) << 24))
-
-#define ntohl htonl
-
-/* Use in case of Big Endian only */
-#define htons(A) ((((unsigned long)(A) & 0xff00) >> 8) | \
- (((unsigned long)(A) & 0x00ff) << 8))
-
-
-#define ntohs htons
-
-/* mDNS port - 5353 mDNS multicast address - 224.0.0.251 */
-
-#define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \
- sockaddr.sa_data[1] = 0xe9; \
- sockaddr.sa_data[2] = 0xe0; \
- sockaddr.sa_data[3] = 0x0; \
- sockaddr.sa_data[4] = 0x0; \
- sockaddr.sa_data[5] = 0xfb;
+#define socket(a,t,p) cc3000_socket(a,t,p)
+#define closesocket(s) cc3000_closesocket(s)
+#define bind(s,a,l) cc3000_bind(s,a,l)
+#define connect(s,a,l) cc3000_connect(s,a,l)
+#define listen(s,b) cc3000_listen(s,b)
+#define accept(s,a,l) cc3000_accept(s,a,l)
+#define send(s,b,l,f) cc3000_send(s,b,l,f)
+#define sendto(s,b,l,f,a,n) cc3000_sendto(s,b,l,f,a,n)
+#define recv(s,b,l,f) cc3000_recv(s,b,l,f)
+#define recvfrom(s,b,l,f,a,n) cc3000_recvfrom(s,b,l,f,a,n)
+#define setsockopt(s,l,o,v,n) cc3000_setsockopt(s,l,o,v,n)
+#define getsockopt(s,l,o,v,n) cc3000_getsockopt(s,l,o,v,n)
+#define gethostbyname(h,l,i) cc3000_gethostbyname(h,l,i)
+#define mdnsadvertiser(e,n,l) cc3000_mdnsadvertiser(e,n,l)
/*****************************************************************************
* Public Types
*****************************************************************************/
-typedef struct _in_addr_t
-{
- unsigned long s_addr; /* load with inet_aton() */
-} in_addr;
-
-typedef struct sockaddr
-{
- uint16_t sa_family;
- uint8_t sa_data[14];
-} sockaddr;
-
-typedef struct _sockaddr_in_t
-{
- int16_t sin_family; /* e.g. AF_INET */
- uint16_t sin_port; /* e.g. htons(3490) */
- in_addr sin_addr; /* see struct in_addr, below */
- char sin_zero[8]; /* zero this if you want to */
-} sockaddr_in;
-
-#if 0 /* acassis: conflict with previous declaration on nuttx */
-typedef unsigned long socklen_t;
-#endif
-
-/* The fd_set member is required to be an array of longs. */
-
-typedef long int __fd_mask;
-
-/* fd_set for select and pselect. */
-
-typedef struct
-{
- __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
-} TICC3000fd_set;
-
/*****************************************************************************
* Public Data
*****************************************************************************/
@@ -235,7 +101,7 @@ extern "C" {
*
*****************************************************************************/
-int socket(long domain, long type, long protocol);
+int socket(int domain, int type, int protocol);
/*****************************************************************************
* Name: closesocket
@@ -244,14 +110,14 @@ int socket(long domain, long type, long protocol);
* The socket function closes a created socket.
*
* Input Parameters:
- * sd socket handle.
+ * sockfd socket handle.
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned.
*
*****************************************************************************/
-long closesocket(long sd);
+int closesocket(int sockfd);
/*****************************************************************************
* Name: accept
@@ -276,7 +142,7 @@ long closesocket(long sd);
* length (in bytes) of the address returned.
*
* Input Parameters:
- * sd socket descriptor (handle)
+ * sockfd socket descriptor (handle)
* addr the argument addr is a pointer to a sockaddr structure
* This structure is filled in with the address of the
* peer socket, as known to the communications layer.
@@ -298,7 +164,7 @@ long closesocket(long sd);
*
*****************************************************************************/
-long accept(long sd, sockaddr *addr, socklen_t *addrlen);
+int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
/*****************************************************************************
* Name: bind
@@ -313,7 +179,7 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen);
* socket may receive connections.
*
* Input Parameters:
- * sd socket descriptor (handle)
+ * sockfd socket descriptor (handle)
* addr specifies the destination address. On this version
* only AF_INET is supported.
* addrlen contains the size of the structure pointed to by addr.
@@ -323,7 +189,7 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen);
*
*****************************************************************************/
-long bind(long sd, const sockaddr *addr, long addrlen);
+int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
/*****************************************************************************
* Name: listen
@@ -340,43 +206,16 @@ long bind(long sd, const sockaddr *addr, long addrlen);
* NOTE: On this version, backlog is not supported
*
* Input Parameters:
- * sd socket descriptor (handle)
+ * sockfd socket descriptor (handle)
* backlog specifies the listen queue depth. On this version
- * backlog is not supported.
+ * backlog is not supported.
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned.
*
*****************************************************************************/
-long listen(long sd, long backlog);
-
-/*****************************************************************************
- * Name: gethostbyname
- *
- * Decription:
- * Get host IP by name. Obtain the IP Address of machine on network,
- * by its name.
- *
- * NOTE: On this version, only blocking mode is supported. Also note that
- * the function requires DNS server to be configured prior to its
- * usage.
- *
- * Input Parameters:
- * hostname host name
- * usNameLen name length
- * out_ip_addr This parameter is filled in with host IP address.
- * In case that host name is not resolved,
- * out_ip_addr is zero.
- *
- * Returned Value:
- * On success, positive is returned. On error, negative is returned
- *
- *****************************************************************************/
-
-#ifndef CC3000_TINY_DRIVER
-int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_addr);
-#endif
+int listen(int sockfd, int backlog);
/*****************************************************************************
* Name: connect
@@ -398,7 +237,7 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
* establishment or for the connection establishment failure.
*
* Input Parameters:
- * sd socket descriptor (handle)
+ * sockfd socket descriptor (handle)
* addr specifies the destination addr. On this version
* only AF_INET is supported.
* addrlen contains the size of the structure pointed to by addr
@@ -408,7 +247,7 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
*
*****************************************************************************/
-long connect(long sd, const sockaddr *addr, long addrlen);
+int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
/*****************************************************************************
* Name: select
@@ -425,9 +264,9 @@ long connect(long sd, const sockaddr *addr, long addrlen);
* Input Parameters:
* nfds the highest-numbered file descriptor in any of the
* three sets, plus 1.
- * writesds socket descriptors list for write monitoring
- * readsds socket descriptors list for read monitoring
- * exceptsds socket descriptors list for exception monitoring
+ * readfds socket descriptors list for read monitoring
+ * writefds socket descriptors list for write monitoring
+ * exceptfds socket descriptors list for exception monitoring
* timeout is an upper bound on the amount of time elapsed
* before select() returns. Null means infinity
* timeout. The minimum timeout is 5 milliseconds,
@@ -441,17 +280,18 @@ long connect(long sd, const sockaddr *addr, long addrlen);
* exceptfds) which may be zero if the timeout expires before
* anything interesting happens.
* On error, -1 is returned.
- * *readsds - return the sockets on which Read request will
+ * *readfds - return the sockets on which Read request will
* return without delay with valid data.
- * *writesds - return the sockets on which Write request
+ * *writefds - return the sockets on which Write request
* will return without delay.
- * *exceptsds - return the sockets which closed recently.
+ * *exceptfds - return the sockets which closed recently.
*
*****************************************************************************/
-int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
- TICC3000fd_set *exceptsds, struct timeval *timeout);
+int select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds,
+ struct timeval *timeout);
+#ifndef CC3000_TINY_DRIVER
/*****************************************************************************
* Name: setsockopt
*
@@ -468,10 +308,10 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
* supplied. For example, to indicate that an option is to be
* interpreted by the TCP protocol, level should be set to the
* protocol number of TCP;
- * The parameters optval and optlen are used to access optval -
+ * The parameters value and value_len are used to access value -
* use for setsockopt(). For getsockopt() they identify a buffer
* in which the value for the requested option(s) are to
- * be returned. For getsockopt(), optlen is a value-result
+ * be returned. For getsockopt(), value_len is a value-result
* parameter, initially containing the size of the buffer
* pointed to by option_value, and modified on return to
* indicate the actual size of the value returned. If no option
@@ -480,29 +320,27 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
* NOTE: On this version the following two socket options are enabled:
* The only protocol level supported in this version
* is SOL_SOCKET (level).
- * 1. SOCKOPT_RECV_TIMEOUT (optname)
+ * 1. SOCKOPT_RECV_TIMEOUT (option)
* SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
* in milliseconds.
- * In that case optval should be pointer to unsigned long.
- * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
+ * In that case value should be pointer to unsigned long.
+ * 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on
* or off.
- * In that case optval should be SOCK_ON or SOCK_OFF (optval).
+ * In that case value should be SOCK_ON or SOCK_OFF (value).
*
* Input Parameters:
- * sd socket handle
+ * sockfd socket handle
* level defines the protocol level for this option
- * optname defines the option name to Interrogate
- * optval specifies a value for the option
- * optlen specifies the length of the option value
+ * option defines the option name to Interrogate
+ * value specifies a value for the option
+ * value_len specifies the length of the option value
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
*****************************************************************************/
-#ifndef CC3000_TINY_DRIVER
-int setsockopt(long sd, long level, long optname, const void *optval,
- socklen_t optlen);
+int setsockopt(int sockfd, int level, int option, FAR const void *value, socklen_t value_len);
#endif
/*****************************************************************************
@@ -521,40 +359,39 @@ int setsockopt(long sd, long level, long optname, const void *optval,
* supplied. For example, to indicate that an option is to be
* interpreted by the TCP protocol, level should be set to the
* protocol number of TCP;
- * The parameters optval and optlen are used to access optval -
+ * The parameters value and value_len are used to access value -
* use for setsockopt(). For getsockopt() they identify a buffer
* in which the value for the requested option(s) are to
- * be returned. For getsockopt(), optlen is a value-result
+ * be returned. For getsockopt(), value_len is a value-result
* parameter, initially containing the size of the buffer
* pointed to by option_value, and modified on return to
* indicate the actual size of the value returned. If no option
* value is to be supplied or returned, option_value may be NULL.
*
* NOTE: On this version the following two socket options are enabled:
- * The only protocol level supported in this version
+ * The only protocol level supported in this version
* is SOL_SOCKET (level).
- * 1. SOCKOPT_RECV_TIMEOUT (optname)
- * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
- * in milliseconds.
- * In that case optval should be pointer to unsigned long.
- * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
- * or off.
- * In that case optval should be SOCK_ON or SOCK_OFF (optval).
+ *
+ * 1. SOCKOPT_RECV_TIMEOUT (option)
+ * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
+ * in milliseconds. In that case value should be pointer to unsigned
+ * long.
+ * 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on
+ * or off. In that case value should be SOCK_ON or SOCK_OFF (value).
*
* Input Parameters:
- * sd socket handle
+ * sockfd socket handle
* level defines the protocol level for this option
- * optname defines the option name to Interrogate
- * optval specifies a value for the option
- * optlen specifies the length of the option value
+ * option defines the option name to Interrogate
+ * value specifies a value for the option
+ * value_len specifies the length of the option value
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
*****************************************************************************/
-int getsockopt(long sd, long level, long optname, void *optval,
- socklen_t *optlen);
+int getsockopt(int sockfd, int level, int option, FAR void *value, FAR socklen_t *value_len);
/*****************************************************************************
* Name: recv
@@ -565,7 +402,7 @@ int getsockopt(long sd, long level, long optname, void *optval,
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters:
- * sd socket handle
+ * sockfd socket handle
* buf Points to the buffer where the message should be stored
* len Specifies the length in bytes of the buffer pointed to
* by the buffer argument.
@@ -578,7 +415,7 @@ int getsockopt(long sd, long level, long optname, void *optval,
*
*****************************************************************************/
-int recv(long sd, void *buf, long len, long flags);
+ssize_t recv(int sockfd, FAR void *buf, size_t len, int flags);
/*****************************************************************************
* Name: recvfrom
@@ -592,7 +429,7 @@ int recv(long sd, void *buf, long len, long flags);
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters:
- * sd socket handle
+ * sockfd socket handle
* buf Points to the buffer where the message should be stored
* len Specifies the length in bytes of the buffer pointed to
* by the buffer argument.
@@ -609,8 +446,8 @@ int recv(long sd, void *buf, long len, long flags);
*
*****************************************************************************/
-int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
- socklen_t *fromlen);
+ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags,
+ FAR struct sockaddr *from, FAR socklen_t *fromlen);
/*****************************************************************************
* Name: send
@@ -623,7 +460,7 @@ int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters:
- * sd socket handle
+ * sockfd socket handle
* buf Points to a buffer containing the message to be sent
* len message size in bytes
* flags On this version, this parameter is not supported
@@ -634,7 +471,7 @@ int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
*
*****************************************************************************/
-int send(long sd, const void *buf, long len, long flags);
+ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags);
/*****************************************************************************
* Name: sendto
@@ -647,7 +484,7 @@ int send(long sd, const void *buf, long len, long flags);
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters:
- * sd socket handle
+ * sockfd socket handle
* buf Points to a buffer containing the message to be sent
* len message size in bytes
* flags On this version, this parameter is not supported
@@ -662,8 +499,35 @@ int send(long sd, const void *buf, long len, long flags);
*
*****************************************************************************/
-int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
- socklen_t tolen);
+ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
+ FAR const struct sockaddr *to, socklen_t tolen);
+
+#ifndef CC3000_TINY_DRIVER
+/*****************************************************************************
+ * Name: gethostbyname
+ *
+ * Decription:
+ * Get host IP by name. Obtain the IP Address of machine on network,
+ * by its name.
+ *
+ * NOTE: On this version, only blocking mode is supported. Also note that
+ * the function requires DNS server to be configured prior to its
+ * usage.
+ *
+ * Input Parameters:
+ * hostname host name
+ * usNameLen name length
+ * out_ip_addr This parameter is filled in with host IP address.
+ * In case that host name is not resolved,
+ * out_ip_addr is zero.
+ *
+ * Returned Value:
+ * On success, positive is returned. On error, negative is returned
+ *
+ *****************************************************************************/
+
+int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_addr);
+#endif
/*****************************************************************************
* Name: mdnsAdvertiser
@@ -683,8 +547,9 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
*
*****************************************************************************/
-int mdnsAdvertiser(uint16_t mdnsEnabled, char * deviceServiceName,
+int mdnsadvertiser(uint16_t mdnsEnabled, char *deviceServiceName,
uint16_t deviceServiceNameLength);
+
#ifdef __cplusplus
}
#endif // __cplusplus
diff --git a/nuttx/include/nuttx/wireless/cc3000/wlan.h b/nuttx/include/nuttx/wireless/cc3000/wlan.h
index c59e26b8b..edf9ad07f 100644
--- a/nuttx/include/nuttx/wireless/cc3000/wlan.h
+++ b/nuttx/include/nuttx/wireless/cc3000/wlan.h
@@ -13,29 +13,29 @@
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
+ * documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
-#ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
-#define _INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
+#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
+#define __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
/*****************************************************************************
* Included Files
@@ -112,12 +112,7 @@ extern "C" {
void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
tDriverPatches sDriverPatches,
- tBootLoaderPatches sBootLoaderPatches,
- tWlanReadInteruptPin sReadWlanInterruptPin,
- tWlanInterruptEnable sWlanInterruptEnable,
- tWlanInterruptDisable sWlanInterruptDisable,
- tWriteWlanPin sWriteWlanPin);
-
+ tBootLoaderPatches sBootLoaderPatches);
/*****************************************************************************
* Name: wlan_start
@@ -514,4 +509,4 @@ long wlan_smart_config_process(void);
}
#endif // __cplusplus
-#endif // _INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
+#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H