Skip to content

Commit

Permalink
Resolved build errors for 917 NCP
Browse files Browse the repository at this point in the history
  • Loading branch information
bhmanda-silabs committed Aug 9, 2023
1 parent 02a3a0e commit 06ab053
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 126 deletions.
10 changes: 5 additions & 5 deletions examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ sl_status_t sl_si91x_host_init(void)
NVIC_SetPriority(GPIO_ODD_IRQn, PACKET_PENDING_INT_PRI);

// Configure interrupt, sleep and wake confirmation pins
GPIOINT_CallbackRegister(WFX_INTERRUPT_PIN, gpio_interrupt);
GPIOINT_CallbackRegister(WFX_INTERRUPT_PIN.pin, gpio_interrupt);
GPIO_PinModeSet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin, gpioModeInputPullFilter, 0);
GPIO_ExtIntConfig(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin, SL_WFX_HOST_PINOUT_SPI_IRQ, true, false, true);
GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1);
GPIO_PinModeSet(WAKE_INDICATOR_PIN.port.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0);
GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0);

memset(cmd_queues, 0, sizeof(cmd_queues));

Expand Down Expand Up @@ -337,13 +337,13 @@ uint32_t si91x_host_clear_events(uint32_t event_mask)

void sl_si91x_host_hold_in_reset(void)
{
GPIO_PinModeSet(WFX_RESET_PIN, WFX_RESET_PIN, gpioModePushPull, 1);
GPIO_PinOutClear(WFX_RESET_PIN, WFX_RESET_PIN);
GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, 1);
GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin);
}

void sl_si91x_host_release_from_reset(void)
{
GPIO_PinModeSet(WFX_RESET_PIN, WFX_RESET_PIN, gpioModeWiredOrPullDown, 1);
GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, 1);
}

void sl_si91x_host_enable_bus_interrupt(void)
Expand Down
7 changes: 4 additions & 3 deletions examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
#include "sl_device_init_hfxo.h"

#define DEFAULT_SPI_TRASFER_MODE 0

// Macro to drive semaphore block minimun timer in milli seconds
#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50)
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#include "sl_power_manager.h"
#endif
Expand Down Expand Up @@ -131,7 +132,7 @@ void sl_wfx_host_gpio_init(void)
GPIO_PinModeSet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin, gpioModeInputPull, PINOUT_CLEAR);
GPIO_ExtIntConfig(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin, SL_WFX_HOST_PINOUT_SPI_IRQ, true, false, true);
GPIOINT_CallbackRegister(SL_WFX_HOST_PINOUT_SPI_IRQ, rsi_gpio_irq_cb);
GPIO_IntDisable(1 << SG+SL_WFX_HOST_PINOUT_SPI_IRQ); /* Will be enabled by RSI */
GPIO_IntDisable(1 << SL_WFX_HOST_PINOUT_SPI_IRQ); /* Will be enabled by RSI */

// Change GPIO interrupt priority (FreeRTOS asserts unless this is done here!)
NVIC_SetPriority(GPIO_EVEN_IRQn, WFX_SPI_NVIC_PRIORITY);
Expand Down Expand Up @@ -435,5 +436,5 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint
**************************************************************************/
sl_status_t si91x_host_spi_transfer(const void *tx_buf, void *rx_buf, uint16_t xlen)
{
rsi_spi_transfer(tx_buf, rx_buf, xlen, DEFAULT_SPI_TRASFER_MODE);
return(rsi_spi_transfer((uint8_t *)tx_buf, rx_buf, xlen, DEFAULT_SPI_TRASFER_MODE));
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ typedef struct
unsigned char pin;
} sl_pin_t;

#define PACKET_PENDING_INT_PRI 3
#define PIN(port_id, pin_id) \
(sl_pin_t) \
{ \
.port = gpioPort##port_id, .pin = pin_id \
}

