Eric Wu / Mbed 2 deprecated WifiRobot

Dependencies:   mbed

Committer:
wueric
Date:
Tue Dec 09 05:06:37 2014 +0000
Revision:
0:2deb247ab4bd
sharing stuff;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wueric 0:2deb247ab4bd 1 /*****************************************************************************
wueric 0:2deb247ab4bd 2 *
wueric 0:2deb247ab4bd 3 * C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
wueric 0:2deb247ab4bd 4 * Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
wueric 0:2deb247ab4bd 5 * provided help.
wueric 0:2deb247ab4bd 6 *
wueric 0:2deb247ab4bd 7 * This version of "host driver" uses CC3000 Host Driver Implementation. Thus
wueric 0:2deb247ab4bd 8 * read the following copyright:
wueric 0:2deb247ab4bd 9 *
wueric 0:2deb247ab4bd 10 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
wueric 0:2deb247ab4bd 11 *
wueric 0:2deb247ab4bd 12 * Redistribution and use in source and binary forms, with or without
wueric 0:2deb247ab4bd 13 * modification, are permitted provided that the following conditions
wueric 0:2deb247ab4bd 14 * are met:
wueric 0:2deb247ab4bd 15 *
wueric 0:2deb247ab4bd 16 * Redistributions of source code must retain the above copyright
wueric 0:2deb247ab4bd 17 * notice, this list of conditions and the following disclaimer.
wueric 0:2deb247ab4bd 18 *
wueric 0:2deb247ab4bd 19 * Redistributions in binary form must reproduce the above copyright
wueric 0:2deb247ab4bd 20 * notice, this list of conditions and the following disclaimer in the
wueric 0:2deb247ab4bd 21 * documentation and/or other materials provided with the
wueric 0:2deb247ab4bd 22 * distribution.
wueric 0:2deb247ab4bd 23 *
wueric 0:2deb247ab4bd 24 * Neither the name of Texas Instruments Incorporated nor the names of
wueric 0:2deb247ab4bd 25 * its contributors may be used to endorse or promote products derived
wueric 0:2deb247ab4bd 26 * from this software without specific prior written permission.
wueric 0:2deb247ab4bd 27 *
wueric 0:2deb247ab4bd 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
wueric 0:2deb247ab4bd 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
wueric 0:2deb247ab4bd 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
wueric 0:2deb247ab4bd 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
wueric 0:2deb247ab4bd 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
wueric 0:2deb247ab4bd 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
wueric 0:2deb247ab4bd 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
wueric 0:2deb247ab4bd 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
wueric 0:2deb247ab4bd 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
wueric 0:2deb247ab4bd 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
wueric 0:2deb247ab4bd 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
wueric 0:2deb247ab4bd 39 *
wueric 0:2deb247ab4bd 40 *****************************************************************************/
wueric 0:2deb247ab4bd 41 #ifndef CC3000_SPI_H
wueric 0:2deb247ab4bd 42 #define CC3000_SPI_H
wueric 0:2deb247ab4bd 43
wueric 0:2deb247ab4bd 44 typedef struct
wueric 0:2deb247ab4bd 45 {
wueric 0:2deb247ab4bd 46 uint16_t tx_packet_length;
wueric 0:2deb247ab4bd 47 uint16_t rx_packet_length;
wueric 0:2deb247ab4bd 48 uint32_t spi_state;
wueric 0:2deb247ab4bd 49 } tSpiInfo;
wueric 0:2deb247ab4bd 50
wueric 0:2deb247ab4bd 51
wueric 0:2deb247ab4bd 52 /* ===========================================================================================
wueric 0:2deb247ab4bd 53 SPI
wueric 0:2deb247ab4bd 54 =========================================================================================== */
wueric 0:2deb247ab4bd 55 #define READ 3
wueric 0:2deb247ab4bd 56 #define WRITE 1
wueric 0:2deb247ab4bd 57
wueric 0:2deb247ab4bd 58 #define HI(value) (((value) & 0xFF00) >> 8)
wueric 0:2deb247ab4bd 59 #define LO(value) ((value) & 0x00FF)
wueric 0:2deb247ab4bd 60
wueric 0:2deb247ab4bd 61 #define HEADERS_SIZE_EVNT (SPI_HEADER_SIZE + 5)
wueric 0:2deb247ab4bd 62
wueric 0:2deb247ab4bd 63 #define SPI_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 64
wueric 0:2deb247ab4bd 65 #define eSPI_STATE_POWERUP (0)
wueric 0:2deb247ab4bd 66 #define eSPI_STATE_INITIALIZED (1)
wueric 0:2deb247ab4bd 67 #define eSPI_STATE_IDLE (2)
wueric 0:2deb247ab4bd 68 #define eSPI_STATE_WRITE_IRQ (3)
wueric 0:2deb247ab4bd 69 #define eSPI_STATE_WRITE_FIRST_PORTION (4)
wueric 0:2deb247ab4bd 70 #define eSPI_STATE_WRITE_EOT (5)
wueric 0:2deb247ab4bd 71 #define eSPI_STATE_READ_IRQ (6)
wueric 0:2deb247ab4bd 72 #define eSPI_STATE_READ_FIRST_PORTION (7)
wueric 0:2deb247ab4bd 73 #define eSPI_STATE_READ_EOT (8)
wueric 0:2deb247ab4bd 74
wueric 0:2deb247ab4bd 75 // The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)
wueric 0:2deb247ab4bd 76 // for the purpose of detection of the overrun. The location of the memory where the magic number
wueric 0:2deb247ab4bd 77 // resides shall never be written. In case it is written - overrun occured and either recevie function
wueric 0:2deb247ab4bd 78 // or send function will be stuck forever.
wueric 0:2deb247ab4bd 79 #define CC3000_BUFFER_MAGIC_NUMBER (0xDE)
wueric 0:2deb247ab4bd 80
wueric 0:2deb247ab4bd 81 /* ===========================================================================================
wueric 0:2deb247ab4bd 82 HCI
wueric 0:2deb247ab4bd 83 =========================================================================================== */
wueric 0:2deb247ab4bd 84
wueric 0:2deb247ab4bd 85 #define SL_PATCH_PORTION_SIZE (1000)
wueric 0:2deb247ab4bd 86
wueric 0:2deb247ab4bd 87 #define SPI_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 88 #define SIMPLE_LINK_HCI_CMND_HEADER_SIZE (4)
wueric 0:2deb247ab4bd 89 #define HEADERS_SIZE_CMD (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE)
wueric 0:2deb247ab4bd 90 #define SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 91 #define SIMPLE_LINK_HCI_DATA_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 92 #define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE (2)
wueric 0:2deb247ab4bd 93
wueric 0:2deb247ab4bd 94 // Values that can be used as HCI Commands and HCI Packet header defines
wueric 0:2deb247ab4bd 95 #define HCI_TYPE_CMND 0x1
wueric 0:2deb247ab4bd 96 #define HCI_TYPE_DATA 0x2
wueric 0:2deb247ab4bd 97 #define HCI_TYPE_PATCH 0x3
wueric 0:2deb247ab4bd 98 #define HCI_TYPE_EVNT 0x4
wueric 0:2deb247ab4bd 99
wueric 0:2deb247ab4bd 100
wueric 0:2deb247ab4bd 101 #define HCI_EVENT_PATCHES_DRV_REQ (1)
wueric 0:2deb247ab4bd 102 #define HCI_EVENT_PATCHES_FW_REQ (2)
wueric 0:2deb247ab4bd 103 #define HCI_EVENT_PATCHES_BOOTLOAD_REQ (3)
wueric 0:2deb247ab4bd 104
wueric 0:2deb247ab4bd 105
wueric 0:2deb247ab4bd 106 #define HCI_CMND_WLAN_BASE (0x0000)
wueric 0:2deb247ab4bd 107 #define HCI_CMND_WLAN_CONNECT 0x0001
wueric 0:2deb247ab4bd 108 #define HCI_CMND_WLAN_DISCONNECT 0x0002
wueric 0:2deb247ab4bd 109 #define HCI_CMND_WLAN_IOCTL_SET_SCANPARAM 0x0003
wueric 0:2deb247ab4bd 110 #define HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY 0x0004
wueric 0:2deb247ab4bd 111 #define HCI_CMND_WLAN_IOCTL_ADD_PROFILE 0x0005
wueric 0:2deb247ab4bd 112 #define HCI_CMND_WLAN_IOCTL_DEL_PROFILE 0x0006
wueric 0:2deb247ab4bd 113 #define HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS 0x0007
wueric 0:2deb247ab4bd 114 #define HCI_CMND_EVENT_MASK 0x0008
wueric 0:2deb247ab4bd 115 #define HCI_CMND_WLAN_IOCTL_STATUSGET 0x0009
wueric 0:2deb247ab4bd 116 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START 0x000A
wueric 0:2deb247ab4bd 117 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP 0x000B
wueric 0:2deb247ab4bd 118 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX 0x000C
wueric 0:2deb247ab4bd 119 #define HCI_CMND_WLAN_CONFIGURE_PATCH 0x000D
wueric 0:2deb247ab4bd 120
wueric 0:2deb247ab4bd 121
wueric 0:2deb247ab4bd 122 #define HCI_CMND_SOCKET_BASE 0x1000
wueric 0:2deb247ab4bd 123 #define HCI_CMND_SOCKET 0x1001
wueric 0:2deb247ab4bd 124 #define HCI_CMND_BIND 0x1002
wueric 0:2deb247ab4bd 125 #define HCI_CMND_RECV 0x1004
wueric 0:2deb247ab4bd 126 #define HCI_CMND_ACCEPT 0x1005
wueric 0:2deb247ab4bd 127 #define HCI_CMND_LISTEN 0x1006
wueric 0:2deb247ab4bd 128 #define HCI_CMND_CONNECT 0x1007
wueric 0:2deb247ab4bd 129 #define HCI_CMND_BSD_SELECT 0x1008
wueric 0:2deb247ab4bd 130 #define HCI_CMND_SETSOCKOPT 0x1009
wueric 0:2deb247ab4bd 131 #define HCI_CMND_GETSOCKOPT 0x100A
wueric 0:2deb247ab4bd 132 #define HCI_CMND_CLOSE_SOCKET 0x100B
wueric 0:2deb247ab4bd 133 #define HCI_CMND_RECVFROM 0x100D
wueric 0:2deb247ab4bd 134 #define HCI_CMND_GETHOSTNAME 0x1010
wueric 0:2deb247ab4bd 135 #define HCI_CMND_MDNS_ADVERTISE 0x1011
wueric 0:2deb247ab4bd 136
wueric 0:2deb247ab4bd 137
wueric 0:2deb247ab4bd 138 #define HCI_DATA_BASE 0x80
wueric 0:2deb247ab4bd 139
wueric 0:2deb247ab4bd 140 #define HCI_CMND_SEND (0x01 + HCI_DATA_BASE)
wueric 0:2deb247ab4bd 141 #define HCI_CMND_SENDTO (0x03 + HCI_DATA_BASE)
wueric 0:2deb247ab4bd 142 #define HCI_DATA_BSD_RECVFROM (0x04 + HCI_DATA_BASE)
wueric 0:2deb247ab4bd 143 #define HCI_DATA_BSD_RECV (0x05 + HCI_DATA_BASE)
wueric 0:2deb247ab4bd 144
wueric 0:2deb247ab4bd 145
wueric 0:2deb247ab4bd 146 #define HCI_CMND_NVMEM_CBASE (0x0200)
wueric 0:2deb247ab4bd 147
wueric 0:2deb247ab4bd 148
wueric 0:2deb247ab4bd 149 #define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203)
wueric 0:2deb247ab4bd 150 #define HCI_CMND_NVMEM_SWAP_ENTRY (0x0205)
wueric 0:2deb247ab4bd 151 #define HCI_CMND_NVMEM_READ (0x0201)
wueric 0:2deb247ab4bd 152 #define HCI_CMND_NVMEM_WRITE (0x0090)
wueric 0:2deb247ab4bd 153 #define HCI_CMND_NVMEM_WRITE_PATCH (0x0204)
wueric 0:2deb247ab4bd 154 #define HCI_CMND_READ_SP_VERSION (0x0207)
wueric 0:2deb247ab4bd 155
wueric 0:2deb247ab4bd 156 #define HCI_CMND_READ_BUFFER_SIZE 0x400B
wueric 0:2deb247ab4bd 157 #define HCI_CMND_SIMPLE_LINK_START 0x4000
wueric 0:2deb247ab4bd 158
wueric 0:2deb247ab4bd 159 #define HCI_CMND_NETAPP_BASE 0x2000
wueric 0:2deb247ab4bd 160
wueric 0:2deb247ab4bd 161 #define HCI_NETAPP_DHCP (0x0001 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 162 #define HCI_NETAPP_PING_SEND (0x0002 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 163 #define HCI_NETAPP_PING_REPORT (0x0003 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 164 #define HCI_NETAPP_PING_STOP (0x0004 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 165 #define HCI_NETAPP_IPCONFIG (0x0005 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 166 #define HCI_NETAPP_ARP_FLUSH (0x0006 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 167 #define HCI_NETAPP_SET_DEBUG_LEVEL (0x0008 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 168 #define HCI_NETAPP_SET_TIMERS (0x0009 + HCI_CMND_NETAPP_BASE)
wueric 0:2deb247ab4bd 169
wueric 0:2deb247ab4bd 170 // Values that can be used as HCI Events defines
wueric 0:2deb247ab4bd 171 #define HCI_EVNT_WLAN_BASE 0x0000
wueric 0:2deb247ab4bd 172 #define HCI_EVNT_WLAN_CONNECT 0x0001
wueric 0:2deb247ab4bd 173 #define HCI_EVNT_WLAN_DISCONNECT \
wueric 0:2deb247ab4bd 174 0x0002
wueric 0:2deb247ab4bd 175 #define HCI_EVNT_WLAN_IOCTL_ADD_PROFILE \
wueric 0:2deb247ab4bd 176 0x0005
wueric 0:2deb247ab4bd 177
wueric 0:2deb247ab4bd 178
wueric 0:2deb247ab4bd 179 #define HCI_EVNT_SOCKET HCI_CMND_SOCKET
wueric 0:2deb247ab4bd 180 #define HCI_EVNT_BIND HCI_CMND_BIND
wueric 0:2deb247ab4bd 181 #define HCI_EVNT_RECV HCI_CMND_RECV
wueric 0:2deb247ab4bd 182 #define HCI_EVNT_ACCEPT HCI_CMND_ACCEPT
wueric 0:2deb247ab4bd 183 #define HCI_EVNT_LISTEN HCI_CMND_LISTEN
wueric 0:2deb247ab4bd 184 #define HCI_EVNT_CONNECT HCI_CMND_CONNECT
wueric 0:2deb247ab4bd 185 #define HCI_EVNT_SELECT HCI_CMND_BSD_SELECT
wueric 0:2deb247ab4bd 186 #define HCI_EVNT_CLOSE_SOCKET HCI_CMND_CLOSE_SOCKET
wueric 0:2deb247ab4bd 187 #define HCI_EVNT_RECVFROM HCI_CMND_RECVFROM
wueric 0:2deb247ab4bd 188 #define HCI_EVNT_SETSOCKOPT HCI_CMND_SETSOCKOPT
wueric 0:2deb247ab4bd 189 #define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT
wueric 0:2deb247ab4bd 190 #define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME
wueric 0:2deb247ab4bd 191 #define HCI_EVNT_MDNS_ADVERTISE HCI_CMND_MDNS_ADVERTISE
wueric 0:2deb247ab4bd 192
wueric 0:2deb247ab4bd 193 #define HCI_EVNT_SEND 0x1003
wueric 0:2deb247ab4bd 194 #define HCI_EVNT_WRITE 0x100E
wueric 0:2deb247ab4bd 195 #define HCI_EVNT_SENDTO 0x100F
wueric 0:2deb247ab4bd 196
wueric 0:2deb247ab4bd 197 #define HCI_EVNT_PATCHES_REQ 0x1000
wueric 0:2deb247ab4bd 198
wueric 0:2deb247ab4bd 199 #define HCI_EVNT_UNSOL_BASE 0x4000
wueric 0:2deb247ab4bd 200
wueric 0:2deb247ab4bd 201 #define HCI_EVNT_WLAN_UNSOL_BASE (0x8000)
wueric 0:2deb247ab4bd 202
wueric 0:2deb247ab4bd 203 #define HCI_EVNT_WLAN_UNSOL_CONNECT (0x0001 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 204 #define HCI_EVNT_WLAN_UNSOL_DISCONNECT (0x0002 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 205 #define HCI_EVNT_WLAN_UNSOL_INIT (0x0004 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 206 #define HCI_EVNT_WLAN_TX_COMPLETE (0x0008 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 207 #define HCI_EVNT_WLAN_UNSOL_DHCP (0x0010 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 208 #define HCI_EVNT_WLAN_ASYNC_PING_REPORT (0x0040 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 209 #define HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE (0x0080 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 210 #define HCI_EVNT_WLAN_KEEPALIVE (0x0200 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 211 #define HCI_EVNT_BSD_TCP_CLOSE_WAIT (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE)
wueric 0:2deb247ab4bd 212
wueric 0:2deb247ab4bd 213 #define HCI_EVNT_DATA_UNSOL_FREE_BUFF \
wueric 0:2deb247ab4bd 214 0x4100
wueric 0:2deb247ab4bd 215
wueric 0:2deb247ab4bd 216 #define HCI_EVNT_NVMEM_CREATE_ENTRY \
wueric 0:2deb247ab4bd 217 HCI_CMND_NVMEM_CREATE_ENTRY
wueric 0:2deb247ab4bd 218 #define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY
wueric 0:2deb247ab4bd 219
wueric 0:2deb247ab4bd 220 #define HCI_EVNT_NVMEM_READ HCI_CMND_NVMEM_READ
wueric 0:2deb247ab4bd 221 #define HCI_EVNT_NVMEM_WRITE (0x0202)
wueric 0:2deb247ab4bd 222
wueric 0:2deb247ab4bd 223 #define HCI_EVNT_READ_SP_VERSION \
wueric 0:2deb247ab4bd 224 HCI_CMND_READ_SP_VERSION
wueric 0:2deb247ab4bd 225
wueric 0:2deb247ab4bd 226 #define HCI_EVNT_INPROGRESS 0xFFFF
wueric 0:2deb247ab4bd 227
wueric 0:2deb247ab4bd 228
wueric 0:2deb247ab4bd 229 #define HCI_DATA_RECVFROM 0x84
wueric 0:2deb247ab4bd 230 #define HCI_DATA_RECV 0x85
wueric 0:2deb247ab4bd 231 #define HCI_DATA_NVMEM 0x91
wueric 0:2deb247ab4bd 232
wueric 0:2deb247ab4bd 233 #define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99
wueric 0:2deb247ab4bd 234
wueric 0:2deb247ab4bd 235 // Prototypes for the structures for HCI APIs.
wueric 0:2deb247ab4bd 236 #define HCI_DATA_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 237 #define HCI_EVENT_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 238 #define HCI_DATA_CMD_HEADER_SIZE (5)
wueric 0:2deb247ab4bd 239 #define HCI_PATCH_HEADER_SIZE (6)
wueric 0:2deb247ab4bd 240
wueric 0:2deb247ab4bd 241 #define HCI_PACKET_TYPE_OFFSET (0)
wueric 0:2deb247ab4bd 242 #define HCI_PACKET_ARGSIZE_OFFSET (2)
wueric 0:2deb247ab4bd 243 #define HCI_PACKET_LENGTH_OFFSET (3)
wueric 0:2deb247ab4bd 244
wueric 0:2deb247ab4bd 245
wueric 0:2deb247ab4bd 246 #define HCI_EVENT_OPCODE_OFFSET (1)
wueric 0:2deb247ab4bd 247 #define HCI_EVENT_LENGTH_OFFSET (3)
wueric 0:2deb247ab4bd 248 #define HCI_EVENT_STATUS_OFFSET (4)
wueric 0:2deb247ab4bd 249 #define HCI_DATA_LENGTH_OFFSET (3)
wueric 0:2deb247ab4bd 250
wueric 0:2deb247ab4bd 251 #endif