A Port of TI's Webserver for the CC3000

Dependencies:   mbed

Committer:
dflet
Date:
Mon Sep 16 18:37:14 2013 +0000
Revision:
2:e6a185df9e4c
Parent:
0:6ad60d78b315
ADC and Leds now work on board and config.html page.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:6ad60d78b315 1 /*****************************************************************************
dflet 0:6ad60d78b315 2 *
dflet 0:6ad60d78b315 3 * cc3000_common.h - CC3000 Host Driver Implementation.
dflet 0:6ad60d78b315 4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:6ad60d78b315 5 *
dflet 0:6ad60d78b315 6 * Redistribution and use in source and binary forms, with or without
dflet 0:6ad60d78b315 7 * modification, are permitted provided that the following conditions
dflet 0:6ad60d78b315 8 * are met:
dflet 0:6ad60d78b315 9 *
dflet 0:6ad60d78b315 10 * Redistributions of source code must retain the above copyright
dflet 0:6ad60d78b315 11 * notice, this list of conditions and the following disclaimer.
dflet 0:6ad60d78b315 12 *
dflet 0:6ad60d78b315 13 * Redistributions in binary form must reproduce the above copyright
dflet 0:6ad60d78b315 14 * notice, this list of conditions and the following disclaimer in the
dflet 0:6ad60d78b315 15 * documentation and/or other materials provided with the
dflet 0:6ad60d78b315 16 * distribution.
dflet 0:6ad60d78b315 17 *
dflet 0:6ad60d78b315 18 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:6ad60d78b315 19 * its contributors may be used to endorse or promote products derived
dflet 0:6ad60d78b315 20 * from this software without specific prior written permission.
dflet 0:6ad60d78b315 21 *
dflet 0:6ad60d78b315 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:6ad60d78b315 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:6ad60d78b315 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:6ad60d78b315 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:6ad60d78b315 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:6ad60d78b315 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:6ad60d78b315 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:6ad60d78b315 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:6ad60d78b315 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:6ad60d78b315 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:6ad60d78b315 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:6ad60d78b315 33 *
dflet 0:6ad60d78b315 34 *****************************************************************************/
dflet 0:6ad60d78b315 35 #ifndef __COMMON_H__
dflet 0:6ad60d78b315 36 #define __COMMON_H__
dflet 0:6ad60d78b315 37
dflet 0:6ad60d78b315 38 //******************************************************************************
dflet 0:6ad60d78b315 39 // Include files
dflet 0:6ad60d78b315 40 //******************************************************************************
dflet 0:6ad60d78b315 41 #include <stdlib.h>
dflet 0:6ad60d78b315 42 #include <errno.h>
dflet 0:6ad60d78b315 43 #include <stdint.h>
dflet 0:6ad60d78b315 44
dflet 0:6ad60d78b315 45 //*****************************************************************************
dflet 0:6ad60d78b315 46 //
dflet 0:6ad60d78b315 47 // If building with a C++ compiler, make all of the definitions in this header
dflet 0:6ad60d78b315 48 // have a C binding.
dflet 0:6ad60d78b315 49 //
dflet 0:6ad60d78b315 50 //*****************************************************************************
dflet 0:6ad60d78b315 51 #ifdef __cplusplus
dflet 0:6ad60d78b315 52 extern "C" {
dflet 0:6ad60d78b315 53 #endif
dflet 0:6ad60d78b315 54
dflet 0:6ad60d78b315 55 //*****************************************************************************
dflet 0:6ad60d78b315 56 // ERROR CODES
dflet 0:6ad60d78b315 57 //*****************************************************************************
dflet 0:6ad60d78b315 58 #define ESUCCESS 0
dflet 0:6ad60d78b315 59 #define EFAIL -1
dflet 0:6ad60d78b315 60 #define EERROR EFAIL
dflet 0:6ad60d78b315 61
dflet 0:6ad60d78b315 62 //*****************************************************************************
dflet 0:6ad60d78b315 63 // COMMON DEFINES
dflet 0:6ad60d78b315 64 //*****************************************************************************
dflet 0:6ad60d78b315 65 #define ERROR_SOCKET_INACTIVE -57
dflet 0:6ad60d78b315 66
dflet 0:6ad60d78b315 67 #define WLAN_ENABLE (1)
dflet 0:6ad60d78b315 68 #define WLAN_DISABLE (0)
dflet 0:6ad60d78b315 69
dflet 0:6ad60d78b315 70 #define MAC_ADDR_LEN (6)
dflet 0:6ad60d78b315 71
dflet 0:6ad60d78b315 72 #define SP_PORTION_SIZE (32)
dflet 0:6ad60d78b315 73
dflet 0:6ad60d78b315 74 /*Defines for minimal and maximal RX buffer size. This size includes the spi
dflet 0:6ad60d78b315 75 header and hci header.
dflet 0:6ad60d78b315 76 The maximal buffer size derives from:
dflet 0:6ad60d78b315 77 MTU + HCI header + SPI header + sendto() agrs size
dflet 0:6ad60d78b315 78 The minimum buffer size derives from:
dflet 0:6ad60d78b315 79 HCI header + SPI header + max args size
dflet 0:6ad60d78b315 80
dflet 0:6ad60d78b315 81 This buffer is used for receiving events and data.
dflet 0:6ad60d78b315 82 The packet can not be longer than MTU size and CC3000 does not support
dflet 0:6ad60d78b315 83 fragmentation. Note that the same buffer is used for reception of the data
dflet 0:6ad60d78b315 84 and events from CC3000. That is why the minimum is defined.
dflet 0:6ad60d78b315 85 The calculation for the actual size of buffer for reception is:
dflet 0:6ad60d78b315 86 Given the maximal data size MAX_DATA that is expected to be received by
dflet 0:6ad60d78b315 87 application, the required buffer is:
dflet 0:6ad60d78b315 88 Using recv() or recvfrom():
dflet 0:6ad60d78b315 89
dflet 0:6ad60d78b315 90 max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen
dflet 0:6ad60d78b315 91 + ucArgsize + 1)
dflet 0:6ad60d78b315 92
dflet 0:6ad60d78b315 93 Using gethostbyname() with minimal buffer size will limit the host name
dflet 0:6ad60d78b315 94 returned to 99 bytes only.
dflet 0:6ad60d78b315 95 The 1 is used for the overrun detection
dflet 0:6ad60d78b315 96
dflet 0:6ad60d78b315 97 Buffer size increased to 130 following the add_profile() with WEP security
dflet 0:6ad60d78b315 98 which requires TX buffer size of 130 bytes:
dflet 0:6ad60d78b315 99 HEADERS_SIZE_EVNT + WLAN_ADD_PROFILE_WEP_PARAM_LEN + MAX SSID LEN + 4 * MAX KEY LEN = 130
dflet 0:6ad60d78b315 100 MAX SSID LEN = 32
dflet 0:6ad60d78b315 101 MAX SSID LEN = 13 (with add_profile only ascii key setting is supported,
dflet 0:6ad60d78b315 102 therfore maximum key size is 13)
dflet 0:6ad60d78b315 103 */
dflet 0:6ad60d78b315 104
dflet 0:6ad60d78b315 105 #define CC3000_MINIMAL_RX_SIZE (130 + 1)
dflet 0:6ad60d78b315 106 #define CC3000_MAXIMAL_RX_SIZE (1519 + 1)
dflet 0:6ad60d78b315 107
dflet 0:6ad60d78b315 108 /*Defines for minimal and maximal TX buffer size.
dflet 0:6ad60d78b315 109 This buffer is used for sending events and data.
dflet 0:6ad60d78b315 110 The packet can not be longer than MTU size and CC3000 does not support
dflet 0:6ad60d78b315 111 fragmentation. Note that the same buffer is used for transmission of the data
dflet 0:6ad60d78b315 112 and commands. That is why the minimum is defined.
dflet 0:6ad60d78b315 113 The calculation for the actual size of buffer for transmission is:
dflet 0:6ad60d78b315 114 Given the maximal data size MAX_DATA, the required buffer is:
dflet 0:6ad60d78b315 115 Using Sendto():
dflet 0:6ad60d78b315 116
dflet 0:6ad60d78b315 117 max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
dflet 0:6ad60d78b315 118 + SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
dflet 0:6ad60d78b315 119
dflet 0:6ad60d78b315 120 Using Send():
dflet 0:6ad60d78b315 121
dflet 0:6ad60d78b315 122 max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
dflet 0:6ad60d78b315 123 + HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
dflet 0:6ad60d78b315 124
dflet 0:6ad60d78b315 125 The 1 is used for the overrun detection */
dflet 0:6ad60d78b315 126
dflet 0:6ad60d78b315 127 #define CC3000_MINIMAL_TX_SIZE (130 + 1)
dflet 0:6ad60d78b315 128 #define CC3000_MAXIMAL_TX_SIZE (1519 + 1)
dflet 0:6ad60d78b315 129
dflet 0:6ad60d78b315 130 //TX and RX buffer sizes, allow to receive and transmit maximum data at length 8.
dflet 0:6ad60d78b315 131 #ifdef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 132 #define TINY_CC3000_MAXIMAL_RX_SIZE 44
dflet 0:6ad60d78b315 133 #define TINY_CC3000_MAXIMAL_TX_SIZE 59
dflet 0:6ad60d78b315 134 #endif
dflet 0:6ad60d78b315 135
dflet 0:6ad60d78b315 136 /*In order to determine your preferred buffer size,
dflet 0:6ad60d78b315 137 change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between
dflet 0:6ad60d78b315 138 the minimal and maximal specified above.
dflet 0:6ad60d78b315 139 Note that the buffers are allocated by SPI.
dflet 0:6ad60d78b315 140 In case you change the size of those buffers, you might need also to change
dflet 0:6ad60d78b315 141 the linker file, since for example on MSP430 FRAM devices the buffers are
dflet 0:6ad60d78b315 142 allocated in the FRAM section that is allocated manually and not by IDE.
dflet 0:6ad60d78b315 143 */
dflet 0:6ad60d78b315 144
dflet 0:6ad60d78b315 145 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 146
dflet 0:6ad60d78b315 147 #define CC3000_RX_BUFFER_SIZE (CC3000_MAXIMAL_RX_SIZE)
dflet 0:6ad60d78b315 148 #define CC3000_TX_BUFFER_SIZE (CC3000_MAXIMAL_TX_SIZE)
dflet 0:6ad60d78b315 149
dflet 0:6ad60d78b315 150 //if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption
dflet 0:6ad60d78b315 151 #else
dflet 0:6ad60d78b315 152 #define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE)
dflet 0:6ad60d78b315 153 #define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE)
dflet 0:6ad60d78b315 154
dflet 0:6ad60d78b315 155 #endif
dflet 0:6ad60d78b315 156
dflet 0:6ad60d78b315 157 //*****************************************************************************
dflet 0:6ad60d78b315 158 // Compound Types
dflet 0:6ad60d78b315 159 //*****************************************************************************
dflet 0:6ad60d78b315 160 typedef long time_t_;
dflet 0:6ad60d78b315 161 typedef unsigned long clock_t_;
dflet 0:6ad60d78b315 162 typedef long suseconds_t;
dflet 0:6ad60d78b315 163
dflet 0:6ad60d78b315 164 typedef struct timeval timeval;
dflet 0:6ad60d78b315 165
dflet 0:6ad60d78b315 166 struct timeval
dflet 0:6ad60d78b315 167 {
dflet 0:6ad60d78b315 168 time_t_ tv_sec; /* seconds */
dflet 0:6ad60d78b315 169 suseconds_t tv_usec; /* microseconds */
dflet 0:6ad60d78b315 170 };
dflet 0:6ad60d78b315 171
dflet 0:6ad60d78b315 172 typedef char *(*tFWPatches)(unsigned long *usLength);
dflet 0:6ad60d78b315 173
dflet 0:6ad60d78b315 174 typedef char *(*tDriverPatches)(unsigned long *usLength);
dflet 0:6ad60d78b315 175
dflet 0:6ad60d78b315 176 typedef char *(*tBootLoaderPatches)(unsigned long *usLength);
dflet 0:6ad60d78b315 177
dflet 0:6ad60d78b315 178 typedef void (*tWlanCB)(long event_type, char * data, unsigned char length );
dflet 0:6ad60d78b315 179
dflet 0:6ad60d78b315 180 typedef int (*tWlanReadInteruptPin)(void);
dflet 0:6ad60d78b315 181
dflet 0:6ad60d78b315 182 typedef void (*tWlanInterruptEnable)(void);
dflet 0:6ad60d78b315 183
dflet 0:6ad60d78b315 184 typedef void (*tWlanInterruptDisable)(void);
dflet 0:6ad60d78b315 185
dflet 0:6ad60d78b315 186 typedef void (*tWriteWlanPin)(unsigned char val);
dflet 0:6ad60d78b315 187
dflet 0:6ad60d78b315 188 typedef struct
dflet 0:6ad60d78b315 189 {
dflet 0:6ad60d78b315 190 unsigned short usRxEventOpcode;
dflet 0:6ad60d78b315 191 unsigned short usEventOrDataReceived;
dflet 0:6ad60d78b315 192 unsigned char *pucReceivedData;
dflet 0:6ad60d78b315 193 unsigned char *pucTxCommandBuffer;
dflet 0:6ad60d78b315 194
dflet 0:6ad60d78b315 195 tFWPatches sFWPatches;
dflet 0:6ad60d78b315 196 tDriverPatches sDriverPatches;
dflet 0:6ad60d78b315 197 tBootLoaderPatches sBootLoaderPatches;
dflet 0:6ad60d78b315 198 tWlanCB sWlanCB;
dflet 0:6ad60d78b315 199 tWlanReadInteruptPin ReadWlanInterruptPin;
dflet 0:6ad60d78b315 200 tWlanInterruptEnable WlanInterruptEnable;
dflet 0:6ad60d78b315 201 tWlanInterruptDisable WlanInterruptDisable;
dflet 0:6ad60d78b315 202 tWriteWlanPin WriteWlanPin;
dflet 0:6ad60d78b315 203
dflet 0:6ad60d78b315 204 signed long slTransmitDataError;
dflet 0:6ad60d78b315 205 unsigned short usNumberOfFreeBuffers;
dflet 0:6ad60d78b315 206 unsigned short usSlBufferLength;
dflet 0:6ad60d78b315 207 unsigned short usBufferSize;
dflet 0:6ad60d78b315 208 unsigned short usRxDataPending;
dflet 0:6ad60d78b315 209
dflet 0:6ad60d78b315 210 unsigned long NumberOfSentPackets;
dflet 0:6ad60d78b315 211 unsigned long NumberOfReleasedPackets;
dflet 0:6ad60d78b315 212
dflet 0:6ad60d78b315 213 unsigned char InformHostOnTxComplete;
dflet 0:6ad60d78b315 214 }sSimplLinkInformation;
dflet 0:6ad60d78b315 215
dflet 0:6ad60d78b315 216 extern volatile sSimplLinkInformation tSLInformation;
dflet 0:6ad60d78b315 217
dflet 0:6ad60d78b315 218
dflet 0:6ad60d78b315 219 //*****************************************************************************
dflet 0:6ad60d78b315 220 // Prototypes for the APIs.
dflet 0:6ad60d78b315 221 //*****************************************************************************
dflet 0:6ad60d78b315 222
dflet 0:6ad60d78b315 223
dflet 0:6ad60d78b315 224
dflet 0:6ad60d78b315 225 //*****************************************************************************
dflet 0:6ad60d78b315 226 //
dflet 0:6ad60d78b315 227 //! SimpleLinkWaitEvent
dflet 0:6ad60d78b315 228 //!
dflet 0:6ad60d78b315 229 //! @param usOpcode command operation code
dflet 0:6ad60d78b315 230 //! @param pRetParams command return parameters
dflet 0:6ad60d78b315 231 //!
dflet 0:6ad60d78b315 232 //! @return none
dflet 0:6ad60d78b315 233 //!
dflet 0:6ad60d78b315 234 //! @brief Wait for event, pass it to the hci_event_handler and
dflet 0:6ad60d78b315 235 //! update the event opcode in a global variable.
dflet 0:6ad60d78b315 236 //
dflet 0:6ad60d78b315 237 //*****************************************************************************
dflet 0:6ad60d78b315 238
dflet 0:6ad60d78b315 239 extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
dflet 0:6ad60d78b315 240
dflet 0:6ad60d78b315 241 //*****************************************************************************
dflet 0:6ad60d78b315 242 //
dflet 0:6ad60d78b315 243 //! SimpleLinkWaitData
dflet 0:6ad60d78b315 244 //!
dflet 0:6ad60d78b315 245 //! @param pBuf data buffer
dflet 0:6ad60d78b315 246 //! @param from from information
dflet 0:6ad60d78b315 247 //! @param fromlen from information length
dflet 0:6ad60d78b315 248 //!
dflet 0:6ad60d78b315 249 //! @return none
dflet 0:6ad60d78b315 250 //!
dflet 0:6ad60d78b315 251 //! @brief Wait for data, pass it to the hci_event_handler
dflet 0:6ad60d78b315 252 //! and update in a global variable that there is
dflet 0:6ad60d78b315 253 //! data to read.
dflet 0:6ad60d78b315 254 //
dflet 0:6ad60d78b315 255 //*****************************************************************************
dflet 0:6ad60d78b315 256
dflet 0:6ad60d78b315 257 extern void SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from, unsigned char *fromlen);
dflet 0:6ad60d78b315 258
dflet 0:6ad60d78b315 259 //*****************************************************************************
dflet 0:6ad60d78b315 260 //
dflet 0:6ad60d78b315 261 //! UINT32_TO_STREAM_f
dflet 0:6ad60d78b315 262 //!
dflet 0:6ad60d78b315 263 //! \param p pointer to the new stream
dflet 0:6ad60d78b315 264 //! \param u32 pointer to the 32 bit
dflet 0:6ad60d78b315 265 //!
dflet 0:6ad60d78b315 266 //! \return pointer to the new stream
dflet 0:6ad60d78b315 267 //!
dflet 0:6ad60d78b315 268 //! \brief This function is used for copying 32 bit to stream
dflet 0:6ad60d78b315 269 //! while converting to little endian format.
dflet 0:6ad60d78b315 270 //
dflet 0:6ad60d78b315 271 //*****************************************************************************
dflet 0:6ad60d78b315 272
dflet 0:6ad60d78b315 273 extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32);
dflet 0:6ad60d78b315 274
dflet 0:6ad60d78b315 275 //*****************************************************************************
dflet 0:6ad60d78b315 276 //
dflet 0:6ad60d78b315 277 //! UINT16_TO_STREAM_f
dflet 0:6ad60d78b315 278 //!
dflet 0:6ad60d78b315 279 //! \param p pointer to the new stream
dflet 0:6ad60d78b315 280 //! \param u32 pointer to the 16 bit
dflet 0:6ad60d78b315 281 //!
dflet 0:6ad60d78b315 282 //! \return pointer to the new stream
dflet 0:6ad60d78b315 283 //!
dflet 0:6ad60d78b315 284 //! \brief This function is used for copying 16 bit to stream
dflet 0:6ad60d78b315 285 //! while converting to little endian format.
dflet 0:6ad60d78b315 286 //
dflet 0:6ad60d78b315 287 //*****************************************************************************
dflet 0:6ad60d78b315 288
dflet 0:6ad60d78b315 289 extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16);
dflet 0:6ad60d78b315 290
dflet 0:6ad60d78b315 291 //*****************************************************************************
dflet 0:6ad60d78b315 292 //
dflet 0:6ad60d78b315 293 //! STREAM_TO_UINT16_f
dflet 0:6ad60d78b315 294 //!
dflet 0:6ad60d78b315 295 //! \param p pointer to the stream
dflet 0:6ad60d78b315 296 //! \param offset offset in the stream
dflet 0:6ad60d78b315 297 //!
dflet 0:6ad60d78b315 298 //! \return pointer to the new 16 bit
dflet 0:6ad60d78b315 299 //!
dflet 0:6ad60d78b315 300 //! \brief This function is used for copying received stream to
dflet 0:6ad60d78b315 301 //! 16 bit in little endian format.
dflet 0:6ad60d78b315 302 //
dflet 0:6ad60d78b315 303 //*****************************************************************************
dflet 0:6ad60d78b315 304
dflet 0:6ad60d78b315 305 extern unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset);
dflet 0:6ad60d78b315 306
dflet 0:6ad60d78b315 307 //*****************************************************************************
dflet 0:6ad60d78b315 308 //
dflet 0:6ad60d78b315 309 //! STREAM_TO_UINT32_f
dflet 0:6ad60d78b315 310 //!
dflet 0:6ad60d78b315 311 //! \param p pointer to the stream
dflet 0:6ad60d78b315 312 //! \param offset offset in the stream
dflet 0:6ad60d78b315 313 //!
dflet 0:6ad60d78b315 314 //! \return pointer to the new 32 bit
dflet 0:6ad60d78b315 315 //!
dflet 0:6ad60d78b315 316 //! \brief This function is used for copying received stream to
dflet 0:6ad60d78b315 317 //! 32 bit in little endian format.
dflet 0:6ad60d78b315 318 //
dflet 0:6ad60d78b315 319 //*****************************************************************************
dflet 0:6ad60d78b315 320
dflet 0:6ad60d78b315 321 extern unsigned long STREAM_TO_UINT32_f(char* p, unsigned short offset);
dflet 0:6ad60d78b315 322
dflet 0:6ad60d78b315 323
dflet 0:6ad60d78b315 324 //*****************************************************************************
dflet 0:6ad60d78b315 325 // COMMON MACROs
dflet 0:6ad60d78b315 326 //*****************************************************************************
dflet 0:6ad60d78b315 327
dflet 0:6ad60d78b315 328
dflet 0:6ad60d78b315 329 //This macro is used for copying 8 bit to stream while converting to little endian format.
dflet 0:6ad60d78b315 330 #define UINT8_TO_STREAM(_p, _val) {*(_p)++ = (_val);}
dflet 0:6ad60d78b315 331 //This macro is used for copying 16 bit to stream while converting to little endian format.
dflet 0:6ad60d78b315 332 #define UINT16_TO_STREAM(_p, _u16) (UINT16_TO_STREAM_f(_p, _u16))
dflet 0:6ad60d78b315 333 //This macro is used for copying 32 bit to stream while converting to little endian format.
dflet 0:6ad60d78b315 334 #define UINT32_TO_STREAM(_p, _u32) (UINT32_TO_STREAM_f(_p, _u32))
dflet 0:6ad60d78b315 335 //This macro is used for copying a specified value length bits (l) to stream while converting to little endian format.
dflet 0:6ad60d78b315 336 #define ARRAY_TO_STREAM(p, a, l) {register short _i; for (_i = 0; _i < l; _i++) *(p)++ = ((unsigned char *) a)[_i];}
dflet 0:6ad60d78b315 337 //This macro is used for copying received stream to 8 bit in little endian format.
dflet 0:6ad60d78b315 338 #define STREAM_TO_UINT8(_p, _offset, _u8) {_u8 = (unsigned char)(*(_p + _offset));}
dflet 0:6ad60d78b315 339 //This macro is used for copying received stream to 16 bit in little endian format.
dflet 0:6ad60d78b315 340 #define STREAM_TO_UINT16(_p, _offset, _u16) {_u16 = STREAM_TO_UINT16_f(_p, _offset);}
dflet 0:6ad60d78b315 341 //This macro is used for copying received stream to 32 bit in little endian format.
dflet 0:6ad60d78b315 342 #define STREAM_TO_UINT32(_p, _offset, _u32) {_u32 = STREAM_TO_UINT32_f(_p, _offset);}
dflet 0:6ad60d78b315 343 #define STREAM_TO_STREAM(p, a, l) {register short _i; for (_i = 0; _i < l; _i++) *(a)++= ((unsigned char *) p)[_i];}
dflet 0:6ad60d78b315 344
dflet 0:6ad60d78b315 345
dflet 0:6ad60d78b315 346
dflet 0:6ad60d78b315 347
dflet 0:6ad60d78b315 348 //*****************************************************************************
dflet 0:6ad60d78b315 349 //
dflet 0:6ad60d78b315 350 // Mark the end of the C bindings section for C++ compilers.
dflet 0:6ad60d78b315 351 //
dflet 0:6ad60d78b315 352 //*****************************************************************************
dflet 0:6ad60d78b315 353 #ifdef __cplusplus
dflet 0:6ad60d78b315 354 }
dflet 0:6ad60d78b315 355 #endif // __cplusplus
dflet 0:6ad60d78b315 356
dflet 0:6ad60d78b315 357 #endif // __COMMON_H__
dflet 0:6ad60d78b315 358