#define PIN(port_id, pin_id) \
(sl_pin_t) { .port = gpioPort##port_id, .pin = pin_id }
#define PACKET_PENDING_INT_PRI 3

#if defined(EFR32MG12_BRD4161A) || defined(BRD4161A) || defined(EFR32MG12_BRD4162A) || defined(BRD4162A) || \
defined(EFR32MG12_BRD4163A) || defined(BRD4163A) || defined(EFR32MG12_BRD4164A) || defined(BRD4164A) || \
Expand Down
66 changes: 7 additions & 59 deletions examples/platform/silabs/efr32/rs911x/sl_wifi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ volatile sl_status_t callback_status = SL_STATUS_OK;
int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap)
{
sl_status_t status = SL_STATUS_OK;
uint8_t rssi = 0;
int32_t rssi = 0;
ap->security = wfx_rsi.sec.security;
ap->chan = wfx_rsi.ap_chan;
memcpy(&ap->bssid[0], &wfx_rsi.ap_mac.octet[0], BSSID_MAX_STR_LEN);
Expand Down Expand Up @@ -299,7 +299,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
}
wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED;
wfx_rsi.ap_chan = scan_result->scan_info[0].rf_channel;
memcpy(&wfx_rsi.ap_mac.octet[0], scan_result->scan_info[0].bssid[0], BSSID_MAX_STR_LEN);
memcpy(&wfx_rsi.ap_mac.octet, scan_result->scan_info[0].bssid, BSSID_MAX_STR_LEN);
switch (scan_result->scan_info[0].security_mode)
{
case SL_WIFI_OPEN:
Expand Down Expand Up @@ -338,10 +338,10 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t *scan_result)
wfx_wifi_scan_result_t ap;
if (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED)
{
for (x = 0; x < scan_result->scan_count; x++)
for (x = 0; x < (int)scan_result->scan_count; x++)
{
strcpy(&ap.ssid[0], (char *) &scan_result->scan_info[x].ssid);
uint8_t *bssid = (uint8_t *)&scan_result->scan_info[x].bssid;
// uint8_t *bssid = (uint8_t *)&scan_result->scan_info[x].bssid;
if (wfx_rsi.scan_ssid)
{
SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid);
Expand Down Expand Up @@ -408,7 +408,7 @@ static void wfx_rsi_save_ap_info() // translation
}
status = scan_results_complete ? callback_status : SL_STATUS_TIMEOUT;
}
return status;
return ;
}

/********************************************************************************************
Expand Down Expand Up @@ -475,7 +475,7 @@ static void wfx_rsi_do_join(void)
status = sl_net_set_credential(id, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey));
if (SL_STATUS_OK != status)
{
return status;
return ;
}

sl_wifi_client_configuration_t ap = { 0 };
Expand Down Expand Up @@ -660,10 +660,8 @@ void wfx_rsi_task(void * arg)
if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED))
{
SILABS_LOG("%s: start SSID scan", __func__);
int x;
sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 };
wfx_wifi_scan_result_t ap;
// TODO: Add scan logic

sl_wifi_advanced_scan_configuration_t advanced_scan_configuration = { 0 };
int32_t status;
advanced_scan_configuration.active_channel_time = ADV_ACTIVE_SCAN_DURATION;
Expand All @@ -672,7 +670,6 @@ void wfx_rsi_task(void * arg)
advanced_scan_configuration.trigger_level_change = ADV_RSSI_TOLERANCE_THRESHOLD;
advanced_scan_configuration.enable_multi_probe = ADV_MULTIPROBE;
status = sl_wifi_set_advanced_scan_configuration(&advanced_scan_configuration);
VERIFY_STATUS_AND_RETURN(status);
/* Terminate with end of scan which is no ap sent back */
wifi_scan_configuration.type = SL_WIFI_SCAN_TYPE_ADV_SCAN;
wifi_scan_configuration.periodic_scan_interval = ADV_SCAN_PERIODICITY;
Expand Down Expand Up @@ -734,32 +731,6 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
* level of indirection - when using LWIP buffers
* see also: int32_t rsi_wlan_send_data_xx(uint8_t *buffer, uint32_t length)
*/
/********************************************************************************************
* @fn void *wfx_rsi_alloc_pkt()
* @brief
* Allocate packet to send data
* @param[in] None
* @return
* None
**********************************************************************************************/
void * wfx_rsi_alloc_pkt(uint16_t data_length)
{
sl_wifi_buffer_t * buffer;
sl_si91x_packet_t * packet;
sl_status_t status = SL_STATUS_OK;

/* Confirm if packet is allocated */

status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + data_length,
SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME);
// VERIFY_STATUS_AND_RETURN(status);
if (packet == NULL)
{
return SL_STATUS_ALLOCATION_FAILED;
}
return (void *) packet;
}

