user.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. /*
  2. * user.h - CC31xx/CC32xx Host Driver Implementation
  3. *
  4. * Copyright (C) 2014 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. #ifndef __USER_H__
  37. #define __USER_H__
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /*!
  42. ******************************************************************************
  43. \defgroup porting_user_include Porting - User Include Files
  44. This section IS NOT REQUIRED in case user provided primitives are handled
  45. in makefiles or project configurations (IDE)
  46. PORTING ACTION:
  47. - Include all required header files for the definition of:
  48. -# Transport layer library API (e.g. SPI, UART)
  49. -# OS primitives definitions (e.g. Task spawn, Semaphores)
  50. -# Memory management primitives (e.g. alloc, free)
  51. ******************************************************************************
  52. */
  53. #include <string.h>
  54. #include "cc_pal.h"
  55. #include "debug.h"
  56. /*!
  57. \def MAX_CONCURRENT_ACTIONS
  58. \brief Defines the maximum number of concurrent action in the system
  59. Min:1 , Max: 32
  60. Actions which has async events as return, can be
  61. \sa
  62. \note In case there are not enough resources for the actions needed in the system,
  63. error is received: POOL_IS_EMPTY
  64. one option is to increase MAX_CONCURRENT_ACTIONS
  65. (improves performance but results in memory consumption)
  66. Other option is to call the API later (decrease performance)
  67. \warning In case of setting to one, recommend to use non-blocking recv\recvfrom to allow
  68. multiple socket recv
  69. */
  70. #define MAX_CONCURRENT_ACTIONS 10
  71. /*!
  72. \def CPU_FREQ_IN_MHZ
  73. \brief Defines CPU frequency for Host side, for better accuracy of busy loops, if any
  74. \sa
  75. \note
  76. \warning If not set the default CPU frequency is set to 200MHz
  77. This option will be deprecated in future release
  78. */
  79. #define CPU_FREQ_IN_MHZ 80
  80. /*!
  81. ******************************************************************************
  82. \defgroup porting_capabilities Porting - Capabilities Set
  83. This section IS NOT REQUIRED in case one of the following pre defined
  84. capabilities set is in use:
  85. - SL_TINY
  86. - SL_SMALL
  87. - SL_FULL
  88. PORTING ACTION:
  89. - Define one of the pre-defined capabilities set or uncomment the
  90. relevant definitions below to select the required capabilities
  91. @{
  92. *******************************************************************************
  93. */
  94. /*!
  95. \def SL_INC_ARG_CHECK
  96. \brief Defines whether the SimpleLink driver perform argument check
  97. or not
  98. When defined, the SimpleLink driver perform argument check on
  99. function call. Removing this define could reduce some code
  100. size and improve slightly the performances but may impact in
  101. unpredictable behavior in case of invalid arguments
  102. \sa
  103. \note belongs to \ref proting_sec
  104. \warning Removing argument check may cause unpredictable behavior in
  105. case of invalid arguments.
  106. In this case the user is responsible to argument validity
  107. (for example all handlers must not be NULL)
  108. */
  109. #define SL_INC_ARG_CHECK
  110. /*!
  111. \def SL_INC_STD_BSD_API_NAMING
  112. \brief Defines whether SimpleLink driver should expose standard BSD
  113. APIs or not
  114. When defined, the SimpleLink driver in addtion to its alternative
  115. BSD APIs expose also standard BSD APIs.
  116. Stadrad BSD API includs the following functions:
  117. socket , close , accept , bind , listen , connect , select ,
  118. setsockopt , getsockopt , recv , recvfrom , write , send , sendto ,
  119. gethostbyname
  120. \sa
  121. \note belongs to \ref porting_sec
  122. \warning
  123. */
  124. /* #define SL_INC_STD_BSD_API_NAMING */
  125. /*!
  126. \brief Defines whether to include extended API in SimpleLink driver
  127. or not
  128. When defined, the SimpleLink driver will include also all
  129. exteded API of the included packages
  130. \sa ext_api
  131. \note belongs to \ref porting_sec
  132. \warning
  133. */
  134. #define SL_INC_EXT_API
  135. /*!
  136. \brief Defines whether to include WLAN package in SimpleLink driver
  137. or not
  138. When defined, the SimpleLink driver will include also
  139. the WLAN package
  140. \sa
  141. \note belongs to \ref porting_sec
  142. \warning
  143. */
  144. #define SL_INC_WLAN_PKG
  145. /*!
  146. \brief Defines whether to include SOCKET package in SimpleLink
  147. driver or not
  148. When defined, the SimpleLink driver will include also
  149. the SOCKET package
  150. \sa
  151. \note belongs to \ref porting_sec
  152. \warning
  153. */
  154. #define SL_INC_SOCKET_PKG
  155. /*!
  156. \brief Defines whether to include NET_APP package in SimpleLink
  157. driver or not
  158. When defined, the SimpleLink driver will include also the
  159. NET_APP package
  160. \sa
  161. \note belongs to \ref porting_sec
  162. \warning
  163. */
  164. #define SL_INC_NET_APP_PKG
  165. /*!
  166. \brief Defines whether to include NET_CFG package in SimpleLink
  167. driver or not
  168. When defined, the SimpleLink driver will include also
  169. the NET_CFG package
  170. \sa
  171. \note belongs to \ref porting_sec
  172. \warning
  173. */
  174. #define SL_INC_NET_CFG_PKG
  175. /*!
  176. \brief Defines whether to include NVMEM package in SimpleLink
  177. driver or not
  178. When defined, the SimpleLink driver will include also the
  179. NVMEM package
  180. \sa
  181. \note belongs to \ref porting_sec
  182. \warning
  183. */
  184. #define SL_INC_NVMEM_PKG
  185. /*!
  186. \brief Defines whether to include socket server side APIs
  187. in SimpleLink driver or not
  188. When defined, the SimpleLink driver will include also socket
  189. server side APIs
  190. \sa server_side
  191. \note
  192. \warning
  193. */
  194. #define SL_INC_SOCK_SERVER_SIDE_API
  195. /*!
  196. \brief Defines whether to include socket client side APIs in SimpleLink
  197. driver or not
  198. When defined, the SimpleLink driver will include also socket
  199. client side APIs
  200. \sa client_side
  201. \note belongs to \ref porting_sec
  202. \warning
  203. */
  204. #define SL_INC_SOCK_CLIENT_SIDE_API
  205. /*!
  206. \brief Defines whether to include socket receive APIs in SimpleLink
  207. driver or not
  208. When defined, the SimpleLink driver will include also socket
  209. receive side APIs
  210. \sa recv_api
  211. \note belongs to \ref porting_sec
  212. \warning
  213. */
  214. #define SL_INC_SOCK_RECV_API
  215. /*!
  216. \brief Defines whether to include socket send APIs in SimpleLink
  217. driver or not
  218. When defined, the SimpleLink driver will include also socket
  219. send side APIs
  220. \sa send_api
  221. \note belongs to \ref porting_sec
  222. \warning
  223. */
  224. #define SL_INC_SOCK_SEND_API
  225. /*!
  226. Close the Doxygen group.
  227. @}
  228. */
  229. /*!
  230. ******************************************************************************
  231. \defgroup ported_enable_device Ported on CC32XX - Device Enable/Disable
  232. The enable/disable API provide mechanism to enable/disable the network processor
  233. PORTING ACTION:
  234. - None
  235. @{
  236. ******************************************************************************
  237. */
  238. /*!
  239. \brief Preamble to the enabling the Network Processor.
  240. Placeholder to implement any pre-process operations
  241. before enabling networking operations.
  242. \sa sl_DeviceEnable
  243. \note belongs to \ref ported_sec
  244. */
  245. #ifdef DEBUG
  246. #define sl_DeviceEnablePreamble() NwpPowerOnPreamble()
  247. #else
  248. #define sl_DeviceEnablePreamble()
  249. #endif
  250. /*!
  251. \brief Enable the Network Processor
  252. \sa sl_DeviceDisable
  253. \note belongs to \ref ported_sec
  254. */
  255. #define sl_DeviceEnable() NwpPowerOn()
  256. /*!
  257. \brief Disable the Network Processor
  258. \sa sl_DeviceEnable
  259. \note belongs to \ref ported_sec
  260. */
  261. #define sl_DeviceDisable() NwpPowerOff()
  262. /*!
  263. Close the Doxygen group.
  264. @}
  265. */
  266. /*!
  267. ******************************************************************************
  268. \defgroup ported_interface Ported on CC32XX - Communication Interface
  269. The simple link device can work with different communication
  270. channels (e.g. spi/uart). Texas Instruments provides single driver
  271. that can work with all these types. This section bind between the
  272. physical communication interface channel and the SimpleLink driver
  273. \note Correct and efficient implementation of this driver is critical
  274. for the performances of the SimpleLink device on this platform.
  275. PORTING ACTION:
  276. - None
  277. @{
  278. ******************************************************************************
  279. */
  280. #define _SlFd_t Fd_t
  281. /*!
  282. \brief Opens an interface communication port to be used for communicating
  283. with a SimpleLink device
  284. Given an interface name and option flags, this function opens
  285. the communication port and creates a file descriptor.
  286. This file descriptor is used afterwards to read and write
  287. data from and to this specific communication channel.
  288. The speed, clock polarity, clock phase, chip select and all other
  289. specific attributes of the channel are all should be set to hardcoded
  290. in this function.
  291. \param ifName - points to the interface name/path. The interface name is an
  292. optional attributes that the simple link driver receives
  293. on opening the driver (sl_Start).
  294. In systems that the spi channel is not implemented as
  295. part of the os device drivers, this parameter could be NULL.
  296. \param flags - optional flags parameters for future use
  297. \return upon successful completion, the function shall open the channel
  298. and return a non-negative integer representing the file descriptor.
  299. Otherwise, -1 shall be returned
  300. \sa sl_IfClose , sl_IfRead , sl_IfWrite
  301. \note The prototype of the function is as follow:
  302. Fd_t xxx_IfOpen(char* pIfName , unsigned long flags);
  303. \note belongs to \ref ported_sec
  304. \warning
  305. */
  306. #define sl_IfOpen spi_Open
  307. /*!
  308. \brief Closes an opened interface communication port
  309. \param fd - file descriptor of opened communication channel
  310. \return upon successful completion, the function shall return 0.
  311. Otherwise, -1 shall be returned
  312. \sa sl_IfOpen , sl_IfRead , sl_IfWrite
  313. \note The prototype of the function is as follow:
  314. int xxx_IfClose(Fd_t Fd);
  315. \note belongs to \ref ported_sec
  316. \warning
  317. */
  318. #define sl_IfClose spi_Close
  319. /*!
  320. \brief Attempts to read up to len bytes from an opened communication channel
  321. into a buffer starting at pBuff.
  322. \param fd - file descriptor of an opened communication channel
  323. \param pBuff - pointer to the first location of a buffer that contains enough
  324. space for all expected data
  325. \param len - number of bytes to read from the communication channel
  326. \return upon successful completion, the function shall return the number of read bytes.
  327. Otherwise, 0 shall be returned
  328. \sa sl_IfClose , sl_IfOpen , sl_IfWrite
  329. \note The prototype of the function is as follow:
  330. int xxx_IfRead(Fd_t Fd , char* pBuff , int Len);
  331. \note belongs to \ref ported_sec
  332. \warning
  333. */
  334. #define sl_IfRead spi_Read
  335. /*!
  336. \brief attempts to write up to len bytes to the SPI channel
  337. \param fd - file descriptor of an opened communication channel
  338. \param pBuff - pointer to the first location of a buffer that contains
  339. the data to send over the communication channel
  340. \param len - number of bytes to write to the communication channel
  341. \return upon successful completion, the function shall return the number of sent bytes.
  342. therwise, 0 shall be returned
  343. \sa sl_IfClose , sl_IfOpen , sl_IfRead
  344. \note This function could be implemented as zero copy and return only upon successful completion
  345. of writing the whole buffer, but in cases that memory allocation is not too tight, the
  346. function could copy the data to internal buffer, return back and complete the write in
  347. parallel to other activities as long as the other SPI activities would be blocked until
  348. the entire buffer write would be completed
  349. The prototype of the function is as follow:
  350. int xxx_IfWrite(Fd_t Fd , char* pBuff , int Len);
  351. \note belongs to \ref ported_sec
  352. \warning
  353. */
  354. #define sl_IfWrite spi_Write
  355. /*!
  356. \brief register an interrupt handler routine for the host IRQ
  357. \param InterruptHdl - pointer to interrupt handler routine
  358. \param pValue - pointer to a memory structure that is passed
  359. to the interrupt handler.
  360. \return upon successful registration, the function shall return 0.
  361. Otherwise, -1 shall be returned
  362. \sa
  363. \note If there is already registered interrupt handler, the function
  364. should overwrite the old handler with the new one
  365. \note If the handler is a null pointer, the function should un-register the
  366. interrupt handler, and the interrupts can be disabled.
  367. \note belongs to \ref ported_sec
  368. \warning
  369. */
  370. #define sl_IfRegIntHdlr(InterruptHdl , pValue) NwpRegisterInterruptHandler(InterruptHdl , pValue)
  371. /*!
  372. \brief Masks the Host IRQ
  373. \sa sl_IfUnMaskIntHdlr
  374. \note belongs to \ref ported_sec
  375. \warning
  376. */
  377. #define sl_IfMaskIntHdlr() NwpMaskInterrupt()
  378. /*!
  379. \brief Unmasks the Host IRQ
  380. \sa sl_IfMaskIntHdlr
  381. \note belongs to \ref ported_sec
  382. \warning
  383. */
  384. #define sl_IfUnMaskIntHdlr() NwpUnMaskInterrupt()
  385. /*!
  386. \brief Write Handers for statistics debug on write
  387. \param interface handler - pointer to interrupt handler routine
  388. \return no return value
  389. \sa
  390. \note An optional hooks for monitoring before and after write info
  391. \note belongs to \ref ported_sec
  392. \warning
  393. */
  394. /* #define SL_START_WRITE_STAT */
  395. /*!
  396. Close the Doxygen group.
  397. @}
  398. */
  399. /*!
  400. ******************************************************************************
  401. \defgroup ported_os Ported on CC32XX - Operating System
  402. The simple link driver can run on multi-threaded environment as well
  403. as non-os environment (mail loop)
  404. This section IS NOT REQUIRED in case you are working on non-os environment.
  405. If you choose to work in multi-threaded environment under any operating system
  406. you will have to provide some basic adaptation routines to allow the driver
  407. to protect access to resources from different threads (locking object) and
  408. to allow synchronization between threads (sync objects).
  409. PORTING ACTION:
  410. -# Uncomment SL_PLATFORM_MULTI_THREADED define
  411. -# Bind locking object routines
  412. -# Bind synchronization object routines
  413. -# Optional - Bind spawn thread routine
  414. @{
  415. ******************************************************************************
  416. */
  417. #define SL_PLATFORM_MULTI_THREADED
  418. #ifdef SL_PLATFORM_MULTI_THREADED
  419. #include "osi.h"
  420. /*!
  421. \brief
  422. \sa
  423. \note belongs to \ref ported_sec
  424. \warning
  425. */
  426. #define SL_OS_RET_CODE_OK ((int)OSI_OK)
  427. /*!
  428. \brief
  429. \sa
  430. \note belongs to \ref ported_sec
  431. \warning
  432. */
  433. #define SL_OS_WAIT_FOREVER ((OsiTime_t)OSI_WAIT_FOREVER)
  434. /*!
  435. \brief
  436. \sa
  437. \note belongs to \ref ported_sec
  438. \warning
  439. */
  440. #define SL_OS_NO_WAIT ((OsiTime_t)OSI_NO_WAIT)
  441. /*!
  442. \brief type definition for a time value
  443. \note On each porting or platform the type could be whatever is needed - integer, pointer to structure etc.
  444. \note belongs to \ref ported_sec
  445. */
  446. #define _SlTime_t OsiTime_t
  447. /*!
  448. \brief type definition for a sync object container
  449. Sync object is object used to synchronize between two threads or thread and interrupt handler.
  450. One thread is waiting on the object and the other thread send a signal, which then
  451. release the waiting thread.
  452. The signal must be able to be sent from interrupt context.
  453. This object is generally implemented by binary semaphore or events.
  454. \note On each porting or platform the type could be whatever is needed - integer, structure etc.
  455. \note belongs to \ref ported_sec
  456. */
  457. typedef OsiSyncObj_t _SlSyncObj_t;
  458. /*!
  459. \brief This function creates a sync object
  460. The sync object is used for synchronization between diffrent thread or ISR and
  461. a thread.
  462. \param pSyncObj - pointer to the sync object control block
  463. \return upon successful creation the function should return 0
  464. Otherwise, a negative value indicating the error code shall be returned
  465. \note belongs to \ref ported_sec
  466. \warning
  467. */
  468. #define sl_SyncObjCreate(pSyncObj,pName) osi_SyncObjCreate(pSyncObj)
  469. /*!
  470. \brief This function deletes a sync object
  471. \param pSyncObj - pointer to the sync object control block
  472. \return upon successful deletion the function should return 0
  473. Otherwise, a negative value indicating the error code shall be returned
  474. \note belongs to \ref ported_sec
  475. \warning
  476. */
  477. #define sl_SyncObjDelete(pSyncObj) osi_SyncObjDelete(pSyncObj)
  478. /*!
  479. \brief This function generates a sync signal for the object.
  480. All suspended threads waiting on this sync object are resumed
  481. \param pSyncObj - pointer to the sync object control block
  482. \return upon successful signaling the function should return 0
  483. Otherwise, a negative value indicating the error code shall be returned
  484. \note the function could be called from ISR context
  485. \warning
  486. */
  487. #define sl_SyncObjSignal(pSyncObj) osi_SyncObjSignal(pSyncObj)
  488. /*!
  489. \brief This function generates a sync signal for the object from Interrupt
  490. This is for RTOS that should signal from IRQ using a dedicated API
  491. \param pSyncObj - pointer to the sync object control block
  492. \return upon successful signaling the function should return 0
  493. Otherwise, a negative value indicating the error code shall be returned
  494. \note the function could be called from ISR context
  495. \warning
  496. */
  497. #define sl_SyncObjSignalFromIRQ(pSyncObj) osi_SyncObjSignalFromISR(pSyncObj)
  498. /*!
  499. \brief This function waits for a sync signal of the specific sync object
  500. \param pSyncObj - pointer to the sync object control block
  501. \param Timeout - numeric value specifies the maximum number of mSec to
  502. stay suspended while waiting for the sync signal
  503. Currently, the simple link driver uses only two values:
  504. - OSI_WAIT_FOREVER
  505. - OSI_NO_WAIT
  506. \return upon successful reception of the signal within the timeout window return 0
  507. Otherwise, a negative value indicating the error code shall be returned
  508. \note belongs to \ref ported_sec
  509. \warning
  510. */
  511. #define sl_SyncObjWait(pSyncObj,Timeout) osi_SyncObjWait(pSyncObj,Timeout)
  512. /*!
  513. \brief type definition for a locking object container
  514. Locking object are used to protect a resource from mutual accesses of two or more threads.
  515. The locking object should suppurt reentrant locks by a signal thread.
  516. This object is generally implemented by mutex semaphore
  517. \note On each porting or platform the type could be whatever is needed - integer, structure etc.
  518. \note belongs to \ref ported_sec
  519. */
  520. typedef OsiLockObj_t _SlLockObj_t;
  521. /*!
  522. \brief This function creates a locking object.
  523. The locking object is used for protecting a shared resources between different
  524. threads.
  525. \param pLockObj - pointer to the locking object control block
  526. \return upon successful creation the function should return 0
  527. Otherwise, a negative value indicating the error code shall be returned
  528. \note belongs to \ref ported_sec
  529. \warning
  530. */
  531. #define sl_LockObjCreate(pLockObj,pName) osi_LockObjCreate(pLockObj)
  532. /*!
  533. \brief This function deletes a locking object.
  534. \param pLockObj - pointer to the locking object control block
  535. \return upon successful deletion the function should return 0
  536. Otherwise, a negative value indicating the error code shall be returned
  537. \note belongs to \ref ported_sec
  538. \warning
  539. */
  540. #define sl_LockObjDelete(pLockObj) osi_LockObjDelete(pLockObj)
  541. /*!
  542. \brief This function locks a locking object.
  543. All other threads that call this function before this thread calls
  544. the osi_LockObjUnlock would be suspended
  545. \param pLockObj - pointer to the locking object control block
  546. \param Timeout - numeric value specifies the maximum number of mSec to
  547. stay suspended while waiting for the locking object
  548. Currently, the simple link driver uses only two values:
  549. - OSI_WAIT_FOREVER
  550. - OSI_NO_WAIT
  551. \return upon successful reception of the locking object the function should return 0
  552. Otherwise, a negative value indicating the error code shall be returned
  553. \note belongs to \ref ported_sec
  554. \warning
  555. */
  556. #define sl_LockObjLock(pLockObj,Timeout) osi_LockObjLock(pLockObj,Timeout)
  557. /*!
  558. \brief This function unlock a locking object.
  559. \param pLockObj - pointer to the locking object control block
  560. \return upon successful unlocking the function should return 0
  561. Otherwise, a negative value indicating the error code shall be returned
  562. \note belongs to \ref ported_sec
  563. \warning
  564. */
  565. #define sl_LockObjUnlock(pLockObj) osi_LockObjUnlock(pLockObj)
  566. #endif
  567. /*!
  568. \brief This function call the pEntry callback from a different context
  569. \param pEntry - pointer to the entry callback function
  570. \param pValue - pointer to any type of memory structure that would be
  571. passed to pEntry callback from the execution thread.
  572. \param flags - execution flags - reserved for future usage
  573. \return upon successful registration of the spawn the function should return 0
  574. (the function is not blocked till the end of the execution of the function
  575. and could be returned before the execution is actually completed)
  576. Otherwise, a negative value indicating the error code shall be returned
  577. \note belongs to \ref ported_sec
  578. \warning
  579. */
  580. #define SL_PLATFORM_EXTERNAL_SPAWN
  581. #ifdef SL_PLATFORM_EXTERNAL_SPAWN
  582. #define sl_Spawn(pEntry,pValue,flags) osi_Spawn(pEntry,pValue,flags)
  583. #endif
  584. /*!
  585. Close the Doxygen group.
  586. @}
  587. */
  588. /*!
  589. ******************************************************************************
  590. \defgroup porting_mem_mgm Porting - Memory Management
  591. This section declare in which memory management model the SimpleLink driver
  592. will run:
  593. -# Static
  594. -# Dynamic
  595. This section IS NOT REQUIRED in case Static model is selected.
  596. The default memory model is Static
  597. PORTING ACTION:
  598. - If dynamic model is selected, define the alloc and free functions.
  599. @{
  600. *****************************************************************************
  601. */
  602. /*!
  603. \brief Defines whether the SimpleLink driver is working in dynamic
  604. memory model or not
  605. When defined, the SimpleLink driver use dynamic allocations
  606. if dynamic allocation is selected malloc and free functions
  607. must be retrieved
  608. \sa
  609. \note belongs to \ref porting_sec
  610. \warning
  611. */
  612. #define SL_MEMORY_MGMT_DYNAMIC 1
  613. #define SL_MEMORY_MGMT_STATIC 0
  614. #define SL_MEMORY_MGMT SL_MEMORY_MGMT_DYNAMIC
  615. #ifdef SL_MEMORY_MGMT_DYNAMIC
  616. #ifdef SL_PLATFORM_MULTI_THREADED
  617. /*!
  618. \brief
  619. \sa
  620. \note belongs to \ref ported_sec
  621. \warning
  622. */
  623. #define sl_Malloc(Size) mem_Malloc(Size)
  624. /*!
  625. \brief
  626. \sa
  627. \note belongs to \ref ported_sec
  628. \warning
  629. */
  630. #define sl_Free(pMem) mem_Free(pMem)
  631. #else
  632. #include <stdlib.h>
  633. /*!
  634. \brief
  635. \sa
  636. \note belongs to \ref ported_sec
  637. \warning
  638. */
  639. #define sl_Malloc(Size) malloc(Size)
  640. /*!
  641. \brief
  642. \sa
  643. \note belongs to \ref ported_sec
  644. \warning
  645. */
  646. #define sl_Free(pMem) free(pMem)
  647. #endif
  648. #endif
  649. /*!
  650. Close the Doxygen group.
  651. @}
  652. */
  653. /*!
  654. ******************************************************************************
  655. \defgroup porting_events Porting - Event Handlers
  656. This section includes the asynchronous event handlers routines
  657. PORTING ACTION:
  658. -Uncomment the required handler and define your routine as the value
  659. of this handler
  660. @{
  661. ******************************************************************************
  662. */
  663. /*!
  664. \brief
  665. \sa
  666. \note belongs to \ref porting_sec
  667. \warning
  668. */
  669. #define sl_GeneralEvtHdlr SimpleLinkGeneralEventHandler
  670. /*!
  671. \brief An event handler for WLAN connection or disconnection indication
  672. This event handles async WLAN events.
  673. Possible events are:
  674. SL_WLAN_CONNECT_EVENT - indicates WLAN is connected
  675. SL_WLAN_DISCONNECT_EVENT - indicates WLAN is disconnected
  676. \sa
  677. \note belongs to \ref porting_sec
  678. \warning
  679. */
  680. #define sl_WlanEvtHdlr SimpleLinkWlanEventHandler
  681. /*!
  682. \brief An event handler for IP address asynchronous event. Usually accepted after new WLAN connection.
  683. This event handles networking events.
  684. Possible events are:
  685. SL_NETAPP_IPV4_ACQUIRED - IP address was acquired (DHCP or Static)
  686. \sa
  687. \note belongs to \ref porting_sec
  688. \warning
  689. */
  690. #define sl_NetAppEvtHdlr SimpleLinkNetAppEventHandler
  691. /*!
  692. \brief A callback for HTTP server events.
  693. Possible events are:
  694. SL_NETAPP_HTTPGETTOKENVALUE - NWP requests to get the value of a specific token
  695. SL_NETAPP_HTTPPOSTTOKENVALUE - NWP post to the host a new value for a specific token
  696. \param pServerEvent - Contains the relevant event information (SL_NETAPP_HTTPGETTOKENVALUE or SL_NETAPP_HTTPPOSTTOKENVALUE)
  697. \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)
  698. \sa
  699. \note belongs to \ref porting_sec
  700. \warning
  701. */
  702. #define sl_HttpServerCallback SimpleLinkHttpServerCallback
  703. /*!
  704. \brief
  705. \sa
  706. \note belongs to \ref porting_sec
  707. \warning
  708. */
  709. #define sl_SockEvtHdlr SimpleLinkSockEventHandler
  710. #define _SL_USER_TYPES
  711. #define _u8 unsigned char
  712. #define _i8 signed char
  713. #define _u16 unsigned short
  714. #define _i16 signed short
  715. #define _u32 unsigned int
  716. #define _i32 signed int
  717. #define _volatile volatile
  718. #define _const const
  719. /*!
  720. Close the Doxygen group.
  721. @}
  722. */
  723. #ifdef __cplusplus
  724. }
  725. #endif // __cplusplus
  726. #endif // __USER_H__