Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

Committer:
dflet
Date:
Thu Sep 03 14:02:37 2015 +0000
Revision:
3:a8c249046181
SPI Mode change 1 to 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 3:a8c249046181 1 /*
dflet 3:a8c249046181 2 * user.h - CC31xx/CC32xx Host Driver Implementation
dflet 3:a8c249046181 3 *
dflet 3:a8c249046181 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 3:a8c249046181 5 *
dflet 3:a8c249046181 6 *
dflet 3:a8c249046181 7 * Redistribution and use in source and binary forms, with or without
dflet 3:a8c249046181 8 * modification, are permitted provided that the following conditions
dflet 3:a8c249046181 9 * are met:
dflet 3:a8c249046181 10 *
dflet 3:a8c249046181 11 * Redistributions of source code must retain the above copyright
dflet 3:a8c249046181 12 * notice, this list of conditions and the following disclaimer.
dflet 3:a8c249046181 13 *
dflet 3:a8c249046181 14 * Redistributions in binary form must reproduce the above copyright
dflet 3:a8c249046181 15 * notice, this list of conditions and the following disclaimer in the
dflet 3:a8c249046181 16 * documentation and/or other materials provided with the
dflet 3:a8c249046181 17 * distribution.
dflet 3:a8c249046181 18 *
dflet 3:a8c249046181 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 3:a8c249046181 20 * its contributors may be used to endorse or promote products derived
dflet 3:a8c249046181 21 * from this software without specific prior written permission.
dflet 3:a8c249046181 22 *
dflet 3:a8c249046181 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 3:a8c249046181 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 3:a8c249046181 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 3:a8c249046181 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 3:a8c249046181 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 3:a8c249046181 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 3:a8c249046181 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 3:a8c249046181 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 3:a8c249046181 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 3:a8c249046181 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 3:a8c249046181 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 3:a8c249046181 34 *
dflet 3:a8c249046181 35 */
dflet 3:a8c249046181 36
dflet 3:a8c249046181 37
dflet 3:a8c249046181 38 #ifndef USER_H_
dflet 3:a8c249046181 39 #define USER_H_
dflet 3:a8c249046181 40
dflet 3:a8c249046181 41 /*!
dflet 3:a8c249046181 42
dflet 3:a8c249046181 43 \addtogroup Porting
dflet 3:a8c249046181 44 @{
dflet 3:a8c249046181 45
dflet 3:a8c249046181 46 */
dflet 3:a8c249046181 47
dflet 3:a8c249046181 48 /*!
dflet 3:a8c249046181 49 ******************************************************************************
dflet 3:a8c249046181 50
dflet 3:a8c249046181 51 \defgroup porting_user_include User Include Files
dflet 3:a8c249046181 52
dflet 3:a8c249046181 53 This section IS NOT REQUIRED in case user provided primitives are handled
dflet 3:a8c249046181 54 in makefiles or project configurations (IDE)
dflet 3:a8c249046181 55
dflet 3:a8c249046181 56 PORTING ACTION:
dflet 3:a8c249046181 57 - Include all required header files for the definition of:
dflet 3:a8c249046181 58 -# Transport layer library API (e.g. SPI, UART)
dflet 3:a8c249046181 59 -# OS primitives definitions (e.g. Task spawn, Semaphores)
dflet 3:a8c249046181 60 -# Memory management primitives (e.g. alloc, free)
dflet 3:a8c249046181 61
dflet 3:a8c249046181 62 ******************************************************************************
dflet 3:a8c249046181 63 */
dflet 3:a8c249046181 64
dflet 3:a8c249046181 65 #include <string.h>
dflet 3:a8c249046181 66
dflet 3:a8c249046181 67 #ifndef SL_IF_TYPE_UART
dflet 3:a8c249046181 68 #include "cc3100_spi.h"
dflet 3:a8c249046181 69 #else
dflet 3:a8c249046181 70 #include "uart.h"
dflet 3:a8c249046181 71 #endif
dflet 3:a8c249046181 72
dflet 3:a8c249046181 73
dflet 3:a8c249046181 74 /*!
dflet 3:a8c249046181 75 ******************************************************************************
dflet 3:a8c249046181 76
dflet 3:a8c249046181 77 \defgroup porting_capabilities Capability Set Definition
dflet 3:a8c249046181 78
dflet 3:a8c249046181 79 This section IS NOT REQUIRED in case one of the following pre defined
dflet 3:a8c249046181 80 capabilities set is in use:
dflet 3:a8c249046181 81 - SL_TINY
dflet 3:a8c249046181 82 - SL_SMALL
dflet 3:a8c249046181 83 - SL_FULL
dflet 3:a8c249046181 84
dflet 3:a8c249046181 85 PORTING ACTION:
dflet 3:a8c249046181 86 - Define one of the pre-defined capabilities set or uncomment the
dflet 3:a8c249046181 87 relevant definitions below to select the required capabilities
dflet 3:a8c249046181 88 in order to "install" external SimpleLink library one should follow the next steps:
dflet 3:a8c249046181 89 1. Include the external library API header file (i.e. #include "IOT.h")
dflet 3:a8c249046181 90 2. Define each one of the desired external lib with one (out of 5) of the following:
dflet 3:a8c249046181 91 #define SL_EXT_LIB_1 <Your external lib name>
dflet 3:a8c249046181 92 #define SL_EXT_LIB_2 <Your external lib name>
dflet 3:a8c249046181 93 #define SL_EXT_LIB_3 <Your external lib name>
dflet 3:a8c249046181 94 #define SL_EXT_LIB_4 <Your external lib name>
dflet 3:a8c249046181 95 #define SL_EXT_LIB_5 <Your external lib name>
dflet 3:a8c249046181 96 @{
dflet 3:a8c249046181 97 *******************************************************************************
dflet 3:a8c249046181 98 */
dflet 3:a8c249046181 99
dflet 3:a8c249046181 100 #define SL_FULL
dflet 3:a8c249046181 101
dflet 3:a8c249046181 102 /*!
dflet 3:a8c249046181 103 \def MAX_CONCURRENT_ACTIONS
dflet 3:a8c249046181 104
dflet 3:a8c249046181 105 \brief Defines the maximum number of concurrent action in the system
dflet 3:a8c249046181 106 Min:1 , Max: 32
dflet 3:a8c249046181 107
dflet 3:a8c249046181 108 Actions which has async events as return, can be
dflet 3:a8c249046181 109
dflet 3:a8c249046181 110 \sa
dflet 3:a8c249046181 111
dflet 3:a8c249046181 112 \note In case there are not enough resources for the actions needed in the system,
dflet 3:a8c249046181 113 error is received: POOL_IS_EMPTY
dflet 3:a8c249046181 114 one option is to increase MAX_CONCURRENT_ACTIONS
dflet 3:a8c249046181 115 (improves performance but results in memory consumption)
dflet 3:a8c249046181 116 Other option is to call the API later (decrease performance)
dflet 3:a8c249046181 117
dflet 3:a8c249046181 118 \warning In case of setting to one, recommend to use non-blocking recv\recvfrom to allow
dflet 3:a8c249046181 119 multiple socket recv
dflet 3:a8c249046181 120 */
dflet 3:a8c249046181 121 #ifndef SL_TINY_EXT
dflet 3:a8c249046181 122 #define MAX_CONCURRENT_ACTIONS 10
dflet 3:a8c249046181 123 #else
dflet 3:a8c249046181 124 #define MAX_CONCURRENT_ACTIONS 1
dflet 3:a8c249046181 125 #endif
dflet 3:a8c249046181 126
dflet 3:a8c249046181 127 /*!
dflet 3:a8c249046181 128 \def CPU_FREQ_IN_MHZ
dflet 3:a8c249046181 129 \brief Defines CPU frequency for Host side, for better accuracy of busy loops, if any
dflet 3:a8c249046181 130 \sa
dflet 3:a8c249046181 131 \note
dflet 3:a8c249046181 132
dflet 3:a8c249046181 133 \warning If not set the default CPU frequency is set to 200MHz
dflet 3:a8c249046181 134 This option will be deprecated in future release
dflet 3:a8c249046181 135 */
dflet 3:a8c249046181 136 /*
dflet 3:a8c249046181 137 #define CPU_FREQ_IN_MHZ 25
dflet 3:a8c249046181 138 */
dflet 3:a8c249046181 139
dflet 3:a8c249046181 140
dflet 3:a8c249046181 141 /*!
dflet 3:a8c249046181 142 \def SL_INC_ARG_CHECK
dflet 3:a8c249046181 143
dflet 3:a8c249046181 144 \brief Defines whether the SimpleLink driver perform argument check
dflet 3:a8c249046181 145 or not
dflet 3:a8c249046181 146
dflet 3:a8c249046181 147 When defined, the SimpleLink driver perform argument check on
dflet 3:a8c249046181 148 function call. Removing this define could reduce some code
dflet 3:a8c249046181 149 size and improve slightly the performances but may impact in
dflet 3:a8c249046181 150 unpredictable behaviour in case of invalid arguments
dflet 3:a8c249046181 151
dflet 3:a8c249046181 152 \sa
dflet 3:a8c249046181 153
dflet 3:a8c249046181 154 \note belongs to \ref porting_sec
dflet 3:a8c249046181 155
dflet 3:a8c249046181 156 \warning Removing argument check may cause unpredictable behaviour in
dflet 3:a8c249046181 157 case of invalid arguments.
dflet 3:a8c249046181 158 In this case the user is responsible to argument validity
dflet 3:a8c249046181 159 (for example all handlers must not be NULL)
dflet 3:a8c249046181 160 */
dflet 3:a8c249046181 161 #define SL_INC_ARG_CHECK
dflet 3:a8c249046181 162
dflet 3:a8c249046181 163
dflet 3:a8c249046181 164 /*!
dflet 3:a8c249046181 165 \def SL_INC_STD_BSD_API_NAMING
dflet 3:a8c249046181 166
dflet 3:a8c249046181 167 \brief Defines whether SimpleLink driver should expose standard BSD
dflet 3:a8c249046181 168 APIs or not
dflet 3:a8c249046181 169
dflet 3:a8c249046181 170 When defined, the SimpleLink driver in addition to its alternative
dflet 3:a8c249046181 171 BSD APIs expose also standard BSD APIs.
dflet 3:a8c249046181 172 Standard BSD API includes the following functions:
dflet 3:a8c249046181 173 socket , close , accept , bind , listen , connect , select ,
dflet 3:a8c249046181 174 setsockopt , getsockopt , recv , recvfrom , write , send , sendto ,
dflet 3:a8c249046181 175 gethostbyname
dflet 3:a8c249046181 176
dflet 3:a8c249046181 177 \sa
dflet 3:a8c249046181 178
dflet 3:a8c249046181 179 \note belongs to \ref porting_sec
dflet 3:a8c249046181 180
dflet 3:a8c249046181 181 \warning
dflet 3:a8c249046181 182 */
dflet 3:a8c249046181 183
dflet 3:a8c249046181 184 #define SL_INC_STD_BSD_API_NAMING
dflet 3:a8c249046181 185
dflet 3:a8c249046181 186
dflet 3:a8c249046181 187 /*!
dflet 3:a8c249046181 188 \brief Defines whether to include extended API in SimpleLink driver
dflet 3:a8c249046181 189 or not
dflet 3:a8c249046181 190
dflet 3:a8c249046181 191 When defined, the SimpleLink driver will include also all
dflet 3:a8c249046181 192 extended API of the included packages
dflet 3:a8c249046181 193
dflet 3:a8c249046181 194 \sa ext_api
dflet 3:a8c249046181 195
dflet 3:a8c249046181 196 \note belongs to \ref porting_sec
dflet 3:a8c249046181 197
dflet 3:a8c249046181 198 \warning
dflet 3:a8c249046181 199 */
dflet 3:a8c249046181 200 #define SL_INC_EXT_API
dflet 3:a8c249046181 201
dflet 3:a8c249046181 202 /*!
dflet 3:a8c249046181 203 \brief Defines whether to include WLAN package in SimpleLink driver
dflet 3:a8c249046181 204 or not
dflet 3:a8c249046181 205
dflet 3:a8c249046181 206 When defined, the SimpleLink driver will include also
dflet 3:a8c249046181 207 the WLAN package
dflet 3:a8c249046181 208
dflet 3:a8c249046181 209 \sa
dflet 3:a8c249046181 210
dflet 3:a8c249046181 211 \note belongs to \ref porting_sec
dflet 3:a8c249046181 212
dflet 3:a8c249046181 213 \warning
dflet 3:a8c249046181 214 */
dflet 3:a8c249046181 215 #define SL_INC_WLAN_PKG
dflet 3:a8c249046181 216
dflet 3:a8c249046181 217 /*!
dflet 3:a8c249046181 218 \brief Defines whether to include SOCKET package in SimpleLink
dflet 3:a8c249046181 219 driver or not
dflet 3:a8c249046181 220
dflet 3:a8c249046181 221 When defined, the SimpleLink driver will include also
dflet 3:a8c249046181 222 the SOCKET package
dflet 3:a8c249046181 223
dflet 3:a8c249046181 224 \sa
dflet 3:a8c249046181 225
dflet 3:a8c249046181 226 \note belongs to \ref porting_sec
dflet 3:a8c249046181 227
dflet 3:a8c249046181 228 \warning
dflet 3:a8c249046181 229 */
dflet 3:a8c249046181 230 #define SL_INC_SOCKET_PKG
dflet 3:a8c249046181 231
dflet 3:a8c249046181 232 /*!
dflet 3:a8c249046181 233 \brief Defines whether to include NET_APP package in SimpleLink
dflet 3:a8c249046181 234 driver or not
dflet 3:a8c249046181 235
dflet 3:a8c249046181 236 When defined, the SimpleLink driver will include also the
dflet 3:a8c249046181 237 NET_APP package
dflet 3:a8c249046181 238
dflet 3:a8c249046181 239 \sa
dflet 3:a8c249046181 240
dflet 3:a8c249046181 241 \note belongs to \ref porting_sec
dflet 3:a8c249046181 242
dflet 3:a8c249046181 243 \warning
dflet 3:a8c249046181 244 */
dflet 3:a8c249046181 245 #define SL_INC_NET_APP_PKG
dflet 3:a8c249046181 246
dflet 3:a8c249046181 247 /*!
dflet 3:a8c249046181 248 \brief Defines whether to include NET_CFG package in SimpleLink
dflet 3:a8c249046181 249 driver or not
dflet 3:a8c249046181 250
dflet 3:a8c249046181 251 When defined, the SimpleLink driver will include also
dflet 3:a8c249046181 252 the NET_CFG package
dflet 3:a8c249046181 253
dflet 3:a8c249046181 254 \sa
dflet 3:a8c249046181 255
dflet 3:a8c249046181 256 \note belongs to \ref porting_sec
dflet 3:a8c249046181 257
dflet 3:a8c249046181 258 \warning
dflet 3:a8c249046181 259 */
dflet 3:a8c249046181 260 #define SL_INC_NET_CFG_PKG
dflet 3:a8c249046181 261
dflet 3:a8c249046181 262 /*!
dflet 3:a8c249046181 263 \brief Defines whether to include NVMEM package in SimpleLink
dflet 3:a8c249046181 264 driver or not
dflet 3:a8c249046181 265
dflet 3:a8c249046181 266 When defined, the SimpleLink driver will include also the
dflet 3:a8c249046181 267 NVMEM package
dflet 3:a8c249046181 268
dflet 3:a8c249046181 269 \sa
dflet 3:a8c249046181 270
dflet 3:a8c249046181 271 \note belongs to \ref porting_sec
dflet 3:a8c249046181 272
dflet 3:a8c249046181 273 \warning
dflet 3:a8c249046181 274 */
dflet 3:a8c249046181 275 #define SL_INC_NVMEM_PKG
dflet 3:a8c249046181 276
dflet 3:a8c249046181 277 /*!
dflet 3:a8c249046181 278 \brief Defines whether to include socket server side APIs
dflet 3:a8c249046181 279 in SimpleLink driver or not
dflet 3:a8c249046181 280
dflet 3:a8c249046181 281 When defined, the SimpleLink driver will include also socket
dflet 3:a8c249046181 282 server side APIs
dflet 3:a8c249046181 283
dflet 3:a8c249046181 284 \sa server_side
dflet 3:a8c249046181 285
dflet 3:a8c249046181 286 \note
dflet 3:a8c249046181 287
dflet 3:a8c249046181 288 \warning
dflet 3:a8c249046181 289 */
dflet 3:a8c249046181 290 #define SL_INC_SOCK_SERVER_SIDE_API
dflet 3:a8c249046181 291
dflet 3:a8c249046181 292 /*!
dflet 3:a8c249046181 293 \brief Defines whether to include socket client side APIs in SimpleLink
dflet 3:a8c249046181 294 driver or not
dflet 3:a8c249046181 295
dflet 3:a8c249046181 296 When defined, the SimpleLink driver will include also socket
dflet 3:a8c249046181 297 client side APIs
dflet 3:a8c249046181 298
dflet 3:a8c249046181 299 \sa client_side
dflet 3:a8c249046181 300
dflet 3:a8c249046181 301 \note belongs to \ref porting_sec
dflet 3:a8c249046181 302
dflet 3:a8c249046181 303 \warning
dflet 3:a8c249046181 304 */
dflet 3:a8c249046181 305 #define SL_INC_SOCK_CLIENT_SIDE_API
dflet 3:a8c249046181 306
dflet 3:a8c249046181 307 /*!
dflet 3:a8c249046181 308 \brief Defines whether to include socket receive APIs in SimpleLink
dflet 3:a8c249046181 309 driver or not
dflet 3:a8c249046181 310
dflet 3:a8c249046181 311 When defined, the SimpleLink driver will include also socket
dflet 3:a8c249046181 312 receive side APIs
dflet 3:a8c249046181 313
dflet 3:a8c249046181 314 \sa recv_api
dflet 3:a8c249046181 315
dflet 3:a8c249046181 316 \note belongs to \ref porting_sec
dflet 3:a8c249046181 317
dflet 3:a8c249046181 318 \warning
dflet 3:a8c249046181 319 */
dflet 3:a8c249046181 320 #define SL_INC_SOCK_RECV_API
dflet 3:a8c249046181 321
dflet 3:a8c249046181 322 /*!
dflet 3:a8c249046181 323 \brief Defines whether to include socket send APIs in SimpleLink
dflet 3:a8c249046181 324 driver or not
dflet 3:a8c249046181 325
dflet 3:a8c249046181 326 When defined, the SimpleLink driver will include also socket
dflet 3:a8c249046181 327 send side APIs
dflet 3:a8c249046181 328
dflet 3:a8c249046181 329 \sa send_api
dflet 3:a8c249046181 330
dflet 3:a8c249046181 331 \note belongs to \ref porting_sec
dflet 3:a8c249046181 332
dflet 3:a8c249046181 333 \warning
dflet 3:a8c249046181 334 */
dflet 3:a8c249046181 335 #define SL_INC_SOCK_SEND_API
dflet 3:a8c249046181 336
dflet 3:a8c249046181 337 /*!
dflet 3:a8c249046181 338
dflet 3:a8c249046181 339 Close the Doxygen group.
dflet 3:a8c249046181 340 @}
dflet 3:a8c249046181 341
dflet 3:a8c249046181 342 */
dflet 3:a8c249046181 343
dflet 3:a8c249046181 344
dflet 3:a8c249046181 345 /*!
dflet 3:a8c249046181 346 ******************************************************************************
dflet 3:a8c249046181 347
dflet 3:a8c249046181 348 \defgroup porting_enable_device Device Enable/Disable IO
dflet 3:a8c249046181 349
dflet 3:a8c249046181 350 The enable/disable API provide mechanism to enable/disable the network processor
dflet 3:a8c249046181 351
dflet 3:a8c249046181 352
dflet 3:a8c249046181 353 PORTING ACTION:
dflet 3:a8c249046181 354 - None
dflet 3:a8c249046181 355 @{
dflet 3:a8c249046181 356
dflet 3:a8c249046181 357 ******************************************************************************
dflet 3:a8c249046181 358 */
dflet 3:a8c249046181 359 /*!
dflet 3:a8c249046181 360 \brief Preamble to the enabling the Network Processor.
dflet 3:a8c249046181 361 Placeholder to implement any pre-process operations
dflet 3:a8c249046181 362 before enabling networking operations.
dflet 3:a8c249046181 363
dflet 3:a8c249046181 364 \sa sl_DeviceEnable
dflet 3:a8c249046181 365
dflet 3:a8c249046181 366 \note belongs to \ref ported_sec
dflet 3:a8c249046181 367
dflet 3:a8c249046181 368 */
dflet 3:a8c249046181 369 #define sl_DeviceEnablePreamble()
dflet 3:a8c249046181 370
dflet 3:a8c249046181 371 /*!
dflet 3:a8c249046181 372 \brief Enable the Network Processor
dflet 3:a8c249046181 373
dflet 3:a8c249046181 374 \sa sl_DeviceDisable
dflet 3:a8c249046181 375
dflet 3:a8c249046181 376 \note belongs to \ref porting_sec
dflet 3:a8c249046181 377
dflet 3:a8c249046181 378 */
dflet 3:a8c249046181 379 //#define sl_DeviceEnable _spi->CC3100_enable
dflet 3:a8c249046181 380
dflet 3:a8c249046181 381 /*!
dflet 3:a8c249046181 382 \brief Disable the Network Processor
dflet 3:a8c249046181 383
dflet 3:a8c249046181 384 \sa sl_DeviceEnable
dflet 3:a8c249046181 385
dflet 3:a8c249046181 386 \note belongs to \ref porting_sec
dflet 3:a8c249046181 387 */
dflet 3:a8c249046181 388 //#define sl_DeviceDisable _spi->CC3100_disable
dflet 3:a8c249046181 389
dflet 3:a8c249046181 390 /*!
dflet 3:a8c249046181 391
dflet 3:a8c249046181 392 Close the Doxygen group.
dflet 3:a8c249046181 393 @}
dflet 3:a8c249046181 394
dflet 3:a8c249046181 395 */
dflet 3:a8c249046181 396
dflet 3:a8c249046181 397 /*!
dflet 3:a8c249046181 398 ******************************************************************************
dflet 3:a8c249046181 399
dflet 3:a8c249046181 400 \defgroup porting_interface Hardware Transport Interface
dflet 3:a8c249046181 401
dflet 3:a8c249046181 402 The simple link device can work with different transport interfaces
dflet 3:a8c249046181 403 (namely,SPI or UART). Texas Instruments provides single driver
dflet 3:a8c249046181 404 that can work with all these types. This section binds the
dflet 3:a8c249046181 405 physical transport interface with the SimpleLink driver
dflet 3:a8c249046181 406
dflet 3:a8c249046181 407
dflet 3:a8c249046181 408 \note Correct and efficient implementation of this driver is critical
dflet 3:a8c249046181 409 for the performances of the SimpleLink device on this platform.
dflet 3:a8c249046181 410
dflet 3:a8c249046181 411
dflet 3:a8c249046181 412 PORTING ACTION:
dflet 3:a8c249046181 413 - None
dflet 3:a8c249046181 414
dflet 3:a8c249046181 415 @{
dflet 3:a8c249046181 416
dflet 3:a8c249046181 417 ******************************************************************************
dflet 3:a8c249046181 418 */
dflet 3:a8c249046181 419
dflet 3:a8c249046181 420 #define _SlFd_t int32_t
dflet 3:a8c249046181 421
dflet 3:a8c249046181 422 /*!
dflet 3:a8c249046181 423 \brief Opens an interface communication port to be used for communicating
dflet 3:a8c249046181 424 with a SimpleLink device
dflet 3:a8c249046181 425
dflet 3:a8c249046181 426 Given an interface name and option flags, this function opens
dflet 3:a8c249046181 427 the communication port and creates a file descriptor.
dflet 3:a8c249046181 428 This file descriptor is used afterwards to read and write
dflet 3:a8c249046181 429 data from and to this specific communication channel.
dflet 3:a8c249046181 430 The speed, clock polarity, clock phase, chip select and all other
dflet 3:a8c249046181 431 specific attributes of the channel are all should be set to hardcoded
dflet 3:a8c249046181 432 in this function.
dflet 3:a8c249046181 433
dflet 3:a8c249046181 434 \param ifName - points to the interface name/path. The interface name is an
dflet 3:a8c249046181 435 optional attributes that the simple link driver receives
dflet 3:a8c249046181 436 on opening the driver (sl_Start).
dflet 3:a8c249046181 437 In systems that the spi channel is not implemented as
dflet 3:a8c249046181 438 part of the OS device drivers, this parameter could be NULL.
dflet 3:a8c249046181 439
dflet 3:a8c249046181 440 \param flags - optional flags parameters for future use
dflet 3:a8c249046181 441
dflet 3:a8c249046181 442 \return upon successful completion, the function shall open the channel
dflet 3:a8c249046181 443 and return a non-negative integer representing the file descriptor.
dflet 3:a8c249046181 444 Otherwise, -1 shall be returned
dflet 3:a8c249046181 445
dflet 3:a8c249046181 446 \sa sl_IfClose , sl_IfRead , sl_IfWrite
dflet 3:a8c249046181 447
dflet 3:a8c249046181 448 \note The prototype of the function is as follow:
dflet 3:a8c249046181 449 Fd_t xxx_IfOpen(char* pIfName , unsigned long flags);
dflet 3:a8c249046181 450
dflet 3:a8c249046181 451 \note belongs to \ref porting_sec
dflet 3:a8c249046181 452
dflet 3:a8c249046181 453 \warning
dflet 3:a8c249046181 454 */
dflet 3:a8c249046181 455 //#define sl_IfOpen _spi->spi_Open
dflet 3:a8c249046181 456
dflet 3:a8c249046181 457 /*!
dflet 3:a8c249046181 458 \brief Closes an opened interface communication port
dflet 3:a8c249046181 459
dflet 3:a8c249046181 460 \param fd - file descriptor of opened communication channel
dflet 3:a8c249046181 461
dflet 3:a8c249046181 462 \return upon successful completion, the function shall return 0.
dflet 3:a8c249046181 463 Otherwise, -1 shall be returned
dflet 3:a8c249046181 464
dflet 3:a8c249046181 465 \sa sl_IfOpen , sl_IfRead , sl_IfWrite
dflet 3:a8c249046181 466
dflet 3:a8c249046181 467 \note The prototype of the function is as follow:
dflet 3:a8c249046181 468 int xxx_IfClose(Fd_t Fd);
dflet 3:a8c249046181 469
dflet 3:a8c249046181 470 \note belongs to \ref porting_sec
dflet 3:a8c249046181 471
dflet 3:a8c249046181 472 \warning
dflet 3:a8c249046181 473 */
dflet 3:a8c249046181 474 //#define sl_IfClose _spi->spi_Close
dflet 3:a8c249046181 475
dflet 3:a8c249046181 476 /*!
dflet 3:a8c249046181 477 \brief Attempts to read up to len bytes from an opened communication channel
dflet 3:a8c249046181 478 into a buffer starting at pBuff.
dflet 3:a8c249046181 479
dflet 3:a8c249046181 480 \param fd - file descriptor of an opened communication channel
dflet 3:a8c249046181 481
dflet 3:a8c249046181 482 \param pBuff - pointer to the first location of a buffer that contains enough
dflet 3:a8c249046181 483 space for all expected data
dflet 3:a8c249046181 484
dflet 3:a8c249046181 485 \param len - number of bytes to read from the communication channel
dflet 3:a8c249046181 486
dflet 3:a8c249046181 487 \return upon successful completion, the function shall return the number of read bytes.
dflet 3:a8c249046181 488 Otherwise, 0 shall be returned
dflet 3:a8c249046181 489
dflet 3:a8c249046181 490 \sa sl_IfClose , sl_IfOpen , sl_IfWrite
dflet 3:a8c249046181 491
dflet 3:a8c249046181 492
dflet 3:a8c249046181 493 \note The prototype of the function is as follow:
dflet 3:a8c249046181 494 int xxx_IfRead(Fd_t Fd , char* pBuff , int Len);
dflet 3:a8c249046181 495
dflet 3:a8c249046181 496 \note belongs to \ref porting_sec
dflet 3:a8c249046181 497
dflet 3:a8c249046181 498 \warning
dflet 3:a8c249046181 499 */
dflet 3:a8c249046181 500 //#define sl_IfRead _spi->spi_Read
dflet 3:a8c249046181 501
dflet 3:a8c249046181 502 /*!
dflet 3:a8c249046181 503 \brief attempts to write up to len bytes to the SPI channel
dflet 3:a8c249046181 504
dflet 3:a8c249046181 505 \param fd - file descriptor of an opened communication channel
dflet 3:a8c249046181 506
dflet 3:a8c249046181 507 \param pBuff - pointer to the first location of a buffer that contains
dflet 3:a8c249046181 508 the data to send over the communication channel
dflet 3:a8c249046181 509
dflet 3:a8c249046181 510 \param len - number of bytes to write to the communication channel
dflet 3:a8c249046181 511
dflet 3:a8c249046181 512 \return upon successful completion, the function shall return the number of sent bytes.
dflet 3:a8c249046181 513 otherwise, 0 shall be returned
dflet 3:a8c249046181 514
dflet 3:a8c249046181 515 \sa sl_IfClose , sl_IfOpen , sl_IfRead
dflet 3:a8c249046181 516
dflet 3:a8c249046181 517 \note This function could be implemented as zero copy and return only upon successful completion
dflet 3:a8c249046181 518 of writing the whole buffer, but in cases that memory allocation is not too tight, the
dflet 3:a8c249046181 519 function could copy the data to internal buffer, return back and complete the write in
dflet 3:a8c249046181 520 parallel to other activities as long as the other SPI activities would be blocked until
dflet 3:a8c249046181 521 the entire buffer write would be completed
dflet 3:a8c249046181 522
dflet 3:a8c249046181 523 The prototype of the function is as follow:
dflet 3:a8c249046181 524 int xxx_IfWrite(Fd_t Fd , char* pBuff , int Len);
dflet 3:a8c249046181 525
dflet 3:a8c249046181 526 \note belongs to \ref porting_sec
dflet 3:a8c249046181 527
dflet 3:a8c249046181 528 \warning
dflet 3:a8c249046181 529 */
dflet 3:a8c249046181 530 //#define sl_IfWrite _spi->spi_Write
dflet 3:a8c249046181 531
dflet 3:a8c249046181 532 /*!
dflet 3:a8c249046181 533 \brief register an interrupt handler routine for the host IRQ
dflet 3:a8c249046181 534
dflet 3:a8c249046181 535 \param InterruptHdl - pointer to interrupt handler routine
dflet 3:a8c249046181 536
dflet 3:a8c249046181 537 \param pValue - pointer to a memory structure that is passed
dflet 3:a8c249046181 538 to the interrupt handler.
dflet 3:a8c249046181 539
dflet 3:a8c249046181 540 \return upon successful registration, the function shall return 0.
dflet 3:a8c249046181 541 Otherwise, -1 shall be returned
dflet 3:a8c249046181 542
dflet 3:a8c249046181 543 \sa
dflet 3:a8c249046181 544
dflet 3:a8c249046181 545 \note If there is already registered interrupt handler, the function
dflet 3:a8c249046181 546 should overwrite the old handler with the new one
dflet 3:a8c249046181 547
dflet 3:a8c249046181 548 \note If the handler is a null pointer, the function should un-register the
dflet 3:a8c249046181 549 interrupt handler, and the interrupts can be disabled.
dflet 3:a8c249046181 550
dflet 3:a8c249046181 551 \note belongs to \ref porting_sec
dflet 3:a8c249046181 552
dflet 3:a8c249046181 553 \warning
dflet 3:a8c249046181 554 */
dflet 3:a8c249046181 555 //#define sl_IfRegIntHdlr(InterruptHdl , pValue) \
dflet 3:a8c249046181 556 // _spi->registerInterruptHandler(InterruptHdl , pValue)
dflet 3:a8c249046181 557 /*!
dflet 3:a8c249046181 558 \brief Masks the Host IRQ
dflet 3:a8c249046181 559
dflet 3:a8c249046181 560 \sa sl_IfUnMaskIntHdlr
dflet 3:a8c249046181 561
dflet 3:a8c249046181 562
dflet 3:a8c249046181 563
dflet 3:a8c249046181 564 \note belongs to \ref porting_sec
dflet 3:a8c249046181 565
dflet 3:a8c249046181 566 \warning
dflet 3:a8c249046181 567 */
dflet 3:a8c249046181 568
dflet 3:a8c249046181 569 //#define sl_IfMaskIntHdlr()
dflet 3:a8c249046181 570
dflet 3:a8c249046181 571 /*!
dflet 3:a8c249046181 572 \brief Unmasks the Host IRQ
dflet 3:a8c249046181 573
dflet 3:a8c249046181 574 \sa sl_IfMaskIntHdlr
dflet 3:a8c249046181 575
dflet 3:a8c249046181 576
dflet 3:a8c249046181 577
dflet 3:a8c249046181 578 \note belongs to \ref porting_sec
dflet 3:a8c249046181 579
dflet 3:a8c249046181 580 \warning
dflet 3:a8c249046181 581 */
dflet 3:a8c249046181 582
dflet 3:a8c249046181 583 //#define sl_IfUnMaskIntHdlr()
dflet 3:a8c249046181 584
dflet 3:a8c249046181 585 /*!
dflet 3:a8c249046181 586 \brief Write Handers for statistics debug on write
dflet 3:a8c249046181 587
dflet 3:a8c249046181 588 \param interface handler - pointer to interrupt handler routine
dflet 3:a8c249046181 589
dflet 3:a8c249046181 590
dflet 3:a8c249046181 591 \return no return value
dflet 3:a8c249046181 592
dflet 3:a8c249046181 593 \sa
dflet 3:a8c249046181 594
dflet 3:a8c249046181 595 \note An optional hooks for monitoring before and after write info
dflet 3:a8c249046181 596
dflet 3:a8c249046181 597 \note belongs to \ref porting_sec
dflet 3:a8c249046181 598
dflet 3:a8c249046181 599 \warning
dflet 3:a8c249046181 600 */
dflet 3:a8c249046181 601 /*
dflet 3:a8c249046181 602 #define SL_START_WRITE_STAT
dflet 3:a8c249046181 603 */
dflet 3:a8c249046181 604
dflet 3:a8c249046181 605 #ifdef SL_START_WRITE_STAT
dflet 3:a8c249046181 606 #define sl_IfStartWriteSequence
dflet 3:a8c249046181 607 #define sl_IfEndWriteSequence
dflet 3:a8c249046181 608 #endif
dflet 3:a8c249046181 609 /*!
dflet 3:a8c249046181 610
dflet 3:a8c249046181 611 Close the Doxygen group.
dflet 3:a8c249046181 612 @}
dflet 3:a8c249046181 613
dflet 3:a8c249046181 614 */
dflet 3:a8c249046181 615
dflet 3:a8c249046181 616 /*!
dflet 3:a8c249046181 617 ******************************************************************************
dflet 3:a8c249046181 618
dflet 3:a8c249046181 619 \defgroup porting_mem_mgm Memory Management
dflet 3:a8c249046181 620
dflet 3:a8c249046181 621 This section declare in which memory management model the SimpleLink driver
dflet 3:a8c249046181 622 will run:
dflet 3:a8c249046181 623 -# Static
dflet 3:a8c249046181 624 -# Dynamic
dflet 3:a8c249046181 625
dflet 3:a8c249046181 626 This section IS NOT REQUIRED in case Static model is selected.
dflet 3:a8c249046181 627
dflet 3:a8c249046181 628 The default memory model is Static
dflet 3:a8c249046181 629
dflet 3:a8c249046181 630 PORTING ACTION:
dflet 3:a8c249046181 631 - If dynamic model is selected, define the alloc and free functions.
dflet 3:a8c249046181 632
dflet 3:a8c249046181 633 @{
dflet 3:a8c249046181 634
dflet 3:a8c249046181 635 *****************************************************************************
dflet 3:a8c249046181 636 */
dflet 3:a8c249046181 637
dflet 3:a8c249046181 638 /*!
dflet 3:a8c249046181 639 \brief Defines whether the SimpleLink driver is working in dynamic
dflet 3:a8c249046181 640 memory model or not
dflet 3:a8c249046181 641
dflet 3:a8c249046181 642 When defined, the SimpleLink driver use dynamic allocations
dflet 3:a8c249046181 643 if dynamic allocation is selected malloc and free functions
dflet 3:a8c249046181 644 must be retrieved
dflet 3:a8c249046181 645
dflet 3:a8c249046181 646 \sa
dflet 3:a8c249046181 647
dflet 3:a8c249046181 648 \note belongs to \ref porting_sec
dflet 3:a8c249046181 649
dflet 3:a8c249046181 650 \warning
dflet 3:a8c249046181 651 */
dflet 3:a8c249046181 652 /*
dflet 3:a8c249046181 653 #define SL_MEMORY_MGMT_DYNAMIC
dflet 3:a8c249046181 654 */
dflet 3:a8c249046181 655
dflet 3:a8c249046181 656 #ifdef SL_MEMORY_MGMT_DYNAMIC
dflet 3:a8c249046181 657
dflet 3:a8c249046181 658 /*!
dflet 3:a8c249046181 659 \brief
dflet 3:a8c249046181 660
dflet 3:a8c249046181 661 \sa
dflet 3:a8c249046181 662
dflet 3:a8c249046181 663 \note belongs to \ref porting_sec
dflet 3:a8c249046181 664
dflet 3:a8c249046181 665 \warning
dflet 3:a8c249046181 666 */
dflet 3:a8c249046181 667 #define sl_Malloc(Size) malloc(Size)
dflet 3:a8c249046181 668
dflet 3:a8c249046181 669 /*!
dflet 3:a8c249046181 670 \brief
dflet 3:a8c249046181 671
dflet 3:a8c249046181 672 \sa
dflet 3:a8c249046181 673
dflet 3:a8c249046181 674 \note belongs to \ref porting_sec
dflet 3:a8c249046181 675
dflet 3:a8c249046181 676 \warning
dflet 3:a8c249046181 677 */
dflet 3:a8c249046181 678 #define sl_Free(pMem) free(pMem)
dflet 3:a8c249046181 679
dflet 3:a8c249046181 680 #endif
dflet 3:a8c249046181 681
dflet 3:a8c249046181 682 /*!
dflet 3:a8c249046181 683
dflet 3:a8c249046181 684 Close the Doxygen group.
dflet 3:a8c249046181 685 @}
dflet 3:a8c249046181 686
dflet 3:a8c249046181 687 */
dflet 3:a8c249046181 688
dflet 3:a8c249046181 689 /*!
dflet 3:a8c249046181 690 ******************************************************************************
dflet 3:a8c249046181 691
dflet 3:a8c249046181 692 \defgroup porting_os Operating System (OS)
dflet 3:a8c249046181 693
dflet 3:a8c249046181 694 The simple link driver can run on multi-threaded environment as well
dflet 3:a8c249046181 695 as non-os environment (main loop)
dflet 3:a8c249046181 696
dflet 3:a8c249046181 697 This section IS NOT REQUIRED in case you are working on non-os environment.
dflet 3:a8c249046181 698
dflet 3:a8c249046181 699 If you choose to work in multi-threaded environment under any operating system
dflet 3:a8c249046181 700 you will have to provide some basic adaptation routines to allow the driver
dflet 3:a8c249046181 701 to protect access to resources from different threads (locking object) and
dflet 3:a8c249046181 702 to allow synchronization between threads (sync objects).
dflet 3:a8c249046181 703
dflet 3:a8c249046181 704 PORTING ACTION:
dflet 3:a8c249046181 705 -# Uncomment SL_PLATFORM_MULTI_THREADED define
dflet 3:a8c249046181 706 -# Bind locking object routines
dflet 3:a8c249046181 707 -# Bind synchronization object routines
dflet 3:a8c249046181 708 -# Optional - Bind spawn thread routine
dflet 3:a8c249046181 709
dflet 3:a8c249046181 710 @{
dflet 3:a8c249046181 711
dflet 3:a8c249046181 712 ******************************************************************************
dflet 3:a8c249046181 713 */
dflet 3:a8c249046181 714
dflet 3:a8c249046181 715
dflet 3:a8c249046181 716 //#define SL_PLATFORM_MULTI_THREADED
dflet 3:a8c249046181 717
dflet 3:a8c249046181 718
dflet 3:a8c249046181 719 #ifdef SL_PLATFORM_MULTI_THREADED
dflet 3:a8c249046181 720
dflet 3:a8c249046181 721 /*!
dflet 3:a8c249046181 722 \brief
dflet 3:a8c249046181 723 \sa
dflet 3:a8c249046181 724 \note belongs to \ref porting_sec
dflet 3:a8c249046181 725 \warning
dflet 3:a8c249046181 726 */
dflet 3:a8c249046181 727 #define SL_OS_RET_CODE_OK ((int)OSI_OK)
dflet 3:a8c249046181 728
dflet 3:a8c249046181 729 /*!
dflet 3:a8c249046181 730 \brief
dflet 3:a8c249046181 731 \sa
dflet 3:a8c249046181 732 \note belongs to \ref porting_sec
dflet 3:a8c249046181 733 \warning
dflet 3:a8c249046181 734 */
dflet 3:a8c249046181 735 #define SL_OS_WAIT_FOREVER ((OsiTime_t)OSI_WAIT_FOREVER)
dflet 3:a8c249046181 736
dflet 3:a8c249046181 737 /*!
dflet 3:a8c249046181 738 \brief
dflet 3:a8c249046181 739 \sa
dflet 3:a8c249046181 740 \note belongs to \ref porting_sec
dflet 3:a8c249046181 741 \warning
dflet 3:a8c249046181 742 */
dflet 3:a8c249046181 743 #define SL_OS_NO_WAIT ((OsiTime_t)OSI_NO_WAIT)
dflet 3:a8c249046181 744
dflet 3:a8c249046181 745 /*!
dflet 3:a8c249046181 746 \brief type definition for a time value
dflet 3:a8c249046181 747
dflet 3:a8c249046181 748 \note On each porting or platform the type could be whatever is needed - integer, pointer to structure etc.
dflet 3:a8c249046181 749
dflet 3:a8c249046181 750 \note belongs to \ref porting_sec
dflet 3:a8c249046181 751 */
dflet 3:a8c249046181 752 #define _SlTime_t OsiTime_tv
dflet 3:a8c249046181 753
dflet 3:a8c249046181 754 /*!
dflet 3:a8c249046181 755 \brief type definition for a sync object container
dflet 3:a8c249046181 756
dflet 3:a8c249046181 757 Sync object is object used to synchronize between two threads or thread and interrupt handler.
dflet 3:a8c249046181 758 One thread is waiting on the object and the other thread send a signal, which then
dflet 3:a8c249046181 759 release the waiting thread.
dflet 3:a8c249046181 760 The signal must be able to be sent from interrupt context.
dflet 3:a8c249046181 761 This object is generally implemented by binary semaphore or events.
dflet 3:a8c249046181 762
dflet 3:a8c249046181 763 \note On each porting or platform the type could be whatever is needed - integer, structure etc.
dflet 3:a8c249046181 764
dflet 3:a8c249046181 765 \note belongs to \ref porting_sec
dflet 3:a8c249046181 766 */
dflet 3:a8c249046181 767 #define _SlSyncObj_t OsiSyncObj_t
dflet 3:a8c249046181 768
dflet 3:a8c249046181 769
dflet 3:a8c249046181 770 /*!
dflet 3:a8c249046181 771 \brief This function creates a sync object
dflet 3:a8c249046181 772
dflet 3:a8c249046181 773 The sync object is used for synchronization between different thread or ISR and
dflet 3:a8c249046181 774 a thread.
dflet 3:a8c249046181 775
dflet 3:a8c249046181 776 \param pSyncObj - pointer to the sync object control block
dflet 3:a8c249046181 777
dflet 3:a8c249046181 778 \return upon successful creation the function should return 0
dflet 3:a8c249046181 779 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 780
dflet 3:a8c249046181 781 \note belongs to \ref porting_sec
dflet 3:a8c249046181 782 \warning
dflet 3:a8c249046181 783 */
dflet 3:a8c249046181 784 #define sl_SyncObjCreate(pSyncObj,pName) osi_SyncObjCreate(pSyncObj)
dflet 3:a8c249046181 785
dflet 3:a8c249046181 786
dflet 3:a8c249046181 787 /*!
dflet 3:a8c249046181 788 \brief This function deletes a sync object
dflet 3:a8c249046181 789
dflet 3:a8c249046181 790 \param pSyncObj - pointer to the sync object control block
dflet 3:a8c249046181 791
dflet 3:a8c249046181 792 \return upon successful deletion the function should return 0
dflet 3:a8c249046181 793 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 794 \note belongs to \ref porting_sec
dflet 3:a8c249046181 795 \warning
dflet 3:a8c249046181 796 */
dflet 3:a8c249046181 797 #define sl_SyncObjDelete(pSyncObj) osi_SyncObjDelete(pSyncObj)
dflet 3:a8c249046181 798
dflet 3:a8c249046181 799
dflet 3:a8c249046181 800 /*!
dflet 3:a8c249046181 801 \brief This function generates a sync signal for the object.
dflet 3:a8c249046181 802
dflet 3:a8c249046181 803 All suspended threads waiting on this sync object are resumed
dflet 3:a8c249046181 804
dflet 3:a8c249046181 805 \param pSyncObj - pointer to the sync object control block
dflet 3:a8c249046181 806
dflet 3:a8c249046181 807 \return upon successful signalling the function should return 0
dflet 3:a8c249046181 808 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 809 \note the function could be called from ISR context
dflet 3:a8c249046181 810 \warning
dflet 3:a8c249046181 811 */
dflet 3:a8c249046181 812 #define sl_SyncObjSignal(pSyncObj) osi_SyncObjSignal(pSyncObj)
dflet 3:a8c249046181 813
dflet 3:a8c249046181 814 /*!
dflet 3:a8c249046181 815 \brief This function generates a sync signal for the object from Interrupt
dflet 3:a8c249046181 816
dflet 3:a8c249046181 817 This is for RTOS that should signal from IRQ using a dedicated API
dflet 3:a8c249046181 818
dflet 3:a8c249046181 819 \param pSyncObj - pointer to the sync object control block
dflet 3:a8c249046181 820
dflet 3:a8c249046181 821 \return upon successful signalling the function should return 0
dflet 3:a8c249046181 822 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 823 \note the function could be called from ISR context
dflet 3:a8c249046181 824 \warning
dflet 3:a8c249046181 825 */
dflet 3:a8c249046181 826 #define sl_SyncObjSignalFromIRQ(pSyncObj) osi_SyncObjSignalFromISR( pSyncObj)
dflet 3:a8c249046181 827 /*!
dflet 3:a8c249046181 828 \brief This function waits for a sync signal of the specific sync object
dflet 3:a8c249046181 829
dflet 3:a8c249046181 830 \param pSyncObj - pointer to the sync object control block
dflet 3:a8c249046181 831 \param Timeout - numeric value specifies the maximum number of mSec to
dflet 3:a8c249046181 832 stay suspended while waiting for the sync signal
dflet 3:a8c249046181 833 Currently, the simple link driver uses only two values:
dflet 3:a8c249046181 834 - OSI_WAIT_FOREVER
dflet 3:a8c249046181 835 - OSI_NO_WAIT
dflet 3:a8c249046181 836
dflet 3:a8c249046181 837 \return upon successful reception of the signal within the timeout window return 0
dflet 3:a8c249046181 838 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 839 \note belongs to \ref porting_sec
dflet 3:a8c249046181 840 \warning
dflet 3:a8c249046181 841 */
dflet 3:a8c249046181 842 #define sl_SyncObjWait(pSyncObj,Timeout) osi_SyncObjWait( pSyncObj , Timeout)
dflet 3:a8c249046181 843
dflet 3:a8c249046181 844 /*!
dflet 3:a8c249046181 845 \brief type definition for a locking object container
dflet 3:a8c249046181 846
dflet 3:a8c249046181 847 Locking object are used to protect a resource from mutual accesses of two or more threads.
dflet 3:a8c249046181 848 The locking object should support reentrant locks by a signal thread.
dflet 3:a8c249046181 849 This object is generally implemented by mutex semaphore
dflet 3:a8c249046181 850
dflet 3:a8c249046181 851 \note On each porting or platform the type could be whatever is needed - integer, structure etc.
dflet 3:a8c249046181 852 \note belongs to \ref porting_sec
dflet 3:a8c249046181 853 */
dflet 3:a8c249046181 854 #define _SlLockObj_t OsiLockObj_t
dflet 3:a8c249046181 855
dflet 3:a8c249046181 856 /*!
dflet 3:a8c249046181 857 \brief This function creates a locking object.
dflet 3:a8c249046181 858
dflet 3:a8c249046181 859 The locking object is used for protecting a shared resources between different
dflet 3:a8c249046181 860 threads.
dflet 3:a8c249046181 861
dflet 3:a8c249046181 862 \param pLockObj - pointer to the locking object control block
dflet 3:a8c249046181 863
dflet 3:a8c249046181 864 \return upon successful creation the function should return 0
dflet 3:a8c249046181 865 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 866 \note belongs to \ref porting_sec
dflet 3:a8c249046181 867 \warning
dflet 3:a8c249046181 868 */
dflet 3:a8c249046181 869 #define sl_LockObjCreate(pLockObj,pName) osi_LockObjCreate(pLockObj)
dflet 3:a8c249046181 870
dflet 3:a8c249046181 871 /*!
dflet 3:a8c249046181 872 \brief This function deletes a locking object.
dflet 3:a8c249046181 873
dflet 3:a8c249046181 874 \param pLockObj - pointer to the locking object control block
dflet 3:a8c249046181 875
dflet 3:a8c249046181 876 \return upon successful deletion the function should return 0
dflet 3:a8c249046181 877 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 878 \note belongs to \ref porting_sec
dflet 3:a8c249046181 879 \warning
dflet 3:a8c249046181 880 */
dflet 3:a8c249046181 881 #define sl_LockObjDelete(pLockObj) osi_LockObjDelete(pLockObj)
dflet 3:a8c249046181 882
dflet 3:a8c249046181 883 /*!
dflet 3:a8c249046181 884 \brief This function locks a locking object.
dflet 3:a8c249046181 885
dflet 3:a8c249046181 886 All other threads that call this function before this thread calls
dflet 3:a8c249046181 887 the osi_LockObjUnlock would be suspended
dflet 3:a8c249046181 888
dflet 3:a8c249046181 889 \param pLockObj - pointer to the locking object control block
dflet 3:a8c249046181 890 \param Timeout - numeric value specifies the maximum number of mSec to
dflet 3:a8c249046181 891 stay suspended while waiting for the locking object
dflet 3:a8c249046181 892 Currently, the simple link driver uses only two values:
dflet 3:a8c249046181 893 - OSI_WAIT_FOREVER
dflet 3:a8c249046181 894 - OSI_NO_WAIT
dflet 3:a8c249046181 895
dflet 3:a8c249046181 896
dflet 3:a8c249046181 897 \return upon successful reception of the locking object the function should return 0
dflet 3:a8c249046181 898 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 899 \note belongs to \ref porting_sec
dflet 3:a8c249046181 900 \warning
dflet 3:a8c249046181 901 */
dflet 3:a8c249046181 902 #define sl_LockObjLock(pLockObj,Timeout) osi_LockObjLock( pLockObj , Timeout)
dflet 3:a8c249046181 903
dflet 3:a8c249046181 904 /*!
dflet 3:a8c249046181 905 \brief This function unlock a locking object.
dflet 3:a8c249046181 906
dflet 3:a8c249046181 907 \param pLockObj - pointer to the locking object control block
dflet 3:a8c249046181 908
dflet 3:a8c249046181 909 \return upon successful unlocking the function should return 0
dflet 3:a8c249046181 910 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 911 \note belongs to \ref porting_sec
dflet 3:a8c249046181 912 \warning
dflet 3:a8c249046181 913 */
dflet 3:a8c249046181 914 #define sl_LockObjUnlock(pLockObj) osi_LockObjUnlock( pLockObj)
dflet 3:a8c249046181 915
dflet 3:a8c249046181 916 #endif
dflet 3:a8c249046181 917 /*!
dflet 3:a8c249046181 918 \brief This function call the pEntry callback from a different context
dflet 3:a8c249046181 919
dflet 3:a8c249046181 920 \param pEntry - pointer to the entry callback function
dflet 3:a8c249046181 921
dflet 3:a8c249046181 922 \param pValue - pointer to any type of memory structure that would be
dflet 3:a8c249046181 923 passed to pEntry callback from the execution thread.
dflet 3:a8c249046181 924
dflet 3:a8c249046181 925 \param flags - execution flags - reserved for future usage
dflet 3:a8c249046181 926
dflet 3:a8c249046181 927 \return upon successful registration of the spawn the function should return 0
dflet 3:a8c249046181 928 (the function is not blocked till the end of the execution of the function
dflet 3:a8c249046181 929 and could be returned before the execution is actually completed)
dflet 3:a8c249046181 930 Otherwise, a negative value indicating the error code shall be returned
dflet 3:a8c249046181 931 \note belongs to \ref porting_sec
dflet 3:a8c249046181 932 \warning
dflet 3:a8c249046181 933 */
dflet 3:a8c249046181 934
dflet 3:a8c249046181 935 #define SL_PLATFORM_EXTERNAL_SPAWN
dflet 3:a8c249046181 936
dflet 3:a8c249046181 937
dflet 3:a8c249046181 938 #ifdef SL_PLATFORM_EXTERNAL_SPAWN
dflet 3:a8c249046181 939 #define sl_Spawn(pEntry,pValue,flags) osi_Spawn(pEntry,pValue,flags)
dflet 3:a8c249046181 940 #endif
dflet 3:a8c249046181 941
dflet 3:a8c249046181 942 /*!
dflet 3:a8c249046181 943
dflet 3:a8c249046181 944 Close the Doxygen group.
dflet 3:a8c249046181 945 @}
dflet 3:a8c249046181 946
dflet 3:a8c249046181 947 */
dflet 3:a8c249046181 948
dflet 3:a8c249046181 949
dflet 3:a8c249046181 950 /*!
dflet 3:a8c249046181 951 ******************************************************************************
dflet 3:a8c249046181 952
dflet 3:a8c249046181 953 \defgroup porting_events Event Handlers
dflet 3:a8c249046181 954
dflet 3:a8c249046181 955 This section includes the asynchronous event handlers routines
dflet 3:a8c249046181 956
dflet 3:a8c249046181 957 PORTING ACTION:
dflet 3:a8c249046181 958 -Uncomment the required handler and define your routine as the value
dflet 3:a8c249046181 959 of this handler
dflet 3:a8c249046181 960
dflet 3:a8c249046181 961 @{
dflet 3:a8c249046181 962
dflet 3:a8c249046181 963 ******************************************************************************
dflet 3:a8c249046181 964 */
dflet 3:a8c249046181 965
dflet 3:a8c249046181 966 /*!
dflet 3:a8c249046181 967 \brief
dflet 3:a8c249046181 968
dflet 3:a8c249046181 969 \sa
dflet 3:a8c249046181 970
dflet 3:a8c249046181 971 \note belongs to \ref porting_sec
dflet 3:a8c249046181 972
dflet 3:a8c249046181 973 \warning
dflet 3:a8c249046181 974 */
dflet 3:a8c249046181 975 #define sl_GeneralEvtHdlr SimpleLinkGeneralEventHandler
dflet 3:a8c249046181 976
dflet 3:a8c249046181 977
dflet 3:a8c249046181 978 /*!
dflet 3:a8c249046181 979 \brief An event handler for WLAN connection or disconnection indication
dflet 3:a8c249046181 980 This event handles async WLAN events.
dflet 3:a8c249046181 981 Possible events are:
dflet 3:a8c249046181 982 SL_WLAN_CONNECT_EVENT - indicates WLAN is connected
dflet 3:a8c249046181 983 SL_WLAN_DISCONNECT_EVENT - indicates WLAN is disconnected
dflet 3:a8c249046181 984 \sa
dflet 3:a8c249046181 985
dflet 3:a8c249046181 986 \note belongs to \ref porting_sec
dflet 3:a8c249046181 987
dflet 3:a8c249046181 988 \warning
dflet 3:a8c249046181 989 */
dflet 3:a8c249046181 990 #define sl_WlanEvtHdlr SimpleLinkWlanEventHandler
dflet 3:a8c249046181 991
dflet 3:a8c249046181 992 /*!
dflet 3:a8c249046181 993 \brief An event handler for IP address asynchronous event. Usually accepted after new WLAN connection.
dflet 3:a8c249046181 994 This event handles networking events.
dflet 3:a8c249046181 995 Possible events are:
dflet 3:a8c249046181 996 SL_NETAPP_IPV4_ACQUIRED - IP address was acquired (DHCP or Static)
dflet 3:a8c249046181 997
dflet 3:a8c249046181 998 \sa
dflet 3:a8c249046181 999
dflet 3:a8c249046181 1000 \note belongs to \ref porting_sec
dflet 3:a8c249046181 1001
dflet 3:a8c249046181 1002 \warning
dflet 3:a8c249046181 1003 */
dflet 3:a8c249046181 1004
dflet 3:a8c249046181 1005 #define sl_NetAppEvtHdlr SimpleLinkNetAppEventHandler
dflet 3:a8c249046181 1006
dflet 3:a8c249046181 1007 /*!
dflet 3:a8c249046181 1008 \brief A callback for HTTP server events.
dflet 3:a8c249046181 1009 Possible events are:
dflet 3:a8c249046181 1010 SL_NETAPP_HTTPGETTOKENVALUE - NWP requests to get the value of a specific token
dflet 3:a8c249046181 1011 SL_NETAPP_HTTPPOSTTOKENVALUE - NWP post to the host a new value for a specific token
dflet 3:a8c249046181 1012
dflet 3:a8c249046181 1013 \param pServerEvent - Contains the relevant event information (SL_NETAPP_HTTPGETTOKENVALUE or SL_NETAPP_HTTPPOSTTOKENVALUE)
dflet 3:a8c249046181 1014
dflet 3:a8c249046181 1015 \param pServerResponse - Should be filled by the user with the relevant response information (i.e SL_NETAPP_HTTPSETTOKENVALUE as a response to SL_NETAPP_HTTPGETTOKENVALUE event)
dflet 3:a8c249046181 1016
dflet 3:a8c249046181 1017 \sa
dflet 3:a8c249046181 1018
dflet 3:a8c249046181 1019 \note belongs to \ref porting_sec
dflet 3:a8c249046181 1020
dflet 3:a8c249046181 1021 \warning
dflet 3:a8c249046181 1022 */
dflet 3:a8c249046181 1023
dflet 3:a8c249046181 1024 #define sl_HttpServerCallback SimpleLinkHttpServerCallback
dflet 3:a8c249046181 1025
dflet 3:a8c249046181 1026 /*!
dflet 3:a8c249046181 1027 \brief
dflet 3:a8c249046181 1028
dflet 3:a8c249046181 1029 \sa
dflet 3:a8c249046181 1030
dflet 3:a8c249046181 1031 \note belongs to \ref porting_sec
dflet 3:a8c249046181 1032
dflet 3:a8c249046181 1033 \warning
dflet 3:a8c249046181 1034 */
dflet 3:a8c249046181 1035 #define sl_SockEvtHdlr SimpleLinkSockEventHandler
dflet 3:a8c249046181 1036
dflet 3:a8c249046181 1037
dflet 3:a8c249046181 1038
dflet 3:a8c249046181 1039 /*!
dflet 3:a8c249046181 1040
dflet 3:a8c249046181 1041 Close the Doxygen group.
dflet 3:a8c249046181 1042 @}
dflet 3:a8c249046181 1043
dflet 3:a8c249046181 1044 */
dflet 3:a8c249046181 1045
dflet 3:a8c249046181 1046 #endif /* __USER_H__ */
dflet 3:a8c249046181 1047