/********************************************************************************************
* @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off)
* @brief
Expand All @@ -777,26 +748,3 @@ void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off)
pkt = (sl_si91x_packet_t *) p;
memcpy(((char *) pkt->data) + off, buf, len);
}

/********************************************************************************************
* @fn int32_t wfx_rsi_send_data(void *p, uint16_t len)
* @brief
* Driver send a data
* @param[in] p:
* @param[in] len:
* @return
* None
**********************************************************************************************/
int32_t wfx_rsi_send_data(void * p, uint16_t len)
{
int32_t status;
sl_wifi_buffer_t * buffer;
buffer = (sl_wifi_buffer_t *) p;

if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME))
{
SILABS_LOG("*ERR*EN-RSI:Send fail");
return ERR_IF;
}
return status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
#ifndef RSI_CONFIG_H
#define RSI_CONFIG_H

#include "ble_config.h"
#include "rsi_wisemcu_hardware_setup.h"
#include "rsi_wlan_defines.h"
#include "sl_wifi_device.h"
#include "ble_config.h"
//#include "rsi_wisemcu_hardware_setup.h"
//#include "rsi_wlan_defines.h"

//! Enable feature
#define RSI_ENABLE 1
//! Disable feature
#define RSI_DISABLE 0

#define SI91X_LISTEN_INTERVAL 0
//#define SI91X_LISTEN_INTERVAL 0

static const sl_wifi_device_configuration_t config = {
.boot_option = LOAD_NWP_FW,
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "event_groups.h"
#include "task.h"

#include "rsi_error.h"
//#include "rsi_error.h"
#include "wfx_host_events.h"
#include "wfx_rsi.h"

Expand Down
56 changes: 41 additions & 15 deletions src/platform/silabs/efr32/wifi/ethernetif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
#include "FreeRTOS.h"
#include "event_groups.h"
#include "task.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "cmsis_os2.h"
#include "sl_board_configuration.h"
#include "sl_net.h"
#include "sl_si91x_driver.h"
#include "sl_si91x_host_interface.h"
#include "sl_si91x_types.h"
#include "sl_wifi_callback_framework.h"
#include "sl_wifi_constants.h"
#include "sl_wifi_types.h"
#ifdef __cplusplus
}
#endif
#endif

#include "wfx_host_events.h"
Expand Down Expand Up @@ -333,10 +348,14 @@ static SemaphoreHandle_t ethout_sem;
******************************************************************************/
static err_t low_level_output(struct netif * netif, struct pbuf * p)
{
void * rsipkt;
sl_wifi_buffer_t * buffer;
sl_si91x_packet_t * packet;
sl_status_t status = SL_STATUS_OK;
struct pbuf * q;
uint16_t framelength;

#ifdef WIFI_DEBUG_ENABLED
SILABS_LOG("LWIP : low_level_output");
#endif
if (xSemaphoreTake(ethout_sem, portMAX_DELAY) != pdTRUE)
{
return ERR_IF;
Expand All @@ -351,14 +370,17 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
return ERR_IF;
}
/* Confirm if packet is allocated */
rsipkt = wfx_rsi_alloc_pkt();
if (!rsipkt)

status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + p->len,
SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME);
VERIFY_STATUS_AND_RETURN(status);
if (packet == NULL)
{
SILABS_LOG("EN-RSI:No buf");
xSemaphoreGive(ethout_sem);
return ERR_IF;
return SL_STATUS_ALLOCATION_FAILED;
}

