21
21
#include < stdlib.h>
22
22
#include < string.h>
23
23
24
- # ifndef WF200_WIFI
25
- #include " FreeRTOS .h"
26
- #include " event_groups .h"
27
- #include " task .h"
28
- # if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD)
29
- #ifdef __cplusplus
24
+ // LwIP includes - Includes must be before the rsi headers due to redefination errors
25
+ #include " lwip/ethip6 .h"
26
+ #include " lwip/timeouts .h"
27
+ #include " netif/etharp .h"
28
+
29
+ #ifdef RS911X_WIFI
30
30
extern " C" {
31
- #endif
32
- #include " cmsis_os2.h"
33
- #include " sl_net.h"
34
- #include " sl_si91x_driver.h"
35
- #include " sl_si91x_host_interface.h"
36
- #include " sl_si91x_types.h"
37
- #include " sl_wifi.h"
38
- #include " sl_wifi_callback_framework.h"
39
- #include " sl_wifi_constants.h"
40
- #include " sl_wifi_types.h"
41
- #ifdef __cplusplus
31
+ #include " rsi_driver.h"
32
+ #include " rsi_pkt_mgmt.h"
42
33
}
43
- #endif
44
- #endif // (SLI_SI91X_MCU_INTERFACE | EXP_BOARD)
45
- #endif // WF200_WIFI
34
+ #endif // RS911X_WIFI
46
35
47
- #include < platform/silabs/wifi/WifiInterface.h>
48
36
#ifdef WF200_WIFI
49
37
#include " sl_wfx.h"
50
38
#endif
51
- /* LwIP includes. */
52
- #include " ethernetif.h"
53
- #include " lwip/ethip6.h"
54
- #include " lwip/timeouts.h"
55
- #include " netif/etharp.h"
56
39
57
40
#include < lib/support/logging/CHIPLogging.h>
41
+ #include < platform/silabs/wifi/WifiInterface.h>
42
+ #include < platform/silabs/wifi/lwip-support/ethernetif.h>
43
+ #include < platform/silabs/wifi/lwip-support/lwip_netif.h>
58
44
59
45
StaticSemaphore_t xEthernetIfSemaBuffer;
60
46
@@ -286,7 +272,7 @@ void sl_wfx_host_received_frame_callback(sl_wfx_received_ind_t * rx_buffer)
286
272
{
287
273
288
274
/* Send received frame to station interface */
289
- if ((netif = wfx_get_netif (SL_WFX_STA_INTERFACE)) != NULL )
275
+ if ((netif = chip::DeviceLayer::Silabs::Lwip::GetNetworkInterface (SL_WFX_STA_INTERFACE)) != NULL )
290
276
{
291
277
uint8_t * buffer;
292
278
uint16_t len;
@@ -316,7 +302,92 @@ void sl_wfx_host_received_frame_callback(sl_wfx_received_ind_t * rx_buffer)
316
302
}
317
303
318
304
#else /* For RS911x - using LWIP */
305
+
319
306
static SemaphoreHandle_t ethout_sem;
307
+
308
+ /* *
309
+ * @brief Allocates packets for the data about to be sent
310
+ *
311
+ * TODO: Validate if this warning still applied and fix the associated code
312
+ * WARNING - Taken from RSI and broken up
313
+ * This is my own RSI stuff for not copying code and allocating an extra
314
+ * level of indirection - when using LWIP buffers
315
+ * see also: int32_t rsi_wlan_send_data_xx(uint8_t *buffer, uint32_t length)
316
+ *
317
+ * @return void* pointer to the allocated packet buffer
318
+ */
319
+ static void * wfx_rsi_alloc_pkt (void )
320
+ {
321
+ rsi_pkt_t * pkt;
322
+
323
+ // Allocate packet to send data
324
+ if ((pkt = rsi_pkt_alloc (&rsi_driver_cb->wlan_cb ->wlan_tx_pool )) == NULL )
325
+ {
326
+ return (void *) 0 ;
327
+ }
328
+
329
+ return (void *) pkt;
330
+ }
331
+
332
+ /* *
333
+ * @brief Adds the buffer data to the allocated packet.
334
+ * the packet must be allocated before adding data to it.
335
+ *
336
+ * @param[in,out] p pointer to the allocated packet
337
+ * @param[in] buf pointer to the data buffer to copy to the packet
338
+ * @param[in] len length of the data buffer
339
+ * @param[in] off the offset at which to put the data in the packet
340
+ */
341
+ void wfx_rsi_pkt_add_data (void * p, uint8_t * buf, uint16_t len, uint16_t off)
342
+ {
343
+ rsi_pkt_t * pkt;
344
+
345
+ pkt = (rsi_pkt_t *) p;
346
+ memcpy (((char *) pkt->data ) + off, buf, len);
347
+ }
348
+
349
+ /* *
350
+ * @brief Triggers the packet to sent on the wire
351
+ *
352
+ * @param p pointer to the packet to send
353
+ * @param len length of the packet to send
354
+ *
355
+ * @return int32_t RSI_ERROR_NONE, if the packet was succesfully sent out
356
+ * RSI_ERROR_RESPONSE_TIMEOUT, if we are unable to acquire the semaphore of the status
357
+ * other error (< 0) if we were unable to send out the the packet
358
+ */
359
+ int32_t wfx_rsi_send_data (void * p, uint16_t len)
360
+ {
361
+ int32_t status;
362
+ uint8_t * host_desc;
363
+ rsi_pkt_t * pkt;
364
+
365
+ pkt = (rsi_pkt_t *) p;
366
+ host_desc = pkt->desc ;
367
+ memset (host_desc, 0 , RSI_HOST_DESC_LENGTH);
368
+ rsi_uint16_to_2bytes (host_desc, (len & 0xFFF ));
369
+
370
+ // Fill packet type
371
+ host_desc[1 ] |= (RSI_WLAN_DATA_Q << 4 );
372
+ host_desc[2 ] |= 0x01 ;
373
+
374
+ rsi_enqueue_pkt (&rsi_driver_cb->wlan_tx_q , pkt);
375
+
376
+ #ifndef RSI_SEND_SEM_BITMAP
377
+ rsi_driver_cb_non_rom->send_wait_bitmap |= BIT (0 );
378
+ #endif
379
+ // Set TX packet pending event
380
+ rsi_set_event (RSI_TX_EVENT);
381
+
382
+ if (rsi_wait_on_wlan_semaphore (&rsi_driver_cb_non_rom->send_data_sem , RSI_SEND_DATA_RESPONSE_WAIT_TIME) != RSI_ERROR_NONE)
383
+ {
384
+ return RSI_ERROR_RESPONSE_TIMEOUT;
385
+ }
386
+ status = rsi_wlan_get_status ();
387
+
388
+ return status;
389
+ }
390
+
320
391
/* ****************************************************************************
321
392
* @fn static err_t low_level_output(struct netif *netif, struct pbuf *p)
322
393
* @brief
@@ -441,7 +512,7 @@ sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface, sl_w
441
512
/* get the network interface for STATION interface,
442
513
* and forward the received frame buffer to LWIP
443
514
*/
444
- if ((ifp = wfx_get_netif (SL_WFX_STA_INTERFACE)) != (struct netif *) 0 )
515
+ if ((ifp = GetNetworkInterface (SL_WFX_STA_INTERFACE)) != (struct netif *) 0 )
445
516
{
446
517
low_level_input (ifp, rsi_pkt->data , rsi_pkt->length );
447
518
}
@@ -465,7 +536,7 @@ void wfx_host_received_sta_frame_cb(uint8_t * buf, int len)
465
536
/* get the network interface for STATION interface,
466
537
* and forward the received frame buffer to LWIP
467
538
*/
468
- if ((ifp = wfx_get_netif (SL_WFX_STA_INTERFACE)) != (struct netif *) 0 )
539
+ if ((ifp = chip::DeviceLayer::Silabs::Lwip::GetNetworkInterface (SL_WFX_STA_INTERFACE)) != (struct netif *) 0 )
469
540
{
470
541
low_level_input (ifp, buf, len);
471
542
}
0 commit comments