1212*
1313* Redistributions in binary form must reproduce the above copyright
1414* notice, this list of conditions and the following disclaimer in the
15- * documentation and/or other materials provided with the
15+ * documentation and/or other materials provided with the
1616* distribution.
1717*
1818* Neither the name of Texas Instruments Incorporated nor the names of
1919* its contributors may be used to endorse or promote products derived
2020* from this software without specific prior written permission.
2121*
22- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2424* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2828* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2929* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3232* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333*
3434*****************************************************************************/
3535#ifndef __COMMON_H__
3636#define __COMMON_H__
3737
38+ #include "data_types.h"
39+
3840//******************************************************************************
3941// Include files
4042//******************************************************************************
43+ #include <stdlib.h>
44+ #include <stdint.h>
4145
4246//*****************************************************************************
4347//
4953extern "C" {
5054#endif
5155
56+ extern int errno ;
57+
5258//*****************************************************************************
5359// ERROR CODES
5460//*****************************************************************************
@@ -59,45 +65,43 @@ extern "C" {
5965//*****************************************************************************
6066// COMMON DEFINES
6167//*****************************************************************************
62- #define ERROR_SOCKET_INACTIVE -57
68+ #define ERROR_SOCKET_INACTIVE -57
6369
64- #define WLAN_ENABLE (1)
70+ #define WLAN_ENABLE (1)
6571#define WLAN_DISABLE (0)
6672
6773#define MAC_ADDR_LEN (6)
6874
6975#define SP_PORTION_SIZE (32)
70-
71- // #define CC3000_TINY_DRIVER
72-
73- /*Defines for minimal and maximal RX buffer size. This size includes the spi
76+
77+ /*Defines for minimal and maximal RX buffer size. This size includes the spi
7478 header and hci header.
7579 The maximal buffer size derives from:
7680 MTU + HCI header + SPI header + sendto() agrs size
7781 The minimum buffer size derives from:
7882 HCI header + SPI header + max args size
7983
8084 This buffer is used for receiving events and data.
81- The packet can not be longer than MTU size and CC3000 does not support
82- fragmentation. Note that the same buffer is used for reception of the data
83- and events from CC3000. That is why the minimum is defined.
85+ The packet can not be longer than MTU size and CC3000 does not support
86+ fragmentation. Note that the same buffer is used for reception of the data
87+ and events from CC3000. That is why the minimum is defined.
8488 The calculation for the actual size of buffer for reception is:
8589 Given the maximal data size MAX_DATA that is expected to be received by
8690 application, the required buffer is:
8791 Using recv() or recvfrom():
88-
92+
8993 max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen
9094 + ucArgsize + 1)
91-
95+
9296 Using gethostbyname() with minimal buffer size will limit the host name
9397 returned to 99 bytes only.
94- The 1 is used for the overrun detection
98+ The 1 is used for the overrun detection
9599
96100 Buffer size increased to 130 following the add_profile() with WEP security
97- which requires TX buffer size of 130 bytes:
101+ which requires TX buffer size of 130 bytes:
98102 HEADERS_SIZE_EVNT + WLAN_ADD_PROFILE_WEP_PARAM_LEN + MAX SSID LEN + 4 * MAX KEY LEN = 130
99- MAX SSID LEN = 32
100- MAX SSID LEN = 13 (with add_profile only ascii key setting is supported,
103+ MAX SSID LEN = 32
104+ MAX SSID LEN = 13 (with add_profile only ascii key setting is supported,
101105 therfore maximum key size is 13)
102106*/
103107
@@ -106,24 +110,24 @@ extern "C" {
106110
107111/*Defines for minimal and maximal TX buffer size.
108112 This buffer is used for sending events and data.
109- The packet can not be longer than MTU size and CC3000 does not support
113+ The packet can not be longer than MTU size and CC3000 does not support
110114 fragmentation. Note that the same buffer is used for transmission of the data
111115 and commands. That is why the minimum is defined.
112116 The calculation for the actual size of buffer for transmission is:
113117 Given the maximal data size MAX_DATA, the required buffer is:
114118 Using Sendto():
115-
119+
116120 max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
117121 + SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
118-
122+
119123 Using Send():
120-
124+
121125 max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
122126 + HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
127+
128+ The 1 is used for the overrun detection */
123129
124- The 1 is used for the overrun detection */
125-
126- #define CC3000_MINIMAL_TX_SIZE (130 + 1)
130+ #define CC3000_MINIMAL_TX_SIZE (130 + 1)
127131#define CC3000_MAXIMAL_TX_SIZE (1519 + 1)
128132
129133//TX and RX buffer sizes, allow to receive and transmit maximum data at length 8.
@@ -132,64 +136,64 @@ extern "C" {
132136#define TINY_CC3000_MAXIMAL_TX_SIZE 59
133137#endif
134138
135- /*In order to determine your preferred buffer size,
139+ /*In order to determine your preferred buffer size,
136140 change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between
137- the minimal and maximal specified above.
141+ the minimal and maximal specified above.
138142 Note that the buffers are allocated by SPI.
139143 In case you change the size of those buffers, you might need also to change
140144 the linker file, since for example on MSP430 FRAM devices the buffers are
141145 allocated in the FRAM section that is allocated manually and not by IDE.
142146*/
143-
147+
144148#ifndef CC3000_TINY_DRIVER
145-
146- #define CC3000_RX_BUFFER_SIZE (CC3000_MINIMAL_RX_SIZE )
147- #define CC3000_TX_BUFFER_SIZE (CC3000_MINIMAL_TX_SIZE )
148-
149+
150+ #define CC3000_RX_BUFFER_SIZE (CC3000_MAXIMAL_RX_SIZE )
151+ #define CC3000_TX_BUFFER_SIZE (CC3000_MAXIMAL_TX_SIZE )
152+
149153//if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption
150154#else
151155 #define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE)
152156 #define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE)
153157
154- #endif
158+ #endif
155159
156160//*****************************************************************************
157161// Compound Types
158162//*****************************************************************************
159- typedef long time_t ;
160- typedef unsigned long clock_t ;
161- typedef long suseconds_t ;
163+ typedef INT32 time_t ;
164+ typedef UINT32 clock_t ;
165+ typedef INT32 suseconds_t ;
162166
163167typedef struct timeval timeval ;
164168
165- struct timeval
169+ struct timeval
166170{
167171 time_t tv_sec ; /* seconds */
168172 suseconds_t tv_usec ; /* microseconds */
169173};
170174
171- typedef char * (* tFWPatches )(unsigned long * usLength );
175+ typedef CHAR * (* tFWPatches )(UINT32 * usLength );
172176
173- typedef char * (* tDriverPatches )(unsigned long * usLength );
177+ typedef CHAR * (* tDriverPatches )(UINT32 * usLength );
174178
175- typedef char * (* tBootLoaderPatches )(unsigned long * usLength );
179+ typedef CHAR * (* tBootLoaderPatches )(UINT32 * usLength );
176180
177- typedef void (* tWlanCB )(long event_type , char * data , unsigned char length );
181+ typedef void (* tWlanCB )(INT32 event_type , CHAR * data , UINT8 length );
178182
179- typedef long (* tWlanReadInteruptPin )(void );
183+ typedef INT32 (* tWlanReadInteruptPin )(void );
180184
181185typedef void (* tWlanInterruptEnable )(void );
182186
183187typedef void (* tWlanInterruptDisable )(void );
184188
185- typedef void (* tWriteWlanPin )(unsigned char val );
189+ typedef void (* tWriteWlanPin )(UINT8 val );
186190
187191typedef struct
188192{
189- unsigned short usRxEventOpcode ;
190- unsigned short usEventOrDataReceived ;
191- unsigned char * pucReceivedData ;
192- unsigned char * pucTxCommandBuffer ;
193+ UINT16 usRxEventOpcode ;
194+ UINT16 usEventOrDataReceived ;
195+ UINT8 * pucReceivedData ;
196+ UINT8 * pucTxCommandBuffer ;
193197
194198 tFWPatches sFWPatches ;
195199 tDriverPatches sDriverPatches ;
@@ -200,16 +204,16 @@ typedef struct
200204 tWlanInterruptDisable WlanInterruptDisable ;
201205 tWriteWlanPin WriteWlanPin ;
202206
203- signed long slTransmitDataError ;
204- unsigned short usNumberOfFreeBuffers ;
205- unsigned short usSlBufferLength ;
206- unsigned short usBufferSize ;
207- unsigned short usRxDataPending ;
207+ INT32 slTransmitDataError ;
208+ UINT16 usNumberOfFreeBuffers ;
209+ UINT16 usSlBufferLength ;
210+ UINT16 usBufferSize ;
211+ UINT16 usRxDataPending ;
208212
209- unsigned long NumberOfSentPackets ;
210- unsigned long NumberOfReleasedPackets ;
213+ UINT32 NumberOfSentPackets ;
214+ UINT32 NumberOfReleasedPackets ;
211215
212- unsigned char InformHostOnTxComplete ;
216+ UINT8 InformHostOnTxComplete ;
213217}sSimplLinkInformation ;
214218
215219extern volatile sSimplLinkInformation tSLInformation ;
@@ -235,7 +239,7 @@ extern volatile sSimplLinkInformation tSLInformation;
235239//
236240//*****************************************************************************
237241
238- extern void SimpleLinkWaitEvent (unsigned short usOpcode , void * pRetParams );
242+ extern void SimpleLinkWaitEvent (UINT16 usOpcode , void * pRetParams );
239243
240244//*****************************************************************************
241245//
@@ -248,12 +252,12 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
248252//! @return none
249253//!
250254//! @brief Wait for data, pass it to the hci_event_handler
251- //! and update in a global variable that there is
255+ //! and update in a global variable that there is
252256//! data to read.
253257//
254258//*****************************************************************************
255259
256- extern void SimpleLinkWaitData (unsigned char * pBuf , unsigned char * from , unsigned char * fromlen );
260+ extern void SimpleLinkWaitData (UINT8 * pBuf , UINT8 * from , UINT8 * fromlen );
257261
258262//*****************************************************************************
259263//
@@ -269,7 +273,7 @@ extern void SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from, unsigne
269273//
270274//*****************************************************************************
271275
272- extern unsigned char * UINT32_TO_STREAM_f (unsigned char * p , unsigned long u32 );
276+ extern UINT8 * UINT32_TO_STREAM_f (UINT8 * p , UINT32 u32 );
273277
274278//*****************************************************************************
275279//
@@ -280,12 +284,12 @@ extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32);
280284//!
281285//! \return pointer to the new stream
282286//!
283- //! \brief This function is used for copying 16 bit to stream
287+ //! \brief This function is used for copying 16 bit to stream
284288//! while converting to little endian format.
285289//
286290//*****************************************************************************
287291
288- extern unsigned char * UINT16_TO_STREAM_f (unsigned char * p , unsigned short u16 );
292+ extern UINT8 * UINT16_TO_STREAM_f (UINT8 * p , UINT16 u16 );
289293
290294//*****************************************************************************
291295//
@@ -296,12 +300,12 @@ extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16);
296300//!
297301//! \return pointer to the new 16 bit
298302//!
299- //! \brief This function is used for copying received stream to
303+ //! \brief This function is used for copying received stream to
300304//! 16 bit in little endian format.
301305//
302306//*****************************************************************************
303307
304- extern unsigned short STREAM_TO_UINT16_f (char * p , unsigned short offset );
308+ extern UINT16 STREAM_TO_UINT16_f (CHAR * p , UINT16 offset );
305309
306310//*****************************************************************************
307311//
@@ -317,21 +321,7 @@ extern unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset);
317321//
318322//*****************************************************************************
319323
320- extern unsigned long STREAM_TO_UINT32_f (char * p , unsigned short offset );
321-
322-
323- //*****************************************************************************
324- //
325- //! cc3k_int_poll
326- //!
327- //! \brief checks if the interrupt pin is low
328- //! just in case the hardware missed a falling edge
329- //! function is in ccspi.cpp
330- //
331- //*****************************************************************************
332-
333- extern void cc3k_int_poll ();
334-
324+ extern UINT32 STREAM_TO_UINT32_f (CHAR * p , UINT16 offset );
335325
336326
337327//*****************************************************************************
@@ -346,14 +336,14 @@ extern void cc3k_int_poll();
346336//This macro is used for copying 32 bit to stream while converting to little endian format.
347337#define UINT32_TO_STREAM (_p , _u32 ) (UINT32_TO_STREAM_f(_p, _u32))
348338//This macro is used for copying a specified value length bits (l) to stream while converting to little endian format.
349- #define ARRAY_TO_STREAM (p , a , l ) {register short _i; for (_i = 0; _i < l; _i++) *(p)++ = ((unsigned char *) a)[_i];}
339+ #define ARRAY_TO_STREAM (p , a , l ) {register INT16 _i; for (_i = 0; _i < l; _i++) *(p)++ = ((UINT8 *) a)[_i];}
350340//This macro is used for copying received stream to 8 bit in little endian format.
351- #define STREAM_TO_UINT8 (_p , _offset , _u8 ) {_u8 = (unsigned char )(*(_p + _offset));}
341+ #define STREAM_TO_UINT8 (_p , _offset , _u8 ) {_u8 = (UINT8 )(*(_p + _offset));}
352342//This macro is used for copying received stream to 16 bit in little endian format.
353343#define STREAM_TO_UINT16 (_p , _offset , _u16 ) {_u16 = STREAM_TO_UINT16_f(_p, _offset);}
354344//This macro is used for copying received stream to 32 bit in little endian format.
355345#define STREAM_TO_UINT32 (_p , _offset , _u32 ) {_u32 = STREAM_TO_UINT32_f(_p, _offset);}
356- #define STREAM_TO_STREAM (p , a , l ) {register short _i; for (_i = 0; _i < l; _i++) *(a)++= ((unsigned char *) p)[_i];}
346+ #define STREAM_TO_STREAM (p , a , l ) {register INT16 _i; for (_i = 0; _i < l; _i++) *(a)++= ((UINT8 *) p)[_i];}
357347
358348
359349
0 commit comments