memset(packet->desc, 0, sizeof(packet->desc));
#ifdef WIFI_DEBUG_ENABLED
uint8_t * b = (uint8_t *) p->payload;
SILABS_LOG("EN-RSI: Out [%02x:%02x:%02x:%02x:%02x:%02x][%02x:%02x:%02x:%02x:%02x:%02x]type=%02x%02x", b[0], b[1], b[2], b[3],
Expand All @@ -367,22 +389,21 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
/* Generate the packet */
for (q = p, framelength = 0; q != NULL; q = q->next)
{
wfx_rsi_pkt_add_data(rsipkt, (uint8_t *) (q->payload), (uint16_t) q->len, framelength);
wfx_rsi_pkt_add_data(packet, (uint8_t *) (q->payload), (uint16_t) q->len, framelength);
framelength += q->len;
}
if (framelength < LWIP_FRAME_ALIGNMENT)
{
/* Add junk data to the end for frame alignment if framelength is less than 60 */
wfx_rsi_pkt_add_data(rsipkt, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - framelength, framelength);
wfx_rsi_pkt_add_data(packet, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - framelength, framelength);
}
#ifdef WIFI_DEBUG_ENABLED
SILABS_LOG("EN-RSI: Sending %d", framelength);
#endif

/* forward the generated packet to RSI to
* send the data over wifi network
*/
if (wfx_rsi_send_data(rsipkt, framelength))
packet->length = p->len & 0xFFF;
packet->command = RSI_SEND_RAW_DATA;
if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, 1000))
{
SILABS_LOG("*ERR*EN-RSI:Send fail");
xSemaphoreGive(ethout_sem);
Expand All @@ -398,7 +419,7 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
}

/*****************************************************************************
* @fn void wfx_host_received_sta_frame_cb(uint8_t *buf, int len)
* @fn void sl_si91x_host_process_data_frame(uint8_t *buf, int len)
* @brief
* host received frame cb
*
Expand All @@ -409,17 +430,22 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
* @return
* None
******************************************************************************/
void wfx_host_received_sta_frame_cb(uint8_t * buf, int len)
sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface, sl_wifi_buffer_t * buffer)
{
void * packet;
struct netif * ifp;
sl_si91x_packet_t * rsi_pkt;
packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL);
rsi_pkt = (sl_si91x_packet_t *) packet;

/* get the network interface for STATION interface,
* and forward the received frame buffer to LWIP
*/
if ((ifp = wfx_get_netif(SL_WFX_STA_INTERFACE)) != (struct netif *) 0)
{
low_level_input(ifp, buf, len);
low_level_input(ifp, rsi_pkt->data, rsi_pkt->length);
}
return SL_STATUS_OK;
}

#endif /* RS911x - with LWIP */
Expand Down
11 changes: 10 additions & 1 deletion src/platform/silabs/efr32/wifi/wfx_host_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s

#include "wfx_msgs.h"

#include "sl_wifi_constants.h"
#include "sl_si91x_types.h"
#include "sl_status.h"

#define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME 1000
/* Wi-Fi events*/
#define SL_WFX_STARTUP_IND_ID 1
#define SL_WFX_CONNECT_IND_ID 2
Expand Down Expand Up @@ -357,7 +362,6 @@ void wfx_ipv6_notify(int got_ip);
sl_status_t wfx_power_save();
#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
/* RSI for LWIP */
void * wfx_rsi_alloc_pkt(void);
void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off);
int32_t wfx_rsi_send_data(void * p, uint16_t len);
#endif /* RS911X_WIFI */
Expand All @@ -369,6 +373,11 @@ void sl_wfx_host_gpio_init(void);
sl_status_t sl_wfx_host_process_event(sl_wfx_generic_message_t * event_payload);
#endif

void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin);
sl_status_t sl_si91x_driver_send_data_packet(sl_si91x_queue_type_t queue_type, sl_wifi_buffer_t * buffer, uint32_t wait_time);
sl_status_t sl_si91x_allocate_command_buffer(sl_wifi_buffer_t ** host_buffer, void ** buffer, uint32_t requested_buffer_size,
uint32_t wait_duration_ms);

void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin);

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 06ab053

Please sign in to comment.