Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
cc3000_spi.h
00001 /***************************************************************************** 00002 * 00003 * C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to 00004 * Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and 00005 * provided help. 00006 * 00007 * This version of "host driver" uses CC3000 Host Driver Implementation. Thus 00008 * read the following copyright: 00009 * 00010 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions 00014 * are met: 00015 * 00016 * Redistributions of source code must retain the above copyright 00017 * notice, this list of conditions and the following disclaimer. 00018 * 00019 * Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in the 00021 * documentation and/or other materials provided with the 00022 * distribution. 00023 * 00024 * Neither the name of Texas Instruments Incorporated nor the names of 00025 * its contributors may be used to endorse or promote products derived 00026 * from this software without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00029 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00030 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00031 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00032 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00033 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00034 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00035 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00036 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00037 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00038 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00039 * 00040 *****************************************************************************/ 00041 #ifndef CC3000_SPI_H 00042 #define CC3000_SPI_H 00043 00044 typedef struct 00045 { 00046 uint16_t tx_packet_length; 00047 uint16_t rx_packet_length; 00048 uint32_t spi_state; 00049 } tSpiInfo; 00050 00051 00052 /* =========================================================================================== 00053 SPI 00054 =========================================================================================== */ 00055 #define READ 3 00056 #define WRITE 1 00057 00058 #define HI(value) (((value) & 0xFF00) >> 8) 00059 #define LO(value) ((value) & 0x00FF) 00060 00061 #define HEADERS_SIZE_EVNT (SPI_HEADER_SIZE + 5) 00062 00063 #define SPI_HEADER_SIZE (5) 00064 00065 #define eSPI_STATE_POWERUP (0) 00066 #define eSPI_STATE_INITIALIZED (1) 00067 #define eSPI_STATE_IDLE (2) 00068 #define eSPI_STATE_WRITE_IRQ (3) 00069 #define eSPI_STATE_WRITE_FIRST_PORTION (4) 00070 #define eSPI_STATE_WRITE_EOT (5) 00071 #define eSPI_STATE_READ_IRQ (6) 00072 #define eSPI_STATE_READ_FIRST_PORTION (7) 00073 #define eSPI_STATE_READ_EOT (8) 00074 00075 // The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size) 00076 // for the purpose of detection of the overrun. The location of the memory where the magic number 00077 // resides shall never be written. In case it is written - overrun occured and either recevie function 00078 // or send function will be stuck forever. 00079 #define CC3000_BUFFER_MAGIC_NUMBER (0xDE) 00080 00081 /* =========================================================================================== 00082 HCI 00083 =========================================================================================== */ 00084 00085 #define SL_PATCH_PORTION_SIZE (1000) 00086 00087 #define SPI_HEADER_SIZE (5) 00088 #define SIMPLE_LINK_HCI_CMND_HEADER_SIZE (4) 00089 #define HEADERS_SIZE_CMD (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE) 00090 #define SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE (5) 00091 #define SIMPLE_LINK_HCI_DATA_HEADER_SIZE (5) 00092 #define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE (2) 00093 00094 // Values that can be used as HCI Commands and HCI Packet header defines 00095 #define HCI_TYPE_CMND 0x1 00096 #define HCI_TYPE_DATA 0x2 00097 #define HCI_TYPE_PATCH 0x3 00098 #define HCI_TYPE_EVNT 0x4 00099 00100 00101 #define HCI_EVENT_PATCHES_DRV_REQ (1) 00102 #define HCI_EVENT_PATCHES_FW_REQ (2) 00103 #define HCI_EVENT_PATCHES_BOOTLOAD_REQ (3) 00104 00105 00106 #define HCI_CMND_WLAN_BASE (0x0000) 00107 #define HCI_CMND_WLAN_CONNECT 0x0001 00108 #define HCI_CMND_WLAN_DISCONNECT 0x0002 00109 #define HCI_CMND_WLAN_IOCTL_SET_SCANPARAM 0x0003 00110 #define HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY 0x0004 00111 #define HCI_CMND_WLAN_IOCTL_ADD_PROFILE 0x0005 00112 #define HCI_CMND_WLAN_IOCTL_DEL_PROFILE 0x0006 00113 #define HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS 0x0007 00114 #define HCI_CMND_EVENT_MASK 0x0008 00115 #define HCI_CMND_WLAN_IOCTL_STATUSGET 0x0009 00116 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START 0x000A 00117 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP 0x000B 00118 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX 0x000C 00119 #define HCI_CMND_WLAN_CONFIGURE_PATCH 0x000D 00120 00121 00122 #define HCI_CMND_SOCKET_BASE 0x1000 00123 #define HCI_CMND_SOCKET 0x1001 00124 #define HCI_CMND_BIND 0x1002 00125 #define HCI_CMND_RECV 0x1004 00126 #define HCI_CMND_ACCEPT 0x1005 00127 #define HCI_CMND_LISTEN 0x1006 00128 #define HCI_CMND_CONNECT 0x1007 00129 #define HCI_CMND_BSD_SELECT 0x1008 00130 #define HCI_CMND_SETSOCKOPT 0x1009 00131 #define HCI_CMND_GETSOCKOPT 0x100A 00132 #define HCI_CMND_CLOSE_SOCKET 0x100B 00133 #define HCI_CMND_RECVFROM 0x100D 00134 #define HCI_CMND_GETHOSTNAME 0x1010 00135 #define HCI_CMND_MDNS_ADVERTISE 0x1011 00136 00137 00138 #define HCI_DATA_BASE 0x80 00139 00140 #define HCI_CMND_SEND (0x01 + HCI_DATA_BASE) 00141 #define HCI_CMND_SENDTO (0x03 + HCI_DATA_BASE) 00142 #define HCI_DATA_BSD_RECVFROM (0x04 + HCI_DATA_BASE) 00143 #define HCI_DATA_BSD_RECV (0x05 + HCI_DATA_BASE) 00144 00145 00146 #define HCI_CMND_NVMEM_CBASE (0x0200) 00147 00148 00149 #define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203) 00150 #define HCI_CMND_NVMEM_SWAP_ENTRY (0x0205) 00151 #define HCI_CMND_NVMEM_READ (0x0201) 00152 #define HCI_CMND_NVMEM_WRITE (0x0090) 00153 #define HCI_CMND_NVMEM_WRITE_PATCH (0x0204) 00154 #define HCI_CMND_READ_SP_VERSION (0x0207) 00155 00156 #define HCI_CMND_READ_BUFFER_SIZE 0x400B 00157 #define HCI_CMND_SIMPLE_LINK_START 0x4000 00158 00159 #define HCI_CMND_NETAPP_BASE 0x2000 00160 00161 #define HCI_NETAPP_DHCP (0x0001 + HCI_CMND_NETAPP_BASE) 00162 #define HCI_NETAPP_PING_SEND (0x0002 + HCI_CMND_NETAPP_BASE) 00163 #define HCI_NETAPP_PING_REPORT (0x0003 + HCI_CMND_NETAPP_BASE) 00164 #define HCI_NETAPP_PING_STOP (0x0004 + HCI_CMND_NETAPP_BASE) 00165 #define HCI_NETAPP_IPCONFIG (0x0005 + HCI_CMND_NETAPP_BASE) 00166 #define HCI_NETAPP_ARP_FLUSH (0x0006 + HCI_CMND_NETAPP_BASE) 00167 #define HCI_NETAPP_SET_DEBUG_LEVEL (0x0008 + HCI_CMND_NETAPP_BASE) 00168 #define HCI_NETAPP_SET_TIMERS (0x0009 + HCI_CMND_NETAPP_BASE) 00169 00170 // Values that can be used as HCI Events defines 00171 #define HCI_EVNT_WLAN_BASE 0x0000 00172 #define HCI_EVNT_WLAN_CONNECT 0x0001 00173 #define HCI_EVNT_WLAN_DISCONNECT \ 00174 0x0002 00175 #define HCI_EVNT_WLAN_IOCTL_ADD_PROFILE \ 00176 0x0005 00177 00178 00179 #define HCI_EVNT_SOCKET HCI_CMND_SOCKET 00180 #define HCI_EVNT_BIND HCI_CMND_BIND 00181 #define HCI_EVNT_RECV HCI_CMND_RECV 00182 #define HCI_EVNT_ACCEPT HCI_CMND_ACCEPT 00183 #define HCI_EVNT_LISTEN HCI_CMND_LISTEN 00184 #define HCI_EVNT_CONNECT HCI_CMND_CONNECT 00185 #define HCI_EVNT_SELECT HCI_CMND_BSD_SELECT 00186 #define HCI_EVNT_CLOSE_SOCKET HCI_CMND_CLOSE_SOCKET 00187 #define HCI_EVNT_RECVFROM HCI_CMND_RECVFROM 00188 #define HCI_EVNT_SETSOCKOPT HCI_CMND_SETSOCKOPT 00189 #define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT 00190 #define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME 00191 #define HCI_EVNT_MDNS_ADVERTISE HCI_CMND_MDNS_ADVERTISE 00192 00193 #define HCI_EVNT_SEND 0x1003 00194 #define HCI_EVNT_WRITE 0x100E 00195 #define HCI_EVNT_SENDTO 0x100F 00196 00197 #define HCI_EVNT_PATCHES_REQ 0x1000 00198 00199 #define HCI_EVNT_UNSOL_BASE 0x4000 00200 00201 #define HCI_EVNT_WLAN_UNSOL_BASE (0x8000) 00202 00203 #define HCI_EVNT_WLAN_UNSOL_CONNECT (0x0001 + HCI_EVNT_WLAN_UNSOL_BASE) 00204 #define HCI_EVNT_WLAN_UNSOL_DISCONNECT (0x0002 + HCI_EVNT_WLAN_UNSOL_BASE) 00205 #define HCI_EVNT_WLAN_UNSOL_INIT (0x0004 + HCI_EVNT_WLAN_UNSOL_BASE) 00206 #define HCI_EVNT_WLAN_TX_COMPLETE (0x0008 + HCI_EVNT_WLAN_UNSOL_BASE) 00207 #define HCI_EVNT_WLAN_UNSOL_DHCP (0x0010 + HCI_EVNT_WLAN_UNSOL_BASE) 00208 #define HCI_EVNT_WLAN_ASYNC_PING_REPORT (0x0040 + HCI_EVNT_WLAN_UNSOL_BASE) 00209 #define HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE (0x0080 + HCI_EVNT_WLAN_UNSOL_BASE) 00210 #define HCI_EVNT_WLAN_KEEPALIVE (0x0200 + HCI_EVNT_WLAN_UNSOL_BASE) 00211 #define HCI_EVNT_BSD_TCP_CLOSE_WAIT (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE) 00212 00213 #define HCI_EVNT_DATA_UNSOL_FREE_BUFF \ 00214 0x4100 00215 00216 #define HCI_EVNT_NVMEM_CREATE_ENTRY \ 00217 HCI_CMND_NVMEM_CREATE_ENTRY 00218 #define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY 00219 00220 #define HCI_EVNT_NVMEM_READ HCI_CMND_NVMEM_READ 00221 #define HCI_EVNT_NVMEM_WRITE (0x0202) 00222 00223 #define HCI_EVNT_READ_SP_VERSION \ 00224 HCI_CMND_READ_SP_VERSION 00225 00226 #define HCI_EVNT_INPROGRESS 0xFFFF 00227 00228 00229 #define HCI_DATA_RECVFROM 0x84 00230 #define HCI_DATA_RECV 0x85 00231 #define HCI_DATA_NVMEM 0x91 00232 00233 #define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99 00234 00235 // Prototypes for the structures for HCI APIs. 00236 #define HCI_DATA_HEADER_SIZE (5) 00237 #define HCI_EVENT_HEADER_SIZE (5) 00238 #define HCI_DATA_CMD_HEADER_SIZE (5) 00239 #define HCI_PATCH_HEADER_SIZE (6) 00240 00241 #define HCI_PACKET_TYPE_OFFSET (0) 00242 #define HCI_PACKET_ARGSIZE_OFFSET (2) 00243 #define HCI_PACKET_LENGTH_OFFSET (3) 00244 00245 00246 #define HCI_EVENT_OPCODE_OFFSET (1) 00247 #define HCI_EVENT_LENGTH_OFFSET (3) 00248 #define HCI_EVENT_STATUS_OFFSET (4) 00249 #define HCI_DATA_LENGTH_OFFSET (3) 00250 00251 #endif 00252
Generated on Tue Jul 12 2022 18:55:00 by
