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