3
3
* cc3000_common.h - CC3000 Host Driver Implementation.
4
4
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5
5
*
6
- * Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend)
6
+ * Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend)
7
7
* & Limor Fried for Adafruit Industries
8
- * This library works with the Adafruit CC3000 breakout
8
+ * This library works with the Adafruit CC3000 breakout
9
9
* ----> https://www.adafruit.com/products/1469
10
10
* Adafruit invests time and resources providing this open source code,
11
11
* please support Adafruit and open-source hardware by purchasing
20
20
*
21
21
* Redistributions in binary form must reproduce the above copyright
22
22
* notice, this list of conditions and the following disclaimer in the
23
- * documentation and/or other materials provided with the
23
+ * documentation and/or other materials provided with the
24
24
* distribution.
25
25
*
26
26
* Neither the name of Texas Instruments Incorporated nor the names of
27
27
* its contributors may be used to endorse or promote products derived
28
28
* from this software without specific prior written permission.
29
29
*
30
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32
32
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36
36
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37
37
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40
40
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
41
*
42
42
*****************************************************************************/
@@ -70,45 +70,45 @@ extern "C" {
70
70
//*****************************************************************************
71
71
// COMMON DEFINES
72
72
//*****************************************************************************
73
- #define ERROR_SOCKET_INACTIVE -57
73
+ #define ERROR_SOCKET_INACTIVE -57
74
74
75
- #define WLAN_ENABLE (1)
75
+ #define WLAN_ENABLE (1)
76
76
#define WLAN_DISABLE (0)
77
77
78
78
#define MAC_ADDR_LEN (6)
79
79
80
80
#define SP_PORTION_SIZE (32)
81
81
82
82
// #define CC3000_TINY_DRIVER
83
-
84
- /*Defines for minimal and maximal RX buffer size. This size includes the spi
83
+
84
+ /*Defines for minimal and maximal RX buffer size. This size includes the spi
85
85
header and hci header.
86
86
The maximal buffer size derives from:
87
87
MTU + HCI header + SPI header + sendto() agrs size
88
88
The minimum buffer size derives from:
89
89
HCI header + SPI header + max args size
90
90
91
91
This buffer is used for receiving events and data.
92
- The packet can not be longer than MTU size and CC3000 does not support
93
- fragmentation. Note that the same buffer is used for reception of the data
94
- and events from CC3000. That is why the minimum is defined.
92
+ The packet can not be longer than MTU size and CC3000 does not support
93
+ fragmentation. Note that the same buffer is used for reception of the data
94
+ and events from CC3000. That is why the minimum is defined.
95
95
The calculation for the actual size of buffer for reception is:
96
96
Given the maximal data size MAX_DATA that is expected to be received by
97
97
application, the required buffer is:
98
98
Using recv() or recvfrom():
99
-
99
+
100
100
max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen
101
101
+ ucArgsize + 1)
102
-
102
+
103
103
Using gethostbyname() with minimal buffer size will limit the host name
104
104
returned to 99 bytes only.
105
- The 1 is used for the overrun detection
105
+ The 1 is used for the overrun detection
106
106
107
107
Buffer size increased to 130 following the add_profile() with WEP security
108
- which requires TX buffer size of 130 bytes:
108
+ which requires TX buffer size of 130 bytes:
109
109
HEADERS_SIZE_EVNT + WLAN_ADD_PROFILE_WEP_PARAM_LEN + MAX SSID LEN + 4 * MAX KEY LEN = 130
110
- MAX SSID LEN = 32
111
- MAX SSID LEN = 13 (with add_profile only ascii key setting is supported,
110
+ MAX SSID LEN = 32
111
+ MAX SSID LEN = 13 (with add_profile only ascii key setting is supported,
112
112
therfore maximum key size is 13)
113
113
*/
114
114
@@ -117,24 +117,24 @@ extern "C" {
117
117
118
118
/*Defines for minimal and maximal TX buffer size.
119
119
This buffer is used for sending events and data.
120
- The packet can not be longer than MTU size and CC3000 does not support
120
+ The packet can not be longer than MTU size and CC3000 does not support
121
121
fragmentation. Note that the same buffer is used for transmission of the data
122
122
and commands. That is why the minimum is defined.
123
123
The calculation for the actual size of buffer for transmission is:
124
124
Given the maximal data size MAX_DATA, the required buffer is:
125
125
Using Sendto():
126
-
126
+
127
127
max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
128
128
+ SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
129
-
129
+
130
130
Using Send():
131
-
131
+
132
132
max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
133
133
+ HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
134
-
135
- The 1 is used for the overrun detection */
136
134
137
- #define CC3000_MINIMAL_TX_SIZE (130 + 1)
135
+ The 1 is used for the overrun detection */
136
+
137
+ #define CC3000_MINIMAL_TX_SIZE (130 + 1)
138
138
#define CC3000_MAXIMAL_TX_SIZE (1519 + 1)
139
139
140
140
//TX and RX buffer sizes, allow to receive and transmit maximum data at length 8.
@@ -143,26 +143,26 @@ extern "C" {
143
143
#define TINY_CC3000_MAXIMAL_TX_SIZE 59
144
144
#endif
145
145
146
- /*In order to determine your preferred buffer size,
146
+ /*In order to determine your preferred buffer size,
147
147
change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between
148
- the minimal and maximal specified above.
148
+ the minimal and maximal specified above.
149
149
Note that the buffers are allocated by SPI.
150
150
In case you change the size of those buffers, you might need also to change
151
151
the linker file, since for example on MSP430 FRAM devices the buffers are
152
152
allocated in the FRAM section that is allocated manually and not by IDE.
153
153
*/
154
-
154
+
155
155
#ifndef CC3000_TINY_DRIVER
156
-
156
+
157
157
#define CC3000_RX_BUFFER_SIZE (CC3000_MINIMAL_RX_SIZE)
158
158
#define CC3000_TX_BUFFER_SIZE (CC3000_MINIMAL_TX_SIZE)
159
-
159
+
160
160
//if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption
161
161
#else
162
162
#define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE)
163
163
#define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE)
164
164
165
- #endif
165
+ #endif
166
166
167
167
//*****************************************************************************
168
168
// Compound Types
@@ -177,7 +177,7 @@ typedef long suseconds_t;
177
177
178
178
typedef struct timeval timeval ;
179
179
180
- struct timeval
180
+ struct timeval
181
181
{
182
182
time_t tv_sec ; /* seconds */
183
183
suseconds_t tv_usec ; /* microseconds */
@@ -263,7 +263,7 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
263
263
//! @return none
264
264
//!
265
265
//! @brief Wait for data, pass it to the hci_event_handler
266
- //! and update in a global variable that there is
266
+ //! and update in a global variable that there is
267
267
//! data to read.
268
268
//
269
269
//*****************************************************************************
@@ -295,7 +295,7 @@ extern uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32);
295
295
//!
296
296
//! \return pointer to the new stream
297
297
//!
298
- //! \brief This function is used for copying 16 bit to stream
298
+ //! \brief This function is used for copying 16 bit to stream
299
299
//! while converting to little endian format.
300
300
//
301
301
//*****************************************************************************
@@ -311,7 +311,7 @@ extern uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16);
311
311
//!
312
312
//! \return pointer to the new 16 bit
313
313
//!
314
- //! \brief This function is used for copying received stream to
314
+ //! \brief This function is used for copying received stream to
315
315
//! 16 bit in little endian format.
316
316
//
317
317
//*****************************************************************************
0 commit comments