indexpage.xml 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. <?xml version='1.0' encoding='UTF-8' standalone='no'?>
  2. <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.15">
  3. <compounddef id="indexpage" kind="page">
  4. <compoundname>index</compoundname>
  5. <title>Wi-Fi Host Driver (WHD)</title>
  6. <briefdescription>
  7. </briefdescription>
  8. <detaileddescription>
  9. <sect1 id="index_1overview">
  10. <title>WHD Overview</title>
  11. <para>The WHD is an independent, embedded Wi-Fi Host Driver that provides a set of APIs to interact with Infineon WLAN chips. The WHD is an independent firmware product that is easily portable to any embedded software environment, including popular IOT frameworks like Mbed OS, Amazon FreeRTOS, etc. Hence, the WHD includes hooks for RTOS and TCP/IP network abstraction layers. <linebreak/>
  12. The WHD requires the following services: <itemizedlist>
  13. <listitem>
  14. <para><bold>HAL:</bold> High-level abstraction layer that provides access to hardware like SDIO/SPI host controllers within the platform. </para>
  15. </listitem>
  16. <listitem>
  17. <para><bold>RTOS:</bold> The WHD uses the abstraction layer to access RTOS functionality like threads, semaphores etc. This is the same interface that the Infineon Middleware uses. </para>
  18. </listitem>
  19. <listitem>
  20. <para><bold>BSP:</bold> The WHD uses the bus definitions to specify whether the board should use SDIO, SPI or M2M. The definition are the same as Infineon BSP uses. </para>
  21. </listitem>
  22. </itemizedlist>
  23. <linebreak/>
  24. </para>
  25. </sect1>
  26. <sect1 id="index_1whd_features">
  27. <title>WHD Features</title>
  28. <para><itemizedlist>
  29. <listitem>
  30. <para>Supports Wi-Fi Station (STA) and AP mode of operation. </para>
  31. </listitem>
  32. <listitem>
  33. <para>Supports concurrent operation of STA and AP interface. </para>
  34. </listitem>
  35. <listitem>
  36. <para>Includes multiple security support like WPA2, WPA3, and open. </para>
  37. </listitem>
  38. <listitem>
  39. <para>Provides function to perform Advanced Power Management. </para>
  40. </listitem>
  41. <listitem>
  42. <para>Supports low power offloads, including ARP and packet filters. </para>
  43. </listitem>
  44. <listitem>
  45. <para>Includes WFA Pre-certification support for 802.11n and WPA3. </para>
  46. </listitem>
  47. </itemizedlist>
  48. <linebreak/>
  49. </para>
  50. </sect1>
  51. <sect1 id="index_1whd_folder_struct">
  52. <title>WHD Folder Structure</title>
  53. <para><itemizedlist>
  54. <listitem>
  55. <para>whd\src - Core WHD files </para>
  56. </listitem>
  57. <listitem>
  58. <para>whd\inc - WHD API files </para>
  59. </listitem>
  60. <listitem>
  61. <para>whd\resources - WLAN Firmware </para>
  62. </listitem>
  63. <listitem>
  64. <para>whd.mk - A simple make file to build a <emphasis>libwhd.a</emphasis> library. </para>
  65. </listitem>
  66. </itemizedlist>
  67. <linebreak/>
  68. </para>
  69. </sect1>
  70. <sect1 id="index_1whd_architecture">
  71. <title>WHD Architecture</title>
  72. <para>The WHD consists of 3 different components as shown in the following architectural diagram. Blocks highlighted in red are external dependencies for the WHD, blue ones are Porting layer and black ones are WHD core.<linebreak/>
  73. <image type="html" name="whd_arch.png" inline="yes">></image>
  74. <linebreak/>
  75. </para>
  76. </sect1>
  77. <sect1 id="index_1whd_porting">
  78. <title>Porting WHD</title>
  79. <para>To port the WHD, implement the following APIs or Function Pointers (shown in the the WHD Architecture section diagram), so that the WHD is functional:</para>
  80. <para><itemizedlist>
  81. <listitem>
  82. <para><ulink url="#_CY_RTOS_API">CY RTOS API</ulink> </para>
  83. </listitem>
  84. <listitem>
  85. <para><ulink url="#_CY_HAL_Resource_API">CY HAL Resource API</ulink> </para>
  86. </listitem>
  87. <listitem>
  88. <para><ulink url="#_Buffer_Interface_API">Buffer Interface API</ulink> </para>
  89. </listitem>
  90. <listitem>
  91. <para><ulink url="#_Network_Interface_API">Network Interface API</ulink> </para>
  92. </listitem>
  93. <listitem>
  94. <para><ulink url="#_CY_HAL_SPI/SDIO_Bus_API">CY HAL SPI/SDIO Bus API</ulink> </para>
  95. </listitem>
  96. </itemizedlist>
  97. <linebreak/>
  98. <heading level="2"><anchor id="_1_CY_RTOS_API"/>CY RTOS API</heading>
  99. </para>
  100. <para>The CY RTOS API provides prototypes for functions that allow the WHD to use RTOS functionality, such as threads, semaphores, and timing functions.<linebreak/>
  101. You must implement the appropriate functions in your code. See <bold><ulink url="whd_rtos.c">here</ulink></bold> for an example implementation. <table rows="10" cols="2"><row>
  102. <entry thead="no"><para></para>
  103. <para><bold>Function</bold></para>
  104. <para></para>
  105. </entry><entry thead="no"><para></para>
  106. <para><bold>Description</bold></para>
  107. <para></para>
  108. </entry></row>
  109. <row>
  110. <entry thead="no"><para></para>
  111. <para>cy_rtos_create_thread</para>
  112. <para></para>
  113. </entry><entry thead="no"><para></para>
  114. <para>Create RTOS thread.</para>
  115. <para></para>
  116. <para>The WHD calls this function to create the main WHD thread.</para>
  117. <para></para>
  118. </entry></row>
  119. <row>
  120. <entry thead="no"><para></para>
  121. <para>cy_rtos_terminate_thread</para>
  122. <para></para>
  123. </entry><entry thead="no"><para></para>
  124. <para>Terminate the RTOS thread.</para>
  125. <para></para>
  126. <para>The WHD calls this function to terminate WHD main thread created using cy_rtos_create_thread. It is called after calling cy_rtos_join_thread().</para>
  127. <para></para>
  128. </entry></row>
  129. <row>
  130. <entry thead="no"><para></para>
  131. <para>cy_rtos_join_thread</para>
  132. <para></para>
  133. </entry><entry thead="no"><para></para>
  134. <para>Join the RTOS thread.</para>
  135. <para></para>
  136. <para>The WHD calls this function so that any resources that were allocated for it are cleaned up. It is called by WHD before cy_rtos_terminate_thread()</para>
  137. <para></para>
  138. </entry></row>
  139. <row>
  140. <entry thead="no"><para></para>
  141. <para>cy_rtos_get_time</para>
  142. <para></para>
  143. </entry><entry thead="no"><para></para>
  144. <para>To provide time in milliseconds since RTOS start</para>
  145. <para></para>
  146. <para>The WHD uses this to get the time in milliseconds.</para>
  147. <para></para>
  148. </entry></row>
  149. <row>
  150. <entry thead="no"><para></para>
  151. <para>cy_rtos_delay_milliseconds</para>
  152. <para></para>
  153. </entry><entry thead="no"><para></para>
  154. <para>Delay for a specified number of milliseconds.</para>
  155. <para></para>
  156. <para>The WHD calls this function to obtain the time delay.</para>
  157. <para></para>
  158. </entry></row>
  159. <row>
  160. <entry thead="no"><para></para>
  161. <para>cy_rtos_init_semaphore</para>
  162. <para></para>
  163. </entry><entry thead="no"><para></para>
  164. <para>Create a semaphore.</para>
  165. <para></para>
  166. <para>The WHD uses only binary semaphore, this function is used to init a semaphore</para>
  167. <para></para>
  168. </entry></row>
  169. <row>
  170. <entry thead="no"><para></para>
  171. <para>cy_rtos_get_semaphore</para>
  172. <para></para>
  173. </entry><entry thead="no"><para></para>
  174. <para>Get/Acquire a semaphore</para>
  175. <para></para>
  176. </entry></row>
  177. <row>
  178. <entry thead="no"><para></para>
  179. <para>cy_rtos_set_semaphore</para>
  180. <para></para>
  181. </entry><entry thead="no"><para></para>
  182. <para>Set/Release a semaphore</para>
  183. <para></para>
  184. </entry></row>
  185. <row>
  186. <entry thead="no"><para></para>
  187. <para>cy_rtos_deinit_semaphore</para>
  188. <para></para>
  189. </entry><entry thead="no"><para></para>
  190. <para>Deletes a semaphore</para>
  191. <para></para>
  192. <para>This function frees the resources associated with a semaphore.</para>
  193. <para></para>
  194. </entry></row>
  195. </table>
  196. <linebreak/>
  197. <heading level="2"><anchor id="_1_CY_HAL_Resource_API"/>CY HAL Resource API</heading>
  198. </para>
  199. <para>The Wi-Fi firmware, NVRAM, and CLM BLOB information are treated as resources to be downloaded onto the Wi-Fi chip. Refer to the file <emphasis><ref refid="whd__resource__api_8h" kindref="compound">inc\whd_resource_api.h</ref></emphasis> for a detailed description. <linebreak/>
  200. You must implement the appropriate function pointers in your code. See <bold><ulink url="whd_resources.c">here</ulink></bold> for an example implementation. <table rows="5" cols="2"><row>
  201. <entry thead="no"><para></para>
  202. <para><bold>Function</bold></para>
  203. <para></para>
  204. </entry><entry thead="no"><para></para>
  205. <para><bold>Description</bold></para>
  206. <para></para>
  207. </entry></row>
  208. <row>
  209. <entry thead="no"><para></para>
  210. <para>whd_resource_size</para>
  211. <para></para>
  212. </entry><entry thead="no"><para></para>
  213. <para>Gets the size of the resource for respective resource type</para>
  214. <para></para>
  215. </entry></row>
  216. <row>
  217. <entry thead="no"><para></para>
  218. <para>whd_get_resource_block</para>
  219. <para></para>
  220. </entry><entry thead="no"><para></para>
  221. <para>Gets the resource block for specified resource type</para>
  222. <para></para>
  223. </entry></row>
  224. <row>
  225. <entry thead="no"><para></para>
  226. <para>whd_get_resource_no_of_blocks</para>
  227. <para></para>
  228. </entry><entry thead="no"><para></para>
  229. <para>Gets block count for the specified resource_type</para>
  230. <para></para>
  231. </entry></row>
  232. <row>
  233. <entry thead="no"><para></para>
  234. <para>whd_get_resource_block_size</para>
  235. <para></para>
  236. </entry><entry thead="no"><para></para>
  237. <para>Gets block size for the specified resource_type</para>
  238. <para></para>
  239. </entry></row>
  240. </table>
  241. <linebreak/>
  242. <heading level="2"><anchor id="_1_Buffer_Interface_API"/>Buffer Interface API</heading>
  243. </para>
  244. <para>The WHD requires packet buffers to exchange information between the host and Wi-Fi firmware. Refer to the file <emphasis><ref refid="whd__network__types_8h" kindref="compound">inc\whd_network_types.h</ref></emphasis> for a detailed description. <linebreak/>
  245. You must implement the appropriate function pointers in your code. See <bold><ulink url="cy_network_buffer.c">here</ulink></bold> for an example implementation. <table rows="7" cols="2"><row>
  246. <entry thead="no"><para></para>
  247. <para><bold>Function</bold></para>
  248. <para></para>
  249. </entry><entry thead="no"><para></para>
  250. <para><bold>Description</bold></para>
  251. <para></para>
  252. </entry></row>
  253. <row>
  254. <entry thead="no"><para></para>
  255. <para>whd_host_buffer_get</para>
  256. <para></para>
  257. </entry><entry thead="no"><para>Allocates a packet buffer <linebreak/>
  258. <linebreak/>
  259. You can implement this function by allocating a pre-existing packet from a pool, using a static buffer, or by dynamically allocating memory. The method chosen must match the way the network stack expects packet buffers to be allocated. Usually, the WHD requires a packet of size of WHD_LINK_MTU which includes the MTU and various other headers. Refer to <ref refid="whd__types_8h" kindref="compound">whd_types.h</ref> to find the size of WHD_LINK_MTU. The following include expected return error codes other than WHD_SUCCESS: <itemizedlist>
  260. <listitem>
  261. <para><bold>WHD_BUFFER_UNAVAILABLE_PERMANENT </bold>: Attempt to allocate more than MTU size </para>
  262. </listitem>
  263. <listitem>
  264. <para><bold>WHD_BUFFER_UNAVAILABLE_TEMPORARY </bold>: No Packet available in any pool </para>
  265. </listitem>
  266. <listitem>
  267. <para><bold>WHD_BUFFER_ALLOC_FAIL </bold>: Packet allocation fails </para>
  268. </listitem>
  269. </itemizedlist>
  270. </para>
  271. </entry></row>
  272. <row>
  273. <entry thead="no"><para></para>
  274. <para>whd_buffer_release</para>
  275. <para></para>
  276. </entry><entry thead="no"><para></para>
  277. <para>Releases a packet buffer</para>
  278. <para></para>
  279. <para>The WHD uses this function to indicate that it no longer requires a packet buffer. The buffer can then be released back into a pool for reuse, or the dynamically allocated memory can be freed, according to how the packet was allocated.</para>
  280. <para></para>
  281. </entry></row>
  282. <row>
  283. <entry thead="no"><para></para>
  284. <para>whd_buffer_get_current_piece_data_pointer</para>
  285. <para></para>
  286. </entry><entry thead="no"><para></para>
  287. <para>Retrieves the current pointer of a packet buffer</para>
  288. <para></para>
  289. <para>Since packet buffers usually need to be created with space at the front for additional headers, this function allows the WHD to get the current &apos;front&apos; location pointer.</para>
  290. <para></para>
  291. </entry></row>
  292. <row>
  293. <entry thead="no"><para></para>
  294. <para>whd_buffer_get_current_piece_size</para>
  295. <para></para>
  296. </entry><entry thead="no"><para></para>
  297. <para>Retrieves the size of a packet buffer</para>
  298. <para></para>
  299. <para>Since packet buffers usually need to be created with space at the front for additional headers, the memory block used to contain a packet buffer will often be larger than the current size of the packet buffer data. This function allows the WHD to retrieve the current size of a packet buffer&apos;s data.</para>
  300. <para></para>
  301. </entry></row>
  302. <row>
  303. <entry thead="no"><para></para>
  304. <para>whd_buffer_set_size</para>
  305. <para></para>
  306. </entry><entry thead="no"><para></para>
  307. <para>Sets the current length of a WHD packet buffer.</para>
  308. <para></para>
  309. </entry></row>
  310. <row>
  311. <entry thead="no"><para></para>
  312. <para>whd_buffer_add_remove_at_front</para>
  313. <para></para>
  314. </entry><entry thead="no"><para></para>
  315. <para>Moves the current pointer of a packet buffer</para>
  316. <para></para>
  317. <para>Since packet buffers usually need to be created with space at the front for additional headers, this function allows the WHD to move the current &apos;front&apos; location pointer. This ensures that the WHD has space to add headers to transmit packets, and that the network stack does not see the internal WHD headers on received packets.</para>
  318. <para></para>
  319. </entry></row>
  320. </table>
  321. <linebreak/>
  322. <heading level="2"><anchor id="_1_Network_Interface_API"/>Network Interface API</heading>
  323. </para>
  324. <para>The WHD calls this function pointer to pass the received TCP/IP data packet from WLAN. Refer to the file <emphasis><ref refid="whd__network__types_8h" kindref="compound">inc\whd_network_types.h</ref></emphasis> for a detailed description. <linebreak/>
  325. You must implement the appropriate function pointers in your code. See <bold><ulink url="whd_network.c">here</ulink></bold> for an example implementation. <table rows="2" cols="2"><row>
  326. <entry thead="no"><para></para>
  327. <para><bold>FUNCTION</bold></para>
  328. <para></para>
  329. </entry><entry thead="no"><para></para>
  330. <para><bold>Description</bold></para>
  331. <para></para>
  332. </entry></row>
  333. <row>
  334. <entry thead="no"><para></para>
  335. <para>whd_network_process_ethernet_data</para>
  336. <para></para>
  337. </entry><entry thead="no"><para></para>
  338. <para>The WHD calls this function pointer to pass received data to the network stack. You must provide the definition of the function.</para>
  339. <para></para>
  340. <para>This function pointer is called asynchronously in the context of the WHD thread whenever new data has arrived.</para>
  341. <para></para>
  342. <para>Packet buffers are allocated within the WHD, and ownership is transferred to the network stack. The network stack or application is thus responsible for releasing the packet buffers. Most packet buffering systems have a pointer to the &apos;current point&apos; within the packet buffer. When this function is called, the pointer points to the start of the Ethernet header. There are other inconsequential data before the Ethernet header.</para>
  343. <para></para>
  344. <para>It is preferable that you implement this function simply by putting the received packet on a queue for processing by another thread. This avoids the WHD thread being unnecessarily tied up which would delay other packets being transmitted or received.</para>
  345. <para></para>
  346. </entry></row>
  347. </table>
  348. <linebreak/>
  349. <heading level="2"><anchor id="_1_CY_HAL_SPI/SDIO_Bus_API"/>CY HAL SPI/SDIO Bus API</heading>
  350. </para>
  351. <para>The WHD uses the following functions to access the host bus controller for SDIO or SPI buses. <linebreak/>
  352. You must implement these functions in your code. See <bold><ulink url="cyhal_sdhc.c">here</ulink></bold> for an example implementation. <linebreak/>
  353. Based on the target environment implementation, replace and use these functions appropriately to ensure bus operations. <table rows="8" cols="2"><row>
  354. <entry thead="no"><para><heading level="3"><bold>Function</bold></heading>
  355. </para>
  356. <para></para>
  357. </entry><entry thead="no"><para><heading level="3"><bold>Description</bold></heading>
  358. </para>
  359. <para></para>
  360. </entry></row>
  361. <row>
  362. <entry thead="no"><para>cyhal_spi_register_irq </para>
  363. </entry><entry thead="no"><para>The SPI interrupt handler registration. </para>
  364. </entry></row>
  365. <row>
  366. <entry thead="no"><para></para>
  367. <para>cyhal_spi_transfer</para>
  368. <para></para>
  369. </entry><entry thead="no"><para>Writes a block out and receives a value. The total number of bytes sent and received will be the maximum of tx_length and rx_length. The bytes written will be padded with the value 0xff. </para>
  370. </entry></row>
  371. <row>
  372. <entry thead="no"><para></para>
  373. <para>cyhal_spi_irq_enable</para>
  374. <para></para>
  375. </entry><entry thead="no"><para>Configure SPI interrupt. This function is used for word-approach. </para>
  376. </entry></row>
  377. <row>
  378. <entry thead="no"><para></para>
  379. <para>cyhal_sdio_register_irq</para>
  380. <para></para>
  381. <para><nonbreakablespace/></para>
  382. <para></para>
  383. </entry><entry thead="no"><para>The SDIO interrupt handler registration. </para>
  384. </entry></row>
  385. <row>
  386. <entry thead="no"><para></para>
  387. <para>cyhal_sdio_irq_enable</para>
  388. <para></para>
  389. <para><nonbreakablespace/></para>
  390. <para></para>
  391. </entry><entry thead="no"><para>Configures the SDIO interrupt </para>
  392. </entry></row>
  393. <row>
  394. <entry thead="no"><para></para>
  395. <para>cyhal_sdio_send_cmd</para>
  396. <para></para>
  397. </entry><entry thead="no"><para>Sends a command to the SDIO block. </para>
  398. </entry></row>
  399. <row>
  400. <entry thead="no"><para></para>
  401. <para>cyhal_sdio_bulk_transfer</para>
  402. <para></para>
  403. </entry><entry thead="no"><para>Performs a bulk data transfer (CMD=53) to the SDIO block. </para>
  404. </entry></row>
  405. </table>
  406. <linebreak/>
  407. </para>
  408. </sect1>
  409. <sect1 id="index_1power_up">
  410. <title>WHD Power up sequence</title>
  411. <para>Before starting the WHD, perform the following steps: <itemizedlist>
  412. <listitem>
  413. <para>Connect the WLAN chip to a 32 kHz reference clock and to the sleep clock input pin. </para>
  414. </listitem>
  415. <listitem>
  416. <para>Toggle the WL_REG_ON pin shown in the WHD Power up sequence chart. <itemizedlist>
  417. <listitem>
  418. <para>WL_REG_ON pin has same polarity for all the WLAN chips </para>
  419. </listitem>
  420. <listitem>
  421. <para>For SDIO Case, SHDC complete the SD Enumeration as per the “SDIO Simplified Specification.” Refer to <ulink url="https://www.sdcard.org/downloads/pls/">https://www.sdcard.org/downloads/pls/</ulink> “Part E1 Simplified”, “SDIO Simplified Specification,” section 3.1.2, flowchart in Figure 3-2. </para>
  422. </listitem>
  423. </itemizedlist>
  424. <linebreak/>
  425. </para>
  426. <para> <image type="html" name="whd_power_up.png" inline="yes">></image>
  427. <linebreak/>
  428. </para>
  429. <para></para>
  430. </listitem>
  431. </itemizedlist>
  432. </para>
  433. </sect1>
  434. <sect1 id="index_1modes">
  435. <title>WHD Modes of Operation</title>
  436. <para>There are basically three modes of operation in WHD: <itemizedlist>
  437. <listitem>
  438. <para><ulink url="#_WHD_STA_or_AP_mode">WHD STA mode</ulink> </para>
  439. </listitem>
  440. <listitem>
  441. <para><ulink url="#_WHD_STA_or_AP_mode">WHD AP mode</ulink> </para>
  442. </listitem>
  443. <listitem>
  444. <para><ulink url="#_WHD_STA+AP_concurrent_mode">WHD STA+AP concurrent mode</ulink> </para>
  445. </listitem>
  446. </itemizedlist>
  447. <linebreak/>
  448. <heading level="2"><anchor id="_1_WHD_STA_or_AP_mode"/>WHD STA or AP mode</heading>
  449. </para>
  450. <para>The following example code shows the program flow for execution in STA/AP mode: <programlisting><codeline><highlight class="normal">#############################</highlight></codeline>
  451. <codeline><highlight class="normal"><sp/><sp/><sp/>File<sp/>whd.h</highlight></codeline>
  452. <codeline><highlight class="normal">##############################</highlight></codeline>
  453. <codeline><highlight class="normal">//Abstract<sp/>struct</highlight></codeline>
  454. <codeline><highlight class="normal">typedef<sp/>struct<sp/>whd_driver<sp/>*whd_driver_t;</highlight></codeline>
  455. <codeline><highlight class="normal">typedef<sp/>struct<sp/>whd_interface<sp/>*whd_interface_t;</highlight></codeline>
  456. <codeline></codeline>
  457. <codeline><highlight class="normal">##############################</highlight></codeline>
  458. <codeline><highlight class="normal"><sp/><sp/><sp/>File<sp/>app.c</highlight></codeline>
  459. <codeline><highlight class="normal">###############################</highlight></codeline>
  460. <codeline><highlight class="normal">#include<sp/>&quot;whd.h&quot;</highlight></codeline>
  461. <codeline></codeline>
  462. <codeline><highlight class="normal">app_start_whd()</highlight></codeline>
  463. <codeline><highlight class="normal">{</highlight></codeline>
  464. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_driver_t<sp/>whd_driver;</highlight></codeline>
  465. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_interface_t<sp/>ifp;</highlight></codeline>
  466. <codeline></codeline>
  467. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Each<sp/>wifi<sp/>chip,<sp/>will<sp/>have<sp/>it&apos;s<sp/>own<sp/>instance<sp/>of<sp/>whd_driver.</highlight></codeline>
  468. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Each<sp/>whd_driver<sp/>may<sp/>use<sp/>multiple<sp/>instance<sp/>of<sp/>whd_interface_t<sp/>structs<sp/>to<sp/>define<sp/>behavior<sp/>and<sp/>functionality.</highlight></codeline>
  469. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Most<sp/>of<sp/>the<sp/>WHD<sp/>function<sp/>calls<sp/>take<sp/>this<sp/>structure<sp/>as<sp/>input.</highlight></codeline>
  470. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>The<sp/>default<sp/>primary<sp/>interface<sp/>is<sp/>created<sp/>automatically<sp/>at<sp/>the<sp/>time<sp/>of<sp/>power<sp/>up<sp/>of<sp/>wifi<sp/>chip,<sp/>whd_wifi_on(..).</highlight></codeline>
  471. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Primary<sp/>interface<sp/>is<sp/>STA/AP<sp/>role<sp/>neutral.</highlight></codeline>
  472. <codeline></codeline>
  473. <codeline></codeline>
  474. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Call<sp/>whd_init<sp/>per<sp/>wifi<sp/>chip<sp/>(in<sp/>other<sp/>words<sp/>per<sp/>bus<sp/>slot,<sp/>two<sp/>SDIO<sp/>Wifi<sp/>chip<sp/>requires<sp/>two<sp/>calls.)</highlight></codeline>
  475. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_init(&amp;whd_driver,<sp/>&amp;whd_init_config_t,<sp/>&amp;whd_resource_source,<sp/>&amp;whd_buffer_funcs,<sp/>&amp;whd_netif_funcs);</highlight></codeline>
  476. <codeline></codeline>
  477. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Attach<sp/>a<sp/>bus<sp/>SDIO<sp/>or<sp/>SPI</highlight></codeline>
  478. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_bus_sdio_attach(whd_driver,<sp/>&amp;whd_sdio_cfg,<sp/>&amp;sdhc_obj);</highlight></codeline>
  479. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//or<sp/>whd_bus_spi_attach(whd_driver,<sp/>&amp;whd_spi_cfg,<sp/>&amp;spi_obj);</highlight></codeline>
  480. <codeline></codeline>
  481. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>...</highlight></codeline>
  482. <codeline></codeline>
  483. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Switch<sp/>on<sp/>Wifi,<sp/>download<sp/>firmware<sp/>and<sp/>create<sp/>a<sp/>primary<sp/>interface,<sp/>returns<sp/>whd_interface_t</highlight></codeline>
  484. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_on(whd_driver,<sp/>&amp;ifp);</highlight></codeline>
  485. <codeline></codeline>
  486. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//11a.<sp/>Join<sp/>to<sp/>AP<sp/>-<sp/>Note<sp/>that<sp/>it<sp/>doesn&apos;t<sp/>take<sp/>whd_driver,<sp/>instead<sp/>whd_interface_t</highlight></codeline>
  487. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_join(ifp<sp/>,<sp/>&quot;AP<sp/>SSID&quot;,<sp/>WHD_SECURITY_OPEN,<sp/>security_key,<sp/>strlen(security_key),<sp/>NULL);</highlight></codeline>
  488. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//whd_ifp<sp/>will<sp/>be<sp/>in<sp/>STA<sp/>role<sp/>from<sp/>now<sp/>on</highlight></codeline>
  489. <codeline></codeline>
  490. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>or<sp/>11b.<sp/>It<sp/>can<sp/>an<sp/>start<sp/>AP<sp/>also<sp/>here,<sp/>then<sp/>interface<sp/>will<sp/>be<sp/>in<sp/>AP<sp/>role</highlight></codeline>
  491. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//whd_wifi_init_ap(ifp<sp/>..)</highlight></codeline>
  492. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//whd_wifi_start_ap(ifp);</highlight></codeline>
  493. <codeline></codeline>
  494. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Leave<sp/>the<sp/>AP</highlight></codeline>
  495. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_leave(ifp);</highlight></codeline>
  496. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>or<sp/>Stop<sp/>the<sp/>AP</highlight></codeline>
  497. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//whd_wifi_stop_ap(ifp<sp/>,<sp/>...);</highlight></codeline>
  498. <codeline></codeline>
  499. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Switch<sp/>off<sp/>Wifi</highlight></codeline>
  500. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_off(ifp);</highlight></codeline>
  501. <codeline></codeline>
  502. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Detach<sp/>a<sp/>bus<sp/>SDIO<sp/>or<sp/>SPI</highlight></codeline>
  503. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_bus_sdio_detach(whd_driver);</highlight></codeline>
  504. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//or<sp/>whd_bus_spi_detach(whd_driver);</highlight></codeline>
  505. <codeline></codeline>
  506. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Deletes<sp/>all<sp/>the<sp/>interface<sp/>and<sp/>De-init<sp/>the<sp/>whd,<sp/>free<sp/>whd_driver<sp/>memory</highlight></codeline>
  507. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_deinit(ifp);</highlight></codeline>
  508. <codeline></codeline>
  509. <codeline><highlight class="normal">}</highlight></codeline>
  510. </programlisting> <linebreak/>
  511. <heading level="2"><anchor id="_1_WHD_STA+AP_concurrent_mode"/>WHD STA+AP concurrent mode</heading>
  512. </para>
  513. <para>The WHD supports STA+AP concurrent mode of operation. There is no support for STA+STA or AP+AP. For concurrent mode of operation, you need to create a secondary interface along with the primary interface. The primary interface must have an STA interface, and the secondary interface must have an AP interface. Running AP in the primary interface and running STA in the secondary interface is invalid. <linebreak/>
  514. <linebreak/>
  515. The following example code shows the flow for execution in STA+AP concurrent mode: <programlisting><codeline><highlight class="normal">app_start_whd()</highlight></codeline>
  516. <codeline><highlight class="normal">{</highlight></codeline>
  517. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_driver_t<sp/>whd_driver;</highlight></codeline>
  518. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_interface_t<sp/>prim_ifp;</highlight></codeline>
  519. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_interface_t<sp/>sec_ifp;</highlight></codeline>
  520. <codeline></codeline>
  521. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Each<sp/>wifi<sp/>chip,<sp/>will<sp/>have<sp/>it&apos;s<sp/>own<sp/>instance<sp/>of<sp/>whd_driver</highlight></codeline>
  522. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Each<sp/>whd_driver<sp/>may<sp/>use<sp/>multiple<sp/>instance<sp/>of<sp/>whd_interface_t<sp/>structs<sp/>to<sp/>define<sp/>behavior<sp/>and<sp/>functionality.</highlight></codeline>
  523. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Most<sp/>of<sp/>the<sp/>WHD<sp/>function<sp/>calls<sp/>take<sp/>this<sp/>structure<sp/>as<sp/>input.</highlight></codeline>
  524. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>The<sp/>default<sp/>primary<sp/>interface<sp/>is<sp/>created<sp/>automatically<sp/>at<sp/>the<sp/>time<sp/>of<sp/>power<sp/>up<sp/>of<sp/>wifi<sp/>chip,<sp/>whd_wifi_on(..).</highlight></codeline>
  525. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Primary<sp/>interface<sp/>is<sp/>STA/AP<sp/>role<sp/>neutral,<sp/>but<sp/>in<sp/>case<sp/>of<sp/>concurrent<sp/>mode<sp/>of<sp/>STA+AP<sp/>mode,<sp/>primary<sp/>interface<sp/>must<sp/>have<sp/>STA<sp/>role<sp/>only.</highlight></codeline>
  526. <codeline></codeline>
  527. <codeline></codeline>
  528. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Call<sp/>whd_init<sp/>per<sp/>wifi<sp/>chip<sp/>(in<sp/>other<sp/>words<sp/>per<sp/>bus<sp/>slot,<sp/>two<sp/>SDIO<sp/>Wifi<sp/>chip<sp/>requires<sp/>two<sp/>calls.)</highlight></codeline>
  529. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_init(&amp;whd_driver,<sp/>&amp;whd_init_cfg,<sp/>&amp;whd_resource_source,<sp/>&amp;whd_buffer_funcs,<sp/>&amp;whd_netif_funcs)<sp/>;</highlight></codeline>
  530. <codeline></codeline>
  531. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Attach<sp/>a<sp/>bus<sp/>SDIO<sp/>or<sp/>SPI</highlight></codeline>
  532. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_bus_sdio_attach(whd_driver,<sp/>&amp;whd_sdio_cfg,<sp/>&amp;sdhc_obj);</highlight></codeline>
  533. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//or<sp/>whd_bus_spi_attach(whd_driver,<sp/>&amp;whd_spi_cfg,<sp/>&amp;spi_obj);</highlight></codeline>
  534. <codeline></codeline>
  535. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>...</highlight></codeline>
  536. <codeline></codeline>
  537. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Switch<sp/>on<sp/>Wifi,<sp/>download<sp/>firmware<sp/>and<sp/>create<sp/>a<sp/>primary<sp/>interface,<sp/>returns<sp/>whd_interface_t</highlight></codeline>
  538. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_on(whd_driver,<sp/>&amp;prim_ifp<sp/>);</highlight></codeline>
  539. <codeline></codeline>
  540. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Add<sp/>the<sp/>secondary<sp/>interface.<sp/>Secondary<sp/>interface<sp/>can<sp/>only<sp/>be<sp/>used<sp/>as<sp/>AP</highlight></codeline>
  541. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_add_secondary_interface(whd_driver,<sp/>mac_addr,<sp/>&amp;sec_ifp<sp/>);</highlight></codeline>
  542. <codeline></codeline>
  543. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Join<sp/>to<sp/>AP<sp/>-<sp/>Note<sp/>that<sp/>it<sp/>doesn&apos;t<sp/>take<sp/>whd_driver,<sp/>instead<sp/>whd_interface_t</highlight></codeline>
  544. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_join(prim_ifp<sp/>,<sp/>&quot;AP<sp/>SSID&quot;,<sp/>WHD_SECURITY_OPEN,<sp/>security_key,<sp/>strlen(security_key),<sp/>NULL);</highlight></codeline>
  545. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>whd_ifp<sp/>will<sp/>be<sp/>in<sp/>STA<sp/>role<sp/>from<sp/>now<sp/>on</highlight></codeline>
  546. <codeline></codeline>
  547. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Now<sp/>start<sp/>AP<sp/>in<sp/>secondary<sp/>interface,<sp/>then<sp/>it<sp/>will<sp/>be<sp/>in<sp/>AP<sp/>role</highlight></codeline>
  548. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_init_ap(sec_ifp<sp/>..)</highlight></codeline>
  549. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_start_ap(sec_ifp);</highlight></codeline>
  550. <codeline></codeline>
  551. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Leave<sp/>the<sp/>AP</highlight></codeline>
  552. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_leave(prim_ifp);</highlight></codeline>
  553. <codeline></codeline>
  554. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Stop<sp/>the<sp/>AP</highlight></codeline>
  555. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_stop_ap(sec_ifp<sp/>,<sp/>...);</highlight></codeline>
  556. <codeline></codeline>
  557. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Switch<sp/>off<sp/>Wifi</highlight></codeline>
  558. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_off(prim_ifp);</highlight></codeline>
  559. <codeline></codeline>
  560. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Detach<sp/>a<sp/>bus<sp/>SDIO<sp/>or<sp/>SPI</highlight></codeline>
  561. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_bus_sdio_detach(whd_driver);</highlight></codeline>
  562. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//or<sp/>whd_bus_spi_detach(whd_driver);</highlight></codeline>
  563. <codeline></codeline>
  564. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Deletes<sp/>all<sp/>the<sp/>interface<sp/>and<sp/>De-init<sp/>the<sp/>whd,<sp/>free<sp/>whd_driver<sp/>memory</highlight></codeline>
  565. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_deinit(prim_ifp);</highlight></codeline>
  566. <codeline></codeline>
  567. <codeline><highlight class="normal">}</highlight></codeline>
  568. </programlisting> <linebreak/>
  569. <heading level="2"><anchor id="_1_WHD_WPA3/WPA2_transition_mode"/>WHD WPA3/WPA2 transition mode</heading>
  570. </para>
  571. <para>The WHD supports WPA3/WPA2 transition mode. In this mode, if the WPA3 AP goes down and a WPA2 AP is started with the same SSID, the STA automatically transitions to join the WPA2 AP. This mode requires two security keys for the join to be completed. <linebreak/>
  572. The security keys can be the same or different,one key is for setting the psk passphrase, and second key is for setting WPA3 password but it is highly recommended to use different passwords. <linebreak/>
  573. <linebreak/>
  574. The following example code shows the flow for execution in WPA3/WPA2 transition mode: <programlisting><codeline><highlight class="normal">app_start_whd()</highlight></codeline>
  575. <codeline><highlight class="normal">{</highlight></codeline>
  576. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_driver_t<sp/>whd_driver;</highlight></codeline>
  577. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_interface_t<sp/>ifp;</highlight></codeline>
  578. <codeline></codeline>
  579. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Each<sp/>wifi<sp/>chip,<sp/>will<sp/>have<sp/>it&apos;s<sp/>own<sp/>instance<sp/>of<sp/>whd_driver</highlight></codeline>
  580. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Each<sp/>whd_driver<sp/>may<sp/>use<sp/>multiple<sp/>instance<sp/>of<sp/>whd_interface_t<sp/>structs<sp/>to<sp/>define<sp/>behavior<sp/>and<sp/>functionality.</highlight></codeline>
  581. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Most<sp/>of<sp/>the<sp/>WHD<sp/>function<sp/>calls<sp/>take<sp/>this<sp/>structure<sp/>as<sp/>input.</highlight></codeline>
  582. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>The<sp/>default<sp/>primary<sp/>interface<sp/>is<sp/>created<sp/>automatically<sp/>at<sp/>the<sp/>time<sp/>of<sp/>power<sp/>up<sp/>of<sp/>wifi<sp/>chip,<sp/>whd_wifi_on(..).</highlight></codeline>
  583. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Primary<sp/>interface<sp/>is<sp/>STA/AP<sp/>role<sp/>neutral.</highlight></codeline>
  584. <codeline></codeline>
  585. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Call<sp/>whd_init<sp/>per<sp/>wifi<sp/>chip<sp/>(in<sp/>other<sp/>words<sp/>per<sp/>bus<sp/>slot,<sp/>two<sp/>SDIO<sp/>Wifi<sp/>chip<sp/>requires<sp/>two<sp/>calls.)</highlight></codeline>
  586. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_init(&amp;whd_driver,<sp/>&amp;whd_init_cfg,<sp/>&amp;whd_resource_source,<sp/>&amp;whd_buffer_funcs,<sp/>&amp;whd_netif_funcs);</highlight></codeline>
  587. <codeline></codeline>
  588. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Attach<sp/>a<sp/>bus<sp/>SDIO<sp/>or<sp/>SPI</highlight></codeline>
  589. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_bus_sdio_attach(whd_driver,<sp/>&amp;whd_sdio_cfg,<sp/>&amp;sdhc_obj);</highlight></codeline>
  590. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//or<sp/>whd_bus_spi_attach(whd_driver,<sp/>&amp;whd_spi_cfg,<sp/>&amp;spi_obj);</highlight></codeline>
  591. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>...</highlight></codeline>
  592. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Switch<sp/>on<sp/>Wifi,<sp/>download<sp/>firmware<sp/>and<sp/>create<sp/>a<sp/>primary<sp/>interface,<sp/>returns<sp/>whd_interface_t</highlight></codeline>
  593. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_on(whd_driver,<sp/>&amp;ifp);</highlight></codeline>
  594. <codeline></codeline>
  595. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//Enable<sp/>WHD<sp/>internal<sp/>supplicant<sp/>and<sp/>set<sp/>WPA2<sp/>passphrase<sp/>in<sp/>case<sp/>of<sp/>WPA3/WPA2<sp/>transition<sp/>mode</highlight></codeline>
  596. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//Here,<sp/>security_key_psk<sp/>is<sp/>WPA2<sp/>passphrase<sp/>for<sp/>WHD_SECURITY_WPA3_WPA2_PSK<sp/>authentication<sp/>type</highlight></codeline>
  597. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_enable_sup_set_passphrase(<sp/>ifp,<sp/>security_key_psk,<sp/>strlen(security_key_psk),<sp/>WHD_SECURITY_WPA3_WPA2_PSK<sp/>);</highlight></codeline>
  598. <codeline></codeline>
  599. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//11a.<sp/>Join<sp/>to<sp/>AP</highlight></codeline>
  600. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//Here,<sp/>security<sp/>key<sp/>is<sp/>WPA3<sp/>password</highlight></codeline>
  601. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_join(ifp<sp/>,<sp/>&quot;AP<sp/>SSID&quot;,<sp/>WHD_SECURITY_WPA3_WPA2_PSK,<sp/>security_key,<sp/>strlen(security_key),<sp/>NULL);</highlight></codeline>
  602. <codeline></codeline>
  603. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Leave<sp/>the<sp/>AP</highlight></codeline>
  604. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_leave(ifp);</highlight></codeline>
  605. <codeline></codeline>
  606. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Switch<sp/>off<sp/>Wifi</highlight></codeline>
  607. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_wifi_off(ifp);</highlight></codeline>
  608. <codeline></codeline>
  609. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Detach<sp/>a<sp/>bus<sp/>SDIO<sp/>or<sp/>SPI</highlight></codeline>
  610. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_bus_sdio_detach(whd_driver);</highlight></codeline>
  611. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//or<sp/>whd_bus_spi_detach(whd_driver);</highlight></codeline>
  612. <codeline></codeline>
  613. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>//<sp/>Deletes<sp/>all<sp/>the<sp/>interface<sp/>and<sp/>De-init<sp/>the<sp/>whd,<sp/>free<sp/>whd_driver<sp/>memory</highlight></codeline>
  614. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>whd_deinit(ifp);</highlight></codeline>
  615. <codeline></codeline>
  616. <codeline><highlight class="normal">}</highlight></codeline>
  617. </programlisting></para>
  618. <para><linebreak/>
  619. </para>
  620. </sect1>
  621. <sect1 id="index_1whd_design">
  622. <title>Internals of WHD</title>
  623. <para>The WHD consists of various internal modules as shown in the following diagram and explained in the following sections. Once the WHD is powered up, the WLAN Bus specific init sequence is completed, and the WLAN chip is ready for operation. <image type="html" name="whd_design.png" inline="yes">></image>
  624. <linebreak/>
  625. <heading level="2"><bold>FW Download Module</bold></heading>
  626. </para>
  627. <para>This module downloads the WLAN Firmware, NVRAM, and CLM file using HAL Resource API. This module does not use the services of control or data path module. It directly accesses the &quot;WHD Bus Interface&quot; to write the resources. After download is completed, this module allows the WLAN firmware to run.<linebreak/>
  628. <linebreak/>
  629. <heading level="2"><bold>WLAN Chip Logging Module</bold></heading>
  630. </para>
  631. <para>This module is responsible for obtaining the WLAN Chip logs using the WHD Debug APIs.<linebreak/>
  632. <linebreak/>
  633. <heading level="2"><bold>Control Module</bold></heading>
  634. </para>
  635. <para>IOCTLs provide control access to the WLAN Chip, and this module routes all these control messages to/from the WLAN chip.<linebreak/>
  636. <linebreak/>
  637. <heading level="2"><bold>Data Module</bold></heading>
  638. </para>
  639. <para>This module handles User Data received in the TCP/IP interface. It also to sends the User Data received from the WLAN Chip.<linebreak/>
  640. <linebreak/>
  641. <heading level="2"><bold>Event Module</bold></heading>
  642. </para>
  643. <para>Event module handles the events generated from the WLAN chip. It also exposes a function for the application to register for limited set of events and process them.<linebreak/>
  644. <linebreak/>
  645. <heading level="2"><bold>Protocol Module</bold></heading>
  646. </para>
  647. <para>Any packet sent to the WLAN chip needs to have a Protocol Header. Protocol Headers are of two types: <itemizedlist>
  648. <listitem>
  649. <para>CDC (for control packet like IOCTL and IOVAR) </para>
  650. </listitem>
  651. <listitem>
  652. <para>BDC (for User Data or ethernet packets from TCP/IP layer)</para>
  653. </listitem>
  654. </itemizedlist>
  655. The protocol layer is bus independent and is required for either SDIO/SPI/USB.</para>
  656. <para><itemizedlist>
  657. <listitem>
  658. <para><bold>CDC Layer</bold> The Control Module sends messages to this CDC layer, which adds a 16-byte header known as CDC header. The following shows the header details: <image type="html" name="cdc_msg.png" inline="yes">></image>
  659. <linebreak/>
  660. <linebreak/>
  661. <linebreak/>
  662. </para>
  663. <para><programlisting><codeline><highlight class="normal">typedef<sp/>struct</highlight></codeline>
  664. <codeline><highlight class="normal">{</highlight></codeline>
  665. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>uint32_t<sp/>cmd;<sp/><sp/><sp/><sp/><sp/>//<sp/>ioctl<sp/>command<sp/>value</highlight></codeline>
  666. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>uint32_t<sp/>len;<sp/><sp/><sp/><sp/><sp/>//<sp/>lower<sp/>16:<sp/>output<sp/>buflen;<sp/>upper<sp/>16:<sp/>input<sp/>buflen<sp/>(excludes<sp/>header)</highlight></codeline>
  667. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>uint32_t<sp/>flags;<sp/><sp/><sp/>//<sp/>flag<sp/>defns<sp/>given<sp/>in<sp/>bcmcdc.h</highlight></codeline>
  668. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/>uint32_t<sp/>status;<sp/><sp/>//<sp/>status<sp/>code<sp/>returned<sp/>from<sp/>the<sp/>device</highlight></codeline>
  669. <codeline><highlight class="normal">}cdc_header_t;</highlight></codeline>
  670. </programlisting> <linebreak/>
  671. </para>
  672. </listitem>
  673. <listitem>
  674. <para><bold>BDC Layer</bold> The User Data Module sends messages to the BDC Layer. It adds a 4-byte header known as the BDC header. The following shows the header details: <image type="html" name="bdc_msg.png" inline="yes">></image>
  675. <linebreak/>
  676. <linebreak/>
  677. <linebreak/>
  678. </para>
  679. <para><programlisting><codeline><highlight class="normal">typedef<sp/>struct</highlight></codeline>
  680. <codeline><highlight class="normal">{</highlight></codeline>
  681. <codeline><highlight class="normal"><sp/><sp/><sp/>uint8_t<sp/>flags;<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>//<sp/>Flags</highlight></codeline>
  682. <codeline><highlight class="normal"><sp/><sp/><sp/>uint8_t<sp/>priority;<sp/><sp/><sp/><sp/><sp/>//<sp/>802.1d<sp/>Priority<sp/>(low<sp/>3<sp/>bits)</highlight></codeline>
  683. <codeline><highlight class="normal"><sp/><sp/><sp/>uint8_t<sp/>flags2;</highlight></codeline>
  684. <codeline><highlight class="normal"><sp/><sp/><sp/>uint8_t<sp/>data_offset;<sp/><sp/>//<sp/>Offset<sp/>from<sp/>end<sp/>of<sp/>BDC<sp/>header<sp/>to<sp/>packet<sp/>data,<sp/>in<sp/>4-uint8_t<sp/>words.</highlight></codeline>
  685. <codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>//<sp/>Leaves<sp/>room<sp/>for<sp/>optional<sp/>headers.</highlight></codeline>
  686. <codeline><highlight class="normal">}<sp/>bdc_header_t;</highlight></codeline>
  687. </programlisting> </para>
  688. </listitem>
  689. </itemizedlist>
  690. <linebreak/>
  691. <heading level="2"><bold>Bus Layer</bold></heading>
  692. </para>
  693. <para>The Bus layer provides bus level protocol handling. For SDIO, a bus protocol known as SDPCM is used.<linebreak/>
  694. <itemizedlist>
  695. <listitem>
  696. <para><bold>SDPCM - SDIO/SPI Bus Layer</bold> SDPCM Layer takes care of:<linebreak/>
  697. <itemizedlist>
  698. <listitem>
  699. <para>Adding a Sequence number to packet sent to WLAN Chip </para>
  700. </listitem>
  701. <listitem>
  702. <para>Flow control between WHD and WLAN Chip</para>
  703. </listitem>
  704. </itemizedlist>
  705. SDPCM layer adds a fixed 10-byte header and packet format as below: <linebreak/>
  706. <image type="html" name="sdpcm_msg.png" inline="yes">></image>
  707. <linebreak/>
  708. <linebreak/>
  709. <linebreak/>
  710. <linebreak/>
  711. </para>
  712. </listitem>
  713. <listitem>
  714. <para><bold>SDPCM Header</bold> <programlisting><codeline><highlight class="normal">typedef<sp/>struct</highlight></codeline>
  715. <codeline><highlight class="normal">{</highlight></codeline>
  716. <codeline><highlight class="normal"><sp/><sp/>uint16_t<sp/><sp/>frametag[2];<sp/><sp/><sp/><sp/><sp/><sp/>//<sp/>SDPCM<sp/>packet<sp/>size</highlight></codeline>
  717. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>sequence;<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>//<sp/>Sequence<sp/>number<sp/>of<sp/>pkt</highlight></codeline>
  718. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>channel_and_flags;<sp/><sp/>//<sp/>IOCTL/IOVAR<sp/>or<sp/>User<sp/>Data<sp/>or<sp/>Event</highlight></codeline>
  719. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>next_length;</highlight></codeline>
  720. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>header_length;<sp/><sp/><sp/><sp/><sp/><sp/>//<sp/>Offset<sp/>to<sp/>BDC<sp/>or<sp/>CDC<sp/>header</highlight></codeline>
  721. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>wireless_flow_control;</highlight></codeline>
  722. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>bus_data_credit;<sp/><sp/><sp/><sp/>//<sp/>Credit<sp/>from<sp/>WLAN<sp/>Chip</highlight></codeline>
  723. <codeline><highlight class="normal"><sp/><sp/>uint8_t<sp/>_reserved[2];</highlight></codeline>
  724. <codeline><highlight class="normal">}<sp/>sdpcm_header_t;</highlight></codeline>
  725. </programlisting> <linebreak/>
  726. </para>
  727. </listitem>
  728. <listitem>
  729. <para><bold>SDIO - SDPCM Flow control</bold> Before sending any data to the WLAN, the SDPCM Layer must wait for credit from WLAN chip. Credit is sent by the WLAN either in a SDPCM header packet or as piggy-banked information in a RX User Data packet. The SDPCM Layer should not send any packet if no credit is available. <linebreak/>
  730. <linebreak/>
  731. <image type="html" name="sdpcm_flow.png" inline="yes">></image>
  732. <linebreak/>
  733. </para>
  734. </listitem>
  735. </itemizedlist>
  736. <linebreak/>
  737. <heading level="2">Packet Engine</heading>
  738. </para>
  739. <para>All the control or User Data is queued in a link list in this layer. Once the credit is available, this layer sends the data to WLAN chip. Also, this layer checks for any RX data from WLAN Chip and sends the data to host TCP/IP stack via its TCP/IP interface. <linebreak/>
  740. <image type="html" name="data_flow.png" inline="yes">></image>
  741. <linebreak/>
  742. <linebreak/>
  743. <linebreak/>
  744. <linebreak/>
  745. <linebreak/>
  746. <linebreak/>
  747. <linebreak/>
  748. <linebreak/>
  749. <linebreak/>
  750. <linebreak/>
  751. <heading level="2">WHD Bus Interface</heading>
  752. </para>
  753. <para>This module provides bus independent access functions to the packet engine/sdpcm layer. It is primarily used to keep the access functions common between SDIO/SPI. <linebreak/>
  754. <linebreak/>
  755. <heading level="2">SDIO HAL Interface</heading>
  756. </para>
  757. <para>Use the CY HAL interface to access the SDIO Host Controller Hardware. It is external to the WHD driver. <linebreak/>
  758. <linebreak/>
  759. <heading level="3"><bold>SPI HAL Interface</bold></heading>
  760. </para>
  761. <para>Use the CY HAL interface to access the SPI Host Controller Hardware. It is external to the WHD driver <linebreak/>
  762. <linebreak/>
  763. <linebreak/>
  764. </para>
  765. </sect1>
  766. <sect1 id="index_1apis">
  767. <title>WHD API</title>
  768. <para>The WHD provides services in the form of the WLAN API which can be used by layers above the WHD. Broadly, the WLAN API can be classified into the following: <itemizedlist>
  769. <listitem>
  770. <para>Basic API (like scan, join) </para>
  771. </listitem>
  772. <listitem>
  773. <para>Intermediate API (like SoftAP) </para>
  774. </listitem>
  775. <listitem>
  776. <para>Advanced API (to send direct IOCTL to WLAN Chip)</para>
  777. </listitem>
  778. </itemizedlist>
  779. Based on the functionality, APIs can be classified as follows: <itemizedlist>
  780. <listitem>
  781. <para><ulink url="group__busapi.html">WHD Bus API</ulink> </para>
  782. </listitem>
  783. <listitem>
  784. <para><ulink url="group__buffif.html">WHD Buffer Interface API</ulink> </para>
  785. </listitem>
  786. <listitem>
  787. <para><ulink url="group__netif.html">WHD Network Interface API</ulink> </para>
  788. </listitem>
  789. <listitem>
  790. <para><ulink url="group__res.html">WHD Resource API</ulink> </para>
  791. </listitem>
  792. <listitem>
  793. <para><ulink url="group__event.html">WHD Wi-Fi Event handling API</ulink> </para>
  794. </listitem>
  795. <listitem>
  796. <para><ulink url="group__wifi.html">WHD Wi-Fi API</ulink> <itemizedlist>
  797. <listitem>
  798. <para><ulink url="group__wifimanagement.html">WHD Wi-Fi Management API</ulink> </para>
  799. </listitem>
  800. <listitem>
  801. <para><ulink url="group__wifijoin.html">WHD Wi-Fi Join, Scan and Halt API</ulink> </para>
  802. </listitem>
  803. <listitem>
  804. <para><ulink url="group__wifiutilities.html">WHD Wi-Fi Utility API</ulink> </para>
  805. </listitem>
  806. <listitem>
  807. <para><ulink url="group__wifisoftap.html">WHD Wi-Fi SoftAP API</ulink> </para>
  808. </listitem>
  809. <listitem>
  810. <para><ulink url="group__wifipowersave.html">WHD Wi-Fi Power Save API</ulink> </para>
  811. </listitem>
  812. <listitem>
  813. <para><ulink url="group__wifiioctl.html">WHD Wi-Fi IOCTL Set/Get API</ulink> </para>
  814. </listitem>
  815. <listitem>
  816. <para><ulink url="group__dbg.html">WHD Wi-Fi Debug API</ulink> </para>
  817. </listitem>
  818. </itemizedlist>
  819. </para>
  820. </listitem>
  821. </itemizedlist>
  822. <linebreak/>
  823. </para>
  824. </sect1>
  825. </detaileddescription>
  826. </compounddef>
  827. </doxygen>