Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / user.h @ eaef5bd1

History | View | Annotate | Download (30.3 KB)

1
/*
2
 * user.h - CC31xx/CC32xx Host Driver Implementation
3
 *
4
 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
5
 *
6
 *
7
 *  Redistribution and use in source and binary forms, with or without
8
 *  modification, are permitted provided that the following conditions
9
 *  are met:
10
 *
11
 *    Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 *
14
 *    Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the
17
 *    distribution.
18
 *
19
 *    Neither the name of Texas Instruments Incorporated nor the names of
20
 *    its contributors may be used to endorse or promote products derived
21
 *    from this software without specific prior written permission.
22
 *
23
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 *
35
 *
36
 *  Adapted for PIC32 by 2016 Cesanta Software Limited
37
 */
38

    
39
#ifndef __USER_H__
40
#define __USER_H__
41

    
42
#ifdef __cplusplus
43
extern "C" {
44
#endif
45

    
46
/*!
47
 ******************************************************************************
48

49
    \defgroup       porting_user_include        Porting - User Include Files
50

51
    This section IS NOT REQUIRED in case user provided primitives are handled
52
    in makefiles or project configurations (IDE)
53

54
    PORTING ACTION:
55
        - Include all required header files for the definition of:
56
            -# Transport layer library API (e.g. SPI, UART)
57
            -# OS primitives definitions (e.g. Task spawn, Semaphores)
58
            -# Memory management primitives (e.g. alloc, free)
59

60
 ******************************************************************************
61
 */
62
#undef FD_SETSIZE
63
#undef FD_SET
64
#undef FD_CLR
65
#undef FD_ISSET
66
#undef FD_ZERO
67
#undef htonl
68
#undef ntohl
69
#undef htons
70
#undef ntohs
71
#undef EBADF
72
#undef ENOMEM
73
#undef EINVAL
74
#include <string.h>
75

    
76
typedef int Fd_t;
77

    
78
typedef void (*P_EVENT_HANDLER)(void *pValue);
79

    
80
typedef P_EVENT_HANDLER SL_P_EVENT_HANDLER;
81

    
82
/*!
83
    \def        MAX_CONCURRENT_ACTIONS
84

85
    \brief      Defines the maximum number of concurrent action in the system
86
                Min:1 , Max: 32
87

88
                Actions which has async events as return, can be
89

90
    \sa
91

92
    \note       In case there are not enough resources for the actions needed
93
                in the system, error is received: POOL_IS_EMPTY one option is
94
                to increase MAX_CONCURRENT_ACTIONS (improves performance but
95
                results in memory consumption) Other option is to call the API
96
                later (decrease performance)
97

98
    \warning    In case of setting to one, recommend to use non-blocking
99
                recv\recvfrom to allow multiple socket recv
100
*/
101
#define MAX_CONCURRENT_ACTIONS 10
102

    
103
/*!
104
 ******************************************************************************
105

106
    \defgroup       proting_capabilities        Porting - Capabilities Set
107

108
    This section IS NOT REQUIRED in case one of the following pre defined
109
    capabilities set is in use:
110
    - SL_TINY
111
    - SL_SMALL
112
    - SL_FULL
113

114
    PORTING ACTION:
115
        - Define one of the pre-defined capabilities set or uncomment the
116
          relevant definitions below to select the required capabilities
117

118
    @{
119

120
 *******************************************************************************
121
*/
122

    
123
/*!
124
    \def        SL_INC_ARG_CHECK
125

126
    \brief      Defines whether the SimpleLink driver perform argument check
127
                or not
128

129
                When defined, the SimpleLink driver perform argument check on
130
                function call. Removing this define could reduce some code
131
                size and improve slightly the performances but may impact in
132
                unpredictable behavior in case of invalid arguments
133

134
    \sa
135

136
    \note       belongs to \ref proting_sec
137

138
    \warning    Removing argument check may cause unpredictable behavior in
139
                case of invalid arguments.
140
                In this case the user is responsible to argument validity
141
                (for example all handlers must not be NULL)
142
*/
143
#define SL_INC_ARG_CHECK
144

    
145
/*!
146
    \def        SL_INC_STD_BSD_API_NAMING
147

148
    \brief      Defines whether SimpleLink driver should expose standard BSD
149
                APIs or not
150

151
                When defined, the SimpleLink driver in addtion to its
152
   alternative
153
                BSD APIs expose also standard BSD APIs.
154
    Stadrad BSD API includs the following functions:
155
                socket , close , accept , bind , listen , connect , select ,
156
                setsockopt  , getsockopt , recv , recvfrom , write , send ,
157
   sendto ,
158
                gethostbyname
159

160
    \sa
161

162
    \note       belongs to \ref proting_sec
163

164
    \warning
165
*/
166

    
167
#define SL_INC_STD_BSD_API_NAMING
168

    
169
/*!
170
    \brief      Defines whether to include extended API in SimpleLink driver
171
                or not
172

173
                When defined, the SimpleLink driver will include also all
174
                exteded API of the included packages
175

176
    \sa             ext_api
177

178
    \note       belongs to \ref proting_sec
179

180
    \warning
181
*/
182
#define SL_INC_EXT_API
183

    
184
/*!
185
    \brief      Defines whether to include WLAN package in SimpleLink driver
186
                or not
187

188
                When defined, the SimpleLink driver will include also
189
                the WLAN package
190

191
    \sa
192

193
    \note       belongs to \ref proting_sec
194

195
    \warning
196
*/
197
#define SL_INC_WLAN_PKG
198

    
199
/*!
200
    \brief      Defines whether to include SOCKET package in SimpleLink
201
                driver or not
202

203
                When defined, the SimpleLink driver will include also
204
                the SOCKET package
205

206
    \sa
207

208
    \note       belongs to \ref proting_sec
209

210
    \warning
211
*/
212
#define SL_INC_SOCKET_PKG
213

    
214
/*!
215
    \brief      Defines whether to include NET_APP package in SimpleLink
216
                driver or not
217

218
                When defined, the SimpleLink driver will include also the
219
                NET_APP package
220

221
    \sa
222

223
    \note       belongs to \ref proting_sec
224

225
    \warning
226
*/
227
#define SL_INC_NET_APP_PKG
228

    
229
/*!
230
    \brief      Defines whether to include NET_CFG package in SimpleLink
231
                driver or not
232

233
                When defined, the SimpleLink driver will include also
234
                the NET_CFG package
235

236
    \sa
237

238
    \note       belongs to \ref proting_sec
239

240
    \warning
241
*/
242
#define SL_INC_NET_CFG_PKG
243

    
244
/*!
245
    \brief      Defines whether to include NVMEM package in SimpleLink
246
                driver or not
247

248
                When defined, the SimpleLink driver will include also the
249
                NVMEM package
250

251
    \sa
252

253
    \note       belongs to \ref proting_sec
254

255
    \warning
256
*/
257
#define SL_INC_NVMEM_PKG
258

    
259
/*!
260
    \brief      Defines whether to include socket server side APIs
261
                in SimpleLink driver or not
262

263
                When defined, the SimpleLink driver will include also socket
264
                server side APIs
265

266
    \sa             server_side
267

268
    \note
269

270
    \warning
271
*/
272
#define SL_INC_SOCK_SERVER_SIDE_API
273

    
274
/*!
275
    \brief      Defines whether to include socket client side APIs in SimpleLink
276
                driver or not
277

278
                When defined, the SimpleLink driver will include also socket
279
                client side APIs
280

281
    \sa             client_side
282

283
    \note       belongs to \ref proting_sec
284

285
    \warning
286
*/
287
#define SL_INC_SOCK_CLIENT_SIDE_API
288

    
289
/*!
290
    \brief      Defines whether to include socket receive APIs in SimpleLink
291
                driver or not
292

293
                When defined, the SimpleLink driver will include also socket
294
                receive side APIs
295

296
    \sa             recv_api
297

298
    \note       belongs to \ref proting_sec
299

300
    \warning
301
*/
302
#define SL_INC_SOCK_RECV_API
303

    
304
/*!
305
    \brief      Defines whether to include socket send APIs in SimpleLink
306
                driver or not
307

308
                When defined, the SimpleLink driver will include also socket
309
                send side APIs
310

311
    \sa             send_api
312

313
    \note       belongs to \ref proting_sec
314

315
    \warning
316
*/
317
#define SL_INC_SOCK_SEND_API
318

    
319
/*!
320

321
 Close the Doxygen group.
322
 @}
323

324
 */
325

    
326
/*!
327
 ******************************************************************************
328

329
    \defgroup   porting_enable_device       Porting - Device Enable/Disable
330

331
    The enable/disable line (nHib) provide mechanism to enter the device into
332
    the least current consumption mode. This mode could be used when no traffic
333
    is required (tx/rx).
334
    when this hardware line is not connected to any IO of the host this define
335
    should be left empty.
336

337

338
    \note   Not connecting this line results in ability to start the driver
339
            only once.
340

341
    PORTING ACTION:
342
        - Bind the GPIO that is connected to the device to the SimpleLink
343
          driver
344

345
    @{
346

347
 ******************************************************************************
348
*/
349
/*!
350
    \brief                Preamble to the enabling the Network Processor.
351
                        Placeholder to implement any pre-process operations
352
                        before enabling networking operations.
353

354
    \sa                        sl_DeviceEnable
355

356
    \note       belongs to \ref ported_sec
357

358
*/
359
#define sl_DeviceEnablePreamble()
360

    
361
/*!
362
    \brief      Enable the device by set the appropriate GPIO to high
363

364
    \sa         sl_DeviceDisable
365

366
    \note           belongs to \ref proting_sec
367

368
    \warning    if nHib/nShutdown pins are not connected to the host this define
369
                should be left empty. Not connecting on of these lines may
370
   result
371
                in higher power consumption and inability to start and stop the
372
                driver correctly.
373
*/
374
#define sl_DeviceEnable CC3100_enable
375

    
376
/*!
377
    \brief      Disable the device by setting the appropriate GPIO to Low
378

379
    \sa         sl_DeviceEnable
380

381
    \note           belongs to \ref proting_sec
382

383
    \warning    if nHib/nShutdown pins are not connected to the host this define
384
                should be left empty. Not connecting on of these lines may
385
   result
386
                in higher power consumption and inability to start and stop the
387
                driver correctly.
388
*/
389

    
390
#define sl_DeviceDisable CC3100_disable
391

    
392
/*!
393

394
 Close the Doxygen group.
395
 @}
396

397
 */
398

    
399
/*!
400
 ******************************************************************************
401

402
    \defgroup   porting_interface         Porting - Communication Interface
403

404
    The simple link device can work with different communication
405
    channels (e.g. spi/uart). Texas Instruments provides single driver
406
    that can work with all these types. This section bind between the
407
    physical communication interface channel and the SimpleLink driver
408

409

410
    \note       Correct and efficient implementation of this driver is critical
411
                for the performances of the SimpleLink device on this platform.
412

413

414
    PORTING ACTION:
415
        - Bind the functions of the communication channel interface driver with
416
          the simple link driver
417

418
    @{
419

420
 ******************************************************************************
421
*/
422

    
423
#define _SlFd_t int
424

    
425
/*!
426
    \brief      Opens an interface communication port to be used for
427
   communicating
428
                with a SimpleLink device
429

430
                Given an interface name and option flags, this function opens
431
                the communication port and creates a file descriptor.
432
                This file descriptor is used afterwards to read and write
433
                data from and to this specific communication channel.
434
                The speed, clock polarity, clock phase, chip select and all
435
   other
436
                specific attributes of the channel are all should be set to
437
   hardcoded
438
                in this function.
439

440
    \param      ifName  -   points to the interface name/path. The interface
441
   name is an
442
                            optional attributes that the simple link driver
443
   receives
444
                            on opening the driver (sl_Start).
445
                            In systems that the spi channel is not implemented
446
   as
447
                            part of the os device drivers, this parameter could
448
   be NULL.
449

450
    \param      flags   -   optional flags parameters for future use
451

452
    \return     upon successful completion, the function shall open the channel
453
                and return a non-negative integer representing the file
454
   descriptor.
455
                Otherwise, -1 shall be returned
456

457
    \sa         sl_IfClose , sl_IfRead , sl_IfWrite
458

459
    \note       The prototype of the function is as follow:
460
                    Fd_t xxx_IfOpen(char* pIfName , unsigned long flags);
461

462
    \note       belongs to \ref proting_sec
463

464
    \warning
465
*/
466
#define sl_IfOpen spi_Open
467

    
468
/*!
469
    \brief      Closes an opened interface communication port
470

471
    \param      fd  -   file descriptor of opened communication channel
472

473
    \return     upon successful completion, the function shall return 0.
474
                Otherwise, -1 shall be returned
475

476
    \sa         sl_IfOpen , sl_IfRead , sl_IfWrite
477

478
    \note       The prototype of the function is as follow:
479
                    int xxx_IfClose(Fd_t Fd);
480

481
    \note       belongs to \ref proting_sec
482

483
    \warning
484
*/
485
#define sl_IfClose spi_Close
486

    
487
/*!
488
    \brief      Attempts to read up to len bytes from an opened communication
489
   channel
490
                into a buffer starting at pBuff.
491

492
    \param      fd      -   file descriptor of an opened communication channel
493

494
    \param      pBuff   -   pointer to the first location of a buffer that
495
   contains enough
496
                            space for all expected data
497

498
    \param      len     -   number of bytes to read from the communication
499
   channel
500

501
    \return     upon successful completion, the function shall return the number
502
   of read bytes.
503
                Otherwise, 0 shall be returned
504

505
    \sa         sl_IfClose , sl_IfOpen , sl_IfWrite
506

507

508
    \note       The prototype of the function is as follow:
509
                    int xxx_IfRead(Fd_t Fd , char* pBuff , int Len);
510

511
    \note       belongs to \ref proting_sec
512

513
    \warning
514
*/
515
#define sl_IfRead spi_Read
516

    
517
/*!
518
    \brief attempts to write up to len bytes to the SPI channel
519

520
    \param      fd      -   file descriptor of an opened communication channel
521

522
    \param      pBuff   -   pointer to the first location of a buffer that
523
   contains
524
                            the data to send over the communication channel
525

526
    \param      len     -   number of bytes to write to the communication
527
   channel
528

529
    \return     upon successful completion, the function shall return the number
530
   of sent bytes.
531
                therwise, 0 shall be returned
532

533
    \sa         sl_IfClose , sl_IfOpen , sl_IfRead
534

535
    \note       This function could be implemented as zero copy and return only
536
   upon successful completion
537
                of writing the whole buffer, but in cases that memory allocation
538
   is not too tight, the
539
                function could copy the data to internal buffer, return back and
540
   complete the write in
541
                parallel to other activities as long as the other SPI activities
542
   would be blocked until
543
                the entire buffer write would be completed
544

545
               The prototype of the function is as follow:
546
                    int xxx_IfWrite(Fd_t Fd , char* pBuff , int Len);
547

548
    \note       belongs to \ref proting_sec
549

550
    \warning
551
*/
552
#define sl_IfWrite spi_Write
553

    
554
/*!
555
    \brief      register an interrupt handler routine for the host IRQ
556

557
    \param      InterruptHdl    -   pointer to interrupt handler routine
558

559
    \param      pValue          -   pointer to a memory structure that is passed
560
                                    to the interrupt handler.
561

562
    \return     upon successful registration, the function shall return 0.
563
                Otherwise, -1 shall be returned
564

565
    \sa
566

567
    \note       If there is already registered interrupt handler, the function
568
                should overwrite the old handler with the new one
569

570
    \note       If the handler is a null pointer, the function should
571
   un-register the
572
                interrupt handler, and the interrupts can be disabled.
573

574
    \note       belongs to \ref proting_sec
575

576
    \warning
577
*/
578
#define sl_IfRegIntHdlr(InterruptHdl, pValue) \
579
  registerInterruptHandler(InterruptHdl, pValue)
580
/*!
581
    \brief      Masks the Host IRQ
582

583
    \sa         sl_IfUnMaskIntHdlr
584

585

586

587
    \note       belongs to \ref proting_sec
588

589
    \warning
590
*/
591

    
592
#define sl_IfMaskIntHdlr()
593

    
594
/*!
595
    \brief     Unmasks the Host IRQ
596

597
    \sa        sl_IfMaskIntHdlr
598

599

600

601
    \note      belongs to \ref proting_sec
602

603
    \warning
604
*/
605

    
606
#define sl_IfUnMaskIntHdlr()
607

    
608
/*!
609
    \brief      Write Handers for statistics debug on write
610

611
    \param      interface handler   -   pointer to interrupt handler routine
612

613

614
    \return     no return value
615

616
    \sa
617

618
    \note       An optional hooks for monitoring before and after write info
619

620
    \note       belongs to \ref proting_sec
621

622
    \warning
623
*/
624
/*
625
#define SL_START_WRITE_STAT
626
*/
627

    
628
#ifdef SL_START_WRITE_STAT
629
#define sl_IfStartWriteSequence SlStudio_SpiStartWriteSeq
630
#define sl_IfEndWriteSequence SlStudio_SpiEndWriteSeq
631
#endif
632
/*!
633

634
 Close the Doxygen group.
635
 @}
636

637
*/
638

    
639
/*!
640
 ******************************************************************************
641

642
    \defgroup   porting_mem_mgm             Porting - Memory Management
643

644
    This section declare in which memory management model the SimpleLink driver
645
    will run:
646
        -# Static
647
        -# Dynamic
648

649
    This section IS NOT REQUIRED in case Static model is selected.
650

651
    The default memory model is Static
652

653
    PORTING ACTION:
654
        - If dynamic model is selected, define the alloc and free functions.
655

656
    @{
657

658
 *****************************************************************************
659
*/
660

    
661
/*!
662
    \brief      Defines whether the SimpleLink driver is working in dynamic
663
                memory model or not
664

665
                When defined, the SimpleLink driver use dynamic allocations
666
                if dynamic allocation is selected malloc and free functions
667
                must be retrieved
668

669
    \sa
670

671
    \note       belongs to \ref proting_sec
672

673
    \warning
674
*/
675

    
676
/*
677
#define SL_MEMORY_MGMT_DYNAMIC
678
*/
679

    
680
#ifdef SL_MEMORY_MGMT_DYNAMIC
681

    
682
/*!
683
    \brief
684

685
    \sa
686

687
    \note           belongs to \ref proting_sec
688

689
    \warning
690
*/
691
#define sl_Malloc(Size) malloc(Size)
692

    
693
/*!
694
    \brief
695

696
    \sa
697

698
    \note           belongs to \ref proting_sec
699

700
    \warning
701
*/
702
#define sl_Free(pMem) free(pMem)
703

    
704
#endif
705

    
706
/*!
707

708
 Close the Doxygen group.
709
 @}
710

711
*/
712

    
713
/*!
714
 ******************************************************************************
715

716
    \defgroup   porting_os          Porting - Operating System
717

718
    The simple link driver can run on multi-threaded environment as well
719
    as non-os environment (mail loop)
720

721
    This section IS NOT REQUIRED in case you are working on non-os environment.
722

723
    If you choose to work in multi-threaded environment under any operating
724
 system
725
    you will have to provide some basic adaptation routines to allow the driver
726
    to protect access to resources from different threads (locking object) and
727
    to allow synchronization between threads (sync objects).
728

729
    PORTING ACTION:
730
        -# Uncomment SL_PLATFORM_MULTI_THREADED define
731
        -# Bind locking object routines
732
        -# Bind synchronization object routines
733
        -# Optional - Bind spawn thread routine
734

735
    @{
736

737
 ******************************************************************************
738
*/
739

    
740
/*
741
#define SL_PLATFORM_MULTI_THREADED
742
*/
743

    
744
#ifdef SL_PLATFORM_MULTI_THREADED
745

    
746
/*!
747
    \brief
748
    \sa
749
    \note           belongs to \ref proting_sec
750
    \warning
751
*/
752
#define SL_OS_RET_CODE_OK
753

    
754
/*!
755
    \brief
756
    \sa
757
    \note           belongs to \ref proting_sec
758
    \warning
759
*/
760
#define SL_OS_WAIT_FOREVER
761

    
762
/*!
763
    \brief
764
    \sa
765
    \note           belongs to \ref proting_sec
766
    \warning
767
*/
768
#define SL_OS_NO_WAIT
769

    
770
/*!
771
    \brief type definition for a time value
772

773
    \note   On each porting or platform the type could be whatever is needed -
774
   integer, pointer to structure etc.
775

776
    \note       belongs to \ref proting_sec
777
*/
778
#define _SlTime_t
779

    
780
/*!
781
    \brief  type definition for a sync object container
782

783
    Sync object is object used to synchronize between two threads or thread and
784
   interrupt handler.
785
    One thread is waiting on the object and the other thread send a signal,
786
   which then
787
    release the waiting thread.
788
    The signal must be able to be sent from interrupt context.
789
    This object is generally implemented by binary semaphore or events.
790

791
    \note   On each porting or platform the type could be whatever is needed -
792
   integer, structure etc.
793

794
    \note       belongs to \ref proting_sec
795
*/
796
#define _SlSyncObj_t
797

    
798
/*!
799
    \brief  This function creates a sync object
800

801
    The sync object is used for synchronization between diffrent thread or ISR
802
   and
803
    a thread.
804

805
    \param  pSyncObj    -   pointer to the sync object control block
806

807
    \return upon successful creation the function should return 0
808
            Otherwise, a negative value indicating the error code shall be
809
   returned
810

811
    \note       belongs to \ref proting_sec
812
    \warning
813
*/
814
#define sl_SyncObjCreate(pSyncObj, pName)
815

    
816
/*!
817
    \brief  This function deletes a sync object
818

819
    \param  pSyncObj    -   pointer to the sync object control block
820

821
    \return upon successful deletion the function should return 0
822
            Otherwise, a negative value indicating the error code shall be
823
   returned
824
    \note       belongs to \ref proting_sec
825
    \warning
826
*/
827
#define sl_SyncObjDelete(pSyncObj)
828

    
829
/*!
830
    \brief      This function generates a sync signal for the object.
831

832
    All suspended threads waiting on this sync object are resumed
833

834
    \param      pSyncObj    -   pointer to the sync object control block
835

836
    \return     upon successful signaling the function should return 0
837
                Otherwise, a negative value indicating the error code shall be
838
   returned
839
    \note       the function could be called from ISR context
840
    \warning
841
*/
842
#define sl_SyncObjSignal(pSyncObj)
843

    
844
/*!
845
    \brief  This function waits for a sync signal of the specific sync object
846

847
    \param  pSyncObj    -   pointer to the sync object control block
848
    \param  Timeout     -   numeric value specifies the maximum number of mSec
849
   to
850
                            stay suspended while waiting for the sync signal
851
                            Currently, the simple link driver uses only two
852
   values:
853
                                - OSI_WAIT_FOREVER
854
                                - OSI_NO_WAIT
855

856
    \return upon successful reception of the signal within the timeout window
857
   return 0
858
            Otherwise, a negative value indicating the error code shall be
859
   returned
860
    \note       belongs to \ref proting_sec
861
    \warning
862
*/
863
#define sl_SyncObjWait(pSyncObj, Timeout)
864

    
865
/*!
866
    \brief  type definition for a locking object container
867

868
    Locking object are used to protect a resource from mutual accesses of two or
869
   more threads.
870
    The locking object should suppurt reentrant locks by a signal thread.
871
    This object is generally implemented by mutex semaphore
872

873
    \note   On each porting or platform the type could be whatever is needed -
874
   integer, structure etc.
875
    \note       belongs to \ref proting_sec
876
*/
877
#define _SlLockObj_t
878

    
879
/*!
880
    \brief  This function creates a locking object.
881

882
    The locking object is used for protecting a shared resources between
883
   different
884
    threads.
885

886
    \param  pLockObj    -   pointer to the locking object control block
887

888
    \return upon successful creation the function should return 0
889
            Otherwise, a negative value indicating the error code shall be
890
   returned
891
    \note       belongs to \ref proting_sec
892
    \warning
893
*/
894
#define sl_LockObjCreate(pLockObj, pName)
895

    
896
/*!
897
    \brief  This function deletes a locking object.
898

899
    \param  pLockObj    -   pointer to the locking object control block
900

901
    \return upon successful deletion the function should return 0
902
            Otherwise, a negative value indicating the error code shall be
903
   returned
904
    \note       belongs to \ref proting_sec
905
    \warning
906
*/
907
#define sl_LockObjDelete(pLockObj)
908

    
909
/*!
910
    \brief  This function locks a locking object.
911

912
    All other threads that call this function before this thread calls
913
    the osi_LockObjUnlock would be suspended
914

915
    \param  pLockObj    -   pointer to the locking object control block
916
    \param  Timeout     -   numeric value specifies the maximum number of mSec
917
   to
918
                            stay suspended while waiting for the locking object
919
                            Currently, the simple link driver uses only two
920
   values:
921
                                - OSI_WAIT_FOREVER
922
                                - OSI_NO_WAIT
923

924

925
    \return upon successful reception of the locking object the function should
926
   return 0
927
            Otherwise, a negative value indicating the error code shall be
928
   returned
929
    \note       belongs to \ref proting_sec
930
    \warning
931
*/
932
#define sl_LockObjLock(pLockObj, Timeout)
933

    
934
/*!
935
    \brief  This function unlock a locking object.
936

937
    \param  pLockObj    -   pointer to the locking object control block
938

939
    \return upon successful unlocking the function should return 0
940
            Otherwise, a negative value indicating the error code shall be
941
   returned
942
    \note       belongs to \ref proting_sec
943
    \warning
944
*/
945
#define sl_LockObjUnlock(pLockObj)
946

    
947
#endif
948
/*!
949
    \brief  This function call the pEntry callback from a different context
950

951
    \param  pEntry      -   pointer to the entry callback function
952

953
    \param  pValue      -   pointer to any type of memory structure that would
954
   be
955
                            passed to pEntry callback from the execution thread.
956

957
    \param  flags       -   execution flags - reserved for future usage
958

959
    \return upon successful registration of the spawn the function should return
960
   0
961
            (the function is not blocked till the end of the execution of the
962
   function
963
            and could be returned before the execution is actually completed)
964
            Otherwise, a negative value indicating the error code shall be
965
   returned
966
    \note       belongs to \ref proting_sec
967
    \warning
968
*/
969
/*
970
#define SL_PLATFORM_EXTERNAL_SPAWN
971
*/
972

    
973
#ifdef SL_PLATFORM_EXTERNAL_SPAWN
974
#define sl_Spawn(pEntry, pValue, flags)
975
#endif
976

    
977
/*!
978

979
 Close the Doxygen group.
980
 @}
981

982
 */
983

    
984
/*!
985
 ******************************************************************************
986

987
    \defgroup       porting_events      Porting - Event Handlers
988

989
    This section includes the asynchronous event handlers routines
990

991
    PORTING ACTION:
992
        -Uncomment the required handler and define your routine as the value
993
        of this handler
994

995
    @{
996

997
 ******************************************************************************
998
 */
999

    
1000
/*!
1001
    \brief
1002

1003
    \sa
1004

1005
    \note       belongs to \ref proting_sec
1006

1007
    \warning
1008
*/
1009
/*
1010
#define sl_GeneralEvtHdlr
1011
 */
1012

    
1013
/*!
1014
    \brief          An event handler for WLAN connection or disconnection
1015
   indication
1016
                    This event handles async WLAN events.
1017
                    Possible events are:
1018
                    SL_WLAN_CONNECT_EVENT - indicates WLAN is connected
1019
                    SL_WLAN_DISCONNECT_EVENT - indicates WLAN is disconnected
1020
    \sa
1021

1022
    \note           belongs to \ref proting_sec
1023

1024
    \warning
1025
*/
1026
#define sl_WlanEvtHdlr SimpleLinkWlanEventHandler
1027

    
1028
/*!
1029
    \brief          An event handler for IP address asynchronous event. Usually
1030
   accepted after new WLAN connection.
1031
                    This event handles networking events.
1032
                    Possible events are:
1033
                    SL_NETAPP_IPV4_ACQUIRED - IP address was acquired (DHCP or
1034
   Static)
1035

1036
    \sa
1037

1038
    \note           belongs to \ref proting_sec
1039

1040
    \warning
1041
*/
1042

    
1043
#define sl_NetAppEvtHdlr SimpleLinkNetAppEventHandler
1044

    
1045
/*!
1046
    \brief      A callback for HTTP server events.
1047
                Possible events are:
1048
                SL_NETAPP_HTTPGETTOKENVALUE - NWP requests to get the value of
1049
                a specific token SL_NETAPP_HTTPPOSTTOKENVALUE - NWP post to the
1050
                host a new value for a specific token
1051

1052
    \param      pServerEvent - Contains the relevant event information
1053
                (SL_NETAPP_HTTPGETTOKENVALUE or SL_NETAPP_HTTPPOSTTOKENVALUE)
1054

1055
    \param      pServerResponse - Should be filled by the user with the relevant
1056
                response information (i.e SL_NETAPP_HTTPSETTOKENVALUE as a
1057
                response to SL_NETAPP_HTTPGETTOKENVALUE event)
1058

1059
    \sa
1060

1061
    \note       belongs to \ref proting_sec
1062

1063
    \warning
1064
*/
1065

    
1066
// #define sl_HttpServerCallback        SimpleLinkHttpServerCallback
1067
/*!
1068
    \brief
1069

1070
    \sa
1071

1072
    \note           belongs to \ref proting_sec
1073

1074
    \warning
1075
*/
1076
/*
1077
#define sl_SockEvtHdlr
1078
*/
1079

    
1080
/*!
1081
    \brief
1082

1083
    \sa
1084

1085
    \note           belongs to \ref porting_sec
1086

1087
    \warning
1088
*/
1089

    
1090
#define sl_AsyncCmdHdlr SimpleLinkCmdHandler
1091

    
1092
#define SL_STORE_RESTORE_CONTEXT
1093
#ifdef SL_STORE_RESTORE_CONTEXT
1094
#define sl_SuspenedStoreContext SimpleLinkSuspenedStoreContextHandler
1095
#define sl_ResumeRestoreContext SimpleLinkResumeRestoreContextHandler
1096
#endif
1097

    
1098
/*!
1099

1100
 Close the Doxygen group.
1101
 @}
1102

1103
 */
1104

    
1105
#ifdef __cplusplus
1106
}
1107
#endif  // __cplusplus
1108

    
1109
#endif  // __USER_H__