diff --git a/components/board/silabs/config/brd4180b/FreeRTOSConfig.h b/components/board/silabs/config/brd4180b/FreeRTOSConfig.h index ce380374..ae2bf8c9 100644 --- a/components/board/silabs/config/brd4180b/FreeRTOSConfig.h +++ b/components/board/silabs/config/brd4180b/FreeRTOSConfig.h @@ -179,7 +179,6 @@ // Enable Threadsafe Errno support. // Default: 0 #define configUSE_POSIX_ERRNO 0 - //------------- <<< end of configuration section >>> --------------------------- /* Defines needed by FreeRTOS to implement CMSIS RTOS2 API. Do not change! */ diff --git a/components/common/inc/sl_additional_status.h b/components/common/inc/sl_additional_status.h index 32f600ee..4a2bd260 100644 --- a/components/common/inc/sl_additional_status.h +++ b/components/common/inc/sl_additional_status.h @@ -276,6 +276,7 @@ #define SL_STATUS_SI91X_MQTT_ERROR_BAD_USERNAME_PASSWORD \ ((sl_status_t)0x10084) ///< The data in the user name or password is malformed. #define SL_STATUS_SI91X_MQTT_ERROR_NOT_AUTHORIZED ((sl_status_t)0x10085) ///< The Client is not authorized to connect. +#define SL_STATUS_SI91X_SA_QUERY_TIMEOUT ((sl_status_t)0x10086) ///< Disconnection due to SA Query Timeout. #define SL_STATUS_SI91X_DUPLICATE_ENTRY_EXISTS_IN_DNS_SERVER_TABLE \ ((sl_status_t)0x100AF) ///< Duplicate entry exists in DNS server table. #define SL_STATUS_SI91X_NO_MEM_AVAILABLE ((sl_status_t)0x100B1) ///< Memory error: No memory available. diff --git a/components/console/console_minimal_uart_plugin.c b/components/console/console_minimal_uart_plugin.c index 6165d5f4..34994122 100644 --- a/components/console/console_minimal_uart_plugin.c +++ b/components/console/console_minimal_uart_plugin.c @@ -25,9 +25,7 @@ * Macros ******************************************************/ -#ifndef SLI_SI91X_MCU_INTERFACE #define sl_uart_print(a, b) printf(b) -#endif /****************************************************** * Constants @@ -300,7 +298,7 @@ static void print_command_database(const console_database_t *database, const cha sl_uart_print(DEFAULT_UART, command->description); } sl_uart_print(DEFAULT_UART, "\r\n"); - for (int b = 0; b < temp->length; b++) { + for (uint32_t b = 0; b < temp->length; b++) { sl_uart_print(DEFAULT_UART, " - "); sl_uart_print(DEFAULT_UART, temp->entries[b].key); sl_uart_print(DEFAULT_UART, " : "); diff --git a/components/console/variables/console_variables.c b/components/console/variables/console_variables.c index 8c89bf28..c8cd9003 100644 --- a/components/console/variables/console_variables.c +++ b/components/console/variables/console_variables.c @@ -24,6 +24,7 @@ #include #include #include +#include "sl_constants.h" /****************************************************** * Macros @@ -321,6 +322,7 @@ sl_status_t console_variable_set(console_args_t *arguments) sl_status_t console_variable_list(console_args_t *arguments) { + UNUSED_PARAMETER(arguments); if (console_variable_table_size == 0) { printf("No variables available\n"); return SL_STATUS_OK; diff --git a/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c b/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c index c3e84b1f..a3c0626a 100644 --- a/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c +++ b/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c @@ -45,6 +45,14 @@ void fpuInit(void); extern void set_scdc(uint32 Deepsleep); +#ifdef SLI_SI91X_MCU_ENABLE_PSRAM_FEATURE +#include "sl_si91x_psram_config.h" +#ifdef PSRAM_HALF_SLEEP_SUPPORTED +extern void sl_si91x_psram_sleep(void); +extern void sl_si91x_psram_wakeup(void); +#endif +#endif + uint32_t nvic_enable[MAX_NVIC_REGS] = { 0 }; uint8_t nvic_ip_reg[MAX_IPS] = { 0 }; uint8_t scs_shp_reg[MAX_SHP] = { 0 }; @@ -388,7 +396,6 @@ rsi_error_t RSI_PS_EnterDeepSleep(SLEEP_TYPE_T sleepType, uint8_t lf_clk_mode) set_scdc(SL_SCDC_SLEEP); #ifdef SLI_SI91X_MCU_ENABLE_PSRAM_FEATURE -#include "sl_si91x_psram_config.h" #if (defined INTERNAL_LDO_FOR_PSRAM) RSI_PS_M4ssPeriPowerUp(M4SS_PWRGATE_ULP_EFUSE_PERI); if (sleepType == SLEEP_WITH_RETENTION) { diff --git a/components/device/silabs/si91x/mcu/core/common/inc/rsi_debug.h b/components/device/silabs/si91x/mcu/core/common/inc/rsi_debug.h index 12c38eb5..ff694b79 100644 --- a/components/device/silabs/si91x/mcu/core/common/inc/rsi_debug.h +++ b/components/device/silabs/si91x/mcu/core/common/inc/rsi_debug.h @@ -32,6 +32,7 @@ void Board_UARTPutSTR(uint8_t *ptr); uint8_t Board_UARTGetChar(void); void Board_UARTPutChar(uint8_t ch); +#ifndef IOSTREAM_USART #ifdef DEBUG_UART #define DEBUGINIT() Board_Debug_Init() #define DEBUGOUT(...) printf(__VA_ARGS__) @@ -43,6 +44,10 @@ void Board_UARTPutChar(uint8_t ch); #define DEBUGSTR(str) #define DEBUGIN() #endif +#else +#define DEBUGINIT() +#define DEBUGOUT(...) printf(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c b/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c index 355c3e99..f011e7a3 100644 --- a/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c +++ b/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c @@ -21,7 +21,7 @@ #include "rsi_ccp_common.h" void ARM_UART_SignalEvent(uint32_t event); - +extern void cache_uart_rx_data(const char character); #ifdef SLI_SI91X_MCU_CONFIG_RADIO_BOARD_BASE_VER #define M4_UART1_INSTANCE 0U //!Select m4 uart1 for prints #if ((defined(ULP_MODE_EXECUTION)) || (defined(SLI_SI91X_MCU_CONFIG_RADIO_BOARD_VER2))) diff --git a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/component/sl_si70xx.slcc b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/component/sl_si70xx.slcc index b1155cca..3dcbeb41 100644 --- a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/component/sl_si70xx.slcc +++ b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/component/sl_si70xx.slcc @@ -16,3 +16,4 @@ provides: - name: sl_si70xx requires: - name: sl_i2c + - name: sl_gpio diff --git a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/inc/sl_si91x_si70xx.h b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/inc/sl_si91x_si70xx.h index 26c92b19..e7133463 100644 --- a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/inc/sl_si91x_si70xx.h +++ b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/inc/sl_si91x_si70xx.h @@ -52,10 +52,6 @@ extern "C" { #define SI7020_ADDR 0X40 ///< I2C device address for Si7020 #define SI7021_ADDR 0x40 ///< I2C device address for Si7021 #define I2C_BASE I2C2 ///< I2C2 base -#define RX_LEN 2 ///< Read buffer length 2 bytes -#define TX_LEN 2 ///< Write buffer length 2 bytes -#define RD_BUF 6 ///< Read buffer length 6 bytes -#define WR_BUF 1 ///< Write buffer length 1 byte /******************************************************************************* ******************************** ENUMS ************************************ diff --git a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/src/sl_si91x_si70xx.c b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/src/sl_si91x_si70xx.c index d5467626..71d1202e 100644 --- a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/src/sl_si91x_si70xx.c +++ b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/si70xx_sensor/src/sl_si91x_si70xx.c @@ -32,6 +32,10 @@ /******************************************************************************* *************************** Defines / Macros ****************************** ******************************************************************************/ +#define RX_LEN 2 ///< Read buffer length 2 bytes +#define TX_LEN 2 ///< Write buffer length 2 bytes +#define RD_BUF 6 ///< Read buffer length 6 bytes +#define WR_BUF 1 ///< Write buffer length 1 byte /******************************************************************************* ***********************  Local function Prototypes *************************** @@ -105,10 +109,8 @@ sl_status_t sl_si91x_si70xx_start_no_hold_measure_rh_or_temp(sl_i2c_instance_t i uint32_t *data) { sl_status_t status; - uint8_t read_buffer_size = RX_LEN; - uint8_t write_buffer_size = WR_BUF; - uint8_t i2c_read_data[read_buffer_size]; - uint8_t i2c_write_data[write_buffer_size]; + uint8_t i2c_read_data[RX_LEN] = { 0 }; + uint8_t i2c_write_data[WR_BUF] = { 0 }; uint8_t cmd; // Validate invalid parameters if ((i2c_instance >= SL_I2C_LAST) || (type >= SL_LAST_MEASUREMENT)) { @@ -124,18 +126,28 @@ sl_status_t sl_si91x_si70xx_start_no_hold_measure_rh_or_temp(sl_i2c_instance_t i } i2c_write_data[0] = cmd; // Send no hold master mode command to sensor - status = sl_i2c_driver_send_data_blocking(i2c_instance, addr, i2c_write_data, write_buffer_size); + status = sl_i2c_driver_send_data_blocking(i2c_instance, addr, i2c_write_data, WR_BUF); if (status != SL_STATUS_OK) { return status; } wait_till_i2c_gets_idle(I2C_BASE); - // Receive no hold master mode response from sensor - status = sl_i2c_driver_receive_data_blocking(i2c_instance, addr, i2c_read_data, read_buffer_size); - if (status != SL_STATUS_OK) { - return status; + + while (*data == 0) { + // Receive no hold master mode response from sensor + status = sl_i2c_driver_receive_data_blocking(i2c_instance, addr, i2c_read_data, RX_LEN); + if (status != SL_STATUS_OK) { + return status; + } + wait_till_i2c_gets_idle(I2C_BASE); + *data = (uint32_t)((i2c_read_data[0] << 8) | (i2c_read_data[1])); + } + if (i2c_write_data[0] == SL_HUMIDITY_NHM) { + // Convert relative humidity measurement to percent relative humidity + *data = (uint32_t)si70xx_get_percent_relative_humidity(*data); + } else { + // Convert temperature measurement to temperature in degrees Celcius + *data = (int32_t)si70xx_get_celcius_temperature(*data); } - wait_till_i2c_gets_idle(I2C_BASE); - *data = (uint32_t)((i2c_read_data[0] << 8) | (i2c_read_data[1])); return SL_STATUS_OK; } diff --git a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/src/sl_si91x_joystick.c b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/src/sl_si91x_joystick.c index c485866b..2d4d6b0d 100644 --- a/components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/src/sl_si91x_joystick.c +++ b/components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/src/sl_si91x_joystick.c @@ -120,7 +120,7 @@ sl_status_t sl_si91x_joystick_get_position(sl_joystick_state_t state, sl_joystic sample_data = (((float)adc_value / (float)ADC_MAX_OP_VALUE) * vref_value); sample_data = (sample_data * DIVISION_MULTIPLIER); // determine which direction pad was pressed - if ((sample_data <= JOYSTICK_MV_C + JOYSTICK_MV_ERROR)) { + if ((sample_data >= JOYSTICK_MV_C - JOYSTICK_MV_ERROR) && (sample_data <= JOYSTICK_MV_C + JOYSTICK_MV_ERROR)) { joystick_direction = SL_JOYSTICK_C; } else if ((sample_data >= JOYSTICK_MV_N - JOYSTICK_MV_ERROR) && (sample_data <= JOYSTICK_MV_N + JOYSTICK_MV_ERROR)) { diff --git a/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_gpdma.c b/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_gpdma.c index 355e5fbb..f4a31aee 100644 --- a/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_gpdma.c +++ b/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_gpdma.c @@ -24,7 +24,6 @@ extern "C" { #endif /*==============================================*/ -/** /** * @fn RSI_DRIVER_VERSION_M4 RSI_GPDMA_GetVersion(void) * @brief This API is used to get version information of the driver implementation diff --git a/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_sio.c b/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_sio.c index de0cdeef..701cbb63 100644 --- a/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_sio.c +++ b/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_sio.c @@ -1279,7 +1279,6 @@ rsi_error_t RSI_SIO_I2cRead(volatile SIO_Type *pstcSio, uint8_t *u8Data, uint16_t u16Len) { - uint32_t u32Enable = 0, u32Sdat = 0, u32Slav = 0; volatile uint32_t u32RecvDat = 0; int cnt; diff --git a/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_usart.c b/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_usart.c index f9c66d7b..247fd5ee 100644 --- a/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_usart.c +++ b/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_usart.c @@ -33,7 +33,9 @@ #endif #ifdef SL_SI91X_USART_DMA #include "sl_si91x_dma.h" -#define DMA_INSTANCE 0 +sl_dma_init_t dma_init; +#define UART_DMA_INSTANCE 0 +#define ULP_UART_DMA_INSTANCE 1 #endif /***************************************************************************** @@ -404,8 +406,11 @@ int32_t USART_Initialize(ARM_USART_SignalEvent_t cb_event, if (usart->dma_tx || usart->dma_rx) { if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - sl_dma_init_t dma_init; - dma_init.dma_number = DMA_INSTANCE; + if (usart->pREGS == ULP_UART) { + dma_init.dma_number = ULP_UART_DMA_INSTANCE; + } else { + dma_init.dma_number = UART_DMA_INSTANCE; + } if (sl_si91x_dma_init(&dma_init)) { return ARM_DRIVER_ERROR; } @@ -449,7 +454,7 @@ int32_t USART_Uninitialize(USART_RESOURCES *usart, UDMA_RESOURCES *udma) if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { //unintialise dma #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_deinit(DMA_INSTANCE)) { + if (sl_si91x_dma_deinit(dma_init.dma_number)) { return ARM_DRIVER_ERROR; } #else @@ -494,7 +499,7 @@ int32_t USART_PowerControl(ARM_POWER_STATE state, if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_channel_disable(DMA_INSTANCE, usart->dma_tx->channel + 1)) { + if (sl_si91x_dma_channel_disable(dma_init.dma_number, usart->dma_tx->channel + 1)) { return ARM_DRIVER_ERROR; } #else @@ -509,7 +514,7 @@ int32_t USART_PowerControl(ARM_POWER_STATE state, if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_channel_disable(DMA_INSTANCE, usart->dma_rx->channel + 1)) { + if (sl_si91x_dma_channel_disable(dma_init.dma_number, usart->dma_rx->channel + 1)) { return ARM_DRIVER_ERROR; } #else @@ -677,16 +682,16 @@ int32_t USART_Send_Data(const void *data, dma_transfer_tx.signal = chnl_cfg.periAck; //Allocate DMA channel for Tx - status = sl_si91x_dma_allocate_channel(DMA_INSTANCE, &channel, channel_priority); + status = sl_si91x_dma_allocate_channel(dma_init.dma_number, &channel, channel_priority); if (status && (status != SL_STATUS_DMA_CHANNEL_ALLOCATED)) { return ARM_DRIVER_ERROR; } //Register transfer complete and error callback - if (sl_si91x_dma_register_callbacks(DMA_INSTANCE, channel, &usart_tx_callback)) { + if (sl_si91x_dma_register_callbacks(dma_init.dma_number, channel, &usart_tx_callback)) { return ARM_DRIVER_ERROR; } //Configure the channel for DMA transfer - if (sl_si91x_dma_transfer(DMA_INSTANCE, channel, &dma_transfer_tx)) { + if (sl_si91x_dma_transfer(dma_init.dma_number, channel, &dma_transfer_tx)) { return ARM_DRIVER_ERROR; } #else @@ -705,8 +710,8 @@ int32_t USART_Send_Data(const void *data, } #endif #ifdef SL_SI91X_USART_DMA - sl_si91x_dma_channel_enable(DMA_INSTANCE, usart->dma_tx->channel + 1); - sl_si91x_dma_enable(DMA_INSTANCE); + sl_si91x_dma_channel_enable(dma_init.dma_number, usart->dma_tx->channel + 1); + sl_si91x_dma_enable(dma_init.dma_number); #else UDMAx_ChannelEnable(usart->dma_tx->channel, udma, udmaHandle); UDMAx_DMAEnable(udma, udmaHandle); @@ -835,16 +840,16 @@ int32_t USART_Receive_Data(const void *data, dma_transfer_rx.signal = chnl_cfg.periAck; //Allocate DMA channel for Rx - status = sl_si91x_dma_allocate_channel(DMA_INSTANCE, &channel, channel_priority); + status = sl_si91x_dma_allocate_channel(dma_init.dma_number, &channel, channel_priority); if (status && (status != SL_STATUS_DMA_CHANNEL_ALLOCATED)) { return ARM_DRIVER_ERROR; } //Register transfer complete and error callback - if (sl_si91x_dma_register_callbacks(DMA_INSTANCE, channel, &usart_rx_callback)) { + if (sl_si91x_dma_register_callbacks(dma_init.dma_number, channel, &usart_rx_callback)) { return ARM_DRIVER_ERROR; } //Configure the channel for DMA transfer - if (sl_si91x_dma_transfer(DMA_INSTANCE, channel, &dma_transfer_rx)) { + if (sl_si91x_dma_transfer(dma_init.dma_number, channel, &dma_transfer_rx)) { return ARM_DRIVER_ERROR; } #else @@ -863,9 +868,9 @@ int32_t USART_Receive_Data(const void *data, } #endif #ifdef SL_SI91X_USART_DMA - sl_si91x_dma_channel_enable(DMA_INSTANCE, usart->dma_rx->channel + 1); + sl_si91x_dma_channel_enable(dma_init.dma_number, usart->dma_rx->channel + 1); if (usart->sync_mode.en_usart_mode == 0) { - sl_si91x_dma_enable(DMA_INSTANCE); + sl_si91x_dma_enable(dma_init.dma_number); } #else UDMAx_ChannelEnable(usart->dma_rx->channel, udma, udmaHandle); @@ -1086,7 +1091,7 @@ int32_t USART_Control(uint32_t control, if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_channel_disable(DMA_INSTANCE, usart->dma_tx->channel + 1)) { + if (sl_si91x_dma_channel_disable(dma_init.dma_number, usart->dma_tx->channel + 1)) { return ARM_DRIVER_ERROR; } #else @@ -1117,7 +1122,7 @@ int32_t USART_Control(uint32_t control, if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_channel_disable(DMA_INSTANCE, usart->dma_tx->channel + 1)) { + if (sl_si91x_dma_channel_disable(dma_init.dma_number, usart->dma_tx->channel + 1)) { return ARM_DRIVER_ERROR; } #else @@ -1142,7 +1147,7 @@ int32_t USART_Control(uint32_t control, if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_channel_disable(DMA_INSTANCE, usart->dma_tx->channel + 1)) { + if (sl_si91x_dma_channel_disable(dma_init.dma_number, usart->dma_tx->channel + 1)) { return ARM_DRIVER_ERROR; } #else @@ -1155,7 +1160,7 @@ int32_t USART_Control(uint32_t control, if ((usart->pREGS == UART0) || (usart->pREGS == USART0) || (usart->pREGS == UART1) || (usart->pREGS == ULP_UART)) { #ifdef SL_SI91X_USART_DMA - if (sl_si91x_dma_channel_disable(DMA_INSTANCE, usart->dma_rx->channel + 1)) { + if (sl_si91x_dma_channel_disable(dma_init.dma_number, usart->dma_rx->channel + 1)) { return ARM_DRIVER_ERROR; } #else diff --git a/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_efuse.h b/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_efuse.h index 288ff4fe..0308de17 100644 --- a/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_efuse.h +++ b/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_efuse.h @@ -199,4 +199,4 @@ STATIC INLINE rsi_error_t RSI_EFUSE_MemMapReadWord(EFUSE_Type *pstcEfuse, #endif /*__RSI_ROM_EFUSE_H__*/ -/* @} end of RSI_EFUSE_DRIVER */ +/* @} end of RSI_EFUSE_DRIVER */ \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_power_save.h b/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_power_save.h index 657bf5f8..15428b5a 100644 --- a/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_power_save.h +++ b/components/device/silabs/si91x/mcu/drivers/rom_driver/inc/rsi_rom_power_save.h @@ -227,9 +227,14 @@ STATIC INLINE void RSI_PS_RetentionSleepConfig(uint32_t stack_address, { #ifdef SLI_SI917B0 - //!write magic numbers in ulp memory (work around for jtag mode powersave) - (*(volatile uint32_t *)(0x24061F00)) = 0xBEAFBEAF; - (*(volatile uint32_t *)(0x24061FCC)) = 0xBEADBEAD; + //!write magic numbers in retention ram content ulp memory start ,end addresses (work around for jtag mode powersave) + RETEN_RAM_CONTENT_START_LOCATION = 0xBEAFBEAF; + RETEN_RAM_CONTENT_END_LOCATION = 0xBEADBEAD; + + //!remove wakeup flash bit in ulpss ram if flash is not required upon wakuep + if (mode == SL_SI91X_MCU_WAKEUP_PSRAM_MODE) { + RETEN_RAM_CONTENT_WAKEUP_FLASH_BIT_LOCATION = 0x0; + } if ((mode == RSI_WAKEUP_WITH_RETENTION) || (mode == RSI_WAKEUP_WO_RETENTION_WO_ULPSS_RAM)) { RSI_PS_RetentionSleepConfig_bypass(stack_address, jump_cb_address, vector_offset, mode); diff --git a/components/device/silabs/si91x/mcu/drivers/service/iostream/component/iostream_si91x.slcc b/components/device/silabs/si91x/mcu/drivers/service/iostream/component/iostream_si91x.slcc index f8c11367..40100109 100644 --- a/components/device/silabs/si91x/mcu/drivers/service/iostream/component/iostream_si91x.slcc +++ b/components/device/silabs/si91x/mcu/drivers/service/iostream/component/iostream_si91x.slcc @@ -1,5 +1,5 @@ id: iostream_si91x -label: IO Stream +label: IO Stream Si91x package: platform description: > The IO Stream component allows to read/write data using a variety of physical @@ -44,4 +44,5 @@ define: provides: - name: iostream_si91x requires: - - name: sl_usart_iostream \ No newline at end of file + - name: sl_usart_iostream + - name: iostream_retarget_stdio \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/service/nvm3/inc/rsi_wlan_config.h b/components/device/silabs/si91x/mcu/drivers/service/nvm3/inc/rsi_wlan_config.h index 87312718..0b6856b2 100644 --- a/components/device/silabs/si91x/mcu/drivers/service/nvm3/inc/rsi_wlan_config.h +++ b/components/device/silabs/si91x/mcu/drivers/service/nvm3/inc/rsi_wlan_config.h @@ -193,8 +193,7 @@ #define RSI_HT_CAPS_SUPPORT_CH_WIDTH BIT(1) //! HT caps bit map. -#define RSI_HT_CAPS_BIT_MAP \ - (RSI_HT_CAPS_NUM_RX_STBC | RSI_HT_CAPS_SHORT_GI_20MHZ | RSI_HT_CAPS_GREENFIELD_EN | RSI_HT_CAPS_SUPPORT_CH_WIDTH) +#define RSI_HT_CAPS_BIT_MAP (RSI_HT_CAPS_NUM_RX_STBC | RSI_HT_CAPS_SHORT_GI_20MHZ | RSI_HT_CAPS_GREENFIELD_EN) /*=======================================================================*/ //! Scan command parameters diff --git a/components/device/silabs/si91x/mcu/drivers/service/sensorhub/src/sensor_hub.c b/components/device/silabs/si91x/mcu/drivers/service/sensorhub/src/sensor_hub.c index 90ebb40c..3c73e091 100644 --- a/components/device/silabs/si91x/mcu/drivers/service/sensorhub/src/sensor_hub.c +++ b/components/device/silabs/si91x/mcu/drivers/service/sensorhub/src/sensor_hub.c @@ -608,6 +608,7 @@ void NPSS_GPIO_IRQHandler(void) for (uint8_t idx = 0; idx < int_list_map.map_index; idx++) { if (BIT(int_list_map.map_table[idx].intr) == intrStatus) { RSI_NPSSGPIO_ClrIntr(BIT(int_list_map.map_table[idx].intr)); + RSI_NPSSGPIO_IntrMask(BIT(int_list_map.map_table[idx].intr)); osEventFlagsSet(sl_event_group, (0x01 << int_list_map.map_table[idx].sensor_list_index)); } } @@ -630,6 +631,9 @@ sl_status_t sl_si91x_gpio_interrupt_config(uint16_t gpio_pin, sl_gpio_intr_type_ /* Set the direction of the NPSS GPIO */ RSI_NPSSGPIO_SetDir((uint8_t)gpio_pin, NPSS_GPIO_DIR_INPUT); + /* Clear GPIO Rise edge interrupt (it is enabled by default) */ + RSI_NPSSGPIO_ClrIntRiseEdgeEnable(BIT(gpio_pin)); + /*Program interrupt type */ switch (intr_type) { case SL_SH_RISE_EDGE: @@ -695,9 +699,14 @@ void sl_si91x_adc_callback(uint8_t channel_no, uint8_t event) { if (event == SL_INTERNAL_DMA) { bus_intf_info.adc_config.adc_data_ready |= BIT(channel_no); - for (uint8_t idx = 0; idx < int_list_map.map_index; idx++) { - if (int_list_map.map_table[idx].adc_intr_channel - & BIT(channel_no)) { // in non-interrupt mode channel variable in map table will be always zero + for (uint8_t idx = 0; (idx < int_list_map.map_index) && (int_list_map.map_table[idx].adc_intr_channel != 0); + idx++) { + // Checking if we got single channel interrupt, which is required for the respective sensor + if ((IS_SINGLE_CHANNEL(int_list_map.map_table[idx].adc_intr_channel) + && (int_list_map.map_table[idx].adc_intr_channel & bus_intf_info.adc_config.adc_data_ready)) + // Checking if we got multiple channels interrupt, which are required for the respective sensor + || (int_list_map.map_table[idx].adc_intr_channel == bus_intf_info.adc_config.adc_data_ready)) { + bus_intf_info.adc_config.adc_data_ready &= ~(int_list_map.map_table[idx].adc_intr_channel); osEventFlagsSet(sl_event_group, (0x01 << int_list_map.map_table[idx].sensor_list_index)); } } @@ -1057,15 +1066,9 @@ sl_status_t sl_si91x_sensorhub_create_sensor(sl_sensor_id_t sensor_id) case SL_SH_INTERRUPT_MODE: if (sensor_list.sl_sensors_st[sensor_index].config_st->sensor_bus == SL_SH_ADC) { int_list_map.map_table[int_list_map.map_index].adc_intr_channel = - BIT(sensor_list.sl_sensors_st[sensor_index].config_st->channel); + sensor_list.sl_sensors_st[sensor_index].config_st->channel; int_list_map.map_table[int_list_map.map_index].sensor_list_index = sensor_index; int_list_map.map_index++; - uint32_t intr_status = RSI_ADC_ChnlIntrStatus(AUX_ADC_DAC_COMP); - if (intr_status != (int)NULL) { - if (intr_status & BIT(7 + sensor_list.sl_sensors_st[sensor_index].config_st->channel)) { - RSI_ADC_ChnlIntrClr(AUX_ADC_DAC_COMP, sensor_list.sl_sensors_st[sensor_index].config_st->channel); - } - } } else { status = sl_si91x_gpio_interrupt_config(sensor_list.sl_sensors_st[sensor_index].config_st->sampling_intr_req_pin, @@ -1191,8 +1194,11 @@ sl_status_t sl_si91x_sensorhub_start_sensor(sl_sensor_id_t sensor_id) break; case SL_SH_INTERRUPT_MODE: - sl_si91x_gpio_interrupt_start(sensor_list.sl_sensors_st[sensor_index].config_st->sampling_intr_req_pin); - + if (sensor_list.sl_sensors_st[sensor_index].config_st->sensor_bus == SL_SH_ADC) { + NVIC_SetPriority(ADC_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY - 1); + } else { + sl_si91x_gpio_interrupt_start(sensor_list.sl_sensors_st[sensor_index].config_st->sampling_intr_req_pin); + } break; default: //!Post-event to the application as sensor config_st invalid @@ -1557,6 +1563,7 @@ void sl_si91x_sensor_task(void) SL_SENSOR_DATA_READY, sensor_list.sl_sensors_st[i].config_st->sensor_data_ptr, EM_POST_TIME); + RSI_NPSSGPIO_IntrUnMask(BIT(sensor_list.sl_sensors_st[i].config_st->sampling_intr_req_pin)); } break; diff --git a/components/device/silabs/si91x/mcu/drivers/systemlevel/inc/rsi_power_save.h b/components/device/silabs/si91x/mcu/drivers/systemlevel/inc/rsi_power_save.h index 414a2918..19d2f4a6 100644 --- a/components/device/silabs/si91x/mcu/drivers/systemlevel/inc/rsi_power_save.h +++ b/components/device/silabs/si91x/mcu/drivers/systemlevel/inc/rsi_power_save.h @@ -271,8 +271,12 @@ extern "C" { /*Retention sleep configurations*/ #ifdef SLI_SI917B0 -//!BIT(0) refers to flash based sleep wakeup mode ,BIT(4) refers to program flash upon wakeup -#define RSI_WAKEUP_FROM_FLASH_MODE 0x11 + +//!PSRAM only initialized upon wakeup and it branches to PSRAM +#define SL_SI91X_MCU_WAKEUP_PSRAM_MODE 1 + +//!PSRAM and FLASH both will be initialized upon wake up,BIT4 refers to program flash upon wakeup +#define RSI_WAKEUP_FROM_FLASH_MODE (0x1 | (BIT(4))) #else #define RSI_WAKEUP_FROM_FLASH_MODE 1 #endif @@ -281,6 +285,11 @@ extern "C" { #define RSI_WAKEUP_WITH_RETENTION_WO_ULPSS_RAM 4 #define RSI_WAKEUP_WO_RETENTION_WO_ULPSS_RAM 5 +//!Retention ram content ulp memory start ,end addresses for power save retention sleep cases +#define RETEN_RAM_CONTENT_START_LOCATION (*(volatile uint32_t *)(0x24061F00)) +#define RETEN_RAM_CONTENT_END_LOCATION (*(volatile uint32_t *)(0x24061FCC)) +#define RETEN_RAM_CONTENT_WAKEUP_FLASH_BIT_LOCATION (*(volatile uint32_t *)(0x24061FC8)) + #define ICACHE2_ADDR_TRANSLATE_1_REG *(volatile uint32_t *)(0x20280000 + 0x24) // ICACHE address register #define MISC_CFG_SRAM_REDUNDANCY_CTRL *(volatile uint32_t *)(0x46008000 + 0x18) // Misc config register #define MISC_CONFIG_MISC_CTRL1 *(volatile uint32_t *)(0x46008000 + 0x44) // Misc control register diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_dma.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_dma.slcc index a97f2c84..caba66f1 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_dma.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_dma.slcc @@ -21,6 +21,7 @@ provides: define: - name: __STATIC_INLINE value: "static inline" + - name: SL_SI91X_DMA template_contribution: - name: udma_enable value: true \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_gspi.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_gspi.slcc index 02166e08..5ea8a674 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_gspi.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_gspi.slcc @@ -15,9 +15,15 @@ include: - path: "inc" file_list: - path: "sl_si91x_gspi.h" +define: + - name: GSPI_MULTI_SLAVE + - name: GSPI_CONFIG + - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH + - name: SL_SI91X_GSPI_DMA provides: - name: sl_gspi requires: - name: udma_linker_config - name: rsilib_gspi - name: cmsis_gspi + - name: sl_dma diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_i2c.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_i2c.slcc index dbf19e04..353ff0e2 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_i2c.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_i2c.slcc @@ -14,6 +14,9 @@ include: - path: "sl_si91x_i2c.h" provides: - name: sl_i2c +define: + - name: SL_SI91X_DMA + - name: SL_SI91X_I2C_DMA requires: - name: sl_i2c_peripheral - name: sl_gpio_peripheral diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_ssi.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_ssi.slcc index ff473842..b917b854 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_ssi.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_ssi.slcc @@ -17,6 +17,10 @@ include: - path: "sl_si91x_ssi.h" provides: - name: sl_ssi +define: + - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH + - name: SPI_MULTI_SLAVE + - name: SSI_CONFIG requires: - name: udma_linker_config - name: cmsis_spi diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_sysrtc.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_sysrtc.slcc index 24a41622..ee68bd09 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_sysrtc.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_sysrtc.slcc @@ -16,6 +16,9 @@ include: - path: "sl_si91x_sysrtc.h" provides: - name: sl_sysrtc +define: + - name: SI91X_SYSRTC_COUNT + value: "1" requires: - name: udma_linker_config - name: rsilib_sysrtc \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart.slcc index 9164ce15..8a0a6625 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart.slcc @@ -17,5 +17,10 @@ include: - path: "sl_si91x_usart.h" provides: - name: sl_usart +define: + - name: SL_SI91X_USART_DMA + - name: SL_SI91X_DMA + - name: USART_CONFIG requires: - - name: udma_linker_config \ No newline at end of file + - name: udma_linker_config + - name: sl_dma \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart_iostream.slcc b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart_iostream.slcc index 553771cd..ccaa8942 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart_iostream.slcc +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/component/sl_usart_iostream.slcc @@ -8,18 +8,9 @@ quality: production root_path: "components/device/silabs/si91x/mcu/drivers/unified_api" define: - name: IOSTREAM_USART - value: 1 -config_file: - - path: config/sl_si91x_usart_common_config.h - - path: config/sl_si91x_usart_config.h - -source: - - path: "src/sl_si91x_usart.c" -include: - - path: "inc" - file_list: - - path: "sl_si91x_usart.h" + value: 1 provides: - name: sl_usart_iostream requires: - - name: udma_linker_config \ No newline at end of file + - name: udma_linker_config + - name: sl_usart \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps1604m_sqr/sl_si91x_psram_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps1604m_sqr/sl_si91x_psram_config.h index 4e3a47c2..73da97b2 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps1604m_sqr/sl_si91x_psram_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps1604m_sqr/sl_si91x_psram_config.h @@ -32,7 +32,6 @@ // PSRAM clock source selection // <0=> QSPI_ULPREFCLK -// <1=> QSPI_MODELPLLCLK2 // <2=> QSPI_INTFPLLCLK // <3=> QSPI_SOCPLLCLK // <4=> M4_SOCCLKNOSWLSYNCCLKTREEGATED diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqh/sl_si91x_psram_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqh/sl_si91x_psram_config.h index de725b96..caa3c82f 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqh/sl_si91x_psram_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqh/sl_si91x_psram_config.h @@ -32,7 +32,6 @@ // PSRAM clock source selection // <0=> QSPI_ULPREFCLK -// <1=> QSPI_MODELPLLCLK2 // <2=> QSPI_INTFPLLCLK // <3=> QSPI_SOCPLLCLK // <4=> M4_SOCCLKNOSWLSYNCCLKTREEGATED diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqrh/sl_si91x_psram_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqrh/sl_si91x_psram_config.h index bf2cac1d..84d7a047 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqrh/sl_si91x_psram_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/psram_device_config/aps6404l_sqrh/sl_si91x_psram_config.h @@ -32,7 +32,6 @@ // PSRAM clock source selection // <0=> QSPI_ULPREFCLK -// <1=> QSPI_MODELPLLCLK2 // <2=> QSPI_INTFPLLCLK // <3=> QSPI_SOCPLLCLK // <4=> M4_SOCCLKNOSWLSYNCCLKTREEGATED diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_config_timer_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_config_timer_config.h index a8c2ad33..4fd39319 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_config_timer_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_config_timer_config.h @@ -33,24 +33,8 @@ // <<< Use Configuration Wizard in Context Menu >>> -/***************************** CT CONFIG SELECTION ****************************/ - -// Enable Timer-Config -// Default: 1 -#define SET_TIMER_CONFIG 1 - -// Enable WFG-Config -// Default: 0 -#define SET_WFG_CONFIG 0 - -// Enable OCU-Config -// Default: 0 -#define SET_OCU_CONFIG 1 - -/******************************************************************************/ /******************************* CT Configuration **************************/ // CT Configuration -// SET_TIMER_CONFIG // CT Mode // 16-Bit Mode @@ -80,22 +64,6 @@ // Default: 1 #define SL_COUNTER1_PERIODIC_ENABLE_MACRO 1 -// Counter0 : Enable soft reset -// Default: 0 -#define SL_COUNTER0_SOFT_RESET_ENABLE_MACRO 0 - -// Counter1 : Enable soft reset -// Default: 0 -#define SL_COUNTER1_SOFT_RESET_ENABLE_MACRO 0 - -// Counter0 : Enable software trigger -// Default: 0 -#define SL_COUNTER0_TRIGGER_ENABLE_MACRO 0 - -// Counter1 : Enable software trigger -// Default: 0 -#define SL_COUNTER1_TRIGGER_ENABLE_MACRO 0 - // Counter0 : Enable sync trigger // Default: 1 #define SL_COUNTER0_SYNC_TRIGGER_ENABLE_MACRO 1 @@ -104,145 +72,23 @@ // Default: 1 #define SL_COUNTER1_SYNC_TRIGGER_ENABLE_MACRO 1 -// Counter0 : Enable buffer -// Default: 0 -#define SL_COUNTER0_BUFFER_ENABLE_MACRO 0 - -// Counter1 : Enable buffer -// Default: 0 -#define SL_COUNTER1_BUFFER_ENABLE_MACRO 0 - -// // -/******************************************************************************/ -/***************************** OCU Configuration ******************************/ -// OCU Configuration -// SET_OCU_CONFIG - -// Counter0 : Enable OCU Output -// Default: 1 -#define SL_COUNTER0_OCU_OUTPUT_ENABLE_MACRO 0 - -// Counter0 : Enable OCU DMA -// Default: 0 -#define SL_COUNTER0_OCU_DMA_ENABLE_MACRO 0 - -// Counter0 : Enable OCU 8-bit mode -// Default: 0 -#define SL_COUNTER0_OCU_8BIT_MODE_ENABLE_MACRO 0 - -// Counter0 : Enable OCU sync -// Default: 1 -#define SL_COUNTER0_OCU_SYNC_ENABLE_MACRO 1 - -// Counter1 : Enable OCU Output -// Default: 1 -#define SL_COUNTER1_OCU_OUTPUT_ENABLE_MACRO 1 - -// Counter1 : Enable OCU DMA -// Default: 0 -#define SL_COUNTER1_OCU_DMA_ENABLE_MACRO 0 - -// Counter1 : Enable OCU 8-bit mode -// Default: 0 -#define SL_COUNTER1_OCU_8BIT_ENABLE_MACRO 0 - -// Counter1 : Enable OCU sync -// Default: 1 -#define SL_COUNTER1_OCU_SYNC_ENABLE_MACRO 1 - -// OCU output-0 : Toggle HIGH -// Default: 1 -#define SL_OCU_OUTPUT0_TOGGLE_HIGH_MACRO 1 - -// OCU output-0 : Toggle LOW -// Default: 1 -#define SL_OCU_OUTPUT0_TOGGLE_LOW_MACRO 1 - -// OCU output-1 : Toggle HIGH -// Default: 1 -#define SL_OCU_OUTPUT1_TOGGLE_HIGH_MACRO 1 - -// OCU output-1 : Toggle LOW -// Default: 1 -#define SL_OCU_OUTPUT1_TOGGLE_LOW_MACRO 1 - -// -// -/******************************************************************************/ -/***************************** WFG Configuration ******************************/ - -// WFG Configuration -// SET_WFG_CONFIG - -// Select output-0 toggle-LOW -// Default: 0 -#define SL_OUTPUT0_TOGGLE0_MACRO 0 - -// Select output-0 toggle-HIGH -// Default: 0 -#define SL_OUTPUT0_TOGGLE1_MACRO 0 - -// Toggle counter-0 peak -// Default: 0 -#define SL_TOGGLE_COUNTER0_PEAK_MACRO 0 - -// Select output-1 toggle-LOW -// Default: 0 -#define SL_OUTPUT1_TOGGLE0_MACRO 0 - -// Select output-1 toggle-HIGH -// Default: 0 -#define SL_OUTPUT1_TOGGLE1_MACRO 0 - -// Toggle counter-1 peak -// Default: 0 -#define SL_TOGGLE_COUNTER1_PEAK_MACRO 0 - -// -// - -/******************************************************************************/ // <<< end of configuration section >>> sl_config_timer_config_t ct_configuration = { .is_counter_mode_32bit_enabled = SL_CT_MODE_32BIT_ENABLE_MACRO, - .is_counter0_soft_reset_enabled = SL_COUNTER0_SOFT_RESET_ENABLE_MACRO, + .is_counter0_soft_reset_enabled = false, .is_counter0_periodic_enabled = SL_COUNTER0_PERIODIC_ENABLE_MACRO, - .is_counter0_trigger_enabled = SL_COUNTER0_TRIGGER_ENABLE_MACRO, + .is_counter0_trigger_enabled = false, .is_counter0_sync_trigger_enabled = SL_COUNTER0_SYNC_TRIGGER_ENABLE_MACRO, - .is_counter0_buffer_enabled = SL_COUNTER0_BUFFER_ENABLE_MACRO, - .is_counter1_soft_reset_enabled = SL_COUNTER1_SOFT_RESET_ENABLE_MACRO, + .is_counter0_buffer_enabled = false, + .is_counter1_soft_reset_enabled = false, .is_counter1_periodic_enabled = SL_COUNTER1_PERIODIC_ENABLE_MACRO, - .is_counter1_trigger_enabled = SL_COUNTER1_TRIGGER_ENABLE_MACRO, + .is_counter1_trigger_enabled = false, .is_counter1_sync_trigger_enabled = SL_COUNTER1_SYNC_TRIGGER_ENABLE_MACRO, - .is_counter1_buffer_enabled = SL_COUNTER1_BUFFER_ENABLE_MACRO, + .is_counter1_buffer_enabled = false, .counter0_direction = SL_COUNTER0_DIRECTION_MACRO, .counter1_direction = SL_COUNTER1_DIRECTION_MACRO, }; -sl_config_timer_wfg_config_t ct_wfg_configuration = { - .output0_tgl0_sel = SL_OUTPUT0_TOGGLE0_MACRO, - .output0_tgl1_sel = SL_OUTPUT0_TOGGLE1_MACRO, - .tgl_cnt0_peak = SL_TOGGLE_COUNTER0_PEAK_MACRO, - .output1_tgl0_sel = SL_OUTPUT1_TOGGLE0_MACRO, - .output1_tgl1_sel = SL_OUTPUT1_TOGGLE1_MACRO, - .tgl_cnt1_peak = SL_TOGGLE_COUNTER1_PEAK_MACRO, -}; - -sl_config_timer_ocu_config_t ct_ocu_configuration = { - .is_counter0_ocu_output_enabled = SL_COUNTER0_OCU_OUTPUT_ENABLE_MACRO, - .is_counter0_ocu_dma_enabled = SL_COUNTER0_OCU_DMA_ENABLE_MACRO, - .is_counter0_ocu_8bit_mode_enabled = SL_COUNTER0_OCU_8BIT_MODE_ENABLE_MACRO, - .is_counter0_ocu_sync_enabled = SL_COUNTER0_OCU_SYNC_ENABLE_MACRO, - .is_counter1_ocu_output_enabled = SL_COUNTER1_OCU_OUTPUT_ENABLE_MACRO, - .is_counter1_ocu_dma_enabled = SL_COUNTER1_OCU_DMA_ENABLE_MACRO, - .is_counter1_ocu_mode_enabled = SL_COUNTER1_OCU_8BIT_ENABLE_MACRO, - .is_counter1_ocu_sync_enabled = SL_COUNTER1_OCU_SYNC_ENABLE_MACRO, - .is_counter0_toggle_output_high_enabled = SL_OCU_OUTPUT0_TOGGLE_HIGH_MACRO, - .is_counter0_toggle_output_low_enabled = SL_OCU_OUTPUT0_TOGGLE_LOW_MACRO, - .is_counter1_toggle_output_high_enabled = SL_OCU_OUTPUT1_TOGGLE_HIGH_MACRO, - .is_counter1_toggle_output_low_enabled = SL_OCU_OUTPUT1_TOGGLE_LOW_MACRO, -}; - #endif /* SL_SI91X_CONFIG_TIMER_CONFIG_H */ diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_sio_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_sio_config.h index 7f46ae85..6cc385c8 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_sio_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_sio_config.h @@ -160,36 +160,12 @@ extern "C" { #define SL_SIO_UART_STOP_BIT SL_SIO_UART_STOP_BIT_1 // -// I2C Configuration - -// Sample Rate <100000-4000000> -// Default: 100000 #define SL_SIO_I2C_SAMPLE_RATE 100000 -// SCL Channel -// Channel 0 -// Channel 1 -// Channel 2 -// Channel 3 -// Channel 4 -// Channel 5 -// Channel 6 -// Channel 7 -// Default: SL_SIO_CH_6 #define SL_SIO_I2C_SCL_CHANNEL SL_SIO_CH_6 -// SDA Channel -// Channel 0 -// Channel 1 -// Channel 2 -// Channel 3 -// Channel 4 -// Channel 5 -// Channel 6 -// Channel 7 -// Default: SL_SIO_CH_7 #define SL_SIO_I2C_SDA_CHANNEL SL_SIO_CH_7 -// + #ifdef __cplusplus } #endif diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_ulp_timer_inst_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_ulp_timer_inst_config.h index a429d8e5..d3ad70bc 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_ulp_timer_inst_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_ulp_timer_inst_config.h @@ -68,7 +68,6 @@ // 32KHZ_XTAL // 32MHZ_RC (auto select) // 20MHZ_RO -// SOC_CLK // Selection of the Clock source #define SL_ULP_TIMER_CLK_INPUT_SOURCE SL_ULP_TIMER_32MHZ_RC_CLK //default timer clock input source is ref clock diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_watchdog_timer_config.h b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_watchdog_timer_config.h index aa346a11..43a68ce2 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_watchdog_timer_config.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/config/sl_si91x_watchdog_timer_config.h @@ -43,24 +43,7 @@ // XTAL CLK // Selection of Low Frequency FSM CLK #define SL_LOW_FREQ_FSM_CLK_SRC KHZ_RC_CLK_SEL - -#define FSM_20MHZ_RO 1 -#define FSM_32MHZ_RC 2 -#define FSM_40MHZ_XTAL 4 -// High Frequency ClocK -// 20MHZ RO CLK -// 32MHZ RC CLK -// 40MHZ XTAL CLK -// Selection of High Frequency FSM CLK -#define SL_HIGH_FREQ_FSM_CLK_SRC FSM_32MHZ_RC - -#define RO_32KHZ_CLOCK 1 -#define MCU_FSM_CLOCK 2 -// BG PMU Clock -// RO 32KHZ CLK -// MCU FSM CLK -// Selection of BG PMU Clock Source -#define SL_BG_PMU_CLOCK_SRC RO_32KHZ_CLOCK +#define FSM_32MHZ_RC 2 // // Watchdog Timer Configuration @@ -164,8 +147,8 @@ #if defined(SL_LOW_FREQ_FSM_CLK_SRC) watchdog_timer_clock_config_t sl_watchdog_timer_clk_config_handle = { .low_freq_fsm_clock_src = SL_LOW_FREQ_FSM_CLK_SRC, - .high_freq_fsm_clock_src = SL_HIGH_FREQ_FSM_CLK_SRC, - .bg_pmu_clock_source = SL_BG_PMU_CLOCK_SRC, + .high_freq_fsm_clock_src = FSM_32MHZ_RC, + .bg_pmu_clock_source = RO_32KHZ_CLOCK, }; #endif // SL_LOW_FREQ_FSM_CLK_SRC diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_driver_gpio.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_driver_gpio.h index 4b4e7eb3..6b308956 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_driver_gpio.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_driver_gpio.h @@ -49,23 +49,20 @@ extern "C" { ******************************************************************************/ #define GPIO_MAX_OUTPUT_VALUE 1 // GPIO output maximum value #define MAX_GROUP_INT 2 // Maximum number of group interrupts -#define GPIO_PORT_MAX_VALUE 4 // Maximum number of GPIO ports +#define GPIO_PORT_MAX_VALUE 5 // Maximum number of GPIO ports #define MAX_UULP_INT 5 // Maximum number of UULP interrupts #define ULP_MAX_MODE 10 // Maximum ULP mode #define GPIO_MAX_INTR_VALUE 8 // Maximum number of M4 GPIO pin interrupts #define PORTD_PIN_MAX_VALUE 8 // Port D maximum(0-8) number of GPIO pins #define PORTE_PIN_MAX_VALUE 11 // Port E maximum(0-11) number of GPIO pins +#define PORTF_PIN_MAX_VALUE 5 // Port F maximum(0-4) number of GPIO pins #define MAX_ULP_INTR 8 // Maximum number of ULP interrupts #define MAX_MODE 15 // Maximum M4 GPIO mode #define PORT_PIN_MAX_VALUE 15 // GPIO pin maximum(0-15) value for ports #define GPIO_FLAGS_MAX_VALUE 0x0F // GPIO flags maximum value -#define PORTA 0 // Initializing port A value -#define PORTB 1 // Initializing port B value -#define PORTC 2 // Initializing port C value -#define PORTD 3 // Initializing port D value -#define PORTE 4 // Initializing port E value +#define PORTF 5 // Initializing port F value /******************************************************************************* ******************************** ENUMS ************************************ @@ -86,23 +83,23 @@ typedef void (*sl_gpio_irq_callback_t)(uint32_t flag); ***************************** PROTOTYPES ********************************** ******************************************************************************/ -/******************************************************************************* +/*******************************************************************************/ /** * @brief Clear one or more pending GPIO interrupts. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] flags - Bitwise logic OR of GPIO interrupt sources to clear. * @return returns status 0 * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_clear_interrupts(uint32_t flags) { @@ -131,11 +128,11 @@ STATIC __INLINE sl_status_t sl_gpio_driver_clear_interrupts(uint32_t flags) * @return The following values are returned: * - * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_gpio_driver_configure_interrupt(sl_gpio_t *gpio, uint32_t int_no, @@ -161,11 +158,11 @@ sl_status_t sl_gpio_driver_configure_interrupt(sl_gpio_t *gpio, * @return The following values are returned: * - * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_gpio_driver_set_pin_mode(sl_gpio_t *gpio, sl_gpio_mode_t mode, uint32_t output_value); @@ -186,36 +183,51 @@ sl_status_t sl_gpio_driver_set_pin_mode(sl_gpio_t *gpio, sl_gpio_mode_t mode, ui * Use corresponding pad receiver API for corresponding GPIO instance. * \ref sl_gpio_driver_set_pin_mode(); * @param[in] gpio - Pointer to the structure of type \ref sl_gpio_t - * @param[in] mode - The desired pin mode. + * @param[out] mode - The desired pin mode. * @return The following values are returned: * - * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_gpio_driver_get_pin_mode(sl_gpio_t *gpio, sl_gpio_mode_t *mode); -/******************************************************************************* +/*******************************************************************************/ /** * @brief Initialization of GPIO driver. - * @param[in] void * @return returns status 0, * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_gpio_driver_init(void); -/******************************************************************************* +/*******************************************************************************/ /** * @brief De-Initialization of GPIO driver. - * @param[in] void * @return returns status 0, * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_gpio_driver_deinit(void); +/*******************************************************************************/ /** + * @brief Unregister GPIO driver. + * + * @param[in] gpio_instance - Instances of type \ref sl_si91x_gpio_instances_t + * @param[in] gpio_intr - GPIO interrupts of type \ref sl_si91x_gpio_intr_t + * @param[in] flag - GPIO interrupt flag + * @return The following values are returned: + * - + * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument + * - + * \ref SL_STATUS _OK (0X000) - Success + * + ******************************************************************************/ +sl_status_t sl_gpio_driver_unregister(sl_si91x_gpio_instances_t gpio_instance, + sl_si91x_gpio_intr_t gpio_intr, + uint8_t flag); + /***************************************************************************/ /** * @brief Set a single pin in GPIO configuration register to 1. * @pre Pre-conditions: @@ -231,20 +243,20 @@ sl_status_t sl_gpio_driver_deinit(void); * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode(); -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction(); -* + * * @param[in] gpio - Pointer to the structure of type \ref sl_gpio_t - * @return The following values are returned: + * @return The following values are returned: * - * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_set_pin(sl_gpio_t *gpio) { @@ -257,19 +269,19 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_pin(sl_gpio_t *gpio) // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -280,7 +292,7 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_pin(sl_gpio_t *gpio) } /***************************************************************************/ /** - * @brief Set a single pin in GPIO configuration register to 0. + * @brief Clear a single pin in GPIO configuration register to 0. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() @@ -294,20 +306,20 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_pin(sl_gpio_t *gpio) * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(); for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode(); -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction(); -* + * * @param[in] gpio - Pointer to the structure of type \ref sl_gpio_t * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_clear_pin(sl_gpio_t *gpio) { @@ -320,19 +332,19 @@ STATIC __INLINE sl_status_t sl_gpio_driver_clear_pin(sl_gpio_t *gpio) // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -357,20 +369,20 @@ STATIC __INLINE sl_status_t sl_gpio_driver_clear_pin(sl_gpio_t *gpio) * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] gpio - Pointer to the structure of type \ref sl_gpio_t * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_toggle_pin(sl_gpio_t *gpio) { @@ -383,19 +395,19 @@ STATIC __INLINE sl_status_t sl_gpio_driver_toggle_pin(sl_gpio_t *gpio) // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -406,7 +418,7 @@ STATIC __INLINE sl_status_t sl_gpio_driver_toggle_pin(sl_gpio_t *gpio) } /***************************************************************************/ /** - * @brief Read the pad value for a single pin in a GPIO port. + * @brief Read the pin value for a single pin in a GPIO port. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() @@ -420,20 +432,21 @@ STATIC __INLINE sl_status_t sl_gpio_driver_toggle_pin(sl_gpio_t *gpio) * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] gpio - Pointer to the structure of type \ref sl_gpio_t + * @param[out] pin_value - Gets the gpio pin value * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_get_pin(sl_gpio_t *gpio, uint8_t *pin_value) { @@ -446,19 +459,19 @@ STATIC __INLINE sl_status_t sl_gpio_driver_get_pin(sl_gpio_t *gpio, uint8_t *pin // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -483,11 +496,11 @@ STATIC __INLINE sl_status_t sl_gpio_driver_get_pin(sl_gpio_t *gpio, uint8_t *pin * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode(); -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction(); -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 @@ -495,9 +508,9 @@ STATIC __INLINE sl_status_t sl_gpio_driver_get_pin(sl_gpio_t *gpio, uint8_t *pin * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_set_port(sl_gpio_port_t port, uint32_t pins) { @@ -525,11 +538,11 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_port(sl_gpio_port_t port, uint32_ * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 @@ -537,9 +550,9 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_port(sl_gpio_port_t port, uint32_ * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_clear_port(sl_gpio_port_t port, uint32_t pins) { @@ -553,7 +566,7 @@ STATIC __INLINE sl_status_t sl_gpio_driver_clear_port(sl_gpio_port_t port, uint3 } /***************************************************************************/ /** - * Get the current setting for a GPIO configuration register. + * @brief Get the current setting for a GPIO configuration register. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() @@ -567,20 +580,21 @@ STATIC __INLINE sl_status_t sl_gpio_driver_clear_port(sl_gpio_port_t port, uint3 * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 + * @param[out] port_value - Gets the gpio port value * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_get_port_output(sl_gpio_port_t port, uint32_t *port_value) { @@ -608,17 +622,17 @@ STATIC __INLINE sl_status_t sl_gpio_driver_get_port_output(sl_gpio_port_t port, * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] gpio - Pointer to the structure of type \ref sl_gpio_t * @return The GPIO pin value * '0' - Output -*- + * - * '1' - Input -* + * ******************************************************************************/ STATIC __INLINE uint8_t sl_gpio_driver_get_pin_output(sl_gpio_t *gpio) { @@ -632,19 +646,19 @@ STATIC __INLINE uint8_t sl_gpio_driver_get_pin_output(sl_gpio_t *gpio) // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -654,24 +668,24 @@ STATIC __INLINE uint8_t sl_gpio_driver_get_pin_output(sl_gpio_t *gpio) return pin_output; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Set GPIO port configuration register. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance -*- + * - * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode(); -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction(); -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 @@ -680,9 +694,9 @@ STATIC __INLINE uint8_t sl_gpio_driver_get_pin_output(sl_gpio_t *gpio) * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_set_port_output_value(sl_gpio_port_t port, uint32_t val, uint32_t mask) { @@ -695,25 +709,25 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_port_output_value(sl_gpio_port_t return SL_STATUS_OK; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Set slewrate for pins on a GPIO port. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -* + * * @param[in] port - The GPIO port to configure. * @param[in] slewrate - The slewrate to configure for pins on this GPIO port. * @param[in] slewrate_alt - The slewrate to configure for pins using alternate modes on this GPIO port. * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_set_slew_rate(sl_gpio_port_t port, uint32_t slewrate, uint32_t slewrate_alt) { @@ -726,24 +740,24 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_slew_rate(sl_gpio_port_t port, ui return SL_STATUS_OK; } -/******************************************************************************* - * @brief Read the pad values for GPIO port. +/*******************************************************************************/ /** + * @brief Read the port value for GPIO. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance -*- + * - * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 @@ -761,24 +775,24 @@ STATIC __INLINE uint32_t sl_gpio_driver_get_port_input(sl_gpio_port_t port) return port_input; } -/******************************************************************************* - * @brief Toggle pins in GPIO port register. +/*******************************************************************************/ /** + * @brief Toggle port in GPIO port register. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance -*- + * - * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 @@ -786,9 +800,9 @@ STATIC __INLINE uint32_t sl_gpio_driver_get_port_input(sl_gpio_port_t port) * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_toggle_port_output(sl_gpio_port_t port, uint32_t pins) { @@ -801,24 +815,24 @@ STATIC __INLINE sl_status_t sl_gpio_driver_toggle_port_output(sl_gpio_port_t por return SL_STATUS_OK; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Enable one or more GPIO interrupts. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] flags - GPIO interrupt sources to enable. * @return returns status 0 * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_enable_interrupts(uint32_t flags) { @@ -826,24 +840,24 @@ STATIC __INLINE sl_status_t sl_gpio_driver_enable_interrupts(uint32_t flags) return SL_STATUS_OK; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Disable one or more GPIO interrupts. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] flags - GPIO interrupt sources to disable. * @return returns status 0 * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_disable_interrupts(uint32_t flags) { @@ -851,24 +865,24 @@ STATIC __INLINE sl_status_t sl_gpio_driver_disable_interrupts(uint32_t flags) return SL_STATUS_OK; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Set one or more pending GPIO interrupts from SW. * @pre Pre-conditions: * - Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] flags - GPIO interrupt sources to set to pending. * @return returns status 0 * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ STATIC __INLINE sl_status_t sl_gpio_driver_set_interrupts(uint32_t flags) { @@ -876,20 +890,19 @@ STATIC __INLINE sl_status_t sl_gpio_driver_set_interrupts(uint32_t flags) return SL_STATUS_OK; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Get pending GPIO interrupts. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* - * @param[in] None + * * @return GPIO interrupt sources pending. ******************************************************************************/ STATIC __INLINE uint32_t sl_gpio_driver_get_pending_interrupts(void) @@ -899,20 +912,19 @@ STATIC __INLINE uint32_t sl_gpio_driver_get_pending_interrupts(void) return status; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Get enabled GPIO interrupts. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* - * @param[in] None + * * @return Enabled GPIO interrupt sources. ******************************************************************************/ STATIC __INLINE uint32_t sl_gpio_driver_get_enabled_interrupts(void) @@ -922,20 +934,19 @@ STATIC __INLINE uint32_t sl_gpio_driver_get_enabled_interrupts(void) return status; } -/******************************************************************************* +/*******************************************************************************/ /** * @brief Get enabled and pending GPIO interrupt flags. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -*- + * - * \ref sl_gpio_driver_set_pin_mode() -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -* - * @param[in] None + * * @return returns enabled GPIO pending interrupts. ******************************************************************************/ STATIC __INLINE uint32_t sl_gpio_driver_get_enabled_pending_interrupts(void) diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_calendar.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_calendar.h index 70b257e4..3c28456d 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_calendar.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_calendar.h @@ -149,11 +149,9 @@ sl_status_t sl_si91x_calendar_set_date_time(sl_calendar_datetime_config_t *confi /***************************************************************************/ /** * Get the date and time of an existing Calendar RTC. * @pre Pre-conditions: - *- \ref sl_si91x_calendar_set_configuration -* \ref sl_si91x_calendar_init -* - * \ref sl_si91x_calendar_set_date_time -* + * - \ref sl_si91x_calendar_set_configuration + * - \ref sl_si91x_calendar_init + * - \ref sl_si91x_calendar_set_date_time * * @param[in] config (sl_calendar_datetime_config_t) Pointer to the Date Configuration Structure * @return status 0 if successful, else error code as follow diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_config_timer.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_config_timer.h index e595bc41..15cbd1be 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_config_timer.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_config_timer.h @@ -716,9 +716,9 @@ sl_status_t sl_si91x_config_timer_set_wfg_compare_values(sl_counter_number_t cou /***************************************************************************/ /** * De-initialize config-timer by disabling its clock. -* * @param[in] none * @return none +* @note Unregisters the callback and disables all config timer interrupts. *******************************************************************************/ void sl_si91x_config_timer_deinit(void); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_driver_gpio.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_driver_gpio.h index 6bbf7d3d..6a4ac304 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_driver_gpio.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_driver_gpio.h @@ -68,15 +68,15 @@ extern "C" { * ULP instance has total 12 pins. * @param[in] direction - pin direction of type \ref sl_si91x_gpio_direction_t * '0' - Output -*- + * - * '1' - Input -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_pin_direction(uint8_t port, uint8_t pin, sl_si91x_gpio_direction_t direction); @@ -91,11 +91,11 @@ sl_status_t sl_si91x_gpio_driver_set_pin_direction(uint8_t port, uint8_t pin, sl * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance * Use corresponding pad receiver API for corresponding GPIO instance. -*- + * - * \ref sl_si91x_gpio_driver_set_pin_direction() -*- + * - * \ref sl_si91x_gpio_driver_get_pin_direction() -* + * * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 * ULP instance - PORT 4 @@ -105,9 +105,9 @@ sl_status_t sl_si91x_gpio_driver_set_pin_direction(uint8_t port, uint8_t pin, sl * ULP instance has total 12 pins. * @return Returns the direction of the pin. * '0' - Output -*- + * - * '1' - Input -* + * ******************************************************************************/ uint8_t sl_si91x_gpio_driver_get_pin_direction(uint8_t port, uint8_t pin); @@ -115,16 +115,16 @@ uint8_t sl_si91x_gpio_driver_get_pin_direction(uint8_t port, uint8_t pin); * @brief Enable the receiver bit in the PAD configuration register. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -* - * @param[in] gpio_num - GPIO number to be use. + * + * @param[in] gpio_num - GPIO pin number to be use. * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_enable_pad_receiver(uint8_t gpio_num); @@ -132,16 +132,16 @@ sl_status_t sl_si91x_gpio_driver_enable_pad_receiver(uint8_t gpio_num); * @brief Disable the receiver bit in the PAD configuration register. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_pad_selection(), for HP instance -* - * @param[in] gpio_num - GPIO number to be use. + * + * @param[in] gpio_num - GPIO pin number to be use. * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_disable_pad_receiver(uint8_t gpio_num); @@ -149,14 +149,14 @@ sl_status_t sl_si91x_gpio_driver_disable_pad_receiver(uint8_t gpio_num); * @brief Select the pad(0 to 21). * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @param[in] gpio_padnum - PAD number to be use * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_enable_pad_selection(uint8_t gpio_padnum); @@ -168,24 +168,24 @@ sl_status_t sl_si91x_gpio_driver_enable_pad_selection(uint8_t gpio_padnum); * - \ref sl_si91x_gpio_driver_enable_clock * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_pad_receiver() - * @param[in] gpio_num - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] strength - Drive strength selector(E1,E2) of type * \ref sl_si91x_gpio_driver_strength_select_t * possible values are * 0, for two_milli_amps (E1=0,E2=0) -*- + * - * 1, for four_milli_amps (E1=0,E2=1) -*- + * - * 2, for eight_milli_amps (E1=1,E2=0) -*- + * - * 3, for twelve_milli_amps(E1=1,E2=1) -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_pad_driver_strength(uint8_t gpio_num, sl_si91x_gpio_driver_strength_select_t strength); @@ -198,24 +198,24 @@ sl_status_t sl_si91x_gpio_driver_select_pad_driver_strength(uint8_t gpio_num, * - \ref sl_si91x_gpio_driver_enable_clock * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_pad_receiver() - * @param[in] gpio_num - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] disable_state - driver disable state of type * \ref sl_si91x_gpio_driver_disable_state_t * possible values are * 0, for HiZ (P1=0,P2=0) -*- + * - * 1, for Pull-up (P1=0,P2=1) -*- + * - * 2, for Pull-down (P1=1,P2=0) -*- + * - * 3, for Repeater (P1=1,P2=1) -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_pad_driver_disable_state(uint8_t gpio_num, sl_si91x_gpio_driver_disable_state_t disable_state); @@ -228,29 +228,29 @@ sl_status_t sl_si91x_gpio_driver_select_pad_driver_disable_state(uint8_t gpio_nu * Choose AND, all the selected pins are necessary for group interrupt generation * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock, for HP instance -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance -* + * * Use corresponding pad receiver API for corresponding GPIO instance. * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_configure_ulp_group_interrupt(), for HP instance -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_configure_ulp_group_interrupt, for ULP instance -* + * * Use corresponding group interrupt configuration API for corresponding GPIO instance. * @param[in] port - The port to associate with the pin. * HP instance - PORT 0,1,2,3 @@ -260,16 +260,16 @@ sl_status_t sl_si91x_gpio_driver_select_pad_driver_disable_state(uint8_t gpio_nu * @param[in] and_or - AND/OR of GPIO group interrupts of type * \ref sl_si91x_gpio_and_or_t * '0' - AND -*- + * - * '1' - OR -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* -*******************************************************************************/ + * + *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_group_interrupt_and_or(uint8_t port, sl_si91x_group_interrupt_t group_interrupt, sl_si91x_gpio_and_or_t and_or); @@ -293,9 +293,9 @@ sl_status_t sl_si91x_gpio_driver_select_group_interrupt_and_or(uint8_t port, * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_clear_group_interrupt(sl_si91x_group_interrupt_t group_interrupt); @@ -326,9 +326,9 @@ sl_status_t sl_si91x_gpio_driver_clear_group_interrupt(sl_si91x_group_interrupt_ * \ref sl_si91x_group_interrupt_t * @return returns the group interrupt status register * 1, when interrupt is enabled -*- + * - * 0, when interrupt is disabled -* + * ******************************************************************************/ uint32_t sl_si91x_gpio_driver_get_group_interrupt_status(uint8_t port, sl_si91x_group_interrupt_t group_interrupt); @@ -342,15 +342,15 @@ uint32_t sl_si91x_gpio_driver_get_group_interrupt_status(uint8_t port, sl_si91x_ * @param[in] flags - GPIO group interrupt wake up flag of type * \ref sl_si91x_gpio_wakeup_t * '1' - enable -*- + * - * '0' - disable -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_group_interrupt_wakeup(uint8_t port, sl_si91x_group_interrupt_t group_interrupt, @@ -377,9 +377,9 @@ sl_status_t sl_si91x_gpio_driver_select_group_interrupt_wakeup(uint8_t port, * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_configure_group_interrupt(sl_si91x_gpio_group_interrupt_config_t *configuration, sl_gpio_irq_callback_t gpio_callback); @@ -415,9 +415,9 @@ sl_status_t sl_si91x_gpio_driver_configure_group_interrupt(sl_si91x_gpio_group_i * ULP instance has total 12 pins. * @return returns group interrupt polarity * 1, when GPIO pin status is '1' -*- + * - * 0, when GPIO pin status is '0' -* + * ******************************************************************************/ uint8_t sl_si91x_gpio_driver_get_group_interrupt_polarity(sl_si91x_group_interrupt_t group_interrupt, uint8_t port, @@ -455,15 +455,15 @@ uint8_t sl_si91x_gpio_driver_get_group_interrupt_polarity(sl_si91x_group_interru * @param[in] polarity - polarity of GPIO group interrupt of type * \ref sl_si91x_gpio_polarity_t * 1, group interrupt gets generated when GPIO pin status is '1' -*- + * - * 0, group interrupt gets generated when GPIO pin status is '0' -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_group_interrupt_polarity(sl_si91x_group_interrupt_t group_interrupt, uint8_t port, @@ -497,9 +497,9 @@ sl_status_t sl_si91x_gpio_driver_set_group_interrupt_polarity(sl_si91x_group_int * \ref sl_si91x_group_interrupt_t * @return returns group interrupt level_edge * 1, for Edge -*- + * - * 0, for Level -* + * ******************************************************************************/ uint8_t sl_si91x_gpio_driver_get_group_interrupt_level_edge(uint8_t port, sl_si91x_group_interrupt_t group_interrupt); @@ -531,15 +531,15 @@ uint8_t sl_si91x_gpio_driver_get_group_interrupt_level_edge(uint8_t port, sl_si9 * @param[in] level_edge - GPIO level edge group interrupt of type * \ref sl_si91x_gpio_level_edge_t * 1, for Edge -*- + * - * 0, for Level -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_group_interrupt_level_edge(uint8_t port, sl_si91x_group_interrupt_t group_interrupt, @@ -573,9 +573,9 @@ sl_status_t sl_si91x_gpio_driver_set_group_interrupt_level_edge(uint8_t port, * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_unmask_group_interrupt(uint8_t port, sl_si91x_group_interrupt_t group_interrupt); @@ -602,9 +602,9 @@ sl_status_t sl_si91x_gpio_driver_unmask_group_interrupt(uint8_t port, sl_si91x_g * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_mask_group_interrupt(uint8_t port, sl_si91x_group_interrupt_t group_interrupt); @@ -613,15 +613,15 @@ sl_status_t sl_si91x_gpio_driver_mask_group_interrupt(uint8_t port, sl_si91x_gro * @param[in] clock - Selects M4 clock or ULP clock of type * \ref sl_si91x_gpio_select_clock_t * 0, for M4 GPIO CLK -*- + * - * 1, for ULP GPIO CLK -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_disable_clock(sl_si91x_gpio_select_clock_t clock); @@ -630,15 +630,15 @@ sl_status_t sl_si91x_gpio_driver_disable_clock(sl_si91x_gpio_select_clock_t cloc * @param[in] clock - Selects M4 clock or ULP clock of type * \ref sl_si91x_gpio_select_clock_t * 0, for M4 GPIO CLK -*- + * - * 1, for ULP GPIO CLK -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_enable_clock(sl_si91x_gpio_select_clock_t clock); @@ -674,9 +674,9 @@ sl_status_t sl_si91x_gpio_driver_enable_clock(sl_si91x_gpio_select_clock_t clock * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_enable_group_interrupt(sl_si91x_group_interrupt_t group_interrupt, uint8_t port, @@ -686,33 +686,33 @@ sl_status_t sl_si91x_gpio_driver_enable_group_interrupt(sl_si91x_group_interrupt * @brief Disable the group interrupts. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock, for HP instance -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_pad_receiver(), for HP instance -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver(), for ULP instance -* + * * Use corresponding pad receiver API for corresponding GPIO instance. -* + * * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_configure_ulp_group_interrupt(), for HP instance -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_configure_ulp_group_interrupt, for ULP instance -* + * * Use corresponding group interrupt configuration API for corresponding GPIO instance. * @param[in] group_interrupt - GPIO group interrupt number of type * \ref sl_si91x_group_interrupt_t @@ -726,9 +726,9 @@ sl_status_t sl_si91x_gpio_driver_enable_group_interrupt(sl_si91x_group_interrupt * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_disable_group_interrupt(sl_si91x_group_interrupt_t group_interrupt, uint8_t port, @@ -738,21 +738,21 @@ sl_status_t sl_si91x_gpio_driver_disable_group_interrupt(sl_si91x_group_interrup * @brief Select the slew rate. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* - * @param[in] gpio_num - GPIO number to be use + * + * @param[in] gpio_num - GPIO pin number to be use * @param[in] slew_rate - slew rate of type \ref sl_si91x_gpio_slew_rate_t * '0' - Slow -*- + * - * '1' - Fast -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_ulp_pad_slew_rate(uint8_t gpio_num, sl_si91x_gpio_slew_rate_t slew_rate); @@ -760,26 +760,26 @@ sl_status_t sl_si91x_gpio_driver_select_ulp_pad_slew_rate(uint8_t gpio_num, sl_s * @brief Select the drive strength. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* - * @param[in] gpio_padnum - GPIO number to be use + * + * @param[in] gpio_num - GPIO pin number to be use * @param[in] strength - Drive strength selector(E1,E2) of type * \ref sl_si91x_gpio_driver_strength_select_t * 0, for two_milli_amps (E1=0,E2=0) -*- + * - * 1, for four_milli_amps (E1=0,E2=1) -*- + * - * 2, for eight_milli_amps (E1=1,E2=0) -*- + * - * 3, for twelve_milli_amps(E1=1,E2=1) -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_ulp_pad_driver_strength(uint8_t gpio_num, sl_si91x_gpio_driver_strength_select_t strength); @@ -788,26 +788,26 @@ sl_status_t sl_si91x_gpio_driver_select_ulp_pad_driver_strength(uint8_t gpio_num * @brief Select the driver-disabled state control. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* - * @param[in] gpio_num - GPIO number to be use + * + * @param[in] gpio_num - GPIO pin number to be use * @param[in] disable_state - driver disable state of type * \ref sl_si91x_gpio_driver_disable_state_t * 0, for HiZ (P1=0,P2=0) -*- + * - * 1, for Pull up (P1=0,P2=1) -*- + * - * 2, for Pull down (P1=1,P2=0) -*- + * - * 3, for Repeater (P1=1,P2=1) -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_ulp_pad_driver_disable_state( uint8_t gpio_num, @@ -817,14 +817,14 @@ sl_status_t sl_si91x_gpio_driver_select_ulp_pad_driver_disable_state( * @brief Disable the receiver bit for ULP. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* - * @param[in] gpio_num - GPIO number to be used + * + * @param[in] gpio_num - GPIO pin number to be used * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_disable_ulp_pad_receiver(uint8_t gpio_num); @@ -832,14 +832,14 @@ sl_status_t sl_si91x_gpio_driver_disable_ulp_pad_receiver(uint8_t gpio_num); * @brief Enable the receiver bit for ULP. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* - * @param[in] gpio_num - GPIO number to be used + * + * @param[in] gpio_num - GPIO pin number to be used * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_enable_ulp_pad_receiver(uint8_t gpio_num); @@ -847,16 +847,16 @@ sl_status_t sl_si91x_gpio_driver_enable_ulp_pad_receiver(uint8_t gpio_num); * @brief Configure the MCU ULP GPIO pin interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* + * * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] int_no - The interrupt number to trigger. * @param[in] flags - Interrupt configuration flags of type * \ref sl_si91x_gpio_interrupt_config_flag_t @@ -865,11 +865,11 @@ sl_status_t sl_si91x_gpio_driver_enable_ulp_pad_receiver(uint8_t gpio_num); * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_configure_ulp_pin_interrupt(uint8_t int_no, sl_si91x_gpio_interrupt_config_flag_t flags, @@ -880,18 +880,18 @@ sl_status_t sl_si91x_gpio_driver_configure_ulp_pin_interrupt(uint8_t int_no, * @brief Set the NPSS GPIO pin MUX(mode). * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -*- + * - * \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @param[in] pin - NPSS GPIO pin number(0...4) of type * \ref sl_si91x_uulp_npss_mode_t * @param[in] mode - NPSS GPIO MUX value * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_pin_mux(uint8_t pin, sl_si91x_uulp_npss_mode_t mode); @@ -899,20 +899,20 @@ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_pin_mux(uint8_t pin, sl_si91x_uul * @brief Enable/disable NPSS GPIO receiver. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @param[in] pin - is NPSS GPIO pin number (0...4) * @param[in] receiver - is enable/disable NPSS GPIO receiver of type * \ref sl_si91x_gpio_receiver_t * '1' - Enable -*- + * - * '0' - Disable -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_uulp_npss_receiver(uint8_t pin, sl_si91x_gpio_receiver_t receiver); @@ -920,26 +920,26 @@ sl_status_t sl_si91x_gpio_driver_select_uulp_npss_receiver(uint8_t pin, sl_si91x * @brief Set the direction of the NPSS GPIO. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @param[in] pin - is NPSS GPIO pin number (0...4) * @param[in] direction - is direction value (Input / Output) of type * \ref sl_si91x_gpio_direction_t * '1' - Input Direction -*- + * - * '0' - Output Direction -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_direction(uint8_t pin, sl_si91x_gpio_direction_t direction); @@ -947,16 +947,16 @@ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_direction(uint8_t pin, sl_si91x_g * @brief Get the direction of the NPSS GPIO. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @param[in] pin - is NPSS GPIO pin number(0...4) * @return returns the GPIO pin direction * - 1, Input Direction @@ -968,29 +968,29 @@ uint8_t sl_si91x_gpio_driver_get_uulp_npss_direction(uint8_t pin); * @brief Control the NPSS GPIO pin value. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @param[in] pin - is NPSS GPIO pin number (0...4) of type * \ref sl_si91x_gpio_pin_value_t * @param[in] pin_value - is NPSS GPIO pin value * '0' - Output -*- + * - * '1' - Input -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_pin_value(uint8_t pin, sl_si91x_gpio_pin_value_t pin_value); @@ -998,25 +998,25 @@ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_pin_value(uint8_t pin, sl_si91x_g * @brief Get the NPSS GPIO pin value. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_value() -* + * * @param[in] pin - is NPSS GPIO pin number (0...4) * @return returns the pin logical state of pin * '0' - Output -*- + * - * '1' - Input -* + * ******************************************************************************/ uint8_t sl_si91x_gpio_driver_get_uulp_npss_pin(uint8_t pin); @@ -1024,20 +1024,20 @@ uint8_t sl_si91x_gpio_driver_get_uulp_npss_pin(uint8_t pin); * @brief Select the NPSS GPIO polarity. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @param[in] pin - is NPSS GPIO pin number (0...4) * @param[in] polarity - GPIO polarity * \ref sl_si91x_gpio_polarity_t * '1' - High -*- + * - * '0' - Low -* + * * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_select_uulp_npss_polarity(uint8_t pin, sl_si91x_gpio_polarity_t polarity); @@ -1045,14 +1045,14 @@ sl_status_t sl_si91x_gpio_driver_select_uulp_npss_polarity(uint8_t pin, sl_si91x * @brief Set the UULP NPSS GPIO to wake up interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @param[in] npssgpio_interrupt - OR'ed values of the NPSS GPIO interrupts * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_wakeup_interrupt(uint8_t npssgpio_interrupt); @@ -1060,14 +1060,14 @@ sl_status_t sl_si91x_gpio_driver_set_uulp_npss_wakeup_interrupt(uint8_t npssgpio * @brief Clear the UULP NPSS GPIO to wake up interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @param[in] npssgpio_interrupt - OR'ed values of the NPSS GPIO interrupts * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_clear_uulp_npss_wakeup_interrupt(uint8_t npssgpio_interrupt); @@ -1075,26 +1075,26 @@ sl_status_t sl_si91x_gpio_driver_clear_uulp_npss_wakeup_interrupt(uint8_t npssgp * @brief Mask the NPSS GPIO interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_set_uulp_pad_configuration() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @param[in] npssgpio_interrupt - OR'ed values of the NPSS GPIO interrupts * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_mask_uulp_npss_interrupt(uint8_t npssgpio_interrupt); @@ -1102,26 +1102,26 @@ sl_status_t sl_si91x_gpio_driver_mask_uulp_npss_interrupt(uint8_t npssgpio_inter * @brief Unmask the NPSS GPIO interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_set_uulp_pad_configuration() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @param[in] npssgpio_interrupt - OR'ed values of the NPSS GPIO interrupts * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_unmask_uulp_npss_interrupt(uint8_t npssgpio_interrupt); @@ -1129,29 +1129,29 @@ sl_status_t sl_si91x_gpio_driver_unmask_uulp_npss_interrupt(uint8_t npssgpio_int * @brief Clear the NPSS GPIO interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_set_uulp_pad_configuration() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_configure_uulp_interrupt() -* + * * @param[in] npssgpio_interrupt - OR'ed values of the NPSS GPIO interrupts * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_clear_uulp_interrupt(uint8_t npssgpio_interrupt); @@ -1159,28 +1159,28 @@ sl_status_t sl_si91x_gpio_driver_clear_uulp_interrupt(uint8_t npssgpio_interrupt * @brief Get the NPSS GPIO interrupt status. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_set_uulp_pad_configuration() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_configure_uulp_interrupt() -* + * * @param[in] None * @return returns the UULP INTR status. * 1, interrupt has been raised -*- + * - * 0, interrupt is masked or not raised -* + * ******************************************************************************/ uint8_t sl_si91x_gpio_driver_get_uulp_interrupt_status(void); @@ -1188,25 +1188,25 @@ uint8_t sl_si91x_gpio_driver_get_uulp_interrupt_status(void); * @brief Get the ULP GPIO interrupt status. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* + * * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_configure_ulp_pin_interrupt() -* + * * @param[in] flags : ULP GPIO interrupt sources status. * @return returns the ULP INTR status. * 1, interrupt has been raised -*- + * - * 0, interrupt is masked or not raised -* + * ******************************************************************************/ uint32_t sl_si91x_gpio_driver_get_ulp_interrupt_status(uint32_t flags); @@ -1214,26 +1214,26 @@ uint32_t sl_si91x_gpio_driver_get_ulp_interrupt_status(uint32_t flags); * @brief Clear one or more pending ULP GPIO interrupts. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* + * * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_configure_ulp_pin_interrupt() -* + * * @param[in] flags : ULP GPIO interrupt sources to clear. * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_clear_ulp_interrupt(uint32_t flags); @@ -1241,27 +1241,27 @@ sl_status_t sl_si91x_gpio_driver_clear_ulp_interrupt(uint32_t flags); * @brief Clear the ULP group interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* + * * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * \ref sl_si91x_gpio_driver_configure_ulp_group_interrupt() -* + * * Use corresponding group interrupt configuration API for corresponding GPIO instance. * @param[in] group_interrupt - Group interrupt number of type * \ref sl_si91x_group_interrupt_t * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_clear_ulp_group_interrupt(sl_si91x_group_interrupt_t group_interrupt); @@ -1269,19 +1269,19 @@ sl_status_t sl_si91x_gpio_driver_clear_ulp_group_interrupt(sl_si91x_group_interr * @brief Configure the UULP GPIO pin interrupt. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_set_uulp_pad_configuration() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @param[in] flags - Interrupt configuration flags of type * \ref sl_si91x_gpio_interrupt_config_flag_t * @param[in] npssgpio_interrupt - NPSS GPIO input number (0 to 4) @@ -1289,11 +1289,11 @@ sl_status_t sl_si91x_gpio_driver_clear_ulp_group_interrupt(sl_si91x_group_interr * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_configure_uulp_interrupt(sl_si91x_gpio_interrupt_config_flag_t flags, uint8_t npssgpio_interrupt, @@ -1303,25 +1303,25 @@ sl_status_t sl_si91x_gpio_driver_configure_uulp_interrupt(sl_si91x_gpio_interrup * @brief Configure ULP GPIO group interrupts. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_ulp_pad_receiver() -* + * * @pre Pre-conditions: * - \ref sl_gpio_driver_set_pin_mode() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_pin_direction() -* + * * @param[in] configuration - configuration pointer to * \ref sl_si91x_gpio_group_interrupt_config_t structure * @param[in] gpio_callback - IRQ function pointer * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_configure_ulp_group_interrupt(sl_si91x_gpio_group_interrupt_config_t *configuration, sl_gpio_irq_callback_t gpio_callback); @@ -1330,23 +1330,23 @@ sl_status_t sl_si91x_gpio_driver_configure_ulp_group_interrupt(sl_si91x_gpio_gro * @brief Toggle the UULP pin. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_select_uulp_npss_receiver() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_pin_mux() -* + * * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_set_uulp_npss_direction() -* + * * @param[in] pin - UULP pin number to toggle * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is invalid argument -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * ******************************************************************************/ sl_status_t sl_si91x_gpio_driver_toggle_uulp_npss_pin(uint8_t pin); @@ -1354,14 +1354,14 @@ sl_status_t sl_si91x_gpio_driver_toggle_uulp_npss_pin(uint8_t pin); * @brief Indicate UULP GPIO PAD configuration. * @pre Pre-conditions: * - \ref sl_si91x_gpio_driver_enable_clock() -* + * * @param[in] pad_config : PAD configuration pointer to \ref uulp_pad_config_t structure * @return returns status 0 if successful, * else error code as follow. * \ref SL_STATUS_NULL_POINTER (0x0022) - The parameter is null pointer -*- + * - * \ref SL_STATUS _OK (0X000) - Success -* + * *******************************************************************************/ sl_status_t sl_si91x_gpio_driver_set_uulp_pad_configuration(uulp_pad_config_t *pad_config); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram.h index afa2d0ae..d9d68683 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram.h @@ -94,8 +94,10 @@ typedef enum { PSRAM_MAX_SEC_SEGMENT_REACH } sl_psram_return_type_t; +#if PSRAM_BURST_LEN_TOGGLE_SUPPORTED /// Wrap burst size enum typedef enum { _WRAP16, _WRAP32, _WRAP64, _WRAP512 } sl_psram_burst_size_type_t; +#endif /// PSRAM DMA status enum typedef enum { DMA_NONE, DMA_DONE, DMA_FAIL } sl_psram_dma_status_type_t; @@ -125,7 +127,7 @@ typedef struct { } sl_psram_id_type_t; /// PSRAM configuration handle structure -typedef struct { +struct sl_psram_info_type_t { PSRAMDevType deviceName; ///< PSRAM Device enum value sl_psram_id_type_t deviceID; ///< Device ID struct uint32_t devDensity; ///< Device Density in bits @@ -135,46 +137,46 @@ typedef struct { spi_config_t spi_config; ///< SPI Config for QSPI interface uint16_t defaultBurstWrapSize; ///< Default burst wrap size uint16_t toggleBurstWrapSize; ///< Toggle Burst Wrap size -} sl_psram_info_type_t; +}; /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */ /// PSRAM status context -typedef struct { +struct PSRAMStatusType { PSRAMStateType state; ///< PSRAM state enum value uint8_t interfaceMode; ///< QSPI Interface mode for PSRAM bool secureModeEnable; ///< uint8_t secureSegmentNumber; ///< uint16_t burstSize; ///< Burst Size -} PSRAMStatusType; +}; /// PSRAM pin configuration structure -typedef struct { +struct PSRAMPinConfigType { uint8_t port; uint8_t pin; uint8_t mux; uint8_t pad; -} PSRAMPinConfigType; +}; /// DMA transfer status enum typedef enum { IDLE, TX_RUNNING, RX_RUNNING, FAILED } XferStatusType; /// DMA transfer context -typedef struct { +struct xferContextType { XferStatusType xferStatus; uint32_t xferNextAddress; void *xferNextSourceAddress; uint32_t xferRemLength; uint8_t xferHsize; sl_psram_dma_status_type_t *done; -} xferContextType; +}; -typedef struct { +struct PSRAMSecureSegmentType { uint8_t segmentEnable; uint32_t lowerBoundary; uint32_t higherBoundary; #define MAX_SEC_SEGMENTS 4 -} PSRAMSecureSegmentType; +}; /** @endcond */ @@ -372,9 +374,9 @@ sl_psram_return_type_t sl_si91x_psram_enable_encry_decry(uint16_t keySize); - QPI Mode (Quad IO) - Operation frequency Source - Interface PLL Clock - - ULP Reference clock - - Modem PLL clock - - SoC PLL clock + - ULP Reference Clock + - SoC PLL Clock + - M4_SOCCLKNOSWLSYNCCLKTREEGATED Clock # Linker configurations {#psram_linker_configuration} The text segment, data segment, bss, heap and stack can be placed in PSRAM by diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram_handle.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram_handle.h index 1b8c1c4f..7938a98f 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram_handle.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_psram_handle.h @@ -23,7 +23,7 @@ #include "sl_si91x_psram_pin_config.h" // Handle for PSRAM Operations -extern sl_psram_info_type_t PSRAM_Device; +extern struct sl_psram_info_type_t PSRAM_Device; #define PSRAM_GPIO_PIN_SET_52_TO_57 1 #define PSRAM_GPIO_PIN_SET_0_TO_5 2 @@ -199,4 +199,4 @@ extern sl_psram_info_type_t PSRAM_Device; #endif -#endif //__SL_SI91X_PSRAM_HANDLE_H_ \ No newline at end of file +#endif //__SL_SI91X_PSRAM_HANDLE_H_ diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sio.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sio.h index 5f64b98a..4d521d64 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sio.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sio.h @@ -215,6 +215,13 @@ sl_status_t sl_si91x_sio_init(void); ******************************************************************************/ sl_status_t sl_si91x_sio_spi_init(sl_sio_spi_config_t *configuration); +/******************************************************************************* + * @brief This API is used to De-initialize SIO module + * @param[in] none + * @return none + ******************************************************************************/ +void sl_si91x_sio_deinit(void); + /***************************************************************************/ /** * @brief Initialize SIO SPI pins and clock * @param[in] sio_spi_init : Pointer to the structure of type \ref sl_sio_spi_t diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h index 962c3bcb..45237ff8 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ssi.h @@ -153,7 +153,10 @@ sl_status_t sl_si91x_ssi_deinit(sl_ssi_handle_t ssi_handle); /***************************************************************************/ /** * Control the SPI interface. * - * @param[in] ssi handle, pointer to control config structure. + * @param[in] ssi_handle, pointer to ssi instance handle. + * @param[in] control_configuration, pointer to control config structure. + * @param[in] slave_number, SSI chip_select/slave_number, this parameter is + * not using in this function definition. * @return status 0 if successful, else error code as follow. * - SL_STATUS_INVALID_PARAMETER (0x0021) - invalid parameters * - SL_STATUS_OK (0x0000) - Success diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sysrtc.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sysrtc.h index 2e77a2a5..93380c7d 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sysrtc.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_sysrtc.h @@ -446,9 +446,9 @@ sl_sysrtc_version_t sl_si91x_sysrtc_get_version(void); /***************************************************************************/ /** * De-initializes SYSRTC by disabling its clock. -* * @param[in] none * @return none +* @note Unregisters the SYSRTC callback and disables all interrupts. *******************************************************************************/ void sl_si91x_sysrtc_deinit(void); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ulp_timer.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ulp_timer.h index 26e6990b..969e2d94 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ulp_timer.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_ulp_timer.h @@ -93,7 +93,6 @@ typedef enum { ULP_TIMER_32KHZ_XTAL_CLK_SRC, ///< 32 kHz xtal clock input source ULP_TIMER_32MHZ_RC_CLK_SRC, ///< 32 MHz rc clock input source ULP_TIMER_20MHZ_RO_CLK_SRC, ///< 20 MHz ro clock input source - ULP_TIMER_ULP_SOC_CLK_SRC, ///< SoC clock input source ULP_TIMER_ULP_CLK_SRC_LAST, ///< Last member of enum for validation } ulp_timer_clk_input_source_t; @@ -398,13 +397,13 @@ sl_status_t sl_si91x_ulp_timer_init(ulp_timer_clk_src_config_t *timer_clk_ptr); /***************************************************************************/ /** * De-Initializes ULP-Timer clock by disabling the peripheral clock. - * * @pre Pre-conditions: * - \ref sl_si91x_ulp_timer_init * - \ref sl_si91x_ulp_timer_unregister_timeout_callback * * @param[in] none * @return none + * @note Unregisters the callbacks of all timer instances *******************************************************************************/ void sl_si91x_ulp_timer_deinit(void); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h index 657c0ca7..5833f4d8 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h @@ -58,9 +58,8 @@ extern "C" { * @param data (void *)extra parameter for user application ******************************************************************************/ typedef void (*watchdog_timer_callback_t)(void); - -typedef AON_CLK_T low_freq_fsm_clock_t; ///< Renaming low frequency fsm-clock type enum typedef FSM_CLK_T high_freq_fsm_clock_t; ///< Renaming high frequency fsm-clock type enum +typedef AON_CLK_T low_freq_fsm_clock_t; ///< Renaming low frequency fsm-clock type enum /// @brief Enumeration to represent bg-pmu clock sources typedef enum { @@ -157,9 +156,9 @@ void sl_si91x_watchdog_init_timer(void); sl_status_t sl_si91x_watchdog_configure_clock(watchdog_timer_clock_config_t *timer_clk_config_ptr); /***************************************************************************/ /** - * Configure clock sources & timer parameters like interrupt time(WDT restart time), + * Configure timer parameters like interrupt time(WDT restart time), * system reset time & window time (another time stamp for WDT restart, if required). - * Also un-masks its interrupt & sets RTC clock time-period. + * Also un-masks its interrupt. * * @pre Pre-conditions: * - \ref sl_si91x_watchdog_init_timer @@ -283,13 +282,12 @@ boolean_t sl_si91x_watchdog_get_timer_system_reset_status(void); /***************************************************************************/ /** * De-initialize Watchdog timer, mask its interrupt, de-power and disable timer. - * * @pre Pre-conditions: * - \ref sl_si91x_watchdog_init_timer * - \ref sl_si91x_watchdog_unregister_timeout_callback - * * @param[in] none * @return none + * @note Unregisters the timer callback. *******************************************************************************/ void sl_si91x_watchdog_deinit_timer(void); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_adc.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_adc.c index 6cbfbd04..546af764 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_adc.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_adc.c @@ -38,34 +38,31 @@ #define ICACHE2_ADDR_TRANSLATE_1_REG *(volatile uint32_t *)(0x20280000 + 0x24) #define MISC_CFG_SRAM_REDUNDANCY_CTRL *(volatile uint32_t *)(0x46008000 + 0x18) #define MISC_CONFIG_MISC_CTRL1 *(volatile uint32_t *)(0x46008000 + 0x44) -#define SOC_PLL_LIMIT 120000000 // Limit for soc pll clock. -#define MAX_SAMPLE_RATE 5000000 // Maximum sampling rate 5 Msps. -#define MINIMUM_NUMBER_OF_CHANNEL 1 // Minimum number of channel enable -#define MAXIMUM_NUMBER_OF_CHANNEL 16 // Maximum number of channel enable -#define MAXIMUM_CHANNEL_ID 16 // Maximum adc dma support channel id. -#define ADC_PING_ENABLE 1 // Enable the ADC ping buffer. -#define ADC_PONG_ENABLE 1 // Enable the ADC pong buffer. -#define ADC_PING_DISABLE 0 // Disable the ADC Ping buffer. -#define INVALID_POWER_STATE 2 // Invalid power state. -#define MAXIMUM_PING_LENGTH 1024 // Maximum ping length -#define MAXIMUM_PONG_LENGTH 1024 // Maximum pong length -#ifdef ULP_MODE_EXECUTION -#define START_PING_ADDR 0x24060000 // Starting ping address -#define END_PONG_ADDR 0x24061B00 // Ending pong address -#else -#define MAXIMUM_PING_ADDR 0x2F400 // Maximum ping address -#define MAXIMUM_PONG_ADDR 0x2F7FF // Maximum pong address -#endif -#define MAX_THRS_VAL 7 // Maximum threshold value -#define MAX_POS_IN_SEL 31 // Maximum positive input selection -#define MAX_NEG_IN_SEL 15 // Maximum negative input selection -#define MINIMUM_SAMPLING_LENGTH 1 // Minimum sampling length -#define MAXIMUM_SAMPLING_LENGTH 1023 // Maximum sampling length -#define MINIMUM_REF_VOLT 1.8 // Maximum reference voltage -#define MAXMIMUM_REF_VOLT 3.6 // Maximum reference voltage -#define ADC_RELEASE_VERSION 0 // ADC Release version -#define ADC_SQA_VERSION 0 // ADC SQA version -#define ADC_DEV_VERSION 1 // ADC Developer version +#define SOC_PLL_LIMIT 120000000 // Limit for soc pll clock. +#define MAX_SAMPLE_RATE 5000000 // Maximum sampling rate 5 Msps. +#define MINIMUM_NUMBER_OF_CHANNEL 1 // Minimum number of channel enable +#define MAXIMUM_NUMBER_OF_CHANNEL 16 // Maximum number of channel enable +#define MAXIMUM_CHANNEL_ID 16 // Maximum adc dma support channel id. +#define ADC_PING_ENABLE 1 // Enable the ADC ping buffer. +#define ADC_PONG_ENABLE 1 // Enable the ADC pong buffer. +#define ADC_PING_DISABLE 0 // Disable the ADC Ping buffer. +#define INVALID_POWER_STATE 2 // Invalid power state. +#define MAXIMUM_PING_LENGTH 1024 // Maximum ping length +#define MAXIMUM_PONG_LENGTH 1024 // Maximum pong length +#define START_PING_ADDR 0x24060000 // Starting ping address +#define END_PONG_ADDR 0x24061B00 // Ending pong address +#define MAXIMUM_PING_ADDR 0x2F400 // Maximum ping address +#define MAXIMUM_PONG_ADDR 0x2F7FF // Maximum pong address +#define MAX_THRS_VAL 7 // Maximum threshold value +#define MAX_POS_IN_SEL 31 // Maximum positive input selection +#define MAX_NEG_IN_SEL 15 // Maximum negative input selection +#define MINIMUM_SAMPLING_LENGTH 1 // Minimum sampling length +#define MAXIMUM_SAMPLING_LENGTH 1023 // Maximum sampling length +#define MINIMUM_REF_VOLT 1.8 // Maximum reference voltage +#define MAXMIMUM_REF_VOLT 3.6 // Maximum reference voltage +#define ADC_RELEASE_VERSION 0 // ADC Release version +#define ADC_SQA_VERSION 0 // ADC SQA version +#define ADC_DEV_VERSION 1 // ADC Developer version /******************************************************************************* *************************** LOCAL VARIABLES ******************************* @@ -1034,19 +1031,19 @@ static sl_status_t validate_adc_channel_parameters(sl_adc_channel_config_t *adc_ break; } // Validate ping and pong address maximum value. -#ifdef ULP_MODE_EXECUTION - if ((adc_channel_config->chnl_ping_address[0] < ((uint32_t)START_PING_ADDR)) - || (adc_channel_config->chnl_pong_address[0] > ((uint32_t)END_PONG_ADDR))) { - status = SL_STATUS_INVALID_PARAMETER; - break; - } -#else - if ((adc_channel_config->chnl_ping_address[0] > ((uint32_t)MAXIMUM_PING_ADDR)) - || (adc_channel_config->chnl_pong_address[0] > ((uint32_t)MAXIMUM_PONG_ADDR))) { - status = SL_STATUS_INVALID_PARAMETER; - break; + if (adc_channel_config->chnl_ping_address[0] >= START_PING_ADDR) { + if ((adc_channel_config->chnl_ping_address[0] < ((uint32_t)START_PING_ADDR)) + || (adc_channel_config->chnl_pong_address[0] > ((uint32_t)END_PONG_ADDR))) { + status = SL_STATUS_INVALID_PARAMETER; + break; + } + } else { + if ((adc_channel_config->chnl_ping_address[0] > ((uint32_t)MAXIMUM_PING_ADDR)) + || (adc_channel_config->chnl_pong_address[0] > ((uint32_t)MAXIMUM_PONG_ADDR))) { + status = SL_STATUS_INVALID_PARAMETER; + break; + } } -#endif // Returns SL_STATUS_OK if the parameter are appropriate status = SL_STATUS_OK; } while (false); @@ -1112,19 +1109,19 @@ static sl_status_t validate_adc_internal_parameters(sl_adc_internal_config_t *ad break; } // Validate ping and pong address maximum value. -#ifdef ULP_MODE_EXECUTION - if ((adc_internal_config->ping_addr[0] < ((uint32_t)START_PING_ADDR)) - || (adc_internal_config->pong_addr[0] > ((uint32_t)END_PONG_ADDR))) { - status = SL_STATUS_INVALID_PARAMETER; - break; - } -#else - if ((adc_internal_config->ping_addr[0] > ((uint32_t)MAXIMUM_PING_ADDR)) - || (adc_internal_config->pong_addr[0] > ((uint32_t)MAXIMUM_PONG_ADDR))) { - status = SL_STATUS_INVALID_PARAMETER; - break; + if (adc_internal_config->ping_addr[0] >= START_PING_ADDR) { + if ((adc_internal_config->ping_addr[0] < ((uint32_t)START_PING_ADDR)) + || (adc_internal_config->pong_addr[0] > ((uint32_t)END_PONG_ADDR))) { + status = SL_STATUS_INVALID_PARAMETER; + break; + } + } else { + if ((adc_internal_config->ping_addr[0] > ((uint32_t)MAXIMUM_PING_ADDR)) + || (adc_internal_config->pong_addr[0] > ((uint32_t)MAXIMUM_PONG_ADDR))) { + status = SL_STATUS_INVALID_PARAMETER; + break; + } } -#endif // Validate ping and pong length maximum value if ((adc_internal_config->ping_length[0] >= MAXIMUM_PING_LENGTH) || (adc_internal_config->pong_length[0] >= MAXIMUM_PONG_LENGTH)) { diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_config_timer.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_config_timer.c index 782982b6..495a253a 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_config_timer.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_config_timer.c @@ -169,14 +169,6 @@ void sl_si91x_config_timer_reset_configuration(void) *******************************************************************************/ sl_status_t sl_si91x_config_timer_set_ocu_configuration(sl_config_timer_ocu_config_t *ocu_config_ptr) { - /* CONFIG_TIMER_UC is defined by default. when this macro (CONFIG_TIMER_UC) is defined, peripheral - * configuration is directly taken from the configuration set in the universal configuration (UC). - * if the application requires the configuration to be changed in run-time, undefined this macro - * and change the peripheral configuration. - */ -#ifdef CONFIG_TIMER_UC - ocu_config_ptr = &ct_ocu_configuration; -#endif uint32_t ocu_config_value; sl_status_t status; do { @@ -258,14 +250,6 @@ void sl_si91x_config_timer_reset_ocu_configuration(void) *******************************************************************************/ sl_status_t sl_si91x_config_timer_set_wfg_configuration(sl_config_timer_wfg_config_t *wfg_config_ptr) { - /* CONFIG_TIMER_UC is defined by default. when this macro (CONFIG_TIMER_UC) is defined, peripheral - * configuration is directly taken from the configuration set in the universal configuration (UC). - * if the application requires the configuration to be changed in run-time, undefined this macro - * and change the peripheral configuration. - */ -#ifdef CONFIG_TIMER_UC - wfg_config_ptr = &ct_wfg_configuration; -#endif sl_status_t status; rsi_error_t error_status; status = SL_STATUS_OK; @@ -864,17 +848,28 @@ sl_config_timer_version_t sl_si91x_config_timer_get_version(void) } /******************************************************************************* -* @brief: De-initializes config-timer output pins and configures clock +* De-initializes config-timer output pins and configures clock +* Unregisters callback and disable all CT interrupts. * * @details: * Disables CT clock *******************************************************************************/ void sl_si91x_config_timer_deinit(void) { + sl_config_timer_interrupt_flags_t interrupt_flag; + interrupt_flag.is_counter0_event_interrupt_enabled = true; + interrupt_flag.is_counter0_fifo_full_interrupt_enabled = true; + interrupt_flag.is_counter0_hit_peak_interrupt_enabled = true; + interrupt_flag.is_counter0_hit_zero_interrupt_enabled = true; + interrupt_flag.is_counter1_event_interrupt_enabled = true; + interrupt_flag.is_counter1_fifo_full_interrupt_enabled = true; + interrupt_flag.is_counter1_hit_peak_interrupt_enabled = true; + interrupt_flag.is_counter1_hit_zero_interrupt_enabled = true; + // Unregistering callback and disabling all CT interrupts + sl_si91x_config_timer_unregister_callback(&interrupt_flag); // Disabling peripheral clock RSI_CLK_PeripheralClkDisable(M4CLK, CT_CLK); } - /******************************************************************************* * Interrupt handler for config-timer * diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_dma.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_dma.c index 02f67964..bb5d2dc7 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_dma.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_dma.c @@ -248,7 +248,9 @@ sl_status_t sl_si91x_dma_init(sl_dma_init_t *dma_init) sl_status_t sl_si91x_dma_deinit(uint32_t dma_number) { - sl_status_t status = SL_STATUS_OK; + sl_status_t status = SL_STATUS_OK; + uint32_t channel_count = 0; + uint32_t channel; do { if (dma_number > DMA_INSTANCE1) { status = SL_STATUS_INVALID_PARAMETER; @@ -258,14 +260,24 @@ sl_status_t sl_si91x_dma_deinit(uint32_t dma_number) status = SL_STATUS_NOT_INITIALIZED; break; } - for (int ch = 0; ch < DMA_CHANNEL_32; ch++) { - if (channel_status(dma_number, ch)) { + for (channel = 0; channel < DMA_CHANNEL_32; channel++) { + if (channel_status(dma_number, channel)) { // DMA channel is busy status = SL_STATUS_BUSY; break; } } if (status == SL_STATUS_OK) { + //Unregister callbacks for all DMA channels + if (dma_number) { + channel_count = DMA_CHANNEL_32; + } else { + channel_count = DMA_CHANNEL_12; + } + for (channel = 0; channel < channel_count; channel++) { + sl_channel_allocation_data_t[dma_number][channel].dma_callback_t.error_cb = NULL; + sl_channel_allocation_data_t[dma_number][channel].dma_callback_t.transfer_complete_cb = NULL; + } // Uninitialize DMA status = (sl_status_t)UDMAx_Uninitialize(UDMA_driver_resources[dma_number]); } diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_driver_gpio.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_driver_gpio.c index 8b0f4598..c4839b8f 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_driver_gpio.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_driver_gpio.c @@ -67,6 +67,37 @@ #define GPIO_INTERRUPT_PRIOPRITY6 58 // Priority 58 for m4 pin interrupt 6 #define GPIO_INTERRUPT_PRIOPRITY7 59 // Priority 59 for m4 pin interrupt 7 +/******************************************************************************* + ******************************** ENUMS ************************************ + ******************************************************************************/ + +///@brief structure to hold GPIO interrupt configurations +typedef struct { + uint8_t gpio_priority[8]; + uint8_t gpio_nvic[8]; +} sl_gpio_intr_configure_t; + +/******************************************************************************* + *************************** LOCAL VARIABLES ********************************* + ******************************************************************************/ + +const sl_gpio_intr_configure_t intr_config = { { GPIO_INTERRUPT_PRIOPRITY0, + GPIO_INTERRUPT_PRIOPRITY1, + GPIO_INTERRUPT_PRIOPRITY2, + GPIO_INTERRUPT_PRIOPRITY3, + GPIO_INTERRUPT_PRIOPRITY4, + GPIO_INTERRUPT_PRIOPRITY5, + GPIO_INTERRUPT_PRIOPRITY6, + GPIO_INTERRUPT_PRIOPRITY7 }, + { PININT0_NVIC_NAME, + PININT1_NVIC_NAME, + PININT2_NVIC_NAME, + PININT3_NVIC_NAME, + PININT4_NVIC_NAME, + PININT5_NVIC_NAME, + PININT6_NVIC_NAME, + PININT7_NVIC_NAME } }; + /******************************************************************************* ***********************  Global function Prototypes *************************** ******************************************************************************/ @@ -120,73 +151,78 @@ sl_status_t sl_gpio_driver_configure_interrupt(sl_gpio_t *gpio, // Returns null pointer status code if gpio_callback == NULL return SL_STATUS_NULL_POINTER; } + if (flags > GPIO_FLAGS_MAX_VALUE) { + // Returns invalid parameter status code if flags > GPIO_FLAGS_MAX_VALUE + return SL_STATUS_INVALID_PARAMETER; + } if (gpio->port > GPIO_PORT_MAX_VALUE) { // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { - if (gpio->pin > PORT_PIN_MAX_VALUE) { - // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE + switch (gpio->port) { + case 0: + case 1: + case 2: + case 3: + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { + if (gpio->pin > PORT_PIN_MAX_VALUE) { + // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + } + if (gpio->port == SL_GPIO_PORT_D) { + if (gpio->pin > PORTD_PIN_MAX_VALUE) { + // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + } + if (int_no > GPIO_MAX_INTR_VALUE) { + // Returns invalid parameter status code if int_no > GPIO_MAX_INTR_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + if (gpio_callback_function_pointer[int_no] != NULL) { + return SL_STATUS_BUSY; + } + NVIC_EnableIRQ(intr_config.gpio_nvic[int_no]); + NVIC_SetPriority(intr_config.gpio_nvic[int_no], intr_config.gpio_priority[int_no]); + gpio_callback_function_pointer[int_no] = gpio_callback; + sl_gpio_configure_interrupt(gpio->port, gpio->pin, int_no, flags); + break; + default: + break; + } + if (gpio->port == SL_ULP_GPIO_PORT) { + if (gpio->pin > PORTE_PIN_MAX_VALUE) { + // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - } - if (gpio->port == PORTD) { - if (gpio->pin > PORTD_PIN_MAX_VALUE) { - // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE + if (int_no > GPIO_ULP_INTERRUPT_MAX_VALUE) { + // Returns invalid parameter status code if int_no > GPIO_INTERRUPT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - } - if (gpio->port == PORTE) { - if (gpio->pin > PORTE_PIN_MAX_VALUE) { - // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE + if (gpio_ulp_pin_int_callback_fptr[int_no] != NULL) { + return SL_STATUS_BUSY; + } + NVIC_EnableIRQ(ULP_PININT0_NVIC_NAME); + NVIC_SetPriority(ULP_PININT0_NVIC_NAME, ULP_GPIO_INTERRUPT_PRIORITY); + gpio_ulp_pin_int_callback_fptr[int_no] = gpio_callback; + sl_si91x_gpio_configure_ulp_pin_interrupt(int_no, (sl_si91x_gpio_interrupt_config_flag_t)flags, gpio->pin); + } + if (gpio->port == PORTF) { + if (gpio->pin > PORTF_PIN_MAX_VALUE) { + // Returns invalid parameter status code if gpio->pin > PORTF_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } + if (gpio_uulp_pin_int_callback_fptr[int_no] != NULL) { + return SL_STATUS_BUSY; + } + if (int_no > GPIO_NPSS_PIN_MAX_VALUE) { + // Returns invalid parameter status code if npssgpio_interrupt > GPIO_NPSS_PIN_MAX_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + gpio_uulp_pin_int_callback_fptr[int_no] = gpio_callback; + sl_si91x_gpio_configure_uulp_interrupt((sl_si91x_gpio_interrupt_config_flag_t)flags, int_no); } - if (flags > GPIO_FLAGS_MAX_VALUE) { - // Returns invalid parameter status code if flags > GPIO_FLAGS_MAX_VALUE - return SL_STATUS_INVALID_PARAMETER; - } - if (int_no > GPIO_MAX_INTR_VALUE) { - // Returns invalid parameter status code if int_no > GPIO_MAX_INTR_VALUE - return SL_STATUS_INVALID_PARAMETER; - } - if (int_no == 0) { - NVIC_EnableIRQ(PININT0_NVIC_NAME); - NVIC_SetPriority(PININT0_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY0); - } - if (int_no == 1) { - NVIC_EnableIRQ(PININT1_NVIC_NAME); - NVIC_SetPriority(PININT1_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY1); - } - if (int_no == 2) { - NVIC_EnableIRQ(PININT2_NVIC_NAME); - NVIC_SetPriority(PININT2_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY2); - } - if (int_no == 3) { - NVIC_EnableIRQ(PININT3_NVIC_NAME); - NVIC_SetPriority(PININT3_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY3); - } - if (int_no == 4) { - NVIC_EnableIRQ(PININT4_NVIC_NAME); - NVIC_SetPriority(PININT4_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY4); - } - if (int_no == 5) { - NVIC_EnableIRQ(PININT5_NVIC_NAME); - NVIC_SetPriority(PININT5_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY5); - } - if (int_no == 6) { - NVIC_EnableIRQ(PININT6_NVIC_NAME); - NVIC_SetPriority(PININT6_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY6); - } - if (int_no == 7) { - NVIC_EnableIRQ(PININT7_NVIC_NAME); - NVIC_SetPriority(PININT7_NVIC_NAME, GPIO_INTERRUPT_PRIOPRITY7); - } - if (gpio_callback_function_pointer[int_no] != NULL) { - return SL_STATUS_BUSY; - } - gpio_callback_function_pointer[int_no] = gpio_callback; - sl_gpio_configure_interrupt(gpio->port, gpio->pin, int_no, flags); return SL_STATUS_OK; } @@ -223,19 +259,19 @@ sl_status_t sl_gpio_driver_set_pin_mode(sl_gpio_t *gpio, sl_gpio_mode_t mode, ui // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -300,19 +336,19 @@ sl_status_t sl_gpio_driver_get_pin_mode(sl_gpio_t *gpio, sl_gpio_mode_t *mode) // Returns invalid parameter status code if gpio->port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((gpio->port == PORTA) || (gpio->port == PORTB) || (gpio->port == PORTC)) { + if ((gpio->port == SL_GPIO_PORT_A) || (gpio->port == SL_GPIO_PORT_B) || (gpio->port == SL_GPIO_PORT_C)) { if (gpio->pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTD) { + if (gpio->port == SL_GPIO_PORT_D) { if (gpio->pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (gpio->port == PORTE) { + if (gpio->port == SL_ULP_GPIO_PORT) { if (gpio->pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if gpio->pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -410,19 +446,19 @@ sl_status_t sl_si91x_gpio_driver_set_pin_direction(uint8_t port, uint8_t pin, sl // Returns invalid parameter status code if port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((port == PORTA) || (port == PORTB) || (port == PORTC)) { + if ((port == SL_GPIO_PORT_A) || (port == SL_GPIO_PORT_B) || (port == SL_GPIO_PORT_C)) { if (pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTD) { + if (port == SL_GPIO_PORT_D) { if (pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTE) { + if (port == SL_ULP_GPIO_PORT) { if (pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -471,19 +507,19 @@ uint8_t sl_si91x_gpio_driver_get_pin_direction(uint8_t port, uint8_t pin) // Returns invalid parameter status code if port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((port == PORTA) || (port == PORTB) || (port == PORTC)) { + if ((port == SL_GPIO_PORT_A) || (port == SL_GPIO_PORT_B) || (port == SL_GPIO_PORT_C)) { if (pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTD) { + if (port == SL_GPIO_PORT_D) { if (pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTE) { + if (port == SL_ULP_GPIO_PORT) { if (pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -684,19 +720,19 @@ sl_status_t sl_si91x_gpio_driver_enable_group_interrupt(sl_si91x_group_interrupt // Returns invalid parameter status code if port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((port == PORTA) || (port == PORTB) || (port == PORTC)) { + if ((port == SL_GPIO_PORT_A) || (port == SL_GPIO_PORT_B) || (port == SL_GPIO_PORT_C)) { if (pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTD) { + if (port == SL_GPIO_PORT_D) { if (pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTE) { + if (port == SL_ULP_GPIO_PORT) { if (pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -727,19 +763,19 @@ sl_status_t sl_si91x_gpio_driver_disable_group_interrupt(sl_si91x_group_interrup // Returns invalid parameter status code if port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((port == PORTA) || (port == PORTB) || (port == PORTC)) { + if ((port == SL_GPIO_PORT_A) || (port == SL_GPIO_PORT_B) || (port == SL_GPIO_PORT_C)) { if (pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTD) { + if (port == SL_GPIO_PORT_D) { if (pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTE) { + if (port == SL_ULP_GPIO_PORT) { if (pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -885,19 +921,19 @@ sl_status_t sl_si91x_gpio_driver_set_group_interrupt_polarity(sl_si91x_group_int // Returns invalid parameter status code if port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((port == PORTA) || (port == PORTB) || (port == PORTC)) { + if ((port == SL_GPIO_PORT_A) || (port == SL_GPIO_PORT_B) || (port == SL_GPIO_PORT_C)) { if (pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTD) { + if (port == SL_GPIO_PORT_D) { if (pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTE) { + if (port == SL_ULP_GPIO_PORT) { if (pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -929,19 +965,19 @@ uint8_t sl_si91x_gpio_driver_get_group_interrupt_polarity(sl_si91x_group_interru // Returns invalid parameter status code if port > GPIO_PORT_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } - if ((port == PORTA) || (port == PORTB) || (port == PORTC)) { + if ((port == SL_GPIO_PORT_A) || (port == SL_GPIO_PORT_B) || (port == SL_GPIO_PORT_C)) { if (pin > PORT_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORT_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTD) { + if (port == SL_GPIO_PORT_D) { if (pin > PORTD_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTD_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; } } - if (port == PORTE) { + if (port == SL_ULP_GPIO_PORT) { if (pin > PORTE_PIN_MAX_VALUE) { // Returns invalid parameter status code if pin > PORTE_PIN_MAX_VALUE return SL_STATUS_INVALID_PARAMETER; @@ -1850,3 +1886,66 @@ sl_status_t sl_gpio_driver_deinit(void) } while (false); return SL_STATUS_OK; } + +/******************************************************************************* + * Unregister GPIO interrupts + ******************************************************************************/ +sl_status_t sl_gpio_driver_unregister(sl_si91x_gpio_instances_t gpio_instance, + sl_si91x_gpio_intr_t gpio_intr, + uint8_t flag) +{ + if (gpio_instance >= GPIO_INSTANCE_LAST) { + // Returns invalid parameter status code if gpio_instance > GPIO_INSTANCE_LAST + return SL_STATUS_INVALID_PARAMETER; + } + switch (gpio_instance) { + case M4_GPIO_INSTANCE: + switch (gpio_intr) { + case GPIO_PIN_INTERRUPT: + if (flag > GPIO_MAX_INTR_VALUE) { + // Returns invalid parameter status code if flag > GPIO_MAX_INTR_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + gpio_callback_function_pointer[flag] = NULL; + break; + case GPIO_GROUP_INTERRUPT: + if (flag > MAX_GROUP_INT) { + // Returns invalid parameter status code if flag > MAX_GROUP_INT + return SL_STATUS_INVALID_PARAMETER; + } + gpio_group_int_callback_fptr[flag] = NULL; + break; + } + break; + case ULP_GPIO_INSTANCE: + switch (gpio_intr) { + case GPIO_PIN_INTERRUPT: + if (flag > GPIO_MAX_INTR_VALUE) { + // Returns invalid parameter status code if flag > GPIO_MAX_INTR_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + gpio_ulp_pin_int_callback_fptr[flag] = NULL; + break; + case GPIO_GROUP_INTERRUPT: + if (flag > MAX_GROUP_INT) { + // Returns invalid parameter status code if flag > MAX_GROUP_INT + return SL_STATUS_INVALID_PARAMETER; + } + gpio_ulp_group_int_callback_fptr[flag] = NULL; + break; + } + break; + case UULP_GPIO_INSTANCE: + if (flag > MAX_UULP_INT) { + // Returns invalid parameter status code if flag > GPIO_MAX_INTR_VALUE + return SL_STATUS_INVALID_PARAMETER; + } + gpio_uulp_pin_int_callback_fptr[flag] = NULL; + break; + case GPIO_INSTANCE_LAST: + break; + default: + break; + } + return SL_STATUS_OK; +} diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_gspi.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_gspi.c index f386b666..ebe8d1c5 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_gspi.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_gspi.c @@ -215,6 +215,8 @@ sl_status_t sl_si91x_gspi_deinit(sl_gspi_handle_t gspi_handle) if (status != SL_STATUS_OK) { return status; } + // Unregistering the GSPI event callback. + sl_si91x_gspi_unregister_event_callback(); // CMSIS API for un-initialization is called and the arm error code returned from // the API is converted to SL error code via convert_arm_to_sl_error_code function. error_status = ((sl_gspi_driver_t *)gspi_handle)->Uninitialize(); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2c.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2c.c index 3a6dc79e..cbff2632 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2c.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2c.c @@ -36,56 +36,56 @@ #include "sl_si91x_dma.h" #include "sl_si91x_peripheral_gpio.h" #include "sl_si91x_peripheral_i2c.h" +#include "rsi_debug.h" /******************************************************************************* *************************** DEFINES / MACROS ******************************** ******************************************************************************/ -#define DMA_NUMBER 0 // DMA number of DMA used for I2C1 and I2C0 instances -#define I2C2_DMA_NUMBER 1 // DMA number of DMA used for I2C2 instance -#define ZERO_FLAG 0 // Zero flag, No argument -#define PORT_ZERO 0 // Port zero -#define HP_MAX_GPIO 64 // High Power GPIO Maximum number -#define PINMUX_MODE 6 // I2C pinmux mode -#define LAST_DATA_COUNT 0 // Last read-write count -#define DATA_COUNT 1 // Last second data count for verification -#define BIT_SET 1 // Set bit -#define STOP_BIT 9 // Bit to send stop command -#define MASK_READ_BIT 8 // Bit to mask read and write -#define INTERNAL_PULLUP 1 // Internal Pull-up enable -#define ULP_GPIO_SDA 10 // SDA ULP GPIO Pin number -#define ULP_GPIO_SCL 11 // SCL ULP GPIO Pin number -#define ULP_GPIO_SDA2 6 // SDA ULP GPIO Pin number -#define ULP_GPIO_SCL2 7 // SCL ULP GPIO Pin number -#define BUFFER_START_INDEX 0 // Starting buffer index -#define MAX_7BIT_ADDRESS 127 // Maximum 7-bit address -#define SIXTY_FOUR 64 // Value 64 -#define SIXTY_THREE 63 // Value 64 -#define TWENTY_FIVE 25 // Value 25 -#define TWENTY_SIX 26 // Value 26 -#define TWENTY_EIGHT 28 // Value 28 -#define TWENTY_NINE 29 // Value 29 -#define SIX 6 // Value 25 -#define ZERO 0 // Value 0 -#define ONE 1 // Value 1 -#define TWO 2 // Value 2 -#define SET 1 // to set a bit -#define CLEAR 0 // to clear a bit -#define ACK_BYTE 0x00000100 // to write ack -#define FOLLOWER_ADDR_10BIT_MAX 0x3FF // maximum value for 10-bit address -#define REFERENCE_CLOCK_FREQUENCY (32000000u) // Reference clock frequency -#define HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY (40000000u) // Reference clock frequency -#define I2C_STANDARD_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c standard mode -#define I2C_FAST_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c fast mode -#define I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c fast plus mode -#define I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c high speed mode -#define ULP_PORT 4 // GPIO ULP port -#define ULP_MODE 6 // ULP GPIO mode -#define MAX_GPIO 64 // maximum GPIO pins -#define OUTPUT 1 // Output value set -#define HOST_MIN 24 // GPIO host pad minimum pin number -#define HOST_MAX 31 // GPIO host pad maximum pin number -#define I2C2_MUX 4 // I2C2 MUX number -#define I2C2_PAD 0 // I2C2 PAD number +#define DMA_NUMBER 0 // DMA number of DMA used for I2C1 and I2C0 instances +#define I2C2_DMA_NUMBER 1 // DMA number of DMA used for I2C2 instance +#define ZERO_FLAG 0 // Zero flag, No argument +#define PORT_ZERO 0 // Port zero +#define HP_MAX_GPIO 64 // High Power GPIO Maximum number +#define PINMUX_MODE 6 // I2C pinmux mode +#define LAST_DATA_COUNT 0 // Last read-write count +#define DATA_COUNT 1 // Last second data count for verification +#define BIT_SET 1 // Set bit +#define STOP_BIT 9 // Bit to send stop command +#define MASK_READ_BIT 8 // Bit to mask read and write +#define INTERNAL_PULLUP 1 // Internal Pull-up enable +#define ULP_GPIO_SDA 10 // SDA ULP GPIO Pin number +#define ULP_GPIO_SCL 11 // SCL ULP GPIO Pin number +#define ULP_GPIO_SDA2 6 // SDA ULP GPIO Pin number +#define ULP_GPIO_SCL2 7 // SCL ULP GPIO Pin number +#define BUFFER_START_INDEX 0 // Starting buffer index +#define MAX_7BIT_ADDRESS 127 // Maximum 7-bit address +#define SIX 6 // Value 25 +#define ZERO 0 // Value 0 +#define ONE 1 // Value 1 +#define TWO 2 // Value 2 +#define SET 1 // to set a bit +#define CLEAR 0 // to clear a bit +#define ACK_BYTE 0x00000100 // to write ack +#define FOLLOWER_ADDR_10BIT_MAX 0x3FF // maximum value for 10-bit address +#define REFERENCE_CLOCK_FREQUENCY (32000000u) // Reference clock frequency +#define HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY (40000000u) // Reference clock frequency +#define I2C_STANDARD_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c standard mode +#define I2C_FAST_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c fast mode +#define I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c fast plus mode +#define I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY (180000000u) // clock frequency for i2c high speed mode +#define ULP_PORT 4 // GPIO ULP port +#define ULP_MODE 6 // ULP GPIO mode +#define MAX_GPIO 64 // maximum GPIO pins +#define OUTPUT 1 // Output value set +#define HOST_MIN 24 // GPIO host pad minimum pin number +#define HOST_MAX 31 // GPIO host pad maximum pin number +#define I2C2_MUX 4 // I2C2 MUX number +#define I2C2_PAD 0 // I2C2 PAD number +#define ULP_CLOCK_DIV_FACTOR 0 // division factor value for ULP clock +#define ULP_PRO_CLOCK_DIV_FACTOR 0 // division factor value for ULP pro clock +#define EVEN_DIVISION_FACTOR 0 // ulp clock division factor type +#define DELAY_DISABLE 0 // to disable delay function callback for ulp pro clock + /******************************************************************************* ***************************  Local TYPES  ******************************** ******************************************************************************/ @@ -205,7 +205,6 @@ sl_i2c_status_t sl_i2c_driver_init(sl_i2c_instance_t i2c_instance, const sl_i2c_ i2c2_instance.mode = SL_I2C_FOLLOWER_MODE; } } - // Initializing I2c clock i2c_clock_init(i2c); // Default keep M4 in reference clock @@ -225,14 +224,24 @@ sl_i2c_status_t sl_i2c_driver_init(sl_i2c_instance_t i2c_instance, const sl_i2c_ if (p_user_config->operating_mode == SL_I2C_FAST_PLUS_MODE) { RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); RSI_CLK_SetSocPllFreq(M4CLK, I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY, REFERENCE_CLOCK_FREQUENCY); - RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); - config.freq = I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY; + RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0); + if (i2c_instance == SL_I2C2) { + RSI_ULPSS_ClockConfig(M4CLK, ENABLE, ULP_CLOCK_DIV_FACTOR, EVEN_DIVISION_FACTOR); + RSI_ULPSS_UlpProcClkConfig(ULPCLK, ULP_PROC_SOC_CLK, ULP_PRO_CLOCK_DIV_FACTOR, DELAY_DISABLE); + DEBUGINIT(); + } + config.freq = sl_si91x_i2c_get_frequency(i2c); } if ((p_user_config->operating_mode == SL_I2C_HIGH_SPEED_MODE)) { RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); RSI_CLK_SetSocPllFreq(M4CLK, I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY, HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY); RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0); - config.freq = I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY; + if (i2c_instance == SL_I2C2) { + RSI_ULPSS_ClockConfig(M4CLK, ENABLE, ULP_CLOCK_DIV_FACTOR, EVEN_DIVISION_FACTOR); + RSI_ULPSS_UlpProcClkConfig(ULPCLK, ULP_PROC_SOC_CLK, ULP_PRO_CLOCK_DIV_FACTOR, DELAY_DISABLE); + DEBUGINIT(); + } + config.freq = sl_si91x_i2c_get_frequency(i2c); } // Registering callback as per transfer type i2c_callback_function_ptr[i2c_instance] = p_user_config->i2c_callback; @@ -816,7 +825,7 @@ sl_i2c_status_t sl_si91x_i2c_pin_init(sl_i2c_pin_init_t *pin_init) RSI_PS_UlpssPeriPowerUp(ULPSS_PWRGATE_ULP_I2C); // SCL sl_si91x_gpio_enable_ulp_pad_receiver((uint8_t)(pin_init->scl_pin)); - sl_gpio_set_pin_mode(ULP_PORT, (uint8_t)(pin_init->scl_pin), pin_init->sda_mux, OUTPUT); + sl_gpio_set_pin_mode(ULP_PORT, (uint8_t)(pin_init->scl_pin), pin_init->scl_mux, OUTPUT); #if defined(SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH) egpio_ulp_pad_driver_disable_state(pin_init->scl_pin, INTERNAL_PULLUP); #endif @@ -837,13 +846,13 @@ sl_i2c_status_t sl_si91x_i2c_pin_init(sl_i2c_pin_init_t *pin_init) if (pin_init->scl_pin >= MAX_GPIO) { sl_si91x_gpio_enable_ulp_pad_receiver((uint8_t)(pin_init->scl_pin - MAX_GPIO)); sl_gpio_set_pin_mode(ULP_PORT, (uint8_t)(pin_init->scl_pin - MAX_GPIO), ULP_MODE, OUTPUT); +#if defined(SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH) + // Configuring internal pullup for follower mode + egpio_ulp_pad_driver_disable_state(ULP_GPIO_SCL, INTERNAL_PULLUP); +#endif } else { sl_si91x_gpio_enable_pad_receiver(pin_init->scl_pin); } -#if defined(SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH) - // Configuring internal pullup for follower mode - egpio_ulp_pad_driver_disable_state(ULP_GPIO_SCL, INTERNAL_PULLUP); -#endif if (pin_init->scl_pin >= HOST_MIN && pin_init->scl_pin <= HOST_MAX) { sl_si91x_gpio_enable_pad_selection(pin_init->scl_pin); } else { diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2s.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2s.c index 8cb991d2..2726e967 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2s.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2s.c @@ -134,6 +134,14 @@ sl_status_t sl_si91x_i2s_deinit(sl_i2s_handle_t *i2s_handle) status = SL_STATUS_NULL_POINTER; } else { if ((i2s_handle == &Driver_SAI0) || (i2s_handle == &Driver_SAI1)) { + //Unregister callbacks + if (i2s_handle == &Driver_SAI0) { + i2s0_user_callback = NULL; + local_i2s0_handle = NULL; + } else { + i2s1_user_callback = NULL; + local_i2s1_handle = NULL; + } // CMSIS API for un-initialization is called and the arm error code returned from // the API is converted to SL error code via convert_arm_to_sl_error_code function. error_status = ((sl_i2s_driver_t *)i2s_handle)->Uninitialize(); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram.c index 4d5a4ca0..6aab4883 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram.c @@ -15,7 +15,6 @@ * ******************************************************************************/ -#include "sl_si91x_psram.h" #include "UDMA.h" #include "rsi_pll.h" #include "rsi_qspi.h" @@ -41,7 +40,7 @@ ****************************** VARIABLES ********************************** ******************************************************************************/ -extern PSRAMSecureSegmentType PSRAMSecureSegments[MAX_SEC_SEGMENTS]; +extern struct PSRAMSecureSegmentType PSRAMSecureSegments[MAX_SEC_SEGMENTS]; static sl_psram_return_type_t autoModeState = PSRAM_UNKNOWN; @@ -57,7 +56,7 @@ spi_config_t spi_psram_default_config = { .d3d2_data = 3, .continuous = DIS_CONTINUOUS, .read_cmd = 0x03, - .flash_type = 255, + .flash_type = 0xf, .no_of_dummy_bytes = 0, .extra_byte_en = 0 }, @@ -95,7 +94,7 @@ spi_config_t spi_psram_default_config = { }; -static PSRAMStatusType PSRAMStatus = { +static struct PSRAMStatusType PSRAMStatus = { .state = unknown, .interfaceMode = SINGLE_MODE, .burstSize = 0, @@ -103,7 +102,7 @@ static PSRAMStatusType PSRAMStatus = { .secureSegmentNumber = 0, }; -PSRAMPinConfigType PSRAMPinConfig[NUM_OF_PSRAM_PINS] = { +struct PSRAMPinConfigType PSRAMPinConfig[NUM_OF_PSRAM_PINS] = { { M4SS_PSRAM_CLK_PORT, M4SS_PSRAM_CLK_PIN, M4SS_PSRAM_CLK_MUX, M4SS_PSRAM_CLK_PAD }, { M4SS_PSRAM_CSN_PORT, M4SS_PSRAM_CSN_PIN, M4SS_PSRAM_CSN_MUX, M4SS_PSRAM_CSN_PAD }, { M4SS_PSRAM_D0_PORT, M4SS_PSRAM_D0_PIN, M4SS_PSRAM_D0_MUX, M4SS_PSRAM_D0_PAD }, @@ -137,7 +136,7 @@ extern RSI_UDMA_HANDLE_T udmaHandle0; extern uint32_t dma_rom_buff0[30]; -static volatile xferContextType ctx; +static volatile struct xferContextType ctx; RSI_UDMA_CHA_CONFIG_DATA_T control; RSI_UDMA_CHA_CFG_T config; @@ -305,6 +304,7 @@ static void qspi_deassert_csn(qspi_reg_t *qspi_reg); ******************************************************************************/ static void qspi_sram_auto_init(qspi_reg_t *qspi_reg, spi_config_t *spi_config); +#if (PSRAM_MODEL_WRAP == 1) /***************************************************************************/ /** * @brief * Initialize SRAM Wrap mode @@ -316,6 +316,7 @@ static void qspi_sram_auto_init(qspi_reg_t *qspi_reg, spi_config_t *spi_config); * SPI configs for QSPI interface ******************************************************************************/ static void qspi_sram_wrap_init(qspi_reg_t *qspi_reg, spi_config_t *spi_config); +#endif /***************************************************************************/ /** * @brief @@ -340,7 +341,9 @@ static void qspi_auto_mode_en(qspi_reg_t *qspi_reg); static void qspi_qspiload_key_ext(qspi_reg_t *qspi_reg, uint16_t key_size); +#ifdef SECURITY_KEY_CONFIG static void qspi_qspiunload_key_ext(qspi_reg_t *qspi_reg); +#endif /******************************************************************************* *************************** LOCAL FUNCTIONS ******************************* @@ -356,7 +359,7 @@ __STATIC_INLINE void wait_state_manual() } /* UDMA controller transfer descriptor chain complete callback */ -static void udma_transfer_complete(uint32_t event, uint8_t ch) +static void udma_transfer_complete(uint32_t event, uint32_t ch) { if (event == UDMA_EVENT_XFER_DONE) { if (ch == 5 || ch == 4) { @@ -611,6 +614,7 @@ void qspi_sram_auto_init(qspi_reg_t *qspi_reg, spi_config_t *spi_config) } } +#if (PSRAM_MODEL_WRAP == 1) /* Initialize SRAM Wrap mode */ void qspi_sram_wrap_init(qspi_reg_t *qspi_reg, spi_config_t *spi_config) { @@ -638,6 +642,7 @@ void qspi_sram_wrap_init(qspi_reg_t *qspi_reg, spi_config_t *spi_config) // read cmd for wrap mode *auto_2_ptr |= 0x8B << 16; } +#endif /* Set SWAP mode based on SPI config */ void qspi_set_swap_mode(qspi_reg_t *qspi_reg, spi_config_t *spi_config) @@ -692,6 +697,7 @@ void qspi_qspiload_key_ext(qspi_reg_t *qspi_reg, uint16_t key_size) qspi_reg->OCTA_SPI_BUS_CONTROLLER2 = aes_octa_spi_controller_2; // enabling security ; } +#ifdef SECURITY_KEY_CONFIG void qspi_qspiunload_key_ext(qspi_reg_t *qspi_reg) { @@ -703,6 +709,7 @@ void qspi_qspiunload_key_ext(qspi_reg_t *qspi_reg) qspi_reg->QSPI_AES_SEC_KEY_FRM_KH = DEFAULT_AES_SEC_KEY_FRM_KH; } +#endif /* Enters QPI Mode, can only be called in SPI mode */ sl_psram_return_type_t psram_enter_qpi_mode(void) @@ -710,10 +717,6 @@ sl_psram_return_type_t psram_enter_qpi_mode(void) uint8_t command[2]; - if (&PSRAM_Device.spi_config == NULL) { - return PSRAM_NOT_INITIALIZED; - } - // Set the PSRAM device to QPI mode command[0] = PSRAM_ENTER_QPI; @@ -733,10 +736,6 @@ sl_psram_return_type_t psram_exit_qpi_mode(void) uint8_t command[2]; - if (&PSRAM_Device.spi_config == NULL) { - return PSRAM_NOT_INITIALIZED; - } - // Set the PSRAM device to SPI mode command[0] = PSRAM_EXIT_QPI; @@ -1089,9 +1088,6 @@ sl_psram_return_type_t sl_si91x_psram_init() sl_psram_return_type_t sl_si91x_psram_uninit(void) { uint8_t pinIndex = 0; -#ifdef D_CACHE_ENABLE - uint32_t dCacheDeInitStatus = 0; -#endif /*Exits PSRAM device from QPI mode*/ psram_exit_qpi_mode(); @@ -1295,7 +1291,6 @@ sl_psram_return_type_t sl_si91x_psram_manual_read_in_blocking_mode(uint32_t addr uint32_t num_of_elements) { uint32_t prev_bus_mode; - uint32_t dummy_cnt, tmp_dummy; uint16_t readLength; uint8_t psramXferBuf[7]; uint32_t xferAddr; @@ -1583,7 +1578,7 @@ sl_psram_return_type_t sl_si91x_psram_manual_write_in_dma_mode(uint32_t addr, splitLength / hSize, control, &config, - udma_transfer_complete, + (UDMA_SignalEvent_t)udma_transfer_complete, udma0_chnl_info, udmaHandle0); if (status != RSI_OK) { @@ -1721,7 +1716,6 @@ sl_psram_return_type_t sl_si91x_psram_manual_read_in_dma_mode(uint32_t addr, { uint32_t qspi_manual_config_reg; uint32_t prev_bus_mode; - uint32_t dummy_cnt, tmp_dummy; int32_t status = RSI_OK; qspi_reg_t *qspi_reg = (qspi_reg_t *)M4_QSPI_2_BASE_ADDRESS; uint16_t xferLength = 0; @@ -1834,7 +1828,7 @@ sl_psram_return_type_t sl_si91x_psram_manual_read_in_dma_mode(uint32_t addr, splitLength / hSize, control, &config, - udma_transfer_complete, + (UDMA_SignalEvent_t)udma_transfer_complete, udma0_chnl_info, udmaHandle0); if (status != RSI_OK) { @@ -1981,9 +1975,6 @@ sl_psram_return_type_t sl_si91x_psram_manual_read_in_dma_mode(uint32_t addr, sl_psram_return_type_t sl_si91x_psram_reset(void) { uint8_t command; - if (&PSRAM_Device.spi_config == NULL) { - return PSRAM_NOT_INITIALIZED; - } /*Send the RESET Enable command first*/ command = PSRAM_RESET_EN; diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram_handle.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram_handle.c index ddbb8734..1a60fa7e 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram_handle.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_psram_handle.c @@ -16,7 +16,7 @@ ******************************************************************************/ #include "sl_si91x_psram_handle.h" -sl_psram_info_type_t PSRAM_Device = { +struct sl_psram_info_type_t PSRAM_Device = { .devDensity = Mbit_(PSRAM_DEVICE_DENSITY_MBIT), .deviceName = PSRAM_DEVICE_NAME, @@ -40,10 +40,10 @@ sl_psram_info_type_t PSRAM_Device = { .extra_byte_mode = PSRAM_EXTRA_BYTE_MODE, .prefetch_en = DIS_PREFETCH, .dummy_W_or_R = DUMMY_READS, - .d3d2_data = 0x11, + .d3d2_data = 3, .continuous = DIS_CONTINUOUS, .read_cmd = PSRAM_READ_CMD_CODE, - .flash_type = 255, + .flash_type = 0xf, .no_of_dummy_bytes = (PSRAM_RD_DUMMY_BITS/8), .extra_byte_en = 0, }, @@ -99,9 +99,9 @@ sl_psram_info_type_t PSRAM_Device = { } }; -PSRAMSecureSegmentType PSRAMSecureSegments[MAX_SEC_SEGMENTS] = { +struct PSRAMSecureSegmentType PSRAMSecureSegments[MAX_SEC_SEGMENTS] = { { .segmentEnable = 1, .lowerBoundary = 0x0000, .higherBoundary = 0x0ffff }, { .segmentEnable = 0, .lowerBoundary = 0x0000, .higherBoundary = 0x0000 }, { .segmentEnable = 0, .lowerBoundary = 0xf0001, .higherBoundary = 0xfffff }, { .segmentEnable = 0, .lowerBoundary = 0x0000, .higherBoundary = 0x0000 } -}; \ No newline at end of file +}; diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_pwm.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_pwm.c index 6b49f1df..b2b14b00 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_pwm.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_pwm.c @@ -120,6 +120,7 @@ sl_status_t sl_si91x_pwm_init(sl_pwm_init_t *pwm_init) ******************************************************************************/ void sl_si91x_pwm_deinit(void) { + callback.cbFunc = NULL; RSI_CLK_PeripheralClkDisable(M4CLK, PWM_CLK); } diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sio.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sio.c index 0f8107d6..8a5fa0ac 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sio.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sio.c @@ -30,6 +30,7 @@ #include "sl_si91x_sio.h" #include "sl_si91x_sio_config.h" #include "sl_si91x_peripheral_gpio.h" +#include "rsi_chip.h" /******************************************************************************* *************************** LOCAL MACROS *********************************** ******************************************************************************/ @@ -99,6 +100,16 @@ sl_status_t sl_si91x_sio_init(void) return status; } +/******************************************************************************* + * This API is used to De-initialize SIO module + ******************************************************************************/ +void sl_si91x_sio_deinit(void) +{ + sl_si91x_sio_spi_unregister_event_callback(); + sl_si91x_sio_uart_unregister_event_callback(); + RSI_CLK_PeripheralClkDisable3(M4CLK, (SGPIO_PCLK_ENABLE)); +} + /******************************************************************************* * This API initializes SIO-SPI i.e SPI mode, bit length, bit order, SIO * frequency and the SIO channels for the SPI transfer lines. The actions to be diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ssi.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ssi.c index cefa977d..9bbdea51 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ssi.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ssi.c @@ -232,6 +232,9 @@ sl_status_t sl_si91x_ssi_deinit(sl_ssi_handle_t ssi_handle) status = SL_STATUS_INVALID_PARAMETER; break; } + // Unregister the user callback function. + user_callback = NULL; + // Power gate off to ssi peripheral. status = sli_si91x_ssi_configure_power_mode(ssi_handle, ARM_POWER_OFF); if (status != SL_STATUS_OK) { return status; diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sysrtc.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sysrtc.c index 34ff3ba3..189ada54 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sysrtc.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_sysrtc.c @@ -537,12 +537,28 @@ sl_sysrtc_version_t sl_si91x_sysrtc_get_version(void) } /******************************************************************************* * De-Initialization of sysrtc +* Unregisters SYSRTC callback and disables its interrupts * * @details: * This API is used to de-initializes sysrtc by disabling peripheral *******************************************************************************/ void sl_si91x_sysrtc_deinit(void) { + sl_sysrtc_interrupt_enables_t group_0_interrupt_flags; + sl_sysrtc_interrupt_enables_t group_1_interrupt_flags; + group_0_interrupt_flags.group0_capture0_interrupt_is_enabled = true; + group_0_interrupt_flags.group0_compare0_interrupt_is_enabled = true; + group_0_interrupt_flags.group0_compare1_interrupt_is_enabled = true; + group_0_interrupt_flags.group0_overflow_interrupt_is_enabled = true; + group_1_interrupt_flags.group1_capture0_interrupt_is_enabled = true; + group_1_interrupt_flags.group1_compare0_interrupt_is_enabled = true; + group_1_interrupt_flags.group1_compare1_interrupt_is_enabled = true; + group_1_interrupt_flags.group1_overflow_interrupt_is_enabled = true; + // Unregistering callback for all interrupts and disabling interrupts of group-0 + sl_si91x_sysrtc_unregister_callback(SL_SYSRTC_GROUP_0, &group_0_interrupt_flags); + // Unregistering callback for all interrupts and disabling interrupts of group-1 + sl_si91x_sysrtc_unregister_callback(SL_SYSRTC_GROUP_1, &group_1_interrupt_flags); + // disabling SYSRTC rsi_sysrtc_disable(); } diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ulp_timer.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ulp_timer.c index 05bcd867..45e9ad01 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ulp_timer.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_ulp_timer.c @@ -145,7 +145,7 @@ void IRQ005_Handler(void); which can be done through sl_si91x_ulp_timer_configure_xtal_clock(uint8_t xtal_pin) API i.e user need to call that API first. * In order to enable the soc CLK source need to configure the Ulpss soc Clk from M4 soc clk - please refer \ref sl_si91x_ulp_timer_configure_soc_clock(boolean_t div_factor_type, + please use \ref sl_si91x_ulp_timer_configure_soc_clock(boolean_t div_factor_type, uint16_t div_factor ) *******************************************************************************/ sl_status_t sl_si91x_ulp_timer_configure_clock(ulp_timer_clk_src_config_t *timer_clk_ptr) @@ -883,12 +883,22 @@ sl_status_t sl_si91x_ulp_timer_init(ulp_timer_clk_src_config_t *timer_clk_ptr) /******************************************************************************* * De-Initialization of ulp timer clock +* Unregisters callback of all timer instances * * @details: * This API is used to de-initializes timer by disabling peripheral clock *******************************************************************************/ void sl_si91x_ulp_timer_deinit(void) { + //Unregistering callback for timer-0 + sl_si91x_ulp_timer_unregister_timeout_callback(ULP_TIMER_0); + //Unregistering callback for timer-1 + sl_si91x_ulp_timer_unregister_timeout_callback(ULP_TIMER_1); + //Unregistering callback for timer-0 + sl_si91x_ulp_timer_unregister_timeout_callback(ULP_TIMER_2); + //Unregistering callback for timer-0 + sl_si91x_ulp_timer_unregister_timeout_callback(ULP_TIMER_3); + // Disabling clock for ULP-timer peripheral RSI_ULPSS_TimerClkDisable(ULPCLK); } diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_usart.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_usart.c index a5315fda..911a3934 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_usart.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_usart.c @@ -236,6 +236,8 @@ sl_status_t sl_si91x_usart_deinit(sl_usart_handle_t usart_handle) status = SL_STATUS_INVALID_PARAMETER; break; } + // Unregister the Usart callback + sl_si91x_usart_unregister_event_callback(); // Power off the USART module status = sli_si91x_usart_set_power_mode(usart_handle, SL_POWER_OFF); if (status != SL_STATUS_OK) { diff --git a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_watchdog_timer.c b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_watchdog_timer.c index 58a4b0b6..a79be8f6 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_watchdog_timer.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_watchdog_timer.c @@ -80,9 +80,6 @@ void sl_si91x_watchdog_init_timer(void) { // Un-masking WDT interrupt RSI_WWDT_IntrUnMask(); - // RTC time Period Programming - // status = set_rtc_clock_timeperiod(TIME_PERIOD_VALUE); - // RSI_TIMEPERIOD_TimerClkSel(TIME_PERIOD, TIME_PERIOD_VALUE); // Initializing watchdog-timer (powering up WDT and enabling it to run during CPU sleep mode) RSI_WWDT_Init(MCU_WDT); } @@ -134,9 +131,8 @@ sl_status_t sl_si91x_watchdog_configure_clock(watchdog_timer_clock_config_t *tim } // FSM clock enable for WDT to be functional // Enable clock sources - RSI_IPMU_ClockMuxSel(timer_clk_config_ptr->bg_pmu_clock_source); + RSI_IPMU_ClockMuxSel(RO_32KHZ_CLOCK); RSI_PS_FsmLfClkSel(timer_clk_config_ptr->low_freq_fsm_clock_src); - RSI_PS_FsmHfClkSel(timer_clk_config_ptr->high_freq_fsm_clock_src); } while (false); return status; } @@ -388,11 +384,14 @@ boolean_t sl_si91x_watchdog_get_timer_system_reset_status(void) * @brief: De-initializes watchdog-timer * * @details: +* It will unregister the timer callback * It masks the timer interrupt. * Disables the timer and de-powers it. *******************************************************************************/ void sl_si91x_watchdog_deinit_timer(void) { + // Unregistering the callback + sl_si91x_watchdog_unregister_timeout_callback(); // Masking the interrupt RSI_WWDT_IntrMask(); // Disabling the timer diff --git a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio.h b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio.h index 50db24a9..e5f176fc 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio.h @@ -203,6 +203,20 @@ typedef enum { ULP_GPIO_PIN_11 = 11, ///< ULP GPIO pin number 11 } sl_si91x_gpio_pin_ulp_t; +///@brief GPIO instances +typedef enum { + M4_GPIO_INSTANCE = 1, ///< 1 for HP GPIO + ULP_GPIO_INSTANCE = 2, ///< 2 for ULP GPIO + UULP_GPIO_INSTANCE = 3, ///< 3 for UULP GPIO + GPIO_INSTANCE_LAST, ///< Last enum for validating +} sl_si91x_gpio_instances_t; + +///@brief GPIO interrupt type +typedef enum { + GPIO_PIN_INTERRUPT, ///< 0 for GPIO pin interrupt + GPIO_GROUP_INTERRUPT, ///< 1 for GPIO group interrupt +} sl_si91x_gpio_intr_t; + /// @brief Structure to hold the versions of peripheral API typedef struct { uint8_t release; ///< Release version number @@ -258,19 +272,19 @@ uint8_t sl_si91x_gpio_get_pin_direction(uint8_t port, uint8_t pin); * @brief Enable the receiver bit in the PAD configuration register. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n - * @param[in] gpio_padnum - GPIO number to be use. + * @param[in] gpio_num - GPIO pin number to be use. * @return None *******************************************************************************/ -void sl_si91x_gpio_enable_pad_receiver(uint8_t gpio_padnum); +void sl_si91x_gpio_enable_pad_receiver(uint8_t gpio_num); /***************************************************************************/ /** * @brief Disable the receiver bit in the PAD configuration register. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n - * @param[in] gpio_padnum - GPIO number to be use. + * @param[in] gpio_num - GPIO pin number to be use. * @return None *******************************************************************************/ -void sl_si91x_gpio_disable_pad_receiver(uint8_t gpio_padnum); +void sl_si91x_gpio_disable_pad_receiver(uint8_t gpio_num); /***************************************************************************/ /** * @brief Select the pad(0 to 21). @@ -285,7 +299,7 @@ void sl_si91x_gpio_enable_pad_selection(uint8_t gpio_padnum); * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_pad_selection() \n * \ref sl_si91x_gpio_enable_pad_receiver() \n - * @param[in] gpio_padnum - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] strength - Drive strength selector(E1,E2) of type * \ref sl_si91x_gpio_driver_strength_select_t * possible values are @@ -295,14 +309,14 @@ void sl_si91x_gpio_enable_pad_selection(uint8_t gpio_padnum); * 3, for twelve_milli_amps(E1=1,E2=1)\n * @return None ******************************************************************************/ -void sl_si91x_gpio_select_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_gpio_driver_strength_select_t strength); +void sl_si91x_gpio_select_pad_driver_strength(uint8_t gpio_num, sl_si91x_gpio_driver_strength_select_t strength); /***************************************************************************/ /** * @brief Select the Driver disabled state control. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_pad_selection() \n * \ref sl_si91x_gpio_enable_pad_receiver() \n - * @param[in] gpio_padnum - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] disable_state - driver disable state of type * \ref sl_si91x_gpio_driver_disable_state_t * possible values are @@ -312,7 +326,7 @@ void sl_si91x_gpio_select_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_gpio * 3, for Repeater (P1=1,P2=1)\n * @return None ******************************************************************************/ -void sl_si91x_gpio_select_pad_driver_disable_state(uint8_t gpio_padnum, +void sl_si91x_gpio_select_pad_driver_disable_state(uint8_t gpio_num, sl_si91x_gpio_driver_disable_state_t disable_state); /***************************************************************************/ /** @@ -641,19 +655,19 @@ void sl_si91x_gpio_disable_group_interrupt(sl_si91x_group_interrupt_t group_inte * @brief Select the slew rate. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_ulp_pad_receiver() \n - * @param[in] gpio_padnum - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] slew_rate - slew rate of type \ref sl_si91x_gpio_slew_rate_t * '0' - Slow\n * '1' - Fast\n * @return None ******************************************************************************/ -void sl_si91x_gpio_select_ulp_pad_slew_rate(uint8_t gpio_padnum, sl_si91x_gpio_slew_rate_t slew_rate); +void sl_si91x_gpio_select_ulp_pad_slew_rate(uint8_t gpio_num, sl_si91x_gpio_slew_rate_t slew_rate); /***************************************************************************/ /** * @brief Select the drive strength. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_ulp_pad_receiver() \n - * @param[in] gpio_padnum - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] strength - Drive strength selector(E1,E2) of type * \ref sl_si91x_gpio_driver_strength_select_t * 0, for two_milli_amps (E1=0,E2=0)\n @@ -662,13 +676,13 @@ void sl_si91x_gpio_select_ulp_pad_slew_rate(uint8_t gpio_padnum, sl_si91x_gpio_s * 3, for twelve_milli_amps(E1=1,E2=1)\n * @return None ******************************************************************************/ -void sl_si91x_gpio_select_ulp_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_gpio_driver_strength_select_t strength); +void sl_si91x_gpio_select_ulp_pad_driver_strength(uint8_t gpio_num, sl_si91x_gpio_driver_strength_select_t strength); /***************************************************************************/ /** * @brief Select the driver-disabled state control. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_enable_ulp_pad_receiver() \n - * @param[in] gpio_padnum - GPIO number to be use + * @param[in] gpio_num - GPIO pin number to be use * @param[in] disable_state - driver disable state of type * \ref sl_si91x_gpio_driver_disable_state_t * 0, for HiZ (P1=0,P2=0)\n @@ -677,24 +691,24 @@ void sl_si91x_gpio_select_ulp_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_ * 3, for Repeater (P1=1,P2=1)\n * @return None ******************************************************************************/ -void sl_si91x_gpio_select_ulp_pad_driver_disable_state(uint8_t gpio_padnum, +void sl_si91x_gpio_select_ulp_pad_driver_disable_state(uint8_t gpio_num, sl_si91x_gpio_driver_disable_state_t disable_state); /***************************************************************************/ /** * @brief Disable the receiver bit for ULP. * @pre \ref sl_si91x_gpio_enable_clock() \n - * @param[in] gpio_padnum - GPIO number to be used + * @param[in] gpio_num - GPIO pin number to be used * @return None *******************************************************************************/ -void sl_si91x_gpio_disable_ulp_pad_receiver(uint32_t gpio_padnum); +void sl_si91x_gpio_disable_ulp_pad_receiver(uint32_t gpio_num); /***************************************************************************/ /** * @brief Enable the receiver bit for ULP. * @pre \ref sl_si91x_gpio_enable_clock() \n - * @param[in] gpio_padnum - GPIO number to be used + * @param[in] gpio_num - GPIO pin number to be used * @return None *******************************************************************************/ -void sl_si91x_gpio_enable_ulp_pad_receiver(uint8_t gpio_padnum); +void sl_si91x_gpio_enable_ulp_pad_receiver(uint8_t gpio_num); /***************************************************************************/ /** * @brief Configure the MCU ULP GPIO pin interrupt. @@ -912,7 +926,7 @@ void sl_si91x_gpio_clear_ulp_interrupt(uint32_t flags); void sl_si91x_gpio_clear_ulp_group_interrupt(sl_si91x_group_interrupt_t group_interrupt); /***************************************************************************/ /** -* @brief Configure the ULP GPIO pin interrupt. +* @brief Configure the UULP GPIO pin interrupt. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_set_uulp_pad_configuration() \n * \ref sl_si91x_gpio_select_uulp_npss_receiver() \n @@ -946,7 +960,7 @@ void sl_si91x_gpio_configure_ulp_group_interrupt(sl_si91x_gpio_group_interrupt_c void sl_assert_failed(uint8_t *file, uint32_t line); /***************************************************************************/ /** - * Toggle the UULP pin. + * @brief Toggle the UULP pin. * @pre \ref sl_si91x_gpio_enable_clock() \n * \ref sl_si91x_gpio_select_uulp_npss_receiver() \n * \ref sl_si91x_gpio_set_uulp_npss_pin_mux() \n @@ -959,7 +973,7 @@ void sl_si91x_gpio_toggle_uulp_npss_pin(uint8_t pin); /***************************************************************************/ /** * @brief Indicate UULP GPIO PAD configuration. * @pre \ref sl_si91x_gpio_enable_clock() \n - * @param[in] PAD configuration pointer to \ref uulp_pad_config_t structure + * @param[in] pad_config - pointer to \ref uulp_pad_config_t structure * @return None *******************************************************************************/ void sl_si91x_gpio_set_uulp_pad_configuration(uulp_pad_config_t *pad_config); diff --git a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio_common.h b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio_common.h index 0ad083c4..b441f685 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio_common.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_gpio_common.h @@ -163,14 +163,14 @@ extern "C" { #define ULP_PIN_IRQ_Handler IRQ018_Handler ///< ULP Pin Interrupt #define ULP_GROUP_IRQ_Handler IRQ019_Handler ///< ULP Group Interrupt -#define PIN_INTR_0 0 ///< GPIO pin interrupt 0 -#define PIN_INTR_1 1 ///< GPIO pin interrupt 1 -#define PIN_INTR_2 2 ///< GPIO pin interrupt 2 -#define PIN_INTR_3 3 ///< GPIO pin interrupt 3 -#define PIN_INTR_4 4 ///< GPIO pin interrupt 4 -#define PIN_INTR_5 5 ///< GPIO pin interrupt 5 -#define PIN_INTR_6 6 ///< GPIO pin interrupt 6 -#define PIN_INTR_7 7 ///< GPIO pin interrupt 7 +#define PIN_INTR_0 0 ///< HP GPIO pin interrupt 0 +#define PIN_INTR_1 1 ///< HP GPIO pin interrupt 1 +#define PIN_INTR_2 2 ///< HP GPIO pin interrupt 2 +#define PIN_INTR_3 3 ///< HP GPIO pin interrupt 3 +#define PIN_INTR_4 4 ///< HP GPIO pin interrupt 4 +#define PIN_INTR_5 5 ///< HP GPIO pin interrupt 5 +#define PIN_INTR_6 6 ///< HP GPIO pin interrupt 6 +#define PIN_INTR_7 7 ///< HP GPIO pin interrupt 7 #define UULP_MASK 0x00 ///< UULP GPIO pin mask #define ULP_STATUS 0x01 ///< ULP GPIO pin status diff --git a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_peripheral_gpio.h b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_peripheral_gpio.h index 6933161b..d21377c8 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_peripheral_gpio.h +++ b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc/sl_si91x_peripheral_gpio.h @@ -264,7 +264,7 @@ void sl_gpio_configure_interrupt(sl_gpio_port_t port, uint8_t pin, uint32_t int_ void sl_gpio_set_pin_mode(sl_gpio_port_t port, uint8_t pin, sl_gpio_mode_t mode, uint32_t output_value); /***************************************************************************/ /** - * @brief Get the GPIO pin status. + * @brief Get the GPIO pin mode. * @pre \ref sl_si91x_gpio_enable_clock() \n * @pre \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n * @pre \ref sl_si91x_gpio_enable_pad_receiver(), for HP instance \n @@ -385,7 +385,7 @@ static __INLINE void sl_gpio_set_slew_rate(sl_gpio_port_t port, uint32_t slewrat } /***************************************************************************/ /** - * @brief Set a single pin in GPIO configuration register to 0. + * @brief Clear a single pin in GPIO configuration register to 0. * @pre \ref sl_si91x_gpio_enable_clock() \n * @pre \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n * @pre \ref sl_si91x_gpio_enable_pad_receiver(), for HP instance \n @@ -412,7 +412,7 @@ static __INLINE void sl_gpio_clear_pin_output(sl_gpio_port_t port, uint8_t pin) } /***************************************************************************/ /** - * @brief Set bits in configuration register for a port to 0. + * @brief Clear bits in configuration register for a port to 0. * @pre \ref sl_si91x_gpio_enable_clock() \n * @pre \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n * @pre \ref sl_si91x_gpio_enable_pad_receiver(), for HP instance \n @@ -437,7 +437,7 @@ static __INLINE void sl_gpio_clear_port_output(sl_gpio_port_t port, uint32_t pin } /***************************************************************************/ /** - * @brief Read the pad value for a single pin in a GPIO port. + * @brief Read the pin value for a single pin in a GPIO port. * @pre \ref sl_si91x_gpio_enable_clock() \n * @pre \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n * @pre \ref sl_si91x_gpio_enable_pad_receiver(), for HP instance \n @@ -498,7 +498,7 @@ static __INLINE uint8_t sl_gpio_get_pin_output(sl_gpio_port_t port, uint8_t pin) } /***************************************************************************/ /** - * @brief Read the pad values for GPIO port. + * @brief Read the port value for GPIO port. * @pre \ref sl_si91x_gpio_enable_clock() \n * @pre \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n * @pre \ref sl_si91x_gpio_enable_pad_receiver(), for HP instance \n @@ -522,7 +522,7 @@ static __INLINE uint32_t sl_gpio_get_port_input(sl_gpio_port_t port) } /***************************************************************************/ /** - * Get the current setting for a GPIO configuration register. + * @brief Get the current setting for a GPIO configuration register. * @pre \ref sl_si91x_gpio_enable_clock() \n * @pre \ref sl_si91x_gpio_enable_pad_selection(), for HP instance \n * @pre \ref sl_si91x_gpio_enable_pad_receiver(), for HP instance \n @@ -760,6 +760,28 @@ static __INLINE uint32_t sl_gpio_get_enabled_pending_interrupts(void) return intflags; } +/**************************************************************************/ /** + * @brief This API is used set ulp soc gpio mode + * \n(Gpio pin mode,ranges 000 -> Mode 0 to 111 -> Mode 7 Used for GPIO Pin Muxing ) + * @param[in] ulp_gpio : ulp gpio number + * @param[in] mode : GPIO mode + * \n possible values for this parameter are the following + * - \ref EGPIO_PIN_MUX_MODE0 : Select pin mode 0 + * - \ref EGPIO_PIN_MUX_MODE1 : Select pin mode 1 + * - \ref EGPIO_PIN_MUX_MODE2 : Select pin mode 2 + * - \ref EGPIO_PIN_MUX_MODE3 : Select pin mode 3 + * - \ref EGPIO_PIN_MUX_MODE4 : Select pin mode 4 + * - \ref EGPIO_PIN_MUX_MODE5 : Select pin mode 5 + * - \ref EGPIO_PIN_MUX_MODE6 : Select pin mode 6 + * - \ref EGPIO_PIN_MUX_MODE7 : Select pin mode 7 + * @return None + ******************************************************************************/ +static __INLINE void sl_si91x_gpio_ulp_soc_mode(uint8_t ulp_gpio, uint8_t mode) + +{ + ULPCLK->ULP_SOC_GPIO_MODE_REG[ulp_gpio].ULP_SOC_GPIO_MODE_REG_b.ULP_SOC_GPIO_MODE_REG = (unsigned int)(mode & 0x07); +} + /** @} (end addtogroup GPIO) */ #ifdef __cplusplus diff --git a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_gpio.c b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_gpio.c index 23585d15..ddef7102 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_gpio.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_gpio.c @@ -273,11 +273,11 @@ uint8_t sl_si91x_gpio_get_pin_direction(uint8_t port, uint8_t pin) * @note: Select HP GPIO pins for HP instances(GPIO_6 to GPIO_57). Do not use * GPIO pin number(0 to 5) in HP instance as these are used for other functionality. *******************************************************************************/ -void sl_si91x_gpio_enable_pad_receiver(uint8_t gpio_padnum) +void sl_si91x_gpio_enable_pad_receiver(uint8_t gpio_num) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_num)); // Set the REN(receiver bit) in PAD configuration register - PAD_REG(gpio_padnum)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_REN = SET; + PAD_REG(gpio_num)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_REN = SET; } /******************************************************************************* @@ -290,11 +290,11 @@ void sl_si91x_gpio_enable_pad_receiver(uint8_t gpio_padnum) * @note: Select HP GPIO pins for HP instances(GPIO_6 to GPIO_57). Do not use * GPIO pin number(0 to 5) in HP instance as these are used for other functionality. *******************************************************************************/ -void sl_si91x_gpio_disable_pad_receiver(uint8_t gpio_padnum) +void sl_si91x_gpio_disable_pad_receiver(uint8_t gpio_num) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_num)); // Clear the REN(receiver bit) in PAD configuration register - PAD_REG(gpio_padnum)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_REN = CLR; + PAD_REG(gpio_num)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_REN = CLR; } /******************************************************************************* @@ -342,12 +342,12 @@ void sl_si91x_gpio_enable_pad_selection(uint8_t gpio_padnum) * @note: Select HP GPIO pins for HP instances(GPIO_6 to GPIO_57). Do not use * GPIO pin number(0 to 5) in HP instance as these are used for other functionality. ******************************************************************************/ -void sl_si91x_gpio_select_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_gpio_driver_strength_select_t strength) +void sl_si91x_gpio_select_pad_driver_strength(uint8_t gpio_num, sl_si91x_gpio_driver_strength_select_t strength) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_num)); SL_GPIO_ASSERT(SL_GPIO_VALIDATE_STRENGTH(strength)); // Select the required drive strength in HP GPIO instance - PAD_REG(gpio_padnum)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_E1_E2 = strength; + PAD_REG(gpio_num)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_E1_E2 = strength; } /******************************************************************************* @@ -363,13 +363,12 @@ void sl_si91x_gpio_select_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_gpio * @note: Select HP GPIO pins for HP instances(GPIO_6 to GPIO_57). Do not use * GPIO pin number(0 to 5) in HP instance as these are used for other functionality. ******************************************************************************/ -void sl_si91x_gpio_select_pad_driver_disable_state(uint8_t gpio_padnum, - sl_si91x_gpio_driver_disable_state_t disable_state) +void sl_si91x_gpio_select_pad_driver_disable_state(uint8_t gpio_num, sl_si91x_gpio_driver_disable_state_t disable_state) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PIN(gpio_num)); SL_GPIO_ASSERT(SL_GPIO_VALIDATE_DISABLE_STATE(disable_state)); // Select the required driver disable state in HP GPIO instance - PAD_REG(gpio_padnum)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_P1_P2 = disable_state; + PAD_REG(gpio_num)->GPIO_PAD_CONFIG_REG_b.PADCONFIG_P1_P2 = disable_state; } /******************************************************************************* @@ -435,6 +434,8 @@ void sl_si91x_gpio_enable_group_interrupt(sl_si91x_group_interrupt_t group_inter // Enable group interrupt 1 in ULP GPIO instance if (group_interrupt == GROUP_INT_1) { ULP_GPIO->PIN_CONFIG[pin].GPIO_CONFIG_REG_b.GROUP_INTERRUPT1_ENABLE = ENABLE; + } else { + ULP_GPIO->PIN_CONFIG[pin].GPIO_CONFIG_REG_b.GROUP_INTERRUPT2_ENABLE = ENABLE; } } // Enable group interrupt in HP GPIO instance @@ -582,6 +583,8 @@ void sl_si91x_gpio_set_group_interrupt_polarity(sl_si91x_group_interrupt_t group // Set group interrupt polarity in ULP GPIO instance if (group_interrupt == GROUP_INT_1) { ULP_GPIO->PIN_CONFIG[pin].GPIO_CONFIG_REG_b.GROUP_INTERRUPT1_POLARITY = polarity; + } else { + ULP_GPIO->PIN_CONFIG[pin].GPIO_CONFIG_REG_b.GROUP_INTERRUPT2_POLARITY = polarity; } } else { SL_GPIO_ASSERT(SL_GPIO_NDEBUG_PORT_PIN(port, pin)); @@ -872,22 +875,22 @@ void sl_si91x_gpio_select_group_interrupt_wakeup(uint8_t port, * output/input. * @note: Select ULP GPIO pins for ULP instances(ULP_GPIO_0 to ULP_GPIO_11). *******************************************************************************/ -void sl_si91x_gpio_enable_ulp_pad_receiver(uint8_t gpio_padnum) +void sl_si91x_gpio_enable_ulp_pad_receiver(uint8_t gpio_num) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_num)); // Enable receiver bit in PAD configuration register in ULP instance - ULP_PAD_CONFIG_REG |= BIT(gpio_padnum); + ULP_PAD_CONFIG_REG |= BIT(gpio_num); } /******************************************************************************* * This API is used to disable the ULP PAD receiver. * @note: Select ULP GPIO pins for ULP instances(ULP_GPIO_0 to ULP_GPIO_11). *******************************************************************************/ -void sl_si91x_gpio_disable_ulp_pad_receiver(uint32_t gpio_padnum) +void sl_si91x_gpio_disable_ulp_pad_receiver(uint32_t gpio_num) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_num)); // Disable receiver bit in PAD configuration register in ULP instance - ULP_PAD_CONFIG_REG &= ~BIT(gpio_padnum); + ULP_PAD_CONFIG_REG &= ~BIT(gpio_num); } /******************************************************************************* @@ -901,15 +904,15 @@ void sl_si91x_gpio_disable_ulp_pad_receiver(uint32_t gpio_padnum) * - Select the PAD driver disable state of type @ref sl_si91x_gpio_driver_disable_state_t. * @note: Select ULP GPIO pins for ULP instances(ULP_GPIO_0 to ULP_GPIO_11). ******************************************************************************/ -void sl_si91x_gpio_select_ulp_pad_driver_disable_state(uint8_t gpio_padnum, +void sl_si91x_gpio_select_ulp_pad_driver_disable_state(uint8_t gpio_num, sl_si91x_gpio_driver_disable_state_t disable_state) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_num)); SL_GPIO_ASSERT(SL_GPIO_VALIDATE_DISABLE_STATE(disable_state)); // Select driver disable state in ULP PAD configuration registers - if (gpio_padnum <= GPIO_PAD_3) { + if (gpio_num <= GPIO_PAD_3) { ULP_PAD_CONFIG0_REG->ULP_GPIO_PAD_CONFIG_REG_0.PADCONFIG_P1_P2_1 = disable_state; - } else if ((gpio_padnum >= GPIO_PAD_4) && (gpio_padnum <= GPIO_PAD_7)) { + } else if ((gpio_num >= GPIO_PAD_4) && (gpio_num <= GPIO_PAD_7)) { ULP_PAD_CONFIG0_REG->ULP_GPIO_PAD_CONFIG_REG_0.PADCONFIG_P1_P2_2 = disable_state; } else { ULP_PAD_CONFIG1_REG->ULP_GPIO_PAD_CONFIG_REG_1.PADCONFIG_P1_P2_1 = disable_state; @@ -927,14 +930,14 @@ void sl_si91x_gpio_select_ulp_pad_driver_disable_state(uint8_t gpio_padnum, * - Select the PAD driver strength of type @ref sl_si91x_gpio_driver_strength_select_t. * @note: Select ULP GPIO pins for ULP instances(ULP_GPIO_0 to ULP_GPIO_11). ******************************************************************************/ -void sl_si91x_gpio_select_ulp_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_gpio_driver_strength_select_t strength) +void sl_si91x_gpio_select_ulp_pad_driver_strength(uint8_t gpio_num, sl_si91x_gpio_driver_strength_select_t strength) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_num)); SL_GPIO_ASSERT(SL_GPIO_VALIDATE_STRENGTH(strength)); // Select drive strength in ULP PAD configuration registers - if (gpio_padnum <= GPIO_PAD_3) { + if (gpio_num <= GPIO_PAD_3) { ULP_PAD_CONFIG0_REG->ULP_GPIO_PAD_CONFIG_REG_0.PADCONFIG_E1_E2_1 = strength; - } else if ((gpio_padnum >= GPIO_PAD_4) && (gpio_padnum <= GPIO_PAD_7)) { + } else if ((gpio_num >= GPIO_PAD_4) && (gpio_num <= GPIO_PAD_7)) { ULP_PAD_CONFIG0_REG->ULP_GPIO_PAD_CONFIG_REG_0.PADCONFIG_E1_E2_2 = strength; } else { ULP_PAD_CONFIG1_REG->ULP_GPIO_PAD_CONFIG_REG_1.PADCONFIG_E1_E2_1 = strength; @@ -952,14 +955,14 @@ void sl_si91x_gpio_select_ulp_pad_driver_strength(uint8_t gpio_padnum, sl_si91x_ * - Select the PAD slew rate of type @ref sl_si91x_gpio_slew_rate_t. * @note: Select ULP GPIO pins for ULP instances(ULP_GPIO_0 to ULP_GPIO_11). ******************************************************************************/ -void sl_si91x_gpio_select_ulp_pad_slew_rate(uint8_t gpio_padnum, sl_si91x_gpio_slew_rate_t slew_rate) +void sl_si91x_gpio_select_ulp_pad_slew_rate(uint8_t gpio_num, sl_si91x_gpio_slew_rate_t slew_rate) { - SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_padnum)); + SL_GPIO_ASSERT(SL_GPIO_VALIDATE_ULP_PIN(gpio_num)); SL_GPIO_ASSERT(SL_GPIO_VALIDATE_PARAMETER(slew_rate)); // Select slew rate in ULP PAD configuration registers - if (gpio_padnum <= GPIO_PAD_3) { + if (gpio_num <= GPIO_PAD_3) { ULP_PAD_CONFIG0_REG->ULP_GPIO_PAD_CONFIG_REG_0.PADCONFIG_SR_1 = slew_rate; - } else if ((gpio_padnum >= GPIO_PAD_4) && (gpio_padnum <= GPIO_PAD_7)) { + } else if ((gpio_num >= GPIO_PAD_4) && (gpio_num <= GPIO_PAD_7)) { ULP_PAD_CONFIG0_REG->ULP_GPIO_PAD_CONFIG_REG_0.PADCONFIG_SR_2 = slew_rate; } else { ULP_PAD_CONFIG1_REG->ULP_GPIO_PAD_CONFIG_REG_1.PADCONFIG_SR_1 = slew_rate; @@ -1280,4 +1283,4 @@ sl_si91x_gpio_version_t sl_si91x_gpio_get_version(void) version.major = GPIO_MAJOR_VERSION; version.minor = GPIO_MINOR_VERSION; return version; -} +} \ No newline at end of file diff --git a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_i2c.c b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_i2c.c index 4c553492..19977f34 100644 --- a/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_i2c.c +++ b/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_i2c.c @@ -46,8 +46,8 @@ #define I2C_RELEASE_VERSION 0 // I2C Release version #define I2C_SQA_VERSION 0 // I2C SQA version #define I2C_DEV_VERSION 2 // I2C Developer version -#define HIGH_SPEED_HIGH_COUNT_VALUE 14 // High speed mode clock high count value -#define HIGH_SPEED_LOW_COUNT_VALUE 43 // High speed mode clock high count value +#define HIGH_SPEED_HIGH_COUNT_VALUE 8 // High speed mode clock high count value +#define HIGH_SPEED_LOW_COUNT_VALUE 14 // High speed mode clock high count value /******************************************************************************* *************************** LOCAL VARIABLES ******************************* diff --git a/components/device/silabs/si91x/wireless/ahb_interface/inc/rsi_wlan_common_config.h b/components/device/silabs/si91x/wireless/ahb_interface/inc/rsi_wlan_common_config.h index 45fe0791..87bbbb6d 100644 --- a/components/device/silabs/si91x/wireless/ahb_interface/inc/rsi_wlan_common_config.h +++ b/components/device/silabs/si91x/wireless/ahb_interface/inc/rsi_wlan_common_config.h @@ -323,7 +323,7 @@ // HT caps bit map. #ifndef RSI_HT_CAPS_BIT_MAP -#define RSI_HT_CAPS_BIT_MAP 2 +#define RSI_HT_CAPS_BIT_MAP 0 #endif /*=======================================================================*/ diff --git a/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform_wireless.c b/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform_wireless.c index defb7f8c..a7cd0b52 100644 --- a/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform_wireless.c +++ b/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform_wireless.c @@ -21,6 +21,7 @@ #include "rsi_pll.h" #include "rsi_rom_clks.h" #include "rsi_rom_ulpss_clk.h" +#include "rsi_rom_power_save.h" #include "sl_si91x_host_interface.h" #include "sl_rsi_utility.h" #include "system_si91x.h" @@ -227,28 +228,17 @@ void sl_si91x_trigger_sleep(SLEEP_TYPE_T sleepType, // Turn on the ULPSS RAM domains and retain ULPSS RAMs if ((mode != RSI_WAKEUP_WITH_RETENTION_WO_ULPSS_RAM) || (mode != RSI_WAKEUP_WO_RETENTION_WO_ULPSS_RAM)) { -#ifdef CHIP_9118 - /* Turn on ULPSS SRAM domains*/ - RSI_PS_UlpssRamBanksPowerUp(ULPSS_2K_BANK_0 | ULPSS_2K_BANK_1 | ULPSS_2K_BANK_2 | ULPSS_2K_BANK_3 | ULPSS_2K_BANK_4 - | ULPSS_2K_BANK_5 | ULPSS_2K_BANK_6 | ULPSS_2K_BANK_7); -#endif -#ifdef SLI_SI917 /* Turn on ULPSS SRAM domains*/ - RSI_PS_UlpssRamBanksPowerUp(ULPSS_2K_BANK_0 | ULPSS_2K_BANK_1 | ULPSS_2K_BANK_2 | ULPSS_2K_BANK_3); -#endif -#ifdef CHIP_9118 - /* Turn on ULPSS SRAM Core/Periphery domains*/ - RSI_PS_UlpssRamBanksPeriPowerUp(ULPSS_2K_BANK_0 | ULPSS_2K_BANK_1 | ULPSS_2K_BANK_2 | ULPSS_2K_BANK_3 - | ULPSS_2K_BANK_4 | ULPSS_2K_BANK_5 | ULPSS_2K_BANK_6 | ULPSS_2K_BANK_7); -#endif -#ifdef SLI_SI917 /* Turn on ULPSS SRAM Core/Periphery domains*/ RSI_PS_UlpssRamBanksPeriPowerUp(ULPSS_2K_BANK_0 | ULPSS_2K_BANK_1 | ULPSS_2K_BANK_2 | ULPSS_2K_BANK_3); -#endif - if ((mode == RSI_WAKEUP_FROM_FLASH_MODE) || (mode == RSI_WAKEUP_WITH_RETENTION)) { + if ((mode == RSI_WAKEUP_FROM_FLASH_MODE) || (mode == RSI_WAKEUP_WITH_RETENTION) +#if defined SLI_SI917B0 + || (mode == SL_SI91X_MCU_WAKEUP_PSRAM_MODE) +#endif // SLI_SI917B0 + ) { /* Retain ULPSS RAM*/ RSI_PS_SetRamRetention(ULPSS_RAM_RETENTION_MODE_EN); } @@ -256,13 +246,8 @@ void sl_si91x_trigger_sleep(SLEEP_TYPE_T sleepType, // Peripherals needed on Wake-up (without RAM retention) needs to be powered up before going to sleep if ((mode == RSI_WAKEUP_WITH_OUT_RETENTION) || (mode == RSI_WAKEUP_WO_RETENTION_WO_ULPSS_RAM)) { -#ifdef SLI_SI917 RSI_PS_M4ssPeriPowerUp(M4SS_PWRGATE_ULP_M4_DEBUG_FPU); -#endif -#ifdef CHIP_9118 - RSI_PS_M4ssPeriPowerUp(M4SS_PWRGATE_ULP_M4_FPU); -#endif } // Indicate M4 is Inactive P2P_STATUS_REG &= ~M4_is_active; @@ -279,23 +264,12 @@ void sl_si91x_trigger_sleep(SLEEP_TYPE_T sleepType, return; } #ifndef ENABLE_DEBUG_MODULE -#ifdef SLI_SI917 RSI_PS_M4ssPeriPowerDown(M4SS_PWRGATE_ULP_M4_DEBUG_FPU); -#endif -#ifdef CHIP_9118 - RSI_PS_M4ssPeriPowerDown(M4SS_PWRGATE_ULP_M4_DEBUG); -#endif #endif // ENABLE_DEBUG_MODULE /* Define 'SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION' macro if FLASH execution is needed*/ #ifndef SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION - -#ifdef CHIP_9118 - RSI_PS_M4ssPeriPowerDown(M4SS_PWRGATE_ULP_QSPI | M4SS_PWRGATE_ULP_ICACHE); -#endif -#ifdef SLI_SI917 RSI_PS_M4ssPeriPowerDown(M4SS_PWRGATE_ULP_QSPI_ICACHE); -#endif // Remove this if MCU is executing from Flash #endif //SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION @@ -309,7 +283,7 @@ void sl_si91x_trigger_sleep(SLEEP_TYPE_T sleepType, p2p_intr_status_bkp.m4ss_p2p_intr_set_reg_bkp = M4SS_P2P_INTR_SET_REG; // Configure sleep parameters required by bootloader upon Wake-up - ROMAPI_PWR_API->RSI_GotoSleepWithRetention(stack_address, (uint32_t)jump_cb_address, vector_offset, mode); + RSI_PS_RetentionSleepConfig(stack_address, (uint32_t)jump_cb_address, vector_offset, mode); // Trigger M4 to sleep RSI_PS_EnterDeepSleep(sleepType, lf_clk_mode); @@ -393,37 +367,17 @@ void sl_si91x_configure_ram_retention(uint32_t rams_in_use, uint32_t rams_retent if (rams_retention_during_sleep & WISEMCU_RETAIN_DEFAULT_RAM_DURING_SLEEP) { /* If none of the banks are powered on, clear all retention controls*/ if (rams_in_use & WISEMCU_0KB_RAM_IN_USE) { - RSI_PS_ClrRamRetention(M4ULP_RAM16K_RETENTION_MODE_EN | TA_RAM_RETENTION_MODE_EN | M4ULP_RAM_RETENTION_MODE_EN - | M4SS_RAM_RETENTION_MODE_EN); + RSI_PS_ClrRamRetention(M4ULP_RAM16K_RETENTION_MODE_EN | TA_RAM_RETENTION_MODE_EN | M4ULP_RAM_RETENTION_MODE_EN); } /* Set the 16KB SRAM memory retention */ if (rams_in_use == WISEMCU_16KB_RAM_IN_USE) { RSI_PS_SetRamRetention(M4ULP_RAM16K_RETENTION_MODE_EN); } -#ifdef SLI_SI917 /* Set the full SRAM memory retention if the SRAM memory usage is greater than 16KB */ /* For different SRAM retention modes, respective unused SRAM banks (both SRAM power and core/periphery domains) are powered down as part of the initial configuration above */ else { RSI_PS_SetRamRetention(M4ULP_RAM16K_RETENTION_MODE_EN | M4ULP_RAM_RETENTION_MODE_EN); } -#endif -#ifdef CHIP_9118 - /* Set the M4-ULP 112KB RAM retention*/ - if ((rams_in_use & WISEMCU_48KB_RAM_IN_USE) || (rams_in_use & WISEMCU_112KB_RAM_IN_USE) - || (rams_in_use & WISEMCU_128KB_RAM_IN_USE)) { - RSI_PS_SetRamRetention(M4ULP_RAM_RETENTION_MODE_EN); - } - /* Set the M4SS 64KB RAM retention*/ - if ((rams_in_use & WISEMCU_144KB_RAM_IN_USE) || (rams_in_use & WISEMCU_176KB_RAM_IN_USE) - || (rams_in_use & WISEMCU_192KB_RAM_IN_USE)) { - RSI_PS_SetRamRetention(M4SS_RAM_RETENTION_MODE_EN); - } - /* Set the M4SS 64KB RAM retention*/ - if ((rams_in_use & WISEMCU_208KB_RAM_IN_USE) || (rams_in_use & WISEMCU_240KB_RAM_IN_USE) - || (rams_in_use & WISEMCU_320KB_RAM_IN_USE) || (rams_in_use & WISEMCU_384KB_RAM_IN_USE)) { - RSI_PS_SetRamRetention(TA_RAM_RETENTION_MODE_EN); - } -#endif } else { /* Program user configuration*/ RSI_PS_SetRamRetention(rams_retention_during_sleep); diff --git a/components/device/silabs/si91x/wireless/ble/inc/rsi_ble.h b/components/device/silabs/si91x/wireless/ble/inc/rsi_ble.h index 7f9354c7..c4ba30dc 100644 --- a/components/device/silabs/si91x/wireless/ble/inc/rsi_ble.h +++ b/components/device/silabs/si91x/wireless/ble/inc/rsi_ble.h @@ -487,12 +487,10 @@ typedef struct rsi_ble_req_acceptlist_using_payload_s { #define PERIPHERAL_ROLE 0x03 #endif #define CONN_ROLE 0x04 -// Set BLE tx power per role cmd_ix=0x012D +// Set BLE tx power cmd_ix=0x012D typedef struct rsi_ble_set_ble_tx_power_s { - uint8_t role; - //Address of the device - uint8_t dev_addr[RSI_DEV_ADDR_LEN]; - uint8_t tx_power; + //int8, tx power value + int8_t tx_power; } rsi_ble_set_ble_tx_power_t; //Scan response data command structure @@ -1699,8 +1697,5 @@ struct rsi_ble_cb_s { * * BLE internal function declarations * ******************************************************/ void rsi_ble_callbacks_handler(rsi_bt_cb_t *ble_cb, uint16_t rsp_type, uint8_t *payload, uint16_t payload_length); -int32_t rsi_ble_get_multiple_att_values(uint8_t *dev_addr, - uint8_t num_of_handlers, - uint16_t *handles, - rsi_ble_resp_att_value_t *p_att_vals); + #endif diff --git a/components/device/silabs/si91x/wireless/ble/inc/rsi_ble_apis.h b/components/device/silabs/si91x/wireless/ble/inc/rsi_ble_apis.h index 656867a3..f533b8df 100644 --- a/components/device/silabs/si91x/wireless/ble/inc/rsi_ble_apis.h +++ b/components/device/silabs/si91x/wireless/ble/inc/rsi_ble_apis.h @@ -90,7 +90,7 @@ typedef struct rsi_ble_event_conn_status_s { /**Address of the connected device*/ uint8_t dev_addr[RSI_DEV_ADDR_LEN]; /**status of the connection - success/failure*/ - uint8_t status; + uint16_t status; } rsi_ble_event_conn_status_t; @@ -115,7 +115,7 @@ typedef struct rsi_ble_event_enhnace_conn_status_s { /**Only applicable for peripheral, for central this value is set to 0x00*/ uint8_t master_clock_accuracy; /**Status of the Connection - success/failure*/ - uint8_t status; + uint16_t status; } rsi_ble_event_enhance_conn_status_t; //Disconnect event structure @@ -1101,15 +1101,116 @@ typedef struct rsi_ble_per_transmit_s { - Transmit power value for the rf chain parameter set to LP chain and values are: - - 0 -31 o/p power equation is -2+10log10(power_index/31) -- - 32-63 o/p power equation is + TX power for the BLE LP Chain :1 to 31 (0dBm Mode), 33 to 63 ( 10dBm Mode) - - 6 + 10log10((power_index -32)/31) + TX power for the BLE HP chain : 64 to 127 - - TX power for the BLE LP Chain :1 to 31 (0dBm Mode), 33 to 63 ( 10dBm Mode) + @note For the LP Chain - Power index vs Outpt power in dBm + + * ----------------------------------------------------------------------------------------- + * | Power Index | Output Power in dBm | + * ----------------------|------------------------------------------------------------------- + * | 1 | -22.3054959 | + * | 2 | -16.59332574 | + * | 3 | -13.38278365 | + * | 4 | -11.19804718 | + * | 5 | -9.576522466 | + * | 6 | -8.312070432 | + * | 7 | -7.294640362 | + * | 8 | -6.458448154 | + * | 9 | -5.760963318 | + * | 10 | -5.173042366 | + * | 11 | -4.673788189 | + * | 12 | -4.247653993 | + * | 13 | -3.882708784 | + * | 14 | -3.569545894 | + * | 15 | -3.300567503 | + * | 16 | -3.069499167 | + * | 17 | -2.871050592 | + * | 18 | -2.700672503 | + * | 19 | -2.554378603 | + * | 20 | -2.428612817 | + * | 21 | -2.32014891 | + * | 22 | -2.226013876 | + * | 23 | -2.143429275 | + * | 24 | -2.069766557 | + * | 25 | -2.002513642 | + * | 26 | -1.939250859 | + * | 27 | -1.87763493 | + * | 28 | -1.815390046 | + * | 29 | -1.750305305 | + * | 30 | -1.680237892 | + * | 31 | -1.603121401 | + * | 32 | NA | + * | 33 | -10.4822997 | + * | 34 | -4.9531679 | + * | 35 | -1.931961022 | + * | 36 | 0.057132993 | + * | 37 | 1.476764101 | + * | 38 | 2.5332116 | + * | 39 | 3.336771823 | + * | 40 | 3.953605265 | + * | 41 | 4.426779615 | + * | 42 | 4.786171523 | + * | 43 | 5.053647759 | + * | 44 | 5.246007208 | + * | 45 | 5.37676618 | + * | 46 | 5.457304255 | + * | 47 | 5.497635316 | + * | 48 | 5.506945838 | + * | 49 | 5.493978354 | + * | 50 | 5.467302132 | + * | 51 | 5.435491631 | + * | 52 | 5.407220119 | + * | 53 | 5.391268248 | + * | 54 | 5.396444507 | + * | 55 | 5.431416481 | + * | 56 | 5.504458826 | + * | 57 | 5.62313521 | + * | 58 | 5.793945208 | + * | 59 | 6.02197959 | + * | 60 | 6.310634089 | + * | 61 | 6.661428559 | + * | 62 | 7.073964236 | + * | 63 | 7.546029076 | + * ----------------------|------------------------------------------------------------------- - - TX power for the BLE HP chain : 64 to 79 */ + @note For the HP Chain - Power index vs Outpt power in dBm + + * ----------------------------------------------------------------------------------------- + * | Power Index | Output Power in dBm | + * ----------------------|------------------------------------------------------------------- + * | 1 | 1 | + * | 2 | 2 | + * | 3 | 3 | + * | 4 | 4 | + * | 5 | 5 | + * | 6 | 6 | + * | 7 | 7 | + * | 8 | 8 | + * | 9 | 9 | + * | 10 | 10 | + * | - | - | + * | - | - | + * | - | - | + * | - | - | + * | 41 | 0.5 | + * | 42 | 1 | + * | 43 | 1.5 | + * | 44 | 2 | + * | 45 | 2.5 | + * | 46 | 3 | + * | 47 | 3.5 | + * | 48 | 4 | + * | 49 | 4.5 | + * | 50 | 5 | + * | - | - | + * | - | - | + * | 127 | (Max Power Supported by Country region) | + * ----------------------|------------------------------------------------------------------- + + */ + uint8_t tx_power; /** Transmit mode to be used either Burst/Continuous - @@ -2864,67 +2965,136 @@ void BT_LE_ADPacketExtract(uint8_t *remote_name, uint8_t *pbuf, uint8_t buf_len) * - * 0x4D04 BLE not connected * - - * @note Refer Error Codes section for above error codes \ref error-codes . + * @note Refer Error Codes section for above error codes \ref error-codes. */ int32_t rsi_ble_start_encryption(uint8_t *remote_dev_address, uint16_t ediv, uint8_t *rand, uint8_t *ltk); /*==============================================*/ /** - * @fn int32_t rsi_ble_set_ble_tx_power(uint8_t role, uint8_t *remote_dev_address, - * int8_t tx_power) - * @brief Set the TX power value per GAP role. This is a Blocking API - * @note This API is not supported in the current release. - * @param[in] role - * ADV_ROLE 0x01 - * - - * SCAN_AND_CENTRAL_ROLE 0x02 - * - - * PERIPHERAL_ROLE 0x03 - * - - * CONN_ROLE 0x04 - * - - * @param[in] remote_dev_address - Remote device address - * @param[in] tx_power - power value - * @note remote_dev_address is valid only on role=CONN_ROLE - * - - * #define RSI_BLE_PWR_INX_DBM 0 indicate tx_power in index - * - - * Default Value for BLE TX Power Index is 31, The range for the BLE TX Power Index is 1 to 75 (0, 32 indexes are invalid) - * - - * 1 - 31 BLE - 0DBM Mode. - * - - * 33 - 63 BLE - 10DBM Mode. - * - - * 64 - 75 BLE - HP Mode. - * - - * Currently this API is supports only BLE LP mode . i.e. 1 to 63 BLE LP MODE - * - - * #define RSI_BLE_PWR_INX_DBM 1 indicate tx_power in dBm - * - - * tx_power in dBm (-8dBm to 15 dBm) - * - - * Currently this API is supports only BLE LP mode . i.e. -8 dBm to 4dBm BLE LP MODE - * - - * @return The following values are returned: - * - 0 - Success - * - - * Non-Zero Value - Failure - * - - * 0x4E02 Unknown Connection Identifier - * - - * 0x4E01 Unknown HCI Command - * - - * 0x4E0C Command disallowed - * - - * 0x4046 Invalid Arguments - * - - * 0x4D04 BLE not connected - * - - * 0x4D14 BLE parameter out of mandatory range - * @note Refer Error Codes section for above error codes \ref error-codes . - * - */ -int32_t rsi_ble_set_ble_tx_power(uint8_t role, uint8_t *remote_dev_address, int8_t tx_power); + * @fn int32_t rsi_ble_set_ble_tx_power(int8_t tx_power) + * @brief Set TX power + * @param[in] tx_power Power value + * @return The following values are returned: + * - 0 - Success + * - Non-zero value - Failure + * - 0x4E02 - Unknown connection identifier + * - 0x4E01 - Unknown HCI command + * - 0x4E0C - Command disallowed + * - 0x4046 - Invalid arguments + * - 0x4D04 - BLE not connected + * - 0x4D14 - BLE parameter out of mandatory range + * @note This is a Blocking API. + * @note Refer Error Codes section for above error codes \ref error-codes. + * @note The higher power will be backed off based on country region. + * @note Use the following setting to indicate tx_power as an index: `#define RSI_BLE_PWR_INX_DBM 0` + * - Default value for power index is 31. + * - Valid values for power index range from 1 to 31 and 33 to 127: + * - 1 to 31: BLE - 0dBm mode. + * - 33 to 63: BLE - 10dBm mode. + * - 64 to 82: BLE - 1dBm - 18dBm HP mode in the resolution of 1dBm. + * - 104 to 126: BLE - 0.5dBm - 11dBm HP mode in the resolution of 0.5dbm. + * - 127: BLE HP Mode, max power supported. + * @note Use the following setting to indicate tx_power in dBm (-8dBm to 18dBm): `#define RSI_BLE_PWR_INX_DBM 1` + * @note When switching between HP mode and LP mode, please ensure that no protocol activity is running. + * @note For the LP Chain - Power index vs output power in dBm in E2E mode: + * | Power Index | Output Power in dBm | + * ----------------------|-------------------------------------------------------------------| + * | 1 | -22.3054959 | + * | 2 | -16.59332574 | + * | 3 | -13.38278365 | + * | 4 | -11.19804718 | + * | 5 | -9.576522466 | + * | 6 | -8.312070432 | + * | 7 | -7.294640362 | + * | 8 | -6.458448154 | + * | 9 | -5.760963318 | + * | 10 | -5.173042366 | + * | 11 | -4.673788189 | + * | 12 | -4.247653993 | + * | 13 | -3.882708784 | + * | 14 | -3.569545894 | + * | 15 | -3.300567503 | + * | 16 | -3.069499167 | + * | 17 | -2.871050592 | + * | 18 | -2.700672503 | + * | 19 | -2.554378603 | + * | 20 | -2.428612817 | + * | 21 | -2.32014891 | + * | 22 | -2.226013876 | + * | 23 | -2.143429275 | + * | 24 | -2.069766557 | + * | 25 | -2.002513642 | + * | 26 | -1.939250859 | + * | 27 | -1.87763493 | + * | 28 | -1.815390046 | + * | 29 | -1.750305305 | + * | 30 | -1.680237892 | + * | 31 | -1.603121401 | + * | 32 | N/A | + * | 33 | -10.4822997 | + * | 34 | -4.9531679 | + * | 35 | -1.931961022 | + * | 36 | 0.057132993 | + * | 37 | 1.476764101 | + * | 38 | 2.5332116 | + * | 39 | 3.336771823 | + * | 40 | 3.953605265 | + * | 41 | 4.426779615 | + * | 42 | 4.786171523 | + * | 43 | 5.053647759 | + * | 44 | 5.246007208 | + * | 45 | 5.37676618 | + * | 46 | 5.457304255 | + * | 47 | 5.497635316 | + * | 48 | 5.506945838 | + * | 49 | 5.493978354 | + * | 50 | 5.467302132 | + * | 51 | 5.435491631 | + * | 52 | 5.407220119 | + * | 53 | 5.391268248 | + * | 54 | 5.396444507 | + * | 55 | 5.431416481 | + * | 56 | 5.504458826 | + * | 57 | 5.62313521 | + * | 58 | 5.793945208 | + * | 59 | 6.02197959 | + * | 60 | 6.310634089 | + * | 61 | 6.661428559 | + * | 62 | 7.073964236 | + * | 63 | 7.546029076 | + * @note For the HP Chain - Power index vs output power in dBm in E2E mode: + * | Power Index | Output Power in dBm | + * |---------------------|-------------------------------------------------------------------| + * | 64 | 1 | + * | 65 | 2 | + * | 66 | 3 | + * | 67 | 4 | + * | 68 | 5 | + * | 69 | 6 | + * | 70 | 7 | + * | 71 | 8 | + * | 72 | 9 | + * | 73 | 10 | + * | 74 | 11 | + * | 75 | 12 | + * | 76 | 13 | + * | 77 | 14 | + * | 78 | 15 | + * | - | - | + * | - | - | + * | 104 | 0.5 | + * | 105 | 1 | + * | 106 | 1.5 | + * | 107 | 2 | + * | 108 | 2.5 | + * | 109 | 3 | + * | 110 | 3.5 | + * | 111 | 4 | + * | - | - | + * | 126 | 10.5 | + * | 127 | Max Power Supported by Country region | + */ +int32_t rsi_ble_set_ble_tx_power(int8_t tx_power); /** @} */ /****************************************************** @@ -5831,4 +6001,4 @@ void rsi_ble_gatt_extended_register_callbacks(rsi_ble_on_mtu_exchange_info_t ble #ifdef __cplusplus } #endif -#endif +#endif \ No newline at end of file diff --git a/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common.h b/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common.h index 646bcc9e..d1824d60 100644 --- a/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common.h +++ b/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common.h @@ -368,8 +368,6 @@ uint16_t rsi_bt_global_cb_init(struct rsi_driver_cb_s *driver_cb, uint8_t *buffe uint16_t rsi_driver_process_bt_resp_handler(void *rx_pkt); uint16_t rsi_bt_get_proto_type(uint16_t rsp_type, rsi_bt_cb_t **bt_cb); -int32_t rsi_bt_get_local_name(rsi_bt_resp_get_local_name_t *bt_resp_get_local_name); - #define HCI_BT_PER_STATS_CMD_ID 0x08 #define HCI_BLE_TRANSMIT_CMD_ID 0x13 #define HCI_BLE_RECEIVE_CMD_ID 0x14 diff --git a/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common_apis.h b/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common_apis.h index 4cb038f5..13616db2 100644 --- a/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common_apis.h +++ b/components/device/silabs/si91x/wireless/ble/inc/rsi_bt_common_apis.h @@ -102,7 +102,15 @@ int32_t rsi_bt_set_local_name(uint8_t *local_name); * @param[in] node_id - Node ID (0 - BLE, 1 - BT). * @param[in] payload_len - Length of the payload. * @param[in] payload - Payload containing table data of gain table offset/max power - * @param[in] req_type - update gain table request type (0 - max power update, 1 - offset update) + * @param[in] req_type - Update gain table request type + * - + * 0 - Max power update + * - + * 1 - Max power offset update + * - + * 2 - LP_Chain 0dBm offset update + * - + * 3 - LP_chain 10dBm offset update. * @return The following values are returned: * - 0 - Success *- diff --git a/components/device/silabs/si91x/wireless/ble/src/rsi_ble_gap_apis.c b/components/device/silabs/si91x/wireless/ble/src/rsi_ble_gap_apis.c index b6c8299d..64e1f1e6 100644 --- a/components/device/silabs/si91x/wireless/ble/src/rsi_ble_gap_apis.c +++ b/components/device/silabs/si91x/wireless/ble/src/rsi_ble_gap_apis.c @@ -1716,27 +1716,20 @@ int32_t rsi_ble_start_encryption(uint8_t *remote_dev_address, uint16_t ediv, uin /*==============================================*/ /** - * @fn int32_t rsi_ble_set_ble_tx_power(uint8_t role, uint8_t *remote_dev_address, - * int8_t tx_power) - * @brief Set the TX power value per GAP role. This is a Blocking API - * @note This API is not supported in the current release. - * @param[in] role - * ADV_ROLE 0x01 \n - * SCAN_AND_CENTRAL_ROLE 0x02 \n - * PERIPHERAL_ROLE 0x03 \n - * CONN_ROLE 0x04 \n - * @param[in] remote_dev_address - Remote device address + * @fn int32_t rsi_ble_set_ble_tx_power(int8_t tx_power) + * @brief Set the TX power value. This is a Blocking API * @param[in] tx_power - power value - * @note remote_dev_address is valid only on role=CONN_ROLE \n * #define RSI_BLE_PWR_INX_DBM 0 indicate tx_power in index \n - * Default Value for BLE Tx Power Index is 31, The range for the BLE Tx Power Index is 1 to 75 (0, 32 indexes are invalid) \n + * Default Value for BLE Tx Power Index is 31, The range for the BLE Tx Power Index is 1 to 127 (0, 32 indexes are invalid) \n * 1 - 31 BLE - 0DBM Mode. \n * 33 - 63 BLE - 10DBM Mode. \n - * 64 - 79 BLE - HP Mode. \n - * Currently this API is supports only BLE LP mode . i.e. 1 to 63 BLE LP MODE \n + * 64 - 82 BLE - 1dBm - 18dBm HP Mode in the resolution of 1dBm. \n + * @note: the higher power will be backed off based on country region. + * 104 - 126 BLE - 0.5dBm - 11dBm HP Mode in the resolution of 0.5dbm. \n + * 127 BLE HP Mode, Max power supported. \n * #define RSI_BLE_PWR_INX_DBM 1 indicate tx_power in dBm \n - * tx_power in dBm (-8dBm to 15 dBm) \n - * Currently this API is supports only BLE LP mode . i.e. -8 dBm to 4dBm BLE LP MODE \n + * tx_power in dBm (-8dBm to 18 dBm) \n + * @note: When switching between HP mode and LP mode user need to ensure there should not be any protocol activity running. * @return 0 - Success \n * Non-Zero Value - Failure \n * 0x4E02 Unknown Connection Identifier \n @@ -1749,17 +1742,12 @@ int32_t rsi_ble_start_encryption(uint8_t *remote_dev_address, uint16_t ediv, uin * */ -int32_t rsi_ble_set_ble_tx_power(uint8_t role, uint8_t *remote_dev_address, int8_t tx_power) +int32_t rsi_ble_set_ble_tx_power(int8_t tx_power) { SL_PRINTF(SL_RSI_BLE_SET_BLE_TX_POWER, BLE, LOG_INFO); rsi_ble_set_ble_tx_power_t ble_tx_power = { 0 }; -#ifdef BD_ADDR_IN_ASCII - rsi_ascii_dev_address_to_6bytes_rev(ble_tx_power.dev_addr, remote_dev_address); -#else - memcpy(ble_tx_power.dev_addr, remote_dev_address, RSI_DEV_ADDR_LEN); -#endif - ble_tx_power.role = role; + #if RSI_BLE_PWR_INX_DBM ble_tx_power.tx_power = rsi_convert_db_to_powindex(tx_power); if (ble_tx_power.tx_power == 0) { diff --git a/components/device/silabs/si91x/wireless/ble/src/rsi_bt_ble.c b/components/device/silabs/si91x/wireless/ble/src/rsi_bt_ble.c index ad310ccd..2b35dc12 100644 --- a/components/device/silabs/si91x/wireless/ble/src/rsi_bt_ble.c +++ b/components/device/silabs/si91x/wireless/ble/src/rsi_bt_ble.c @@ -1105,6 +1105,7 @@ void rsi_ble_callbacks_handler(rsi_bt_cb_t *ble_cb, uint16_t rsp_type, uint8_t * } break; case RSI_BLE_EVENT_CONN_STATUS: { if (ble_specific_cb->ble_on_conn_status_event != NULL) { + ((rsi_ble_event_conn_status_t *)payload)->status = status; ble_specific_cb->ble_on_conn_status_event((rsi_ble_event_conn_status_t *)payload); } // rsi_bt_set_status(ble_cb, RSI_BLE_STATE_CONNECTION); @@ -1113,6 +1114,7 @@ void rsi_ble_callbacks_handler(rsi_bt_cb_t *ble_cb, uint16_t rsp_type, uint8_t * case RSI_BLE_EVENT_ENHANCE_CONN_STATUS: { if (ble_specific_cb->ble_on_enhance_conn_status_event != NULL) { + ((rsi_ble_event_enhance_conn_status_t *)payload)->status = status; ble_specific_cb->ble_on_enhance_conn_status_event((rsi_ble_event_enhance_conn_status_t *)payload); } // rsi_bt_set_status(ble_cb, RSI_BLE_STATE_CONNECTION); diff --git a/components/device/silabs/si91x/wireless/ble/src/rsi_bt_common_apis.c b/components/device/silabs/si91x/wireless/ble/src/rsi_bt_common_apis.c index 2eca679a..f9cd7db4 100644 --- a/components/device/silabs/si91x/wireless/ble/src/rsi_bt_common_apis.c +++ b/components/device/silabs/si91x/wireless/ble/src/rsi_bt_common_apis.c @@ -88,7 +88,11 @@ int32_t rsi_bt_set_local_name(uint8_t *local_name) * @param[in] node_id - Node ID (0 - BLE, 1 - BT). * @param[in] payload_len - Length of the payload. * @param[in] payload - Payload containing table data of gain table offset/max power - * @param[in] req_type - update gain table request type (0 - max power update, 1 - offset update) + * @param[in] req_type - update gain table request type \n + * 0 - Max power update \n + * 1 - Max power offset update \n + * 2 - LP_chain 0dBm offset update \n + * 3 - LP_chain 10dBm offset update \n * @return 0 - Success \n * 0x4F01 - Invalid gain table payload length \n * 0x4F02 - Invalid region. \n diff --git a/components/device/silabs/si91x/wireless/crypto/aead/src/sl_si91x_psa_aead.c b/components/device/silabs/si91x/wireless/crypto/aead/src/sl_si91x_psa_aead.c index 0d4203f7..df9a56ec 100644 --- a/components/device/silabs/si91x/wireless/crypto/aead/src/sl_si91x_psa_aead.c +++ b/components/device/silabs/si91x/wireless/crypto/aead/src/sl_si91x_psa_aead.c @@ -216,16 +216,17 @@ psa_status_t sli_si91x_crypto_aead_encrypt(const psa_key_attributes_t *attribute } memcpy(config_ccm.key_config.b0.key_buffer, key_buffer, config_ccm.key_config.b0.key_size); #else + config_ccm.key_config.a0.key = (uint8_t *)malloc(key_buffer_size); config_ccm.key_config.a0.key_length = key_buffer_size; memcpy(config_ccm.key_config.a0.key, key_buffer, config_ccm.key_config.a0.key_length); #endif - if (status != PSA_SUCCESS) { - return status; - } /* Calling sl_si91x_ccm() for CCM encryption */ si91x_status = sl_si91x_ccm(&config_ccm, ciphertext); +#ifndef SLI_SI917B0 + free(config_ccm.key_config.a0.key); +#endif /* gets the si91x error codes and returns its equivalent psa_status codes */ status = convert_si91x_error_code_to_psa_status(si91x_status); @@ -271,16 +272,17 @@ psa_status_t sli_si91x_crypto_aead_encrypt(const psa_key_attributes_t *attribute } memcpy(config_gcm.key_config.b0.key_buffer, key_buffer, config_gcm.key_config.b0.key_size); #else + config_gcm.key_config.a0.key = (uint8_t *)malloc(key_buffer_size); config_gcm.key_config.a0.key_length = key_buffer_size; memcpy(config_gcm.key_config.a0.key, key_buffer, config_gcm.key_config.a0.key_length); #endif - if (status != PSA_SUCCESS) { - return status; - } /* Calling sl_si91x_gcm() for GCM encryption */ si91x_status = sl_si91x_gcm(&config_gcm, ciphertext); +#ifndef SLI_SI917B0 + free(config_gcm.key_config.a0.key); +#endif /* gets the si91x error codes and returns its equivalent psa_status codes */ status = convert_si91x_error_code_to_psa_status(si91x_status); @@ -318,9 +320,6 @@ psa_status_t sli_si91x_crypto_aead_encrypt(const psa_key_attributes_t *attribute memcpy(config_chachapoly.key_config.a0.key_chacha, key_buffer, SL_SI91X_CHACHAPOLY_KEY_SIZE_256); #endif - if (status != PSA_SUCCESS) { - return status; - } /* Calling sl_si91x_chachapoly() for CHACHAPOLY encryption */ si91x_status = sl_si91x_chachapoly(&config_chachapoly, ciphertext); @@ -395,7 +394,7 @@ psa_status_t sli_si91x_crypto_aead_decrypt(const psa_key_attributes_t *attribute config_ccm.nonce_length = nonce_length; config_ccm.ad = additional_data; config_ccm.ad_length = additional_data_length; - config_ccm.tag = ciphertext + (ciphertext_length - tag_length); + config_ccm.tag = (uint8_t *)ciphertext + (ciphertext_length - tag_length); config_ccm.tag_length = tag_length; #ifdef SLI_SI917B0 @@ -425,16 +424,17 @@ psa_status_t sli_si91x_crypto_aead_decrypt(const psa_key_attributes_t *attribute } memcpy(config_ccm.key_config.b0.key_buffer, key_buffer, config_ccm.key_config.b0.key_size); #else + config_ccm.key_config.a0.key = (uint8_t *)malloc(key_buffer_size); config_ccm.key_config.a0.key_length = key_buffer_size; memcpy(config_ccm.key_config.a0.key, key_buffer, config_ccm.key_config.a0.key_length); #endif - if (status != PSA_SUCCESS) { - return status; - } /* Calling sl_si91x_ccm() for CCM decryption */ si91x_status = sl_si91x_ccm(&config_ccm, plaintext); +#ifndef SLI_SI917B0 + free(config_ccm.key_config.a0.key); +#endif status = convert_si91x_error_code_to_psa_status(si91x_status); break; #endif /* PSA_WANT_ALG_CCM */ @@ -478,16 +478,17 @@ psa_status_t sli_si91x_crypto_aead_decrypt(const psa_key_attributes_t *attribute } memcpy(config_gcm.key_config.b0.key_buffer, key_buffer, config_gcm.key_config.b0.key_size); #else + config_gcm.key_config.a0.key = (uint8_t *)malloc(key_buffer_size); config_gcm.key_config.a0.key_length = key_buffer_size; memcpy(config_gcm.key_config.a0.key, key_buffer, config_gcm.key_config.a0.key_length); #endif - if (status != PSA_SUCCESS) { - return status; - } /* Calling sl_si91x_gcm() for GCM decryption */ si91x_status = sl_si91x_gcm(&config_gcm, plaintext); +#ifndef SLI_SI917B0 + free(config_gcm.key_config.a0.key); +#endif status = convert_si91x_error_code_to_psa_status(si91x_status); break; #endif /* PSA_WANT_ALG_GCM */ @@ -523,9 +524,6 @@ psa_status_t sli_si91x_crypto_aead_decrypt(const psa_key_attributes_t *attribute memcpy(config_chachapoly.key_config.a0.key_chacha, key_buffer, SL_SI91X_CHACHAPOLY_KEY_SIZE_256); #endif - if (status != PSA_SUCCESS) { - return status; - } /* Calling sl_si91x_chachapoly() for CHACHAPOLY decryption */ si91x_status = sl_si91x_chachapoly(&config_chachapoly, plaintext); diff --git a/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_aes.c b/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_aes.c index 57fe0af3..7f65f2c8 100644 --- a/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_aes.c +++ b/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_aes.c @@ -33,6 +33,9 @@ #include "sl_status.h" #include "sl_constants.h" #include "sl_si91x_protocol_types.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include "sl_si91x_driver.h" #include @@ -110,6 +113,13 @@ sl_status_t sl_si91x_aes(sl_si91x_aes_config_t *config, uint8_t *output) uint16_t total_length = config->msg_length; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_aes_mutex == NULL) { + crypto_aes_mutex = sl_si91x_crypto_threadsafety_init(crypto_aes_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_aes_mutex); +#endif + while (total_length) { // Check total length if (total_length > SL_SI91X_MAX_DATA_SIZE_IN_BYTES) { @@ -133,6 +143,9 @@ sl_status_t sl_si91x_aes(sl_si91x_aes_config_t *config, uint8_t *output) // Send the current chunk length message status = aes_pending(config, chunk_len, aes_flags, output); if (status != SL_STATUS_OK) { +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_aes_mutex); +#endif return status; } @@ -144,5 +157,9 @@ sl_status_t sl_si91x_aes(sl_si91x_aes_config_t *config, uint8_t *output) total_length -= chunk_len; } +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_aes_mutex); +#endif + return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_psa_aes.c b/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_psa_aes.c index de71894c..1cd59585 100644 --- a/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_psa_aes.c +++ b/components/device/silabs/si91x/wireless/crypto/aes/src/sl_si91x_psa_aes.c @@ -115,17 +115,18 @@ psa_status_t sli_si91x_crypto_cipher_encrypt(const psa_key_attributes_t *attribu config.key_config.b0.key_slot = 0; memcpy(config.key_config.b0.key_buffer, key_buffer, config.key_config.b0.key_size); #else + config.key_config.a0.key = (uint8_t *)malloc(key_buffer_size); config.key_config.a0.key_length = key_buffer_size; memcpy(config.key_config.a0.key, key_buffer, config.key_config.a0.key_length); #endif - if (status != PSA_SUCCESS) { - return status; - } - /* Calling sl_si91x_aes() for AES encryption */ si91x_status = sl_si91x_aes(&config, output); +#ifndef SLI_SI917B0 + free(config.key_config.a0.key); +#endif + /* gets the si91x error codes and returns its equivalent psa_status codes */ status = convert_si91x_error_code_to_psa_status(si91x_status); @@ -218,17 +219,18 @@ psa_status_t sli_si91x_crypto_cipher_decrypt(const psa_key_attributes_t *attribu config.key_config.b0.key_slot = 0; memcpy(config.key_config.b0.key_buffer, key_buffer, config.key_config.b0.key_size); #else + config.key_config.a0.key = (uint8_t *)malloc(key_buffer_size); config.key_config.a0.key_length = key_buffer_size; memcpy(config.key_config.a0.key, key_buffer, config.key_config.a0.key_length); #endif - if (status != PSA_SUCCESS) { - return status; - } - /* Calling sl_si91x_aes() for AES decryption */ si91x_status = sl_si91x_aes(&config, output); +#ifndef SLI_SI917B0 + free(config.key_config.a0.key); +#endif + /* gets the si91x error codes and returns its equivalent psa_status codes */ status = convert_si91x_error_code_to_psa_status(si91x_status); diff --git a/components/device/silabs/si91x/wireless/crypto/attestation/src/sl_si91x_attestation.c b/components/device/silabs/si91x/wireless/crypto/attestation/src/sl_si91x_attestation.c index 2b8287e8..4543295f 100644 --- a/components/device/silabs/si91x/wireless/crypto/attestation/src/sl_si91x_attestation.c +++ b/components/device/silabs/si91x/wireless/crypto/attestation/src/sl_si91x_attestation.c @@ -35,6 +35,9 @@ #include "sl_si91x_driver.h" #include #include "sl_si91x_attestation.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif /** * @fn sl_status_t sl_si91x_attestation_get_token(uint8_t *token, uint16_t length, uint32_t *nonce) @@ -76,6 +79,13 @@ sl_status_t sl_si91x_attestation_get_token(uint8_t *token, uint16_t length, uint //! Copy Data memcpy(&attest->msg[0], nonce, NONCE_DATA_SIZE); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_attestation_mutex == NULL) { + crypto_attestation_mutex = sl_si91x_crypto_threadsafety_init(crypto_attestation_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_attestation_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, attest, @@ -87,6 +97,9 @@ sl_status_t sl_si91x_attestation_get_token(uint8_t *token, uint16_t length, uint free(attest); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_attestation_mutex); +#endif return status; } packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); @@ -94,5 +107,10 @@ sl_status_t sl_si91x_attestation_get_token(uint8_t *token, uint16_t length, uint memcpy(token, packet->data, packet->length); sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); free(attest); + +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_attestation_mutex); +#endif + return status; } \ No newline at end of file diff --git a/components/device/silabs/si91x/wireless/crypto/ccm/inc/sl_si91x_ccm.h b/components/device/silabs/si91x/wireless/crypto/ccm/inc/sl_si91x_ccm.h index 98b9af3d..205a0ccc 100644 --- a/components/device/silabs/si91x/wireless/crypto/ccm/inc/sl_si91x_ccm.h +++ b/components/device/silabs/si91x/wireless/crypto/ccm/inc/sl_si91x_ccm.h @@ -86,7 +86,7 @@ typedef struct { const uint8_t *msg; ///< Pointer to the input message uint16_t msg_length; ///< Length of the message const uint8_t *nonce; ///< Pointer to the Initialization vector - const uint8_t *tag; ///< Pointer to the tag + uint8_t *tag; ///< Pointer to the tag const uint8_t *ad; ///< Pointer to the additional data uint16_t nonce_length; ///< Length of the Initialization vector uint16_t tag_length; ///< Length of the tag diff --git a/components/device/silabs/si91x/wireless/crypto/ccm/src/sl_si91x_ccm.c b/components/device/silabs/si91x/wireless/crypto/ccm/src/sl_si91x_ccm.c index 34ebfce2..1d61391b 100644 --- a/components/device/silabs/si91x/wireless/crypto/ccm/src/sl_si91x_ccm.c +++ b/components/device/silabs/si91x/wireless/crypto/ccm/src/sl_si91x_ccm.c @@ -34,6 +34,9 @@ #include "sl_constants.h" #include "sl_si91x_protocol_types.h" #include "sl_si91x_driver.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include static sl_status_t ccm_pending(sl_si91x_ccm_config_t *config, uint16_t chunk_length, uint8_t ccm_flags, uint8_t *output) @@ -127,11 +130,9 @@ sl_status_t sl_si91x_ccm(sl_si91x_ccm_config_t *config, uint8_t *output) SL_VERIFY_POINTER_OR_RETURN(config->msg, SL_STATUS_NULL_POINTER); if (((config->msg == NULL) && (config->msg_length != 0)) || ((config->ad == NULL) && (config->ad_length != 0)) - || (config->nonce == NULL) || (config->tag == NULL) || ((output == NULL) && (config->msg_length != 0)) || -#ifdef SLI_SI917B0 - config->key_config.b0.key_buffer == NULL -#else - config->key_config.a0.key == NULL + || (config->nonce == NULL) || (config->tag == NULL) || ((output == NULL) && (config->msg_length != 0)) +#ifndef SLI_SI917B0 + || (config->key_config.a0.key == NULL) #endif ) { status = SL_STATUS_INVALID_PARAMETER; @@ -139,6 +140,13 @@ sl_status_t sl_si91x_ccm(sl_si91x_ccm_config_t *config, uint8_t *output) uint16_t total_length = config->msg_length; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_ccm_mutex == NULL) { + crypto_ccm_mutex = sl_si91x_crypto_threadsafety_init(crypto_ccm_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_ccm_mutex); +#endif + if (total_length != 0) { while (total_length) { // Check total length @@ -163,6 +171,9 @@ sl_status_t sl_si91x_ccm(sl_si91x_ccm_config_t *config, uint8_t *output) // Send the current chunk length message status = ccm_pending(config, chunk_len, ccm_flags, output); if (status != SL_STATUS_OK) { +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ccm_mutex); +#endif return status; } @@ -181,6 +192,9 @@ sl_status_t sl_si91x_ccm(sl_si91x_ccm_config_t *config, uint8_t *output) // Send the current chunk length message status = ccm_pending(config, chunk_len, ccm_flags, output); if (status != SL_STATUS_OK) { +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ccm_mutex); +#endif return status; } } @@ -188,5 +202,9 @@ sl_status_t sl_si91x_ccm(sl_si91x_ccm_config_t *config, uint8_t *output) // Copy the tag to the tag_buffer memcpy(config->tag, output + config->msg_length, config->tag_length); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ccm_mutex); +#endif + return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/chachapoly/src/sl_si91x_chachapoly.c b/components/device/silabs/si91x/wireless/crypto/chachapoly/src/sl_si91x_chachapoly.c index 90c66751..733cb86a 100644 --- a/components/device/silabs/si91x/wireless/crypto/chachapoly/src/sl_si91x_chachapoly.c +++ b/components/device/silabs/si91x/wireless/crypto/chachapoly/src/sl_si91x_chachapoly.c @@ -34,6 +34,9 @@ #include "sl_constants.h" #include "sl_si91x_protocol_types.h" #include "sl_si91x_driver.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include static sl_status_t chachapoly_pending(sl_si91x_chachapoly_config_t *config, @@ -59,11 +62,7 @@ static sl_status_t chachapoly_pending(sl_si91x_chachapoly_config_t *config, if (config->chachapoly_mode > 3) return SL_STATUS_INVALID_PARAMETER; -#ifdef SLI_SI917B0 - if (config->key_config.b0.key_buffer == NULL) { - return SL_STATUS_INVALID_PARAMETER; - } -#else +#ifndef SLI_SI917B0 if (config->chachapoly_mode == SL_SI91X_CHACHAPOLY_POLY1305_KEYR_KEYS_MODE || config->chachapoly_mode == SL_SI91X_POLY1305_MODE) { if ((config->key_config.a0.keyr_in == NULL) || (config->key_config.a0.keys_in == NULL)) { @@ -154,6 +153,13 @@ sl_status_t sl_si91x_chachapoly(sl_si91x_chachapoly_config_t *config, uint8_t *o uint16_t total_length = config->msg_length; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_chachapoly_mutex == NULL) { + crypto_chachapoly_mutex = sl_si91x_crypto_threadsafety_init(crypto_chachapoly_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_chachapoly_mutex); +#endif + while (total_length) { // Check total length if (total_length > SL_SI91X_MAX_DATA_SIZE_IN_BYTES_FOR_CHACHAPOLY) { @@ -177,6 +183,9 @@ sl_status_t sl_si91x_chachapoly(sl_si91x_chachapoly_config_t *config, uint8_t *o // Send the current chunk length message status = chachapoly_pending(config, chunk_len, chachapoly_flags, output); if (status != SL_STATUS_OK) { +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_chachapoly_mutex); +#endif return status; } @@ -188,5 +197,9 @@ sl_status_t sl_si91x_chachapoly(sl_si91x_chachapoly_config_t *config, uint8_t *o total_length -= chunk_len; } +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_chachapoly_mutex); +#endif + return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/ecdh/inc/sl_si91x_psa_ecdh.h b/components/device/silabs/si91x/wireless/crypto/ecdh/inc/sl_si91x_psa_ecdh.h index cfebb4c2..72fc9d6b 100644 --- a/components/device/silabs/si91x/wireless/crypto/ecdh/inc/sl_si91x_psa_ecdh.h +++ b/components/device/silabs/si91x/wireless/crypto/ecdh/inc/sl_si91x_psa_ecdh.h @@ -127,12 +127,11 @@ psa_status_t sli_si91x_psa_export_public_key_ecdh(const psa_key_attributes_t *at psa_status_t sli_si91x_psa_ecdh_key_agreement(psa_algorithm_t alg, const psa_key_attributes_t *attributes, - uint8_t *private_key, - uint32_t private_key_len, - uint8_t *peer_key, - uint32_t peer_key_length, + const uint8_t *private_key, + size_t private_key_len, + const uint8_t *peer_key, + size_t peer_key_length, uint8_t *shared_secret, - uint32_t shared_secret_size, - uint32_t *shared_secret_length); - + size_t shared_secret_size, + size_t *shared_secret_length); #endif /* SLI_SI91X_PSA_ECDH_H */ diff --git a/components/device/silabs/si91x/wireless/crypto/ecdh/sl_si91x_psa_ecdh.slcc b/components/device/silabs/si91x/wireless/crypto/ecdh/sl_si91x_psa_ecdh.slcc index a7bbc132..7d357e7d 100644 --- a/components/device/silabs/si91x/wireless/crypto/ecdh/sl_si91x_psa_ecdh.slcc +++ b/components/device/silabs/si91x/wireless/crypto/ecdh/sl_si91x_psa_ecdh.slcc @@ -1,7 +1,7 @@ id: sl_si91x_psa_ecdh package: wiseconnect3_sdk description: > - Implenetation of mbedTls PSA crypto ECDH API + Implementation of mbedTls PSA crypto ECDH API label: PSA ECDH category: Device|Si91x|Wireless|PSA Crypto quality: production diff --git a/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_ecdh.c b/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_ecdh.c index d87e0e9f..2bc3a00c 100644 --- a/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_ecdh.c +++ b/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_ecdh.c @@ -34,6 +34,9 @@ #include "sl_constants.h" #include "sl_si91x_driver.h" #include "sl_utility.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include static sl_status_t get_size_from_ecdh_mode(sl_si91x_ecdh_mode_t ecdh_mode, uint8_t *size) @@ -105,6 +108,13 @@ static sl_status_t ecdh_add_sub(sl_si91x_ecdh_mode_t ecdh_mode, memcpy(request->ty, ty, size); memcpy(request->tz, tz, size); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_ecdh_mutex == NULL) { + crypto_ecdh_mutex = sl_si91x_crypto_threadsafety_init(crypto_ecdh_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_ecdh_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -116,6 +126,9 @@ static sl_status_t ecdh_add_sub(sl_si91x_ecdh_mode_t ecdh_mode, free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); @@ -128,6 +141,9 @@ static sl_status_t ecdh_add_sub(sl_si91x_ecdh_mode_t ecdh_mode, memcpy(rz, (result + offset), SL_SI91X_ECDH_MAX_VECTOR_SIZE); sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); free(request); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif return status; } @@ -213,6 +229,13 @@ sl_status_t sl_si91x_ecdh_point_multiplication(sl_si91x_ecdh_mode_t ecdh_mode, reverse_digits(request->d, size); } +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_ecdh_mutex == NULL) { + crypto_ecdh_mutex = sl_si91x_crypto_threadsafety_init(crypto_ecdh_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_ecdh_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -224,6 +247,9 @@ sl_status_t sl_si91x_ecdh_point_multiplication(sl_si91x_ecdh_mode_t ecdh_mode, free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); @@ -243,6 +269,9 @@ sl_status_t sl_si91x_ecdh_point_multiplication(sl_si91x_ecdh_mode_t ecdh_mode, sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); free(request); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif return status; } @@ -287,6 +316,13 @@ sl_status_t sl_si91x_ecdh_point_double(sl_si91x_ecdh_mode_t ecdh_mode, memcpy(request->sy, sy, size); memcpy(request->sz, sz, size); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_ecdh_mutex == NULL) { + crypto_ecdh_mutex = sl_si91x_crypto_threadsafety_init(crypto_ecdh_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_ecdh_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -298,6 +334,9 @@ sl_status_t sl_si91x_ecdh_point_double(sl_si91x_ecdh_mode_t ecdh_mode, free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); @@ -310,6 +349,9 @@ sl_status_t sl_si91x_ecdh_point_double(sl_si91x_ecdh_mode_t ecdh_mode, memcpy(rz, (result + offset), SL_SI91X_ECDH_MAX_VECTOR_SIZE); sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); free(request); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif return status; } @@ -355,6 +397,13 @@ sl_status_t sl_si91x_ecdh_point_affine(sl_si91x_ecdh_mode_t ecdh_mode, memcpy(request->sy, sy, size); memcpy(request->sz, sz, size); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_ecdh_mutex == NULL) { + crypto_ecdh_mutex = sl_si91x_crypto_threadsafety_init(crypto_ecdh_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_ecdh_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -366,6 +415,9 @@ sl_status_t sl_si91x_ecdh_point_affine(sl_si91x_ecdh_mode_t ecdh_mode, free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); @@ -379,5 +431,8 @@ sl_status_t sl_si91x_ecdh_point_affine(sl_si91x_ecdh_mode_t ecdh_mode, sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); free(request); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_ecdh_mutex); +#endif return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_psa_ecdh.c b/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_psa_ecdh.c index d42cea58..1b73bcc0 100644 --- a/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_psa_ecdh.c +++ b/components/device/silabs/si91x/wireless/crypto/ecdh/src/sl_si91x_psa_ecdh.c @@ -176,13 +176,13 @@ psa_status_t sli_si91x_psa_export_public_key_ecdh(const psa_key_attributes_t *at psa_status_t sli_si91x_psa_ecdh_key_agreement(psa_algorithm_t alg, const psa_key_attributes_t *attributes, - uint8_t *private_key, - uint32_t private_key_len, - uint8_t *peer_key, - uint32_t peer_key_length, + const uint8_t *private_key, + size_t private_key_len, + const uint8_t *peer_key, + size_t peer_key_length, uint8_t *shared_secret, - uint32_t shared_secret_size, - uint32_t *shared_secret_length) + size_t shared_secret_size, + size_t *shared_secret_length) { (void)alg; (void)attributes; diff --git a/components/device/silabs/si91x/wireless/crypto/gcm/src/sl_si91x_gcm.c b/components/device/silabs/si91x/wireless/crypto/gcm/src/sl_si91x_gcm.c index 2e3a94b3..cd22942b 100644 --- a/components/device/silabs/si91x/wireless/crypto/gcm/src/sl_si91x_gcm.c +++ b/components/device/silabs/si91x/wireless/crypto/gcm/src/sl_si91x_gcm.c @@ -34,6 +34,9 @@ #include "sl_constants.h" #include "sl_si91x_protocol_types.h" #include "sl_si91x_driver.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include static sl_status_t gcm_pending(sl_si91x_gcm_config_t *config, uint16_t chunk_length, uint8_t gcm_flags, uint8_t *output) @@ -129,7 +132,7 @@ sl_status_t sl_si91x_gcm(sl_si91x_gcm_config_t *config, uint8_t *output) if ((config->msg == NULL) || (output == NULL) || #ifdef SLI_SI917B0 - (config->key_config.b0.key_buffer == NULL) || (config->gcm_mode == SL_SI91X_GCM_MODE && config->nonce == NULL) + (config->gcm_mode == SL_SI91X_GCM_MODE && config->nonce == NULL) #else (config->key_config.a0.key == NULL) || (config->nonce == NULL) #endif @@ -139,6 +142,13 @@ sl_status_t sl_si91x_gcm(sl_si91x_gcm_config_t *config, uint8_t *output) uint16_t total_length = config->msg_length; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_gcm_mutex == NULL) { + crypto_gcm_mutex = sl_si91x_crypto_threadsafety_init(crypto_gcm_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_gcm_mutex); +#endif + while (total_length) { // Check total length if (total_length > SL_SI91X_MAX_DATA_SIZE_IN_BYTES) { @@ -162,6 +172,9 @@ sl_status_t sl_si91x_gcm(sl_si91x_gcm_config_t *config, uint8_t *output) // Send the current chunk length message status = gcm_pending(config, chunk_len, gcm_flags, output); if (status != SL_STATUS_OK) { +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_gcm_mutex); +#endif return status; } @@ -173,5 +186,8 @@ sl_status_t sl_si91x_gcm(sl_si91x_gcm_config_t *config, uint8_t *output) total_length -= chunk_len; } +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_gcm_mutex); +#endif return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_hmac.c b/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_hmac.c index 91421780..1e812b38 100644 --- a/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_hmac.c +++ b/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_hmac.c @@ -32,6 +32,9 @@ #include "sl_si91x_protocol_types.h" #include "sl_constants.h" #include "sl_si91x_driver.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include static sl_status_t hmac_pending(sl_si91x_hmac_config_t *config, @@ -127,6 +130,13 @@ sl_status_t sl_si91x_hmac(sl_si91x_hmac_config_t *config, uint8_t *output) memcpy((data + key_length), config->msg, config->msg_length); // Copy message into data +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_hmac_mutex == NULL) { + crypto_hmac_mutex = sl_si91x_crypto_threadsafety_init(crypto_hmac_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_hmac_mutex); +#endif + while (total_length) { // Check total length if (total_length > SL_SI91X_MAX_DATA_SIZE_IN_BYTES) { @@ -152,6 +162,9 @@ sl_status_t sl_si91x_hmac(sl_si91x_hmac_config_t *config, uint8_t *output) status = hmac_pending(config, data, chunk_len, (config->msg_length + key_length), hmac_sha_flags, output); if (status != SL_STATUS_OK) { free(data); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_hmac_mutex); +#endif return status; } @@ -164,5 +177,8 @@ sl_status_t sl_si91x_hmac(sl_si91x_hmac_config_t *config, uint8_t *output) } free(data); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_hmac_mutex); +#endif return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_psa_hmac.c b/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_psa_hmac.c index dc700825..c462bb7e 100644 --- a/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_psa_hmac.c +++ b/components/device/silabs/si91x/wireless/crypto/hmac/src/sl_si91x_psa_hmac.c @@ -133,16 +133,23 @@ psa_status_t sli_si91x_crypto_mac_compute(const psa_key_attributes_t *attributes /* Set key_size from key_buffer_size */ config.key_config.B0.key_size = key_buffer_size; - + config.key_config.B0.key = (uint8_t *)malloc(key_buffer_size); config.key_config.B0.key_slot = 0; memcpy(config.key_config.B0.key, key_buffer, key_buffer_size); #else + config.key_config.A0.key = (uint8_t *)malloc(key_buffer_size); config.key_config.A0.key_length = key_buffer_size; memcpy(config.key_config.A0.key, key_buffer, key_buffer_size); #endif si91x_status = sl_si91x_hmac(&config, mac); +#ifdef SLI_SI917B0 + free(config.key_config.B0.key); +#else + free(config.key_config.A0.key); +#endif + //Convert the error code from si91x to psa status = convert_si91x_error_code_to_psa_status(si91x_status); if (status != PSA_SUCCESS) { diff --git a/components/device/silabs/si91x/wireless/crypto/inc/sli_si91x_crypto_driver_functions.h b/components/device/silabs/si91x/wireless/crypto/inc/sli_si91x_crypto_driver_functions.h index d8c6c9ed..556255a6 100644 --- a/components/device/silabs/si91x/wireless/crypto/inc/sli_si91x_crypto_driver_functions.h +++ b/components/device/silabs/si91x/wireless/crypto/inc/sli_si91x_crypto_driver_functions.h @@ -33,6 +33,30 @@ #include "psa/crypto.h" #include "sl_status.h" #include "sl_si91x_crypto.h" + +#ifdef SLI_CIPHER_DEVICE_SI91X +#include "sl_si91x_psa_aes.h" +#endif + +#ifdef SLI_AEAD_DEVICE_SI91X +#include "sl_si91x_psa_aead.h" +#endif + +#ifdef SLI_TRNG_DEVICE_SI91X +#include "sl_si91x_psa_trng.h" +#endif + +#ifdef SLI_ECDH_DEVICE_SI91X +#include "sl_si91x_psa_ecdh.h" +#endif + +#ifdef SLI_MAC_DEVICE_SI91X +#include "sl_si91x_psa_hmac.h" +#endif + +#ifdef SLI_SHA_DEVICE_SI91X +#include "sl_si91x_psa_sha.h" +#endif /****************************************************** * Function Declarations *******************************************************/ diff --git a/components/device/silabs/si91x/wireless/crypto/multithread/inc/sl_si91x_crypto_thread.h b/components/device/silabs/si91x/wireless/crypto/multithread/inc/sl_si91x_crypto_thread.h new file mode 100644 index 00000000..5fdf0b6c --- /dev/null +++ b/components/device/silabs/si91x/wireless/crypto/multithread/inc/sl_si91x_crypto_thread.h @@ -0,0 +1,50 @@ +/***************************************************************************/ /** + * @file sl_si91x_crypto_thread.h + * @brief Top level application functions. + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#pragma once + +/****************************************************** + * Includes +*******************************************************/ +#include +#include "cmsis_os2.h" +#include "sl_net.h" +#include "sl_wifi.h" +#include "sl_status.h" + +/****************************************************** + * Variable Declarations +*******************************************************/ + +extern osSemaphoreId_t crypto_aes_mutex; +extern osSemaphoreId_t crypto_ccm_mutex; +extern osSemaphoreId_t crypto_sha_mutex; +extern osSemaphoreId_t crypto_gcm_mutex; +extern osSemaphoreId_t crypto_chachapoly_mutex; +extern osSemaphoreId_t crypto_attestation_mutex; +extern osSemaphoreId_t crypto_ecdh_mutex; +extern osSemaphoreId_t crypto_hmac_mutex; +extern osSemaphoreId_t crypto_trng_mutex; +extern osStatus_t mutex_result; + +/****************************************************** + * Function Declarations +*******************************************************/ + +osSemaphoreId_t sl_si91x_crypto_threadsafety_init(osSemaphoreId_t *mutex); +osStatus_t sl_si91x_crypto_mutex_acquire(osSemaphoreId_t *mutex); +osStatus_t sl_si91x_crypto_mutex_release(osSemaphoreId_t *mutex); diff --git a/components/device/silabs/si91x/wireless/crypto/multithread/sl_si91x_crypto_multithread.slcc b/components/device/silabs/si91x/wireless/crypto/multithread/sl_si91x_crypto_multithread.slcc new file mode 100644 index 00000000..8bfe0e1e --- /dev/null +++ b/components/device/silabs/si91x/wireless/crypto/multithread/sl_si91x_crypto_multithread.slcc @@ -0,0 +1,22 @@ +id: sl_si91x_crypto_multithread +package: wiseconnect3_sdk +description: > + Implementation of the thread-safe mechanism in crypto hardware accelerators +label: CRYPTO MULTITHREAD +category: Device|Si91x|Wireless|Crypto +quality: production +component_root_path: ./components/device/silabs/si91x/wireless/crypto/multithread +provides: +- name: sl_si91x_crypto_multithread +source: +- path: src/sl_si91x_crypto_thread.c +define: +- name: SLI_MULTITHREAD_DEVICE_SI91X +requires: +- name: sl_si91x_crypto + +include: +- path: inc + file_list: + - path: sl_si91x_crypto_thread.h + diff --git a/components/device/silabs/si91x/wireless/crypto/multithread/src/sl_si91x_crypto_thread.c b/components/device/silabs/si91x/wireless/crypto/multithread/src/sl_si91x_crypto_thread.c new file mode 100644 index 00000000..284cb77a --- /dev/null +++ b/components/device/silabs/si91x/wireless/crypto/multithread/src/sl_si91x_crypto_thread.c @@ -0,0 +1,70 @@ +/******************************************************************************* + * @file sl_si91x_crypto_thread.c + * @brief SLI SI91X Crypto thread safety file + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include +#include "cmsis_os2.h" +#include "sl_net.h" +#include "sl_wifi.h" +#include "sl_status.h" +#include "sl_si91x_crypto_thread.h" + +osSemaphoreId_t crypto_aes_mutex = 0; +osSemaphoreId_t crypto_ccm_mutex = 0; +osSemaphoreId_t crypto_sha_mutex = 0; +osSemaphoreId_t crypto_gcm_mutex = 0; +osSemaphoreId_t crypto_chachapoly_mutex = 0; +osSemaphoreId_t crypto_attestation_mutex = 0; +osSemaphoreId_t crypto_ecdh_mutex = 0; +osSemaphoreId_t crypto_hmac_mutex = 0; +osSemaphoreId_t crypto_trng_mutex = 0; +osStatus_t mutex_result = osOK; + +osSemaphoreId_t sl_si91x_crypto_threadsafety_init(osSemaphoreId_t *mutex) +{ + if (mutex == NULL) { + + osSemaphoreAttr_t sl_osSemaphoreAttr_t; + + //Set Semaphore flags attributes + sl_osSemaphoreAttr_t.name = "crypto_mutex"; + sl_osSemaphoreAttr_t.attr_bits = 0U; + sl_osSemaphoreAttr_t.cb_mem = NULL; + sl_osSemaphoreAttr_t.cb_size = 0U; + + mutex = osSemaphoreNew(1U, 1U, &sl_osSemaphoreAttr_t); + + osSemaphoreRelease(mutex); + } + return mutex; +} + +osStatus_t sl_si91x_crypto_mutex_acquire(osSemaphoreId_t *mutex) +{ + mutex_result = osSemaphoreAcquire(mutex, osWaitForever); + if (mutex_result != osOK) { + printf("Mutex acquire fail : %d \r\n", mutex_result); + } + return mutex_result; +} + +osStatus_t sl_si91x_crypto_mutex_release(osSemaphoreId_t *mutex) +{ + mutex_result = osSemaphoreRelease(mutex); + if (mutex_result != osOK) { + printf("Mutex release fail : %d \r\n", mutex_result); + } + return mutex_result; +} diff --git a/components/device/silabs/si91x/wireless/crypto/sha/sl_si91x_psa_sha.slcc b/components/device/silabs/si91x/wireless/crypto/sha/sl_si91x_psa_sha.slcc index 5fc41dab..bc8d48d4 100644 --- a/components/device/silabs/si91x/wireless/crypto/sha/sl_si91x_psa_sha.slcc +++ b/components/device/silabs/si91x/wireless/crypto/sha/sl_si91x_psa_sha.slcc @@ -1,7 +1,7 @@ id: sl_si91x_psa_sha package: wiseconnect3_sdk description: > - Implenetation of mbedTls PSA crypto SHA API + Implementation of mbedTls PSA crypto SHA API label: PSA SHA category: Device|Si91x|Wireless|PSA Crypto quality: production diff --git a/components/device/silabs/si91x/wireless/crypto/sha/src/sl_si91x_sha.c b/components/device/silabs/si91x/wireless/crypto/sha/src/sl_si91x_sha.c index 0075d276..2b1a1fff 100644 --- a/components/device/silabs/si91x/wireless/crypto/sha/src/sl_si91x_sha.c +++ b/components/device/silabs/si91x/wireless/crypto/sha/src/sl_si91x_sha.c @@ -20,6 +20,9 @@ #include "sl_status.h" #include "sl_constants.h" #include "sl_si91x_protocol_types.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include "sl_si91x_driver.h" #include @@ -103,6 +106,13 @@ sl_status_t sl_si91x_sha(uint8_t sha_mode, uint8_t *msg, uint16_t msg_length, ui total_len = msg_length; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_sha_mutex == NULL) { + crypto_sha_mutex = sl_si91x_crypto_threadsafety_init(crypto_sha_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_sha_mutex); +#endif + while (total_len) { // Check total length if (total_len > SL_SI91X_MAX_DATA_SIZE_IN_BYTES) { @@ -131,6 +141,9 @@ sl_status_t sl_si91x_sha(uint8_t sha_mode, uint8_t *msg, uint16_t msg_length, ui if (status != SL_STATUS_OK) { SL_PRINTF(SL_SHA_CHUNK_LENGTH_MSG_ERROR, CRYPTO, LOG_ERROR, "status: %4x", status); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_sha_mutex); +#endif return status; } @@ -142,6 +155,10 @@ sl_status_t sl_si91x_sha(uint8_t sha_mode, uint8_t *msg, uint16_t msg_length, ui total_len -= chunk_len; } +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_sha_mutex); +#endif + SL_PRINTF(SL_SHA_EXIT, CRYPTO, LOG_INFO, "status: %4x", status); return status; } diff --git a/components/device/silabs/si91x/wireless/crypto/trng/src/sl_si91x_trng.c b/components/device/silabs/si91x/wireless/crypto/trng/src/sl_si91x_trng.c index 9aaaeaed..939bbc14 100644 --- a/components/device/silabs/si91x/wireless/crypto/trng/src/sl_si91x_trng.c +++ b/components/device/silabs/si91x/wireless/crypto/trng/src/sl_si91x_trng.c @@ -21,6 +21,9 @@ #include "sl_constants.h" #include "sl_si91x_protocol_types.h" #include "sl_si91x_driver.h" +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) +#include "sl_si91x_crypto_thread.h" +#endif #include #ifdef SLI_TRNG_DEVICE_SI91X @@ -51,6 +54,14 @@ sl_status_t sl_si91x_trng_init(sl_si91x_trng_config_t *config, uint32_t *output) request->total_msg_length = config->input_length; memcpy(request->trng_key, config->trng_key, TRNG_KEY_SIZE * 4); memcpy(request->msg, config->trng_test_data, config->input_length * 4); + +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_trng_mutex == NULL) { + crypto_trng_mutex = sl_si91x_crypto_threadsafety_init(crypto_trng_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_trng_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -62,13 +73,18 @@ sl_status_t sl_si91x_trng_init(sl_si91x_trng_config_t *config, uint32_t *output) free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); memcpy(output, packet->data, packet->length); free(request); sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); - +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif return status; } @@ -86,6 +102,13 @@ sl_status_t sl_si91x_trng_entropy(void) request->algorithm_type = TRNG; request->algorithm_sub_type = TRNG_ENTROPY; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_trng_mutex == NULL) { + crypto_trng_mutex = sl_si91x_crypto_threadsafety_init(crypto_trng_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_trng_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -94,7 +117,9 @@ sl_status_t sl_si91x_trng_entropy(void) NULL, NULL); free(request); - VERIFY_STATUS_AND_RETURN(status); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif return status; } @@ -120,6 +145,13 @@ sl_status_t sl_si91x_trng_program_key(uint32_t *trng_key, uint16_t key_length) request->algorithm_sub_type = TRNG_KEY; memcpy(request->trng_key, trng_key, TRNG_KEY_SIZE * 4); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_trng_mutex == NULL) { + crypto_trng_mutex = sl_si91x_crypto_threadsafety_init(crypto_trng_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_trng_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -131,6 +163,9 @@ sl_status_t sl_si91x_trng_program_key(uint32_t *trng_key, uint16_t key_length) free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); @@ -138,7 +173,9 @@ sl_status_t sl_si91x_trng_program_key(uint32_t *trng_key, uint16_t key_length) memcpy(trng_key, packet->data, packet->length); free(request); sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); - +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif return status; } @@ -164,6 +201,13 @@ sl_status_t sl_si91x_trng_get_random_num(uint32_t *random_number, uint16_t lengt request->algorithm_sub_type = TRNG_GENERATION; request->total_msg_length = length; +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + if (crypto_trng_mutex == NULL) { + crypto_trng_mutex = sl_si91x_crypto_threadsafety_init(crypto_trng_mutex); + } + mutex_result = sl_si91x_crypto_mutex_acquire(crypto_trng_mutex); +#endif + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_ENCRYPT_CRYPTO, SI91X_COMMON_CMD_QUEUE, request, @@ -175,6 +219,9 @@ sl_status_t sl_si91x_trng_get_random_num(uint32_t *random_number, uint16_t lengt free(request); if (buffer != NULL) sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif } VERIFY_STATUS_AND_RETURN(status); @@ -188,7 +235,9 @@ sl_status_t sl_si91x_trng_get_random_num(uint32_t *random_number, uint16_t lengt } free(request); sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); - +#if defined(SLI_MULTITHREAD_DEVICE_SI91X) + mutex_result = sl_si91x_crypto_mutex_release(crypto_trng_mutex); +#endif return status; } diff --git a/components/device/silabs/si91x/wireless/inc/mqtt/inc/si91x_mqtt_client_types.h b/components/device/silabs/si91x/wireless/inc/mqtt/inc/si91x_mqtt_client_types.h index c0984db8..f235288c 100644 --- a/components/device/silabs/si91x/wireless/inc/mqtt/inc/si91x_mqtt_client_types.h +++ b/components/device/silabs/si91x/wireless/inc/mqtt/inc/si91x_mqtt_client_types.h @@ -20,11 +20,12 @@ //Note: Please go through http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html -#define SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH 62 -#define SI91X_MQTT_CLIENT_MESSAGE_MAXIMUM_LENGTH 100 +#define SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH 202 +#define SI91X_MQTT_CLIENT_WILL_TOPIC_MAXIMUM_LENGTH 62 +#define SI91X_MQTT_CLIENT_MESSAGE_MAXIMUM_LENGTH 100 #define SI91X_MQTT_CLIENT_ID_MAXIMUM_LENGTH 62 -#define SI91X_MQTT_CLIENT_USERNAME_MAXIMUM_LENGTH 62 +#define SI91X_MQTT_CLIENT_USERNAME_MAXIMUM_LENGTH 122 #define SI91X_MQTT_CLIENT_PASSWORD_MAXIMUM_LENGTH 62 #define SI91X_MQTT_CLIENT_INIT_COMMAND 1 @@ -93,7 +94,7 @@ typedef struct __attribute__((__packed__)) { // length of topic uint8_t will_topic_len; // topic name of will - uint8_t will_topic[SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH]; + uint8_t will_topic[SI91X_MQTT_CLIENT_WILL_TOPIC_MAXIMUM_LENGTH]; // Length of Will message uint8_t will_message_len; // message of will diff --git a/components/device/silabs/si91x/wireless/inc/sl_rsi_utility.h b/components/device/silabs/si91x/wireless/inc/sl_rsi_utility.h index 4f52d0c5..9b68f192 100644 --- a/components/device/silabs/si91x/wireless/inc/sl_rsi_utility.h +++ b/components/device/silabs/si91x/wireless/inc/sl_rsi_utility.h @@ -67,6 +67,11 @@ typedef struct { sl_si91x_coex_mode_t coex_mode; } sli_si91x_performance_profile_t; +/// Efuse data information +typedef struct { + uint8_t mfg_sw_version; ///< Manufacturing PTE software version +} sl_si91x_efuse_data_t; + typedef uint32_t sl_si91x_host_timestamp_t; typedef void (*sl_si91x_host_atomic_action_function_t)(void *user_data); @@ -149,6 +154,47 @@ sl_status_t convert_sl_wifi_to_sl_si91x_encryption( *********************************************************************************************/ sl_status_t sl_si91x_send_power_save_request(sl_si91x_performance_profile_t profile); +/***************************************************************************/ /** + * @brief + * Get the Efuse Data content from flash. + * @pre Pre-conditions: + * - + * @ref sl_wifi_init should be called before this API. + * @param[out] efuse_data + * @ref sl_si91x_efuse_data_t object that contains the Manufacturing software version. + * @return + * sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details. + * @note + * This API is not supported in the current release. + ******************************************************************************/ +sl_status_t sl_si91x_get_flash_efuse_data(sl_si91x_efuse_data_t *efuse_data); + +/***************************************************************************/ /** + * @brief + * Get the Efuse Data content from driver context. + * @pre Pre-conditions: + * - + * @ref sl_wifi_init should be called before this API. + * @param[out] efuse_data + * @ref sl_si91x_efuse_data_t object that contains the Manufacturing software version. + * @return + * sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details. + ******************************************************************************/ +void sl_si91x_get_efuse_data(sl_si91x_efuse_data_t *efuse_data); + +/***************************************************************************/ /** + * @brief + * Set the Efuse Data content in driver context. + * @pre Pre-conditions: + * - + * @ref sl_wifi_init should be called before this API. + * @param[out] efuse_data + * @ref sl_si91x_efuse_data_t object that contains the Manufacturing software version. + * @return + * sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details. + ******************************************************************************/ +void sl_si91x_set_efuse_data(sl_si91x_efuse_data_t *efuse_data); + /** * An utility function to convert dBm value to si91x specific power value * @param wifi_max_tx_power which holds the join power value with dBm as units. diff --git a/components/device/silabs/si91x/wireless/inc/sl_si91x_constants.h b/components/device/silabs/si91x/wireless/inc/sl_si91x_constants.h index 75c48542..3283053d 100644 --- a/components/device/silabs/si91x/wireless/inc/sl_si91x_constants.h +++ b/components/device/silabs/si91x/wireless/inc/sl_si91x_constants.h @@ -306,7 +306,8 @@ typedef enum { RSI_COMMON_REQ_FEATURE_FRAME = 0xC8, RSI_COMMON_REQ_PWRMODE = 0x15, // Reusing RSI_WLAN_REQ_FW_VERSION as RSI_COMMON_REQ_FW_VERSION - RSI_COMMON_REQ_FW_VERSION = 0x49, + RSI_COMMON_REQ_FW_VERSION = 0x49, + RSI_COMMON_REQ_GET_EFUSE_DATA = 0xA0, // Unimplemented common command requests RSI_COMMON_REQ_SOFT_RESET = 0x1C, @@ -394,12 +395,13 @@ typedef enum { #endif // Reusing RSI_WLAN_REQ_FW_VERSION as RSI_COMMON_REQ_FW_VERSION , - RSI_COMMON_RSP_FW_VERSION = 0x49, - RSI_COMMON_RSP_SWITCH_PROTO = 0x77, - RSI_COMMON_RSP_GET_RAM_DUMP = 0x92, - RSI_COMMON_RSP_ASSERT = 0xE1, - RSI_COMMON_RSP_SET_RTC_TIMER = 0xE9, - RSI_COMMON_RSP_GET_RTC_TIMER = 0xF2 + RSI_COMMON_RSP_GET_EFUSE_DATA = 0xA0, + RSI_COMMON_RSP_FW_VERSION = 0x49, + RSI_COMMON_RSP_SWITCH_PROTO = 0x77, + RSI_COMMON_RSP_GET_RAM_DUMP = 0x92, + RSI_COMMON_RSP_ASSERT = 0xE1, + RSI_COMMON_RSP_SET_RTC_TIMER = 0xE9, + RSI_COMMON_RSP_GET_RTC_TIMER = 0xF2 #ifdef CONFIGURE_GPIO_FROM_HOST , RSI_COMMON_RSP_GPIO_CONFIG = 0x28 @@ -523,6 +525,7 @@ typedef enum { RSI_WLAN_REQ_UPDATE_TCP_WINDOW = 0xF5, RSI_WLAN_REQ_DNS_UPDATE = 0xED, RSI_WLAN_REQ_DNS_SERVER_ADD = 0x55, + RSI_WLAN_REQ_TSF = 0x65, } rsi_wlan_cmd_request_t; // enumeration for WLAN command response codes @@ -659,6 +662,7 @@ typedef enum { RSI_WLAN_RSP_MODULE_STATE = 0x70, RSI_WLAN_RSP_TWT_ASYNC = 0x71, RSI_WLAN_RSP_UPDATE_TCP_WINDOW = 0xF5, + RSI_WLAN_RSP_TSF = 0x65, // Unimplemented commands after 22Q2 RSI_WLAN_RATE_RSP_STATS = 0x88 diff --git a/components/device/silabs/si91x/wireless/inc/sl_si91x_protocol_types.h b/components/device/silabs/si91x/wireless/inc/sl_si91x_protocol_types.h index 1a9830bd..a12c8aa7 100644 --- a/components/device/silabs/si91x/wireless/inc/sl_si91x_protocol_types.h +++ b/components/device/silabs/si91x/wireless/inc/sl_si91x_protocol_types.h @@ -470,13 +470,23 @@ typedef struct { // IPV6 ipconfig command response structure typedef struct { // prefix length - uint8_t prefixLength[2]; + uint16_t prefixLength; - // Configured IPv address - uint8_t ipaddr6[16]; + // reserved bytes + uint16_t reserved; + + // Link local address + uint32_t link_local_address[4]; + + // Global address + uint32_t global_address[4]; + + // Gateway address + uint32_t gateway_address[4]; + + // Mac address + uint8_t mac_address[6]; - // Router IPv6 address - uint8_t defaultgw6[16]; } sl_si91x_rsp_ipv6_params_t; // Structure for firmware upgradation @@ -1549,9 +1559,9 @@ typedef struct { typedef struct { /* Target - * 0 - BURN_INTO_EFUSE (Burns calibration data to EFuse) + * 0 - BURN_INTO_EFUSE (Burns calibration data to EFuse) - - * 1 - BURN_INTO_FLASH (Burns calibration data to Flash) + * 1 - BURN_INTO_FLASH (Burns calibration data to Flash) - **/ uint8_t target; @@ -1560,20 +1570,20 @@ typedef struct { * Bit | MACRO | Description * :---|:---------------------:|:--------------------------------------------------- * 0 | RESERVED_0 | Reserved - * 1 | BURN_FREQ_OFFSET | 1 - Update XO Ctune to calibration data + * 1 | BURN_FREQ_OFFSET | 1 - Update XO Ctune to calibration data - 0 - Skip XO Ctune update - * 2 | SW_XO_CTUNE_VALID | 1 - Use XO Ctune provided as argument to update calibration data + * 2 | SW_XO_CTUNE_VALID | 1 - Use XO Ctune provided as argument to update calibration data - 0 - Use XO Ctune value as read from hardware register * 3 | BURN_XO_FAST_DISABLE | Used to apply patch for cold temperature issue(host interface detection) observed on CC0/CC1 modules. \ref appendix - * 4 | BURN_GAIN_OFFSET_LOW | 1 - Update gain offset for low sub-band (2 GHz) + * 4 | BURN_GAIN_OFFSET_LOW | 1 - Update gain offset for low sub-band (2 GHz) - 0 - Skip low sub-band gain-offset update - * 5 | BURN_GAIN_OFFSET_MID | 1 - Update gain offset for mid sub-band (2 GHz) + * 5 | BURN_GAIN_OFFSET_MID | 1 - Update gain offset for mid sub-band (2 GHz) - 0 - Skip mid sub-band gain-offset update - * 6 | BURN_GAIN_OFFSET_HIGH | 1 - Update gain offset for high sub-band (2 GHz) + * 6 | BURN_GAIN_OFFSET_HIGH | 1 - Update gain offset for high sub-band (2 GHz) - 0 - Skip high sub-band gain-offset update - * 8 | ENABLE_DPD_CALIB | 1 - Collect dpd coefficients data + * 8 | ENABLE_DPD_CALIB | 1 - Collect dpd coefficients data - 0 - Skip dpd coefficients calibration - * 9 | BURN_DPD_COEFFICIENTS | 1 - Burn dpd coefficients data + * 9 | BURN_DPD_COEFFICIENTS | 1 - Burn dpd coefficients data - 0 - Skip dpd coefficients calibration * 31-4 | | Reserved **/ @@ -1593,7 +1603,7 @@ gain_offset_high - gain_offset as observed in dBm in channel-11 typedef struct { /* target -* 0 - READ_FROM_EFUSE (read calibration data from the EFuse) +* 0 - READ_FROM_EFUSE (read calibration data from the EFuse) - * 1 - READ_FROM_FLASH (read calibration data from the Flash) */ @@ -1646,19 +1656,19 @@ typedef struct { **/ uint8_t target; /* - * Flags - Validate information + * Flags - Validate information - * Bit | MACRO | Description * :---|:---------------------:|:--------------------------------------------------- - * 0 | EVM_OFFSET_CUST_0 | 1 - Update evm_offset_11B rate calibration data + * 0 | EVM_OFFSET_CUST_0 | 1 - Update evm_offset_11B rate calibration data - 0 - Skip evm_offset update - * 1 | EVM_OFFSET_CUST_1 | 1 - Update evm_offset_11G_6M_24M_11N_MCS0_MCS2 rate calibration data + * 1 | EVM_OFFSET_CUST_1 | 1 - Update evm_offset_11G_6M_24M_11N_MCS0_MCS2 rate calibration data - 0 - Skip evm_offset update - * 2 | EVM_OFFSET_CUST_2 | 1 - Update evm_offset_11G_36M_54M_11N_MCS3_MCS7 rate calibration data + * 2 | EVM_OFFSET_CUST_2 | 1 - Update evm_offset_11G_36M_54M_11N_MCS3_MCS7 rate calibration data - 0 - Skip evm_offset update - * 3 | EVM_OFFSET_CUST_3 | 1 - Update evm_offset_11N_MCS0 rate calibration data + * 3 | EVM_OFFSET_CUST_3 | 1 - Update evm_offset_11N_MCS0 rate calibration data - 0 - Skip evm_offset update - * 4 | EVM_OFFSET_CUST_4 | 1 - Update evm_offset_11N_MCS7 rate calibration data + * 4 | EVM_OFFSET_CUST_4 | 1 - Update evm_offset_11N_MCS7 rate calibration data - 0 - Skip evm_offset update * 31-5| Reserved */ diff --git a/components/device/silabs/si91x/wireless/inc/sl_wifi_device.h b/components/device/silabs/si91x/wireless/inc/sl_wifi_device.h index e607af8d..ddba86cb 100644 --- a/components/device/silabs/si91x/wireless/inc/sl_wifi_device.h +++ b/components/device/silabs/si91x/wireless/inc/sl_wifi_device.h @@ -94,9 +94,12 @@ #define SL_SI91X_FEAT_HIDE_PSK_CREDENTIALS BIT(9) /// To enable high SSL streaming throughput -/// @note bits 11 - 29 are reserved #define SL_SI91X_FEAT_SSL_HIGH_STREAMING_BIT BIT(10) +///To enable support for long sized ICMP packets. Max 1472 Bytes for IPv4 and Max 1452 Bytes for IPv6. +/// @note bit 11 & bits 13 - 29 are reserved +#define SL_SI91X_FEAT_LONG_ICMP_PACKET BIT(12) + /// Secure Attestation /// @note bit 31 is reserved #define SL_SI91X_FEAT_SECURE_ATTESTATION BIT(30) @@ -356,10 +359,7 @@ /// @note 1. Resource Request Support is not Present. 2. If both BIT[11] and BIT[16] are not enabled then it will select as Legacy Roaming. #define SL_SI91X_EXT_FEAT_ENABLE_11R_ODS BIT(16) -/// @note Bit 17 is reserved - -/// To enable http otaf support -#define SL_SI91X_EXT_FEAT_HTTP_OTAF_SUPPORT BIT(18) +/// @note Bit 17, 18 are reserved /// To enable low power mode in Wlan /// @note EXT_FEAT_LOW_POWER_MODE is not supported for 1.3 version chipset. @@ -552,9 +552,9 @@ /// Enable Embedded/internal MQTT /// @note If user wants to use AT command for MQTT, enable this bit in the Opermode Command #define SL_SI91X_EXT_EMB_MQTT_ENABLE BIT(17) -/// Enables the SSL_HIGH_PERFORMANCE +/// Enables the http otaf support /// @note To do firmware upgrade with HTTP this bit should be enabled -#define SL_SI91X_EXT_TCP_IP_FEAT_SSL_HIGH_PERFORMANCE BIT(18) +#define SL_SI91X_EXT_FEAT_HTTP_OTAF_SUPPORT BIT(18) /// Enabled to update TCP window from host #define SL_SI91X_EXT_TCP_DYNAMIC_WINDOW_UPDATE_FROM_HOST BIT(19) diff --git a/components/device/silabs/si91x/wireless/sl_net/src/sl_si91x_net_internal_stack.c b/components/device/silabs/si91x/wireless/sl_net/src/sl_si91x_net_internal_stack.c index 39c4654a..e1cb669d 100644 --- a/components/device/silabs/si91x/wireless/sl_net/src/sl_si91x_net_internal_stack.c +++ b/components/device/silabs/si91x/wireless/sl_net/src/sl_si91x_net_internal_stack.c @@ -212,14 +212,15 @@ sl_status_t sl_si91x_configure_ip_address(sl_net_ip_configuration_t *address, ui VERIFY_STATUS_AND_RETURN(status); // Extract the IPv6 configuration response data - uint32_t input_buffer[13]; - packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); - memcpy(input_buffer, packet->data, packet->length); + packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); + sl_si91x_rsp_ipv6_params_t *ipv6_response = (sl_si91x_rsp_ipv6_params_t *)packet->data; // Copy the IPv6 addresses to the address structure - memcpy(&address->ip.v6.link_local_address, &input_buffer[1], 16); - memcpy(&address->ip.v6.global_address, &input_buffer[5], 16); - memcpy(&address->ip.v6.gateway, &input_buffer[9], 16); + memcpy(&address->ip.v6.link_local_address, + ipv6_response->link_local_address, + sizeof(ipv6_response->link_local_address)); + memcpy(&address->ip.v6.global_address, ipv6_response->global_address, sizeof(ipv6_response->global_address)); + memcpy(&address->ip.v6.gateway, ipv6_response->gateway_address, sizeof(ipv6_response->gateway_address)); // Free the buffer and return success status sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); diff --git a/components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_utility.h b/components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_utility.h index 7fb405a1..1d7e3702 100644 --- a/components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_utility.h +++ b/components/device/silabs/si91x/wireless/socket/inc/sl_si91x_socket_utility.h @@ -59,6 +59,15 @@ } \ } while (0); \ } +#define SLI_SI91X_NULL_SAFE_FD_ZERO(fd_set) \ +{ \ + do { \ + if (NULL != fd_set) { \ + FD_ZERO(fd_set); \ + } \ + } while(0); \ +} + #define GET_SAFE_MEMCPY_LENGTH(destination_size, source_size) \ source_size > destination_size ? destination_size : source_size diff --git a/components/device/silabs/si91x/wireless/socket/src/sl_si91x_socket_utility.c b/components/device/silabs/si91x/wireless/socket/src/sl_si91x_socket_utility.c index c0ce942e..9526607c 100644 --- a/components/device/silabs/si91x/wireless/socket/src/sl_si91x_socket_utility.c +++ b/components/device/silabs/si91x/wireless/socket/src/sl_si91x_socket_utility.c @@ -103,9 +103,9 @@ int handle_select_response(sl_si91x_socket_select_rsp_t *response, int total_fd_set_count = 0; // Clear file descriptor sets - FD_ZERO(readfds); - FD_ZERO(writefds); - FD_ZERO(exception_fd); + SLI_SI91X_NULL_SAFE_FD_ZERO(readfds); + SLI_SI91X_NULL_SAFE_FD_ZERO(writefds); + SLI_SI91X_NULL_SAFE_FD_ZERO(exception_fd); // Iterate through all host sockets for (int host_socket_index = 0; host_socket_index < NUMBER_OF_SOCKETS; host_socket_index++) { diff --git a/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c b/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c index 8b40f140..0f90e3b0 100644 --- a/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c +++ b/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c @@ -156,6 +156,7 @@ static uint16_t packet_id[SI91X_CMD_MAX] = { 0 }; static uint8_t ap_join_feature_bitmap = SL_SI91X_JOIN_FEAT_LISTEN_INTERVAL_VALID; static uint8_t client_join_feature_bitmap = SL_SI91X_JOIN_FEAT_LISTEN_INTERVAL_VALID; static uint32_t client_listen_interval = 1000; +static sl_si91x_efuse_data_t si91x_efuse_data = { 0 }; //! Currently, initialized_opermode is used only to handle concurrent mode using sl_net_init() static uint16_t initialized_opermode = SL_SI91X_INVALID_MODE; @@ -297,6 +298,16 @@ const sl_si91x_set_region_ap_request_t default_SG_region_5GHZ_configurations = { [SI91X_BT_CMD] = NCP_HOST_BT_RESPONSE_EVENT }; // clang-format on +void sl_si91x_get_efuse_data(sl_si91x_efuse_data_t *efuse_data) +{ + memcpy(efuse_data, &si91x_efuse_data, sizeof(sl_si91x_efuse_data_t)); +} + +void sl_si91x_set_efuse_data(sl_si91x_efuse_data_t *efuse_data) +{ + memcpy(&si91x_efuse_data, efuse_data, sizeof(sl_si91x_efuse_data_t)); +} + sl_status_t sl_si91x_driver_init_wifi_radio(const sl_wifi_device_configuration_t *config) { sl_status_t status; @@ -588,6 +599,9 @@ sl_status_t sl_si91x_driver_init(const sl_wifi_device_configuration_t *config, s } // Save the coexistence mode in the driver save_coex_mode(config->boot_config.coex_mode); +#ifdef SL_SI91X_GET_EFUSE_DATA + status = sl_si91x_get_flash_efuse_data(&si91x_efuse_data); +#endif return status; } @@ -650,6 +664,38 @@ sl_status_t sl_si91x_driver_deinit(void) return status; } +sl_status_t sl_si91x_get_flash_efuse_data(sl_si91x_efuse_data_t *efuse_data) +{ + sl_status_t status; + sl_wifi_buffer_t *buffer = NULL; + + SL_WIFI_ARGS_CHECK_NULL_POINTER(efuse_data); + + if (!device_initialized) { + return SL_STATUS_NOT_INITIALIZED; + } + + status = sl_si91x_driver_send_command(RSI_COMMON_REQ_GET_EFUSE_DATA, + SI91X_COMMON_CMD_QUEUE, + NULL, + 0, + SL_SI91X_WAIT_FOR_RESPONSE(15000), + NULL, + &buffer); + if ((status != SL_STATUS_OK) && (buffer != NULL)) { + sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); + } + VERIFY_STATUS_AND_RETURN(status); + + sl_si91x_packet_t *packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); + if (packet->length > 0) { + sl_si91x_efuse_data_t *response = (sl_si91x_efuse_data_t *)packet->data; + efuse_data->mfg_sw_version = response->mfg_sw_version; + } + sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); + return SL_STATUS_OK; +} + sl_status_t sl_si91x_driver_raw_send_command(uint8_t command, const void *data, uint32_t data_length, diff --git a/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c b/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c index 01ca9b6e..6396b78b 100644 --- a/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c +++ b/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c @@ -394,6 +394,7 @@ void si91x_bus_thread(void *args) } } // intentional fallthrough + case RSI_COMMON_RSP_GET_EFUSE_DATA: case RSI_COMMON_RSP_GET_RAM_DUMP: case RSI_COMMON_RSP_ANTENNA_SELECT: case RSI_COMMON_RSP_ENCRYPT_CRYPTO: @@ -448,6 +449,7 @@ void si91x_bus_thread(void *args) } case RSI_WLAN_RSP_BAND: case RSI_WLAN_RSP_INIT: + case RSI_WLAN_RSP_RADIO: case RSI_WLAN_RSP_EAP_CONFIG: case RSI_WLAN_RSP_SET_CERTIFICATE: case RSI_WLAN_RSP_HOST_PSK: @@ -460,6 +462,7 @@ void si91x_bus_thread(void *args) case RSI_WLAN_RSP_DISCONNECT: case RSI_WLAN_RSP_AP_STOP: case RSI_WLAN_RSP_RSSI: + case RSI_WLAN_RSP_TSF: case RSI_WLAN_RSP_AP_CONFIGURATION: case RSI_WLAN_RSP_WPS_METHOD: case RSI_WLAN_RSP_QUERY_NETWORK_PARAMS: diff --git a/components/protocol/wifi/inc/sl_wifi.h b/components/protocol/wifi/inc/sl_wifi.h index c0724dd7..acdc7c68 100644 --- a/components/protocol/wifi/inc/sl_wifi.h +++ b/components/protocol/wifi/inc/sl_wifi.h @@ -526,6 +526,22 @@ sl_status_t sl_wifi_disconnect(sl_wifi_interface_t interface); ******************************************************************************/ sl_status_t sl_wifi_get_signal_strength(sl_wifi_interface_t interface, int32_t *rssi); +/***************************************************************************/ /** + * @brief + * Get the station TSF time which is synchronised with connected AP beacon TSF. + * @pre + * Pre-condition: @ref sl_wifi_connect should be called before this API. + * @param[in] interface + * Wi-Fi interface as identified by @ref sl_wifi_interface_t + * @param[out] tsf + * 64-bit TSF time in microseconds stored in @ref sl_wifi_tsf64_t structure. + * @return + * sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details. + * @note + * If the station is not connected or at least one beacon is not received after connection, tsf value will be '0'. + ******************************************************************************/ +sl_status_t sl_wifi_get_sta_tsf(sl_wifi_interface_t interface, sl_wifi_tsf64_t *tsf); + /***************************************************************************/ /** * @brief * Set the Wi-Fi roaming configuration. diff --git a/components/protocol/wifi/inc/sl_wifi_types.h b/components/protocol/wifi/inc/sl_wifi_types.h index 72736601..73fa855d 100644 --- a/components/protocol/wifi/inc/sl_wifi_types.h +++ b/components/protocol/wifi/inc/sl_wifi_types.h @@ -337,4 +337,10 @@ typedef struct { typedef struct { uint8_t join_tx_power; } sl_wifi_max_tx_power_t; + +/// Wi-Fi station TSF +typedef struct { + uint32_t tsf_l; ///< Used to store LSB of TSF + uint32_t tsf_m; ///< Used to store MSB of TSF +} sl_wifi_tsf64_t; /** @} */ diff --git a/components/protocol/wifi/si91x/sl_wifi.c b/components/protocol/wifi/si91x/sl_wifi.c index 300a358f..145901e0 100644 --- a/components/protocol/wifi/si91x/sl_wifi.c +++ b/components/protocol/wifi/si91x/sl_wifi.c @@ -135,6 +135,7 @@ static sl_status_t get_configured_join_request(sl_wifi_interface_t module_interf join_request->vap_id = SL_SI91X_WIFI_CLIENT_VAP_ID; // For Station vap_id will be 0 join_request->power_level = convert_dbm_to_si91x_power_level(get_max_tx_power()); join_request->listen_interval = sl_si91x_get_listen_interval(); + memcpy(join_request->join_bssid, client_configuration->bssid.octet, sizeof(join_request->join_bssid)); } else if (module_interface & SL_WIFI_AP_INTERFACE) { // get join feature bitmap status = sl_si91x_get_join_configuration(SL_WIFI_AP_INTERFACE, &(join_request->join_feature_bitmap)); @@ -531,6 +532,43 @@ sl_status_t sl_wifi_get_signal_strength(sl_wifi_interface_t interface, int32_t * return SL_STATUS_OK; } +sl_status_t sl_wifi_get_sta_tsf(sl_wifi_interface_t interface, sl_wifi_tsf64_t *tsf) +{ + sl_status_t status; + sl_wifi_buffer_t *buffer = NULL; + + if (!device_initialized) { + return SL_STATUS_NOT_INITIALIZED; + } + + SL_VERIFY_POINTER_OR_RETURN(tsf, SL_STATUS_WIFI_NULL_PTR_ARG); + + if (interface & SL_WIFI_AP_INTERFACE) { + return SL_STATUS_NOT_SUPPORTED; + } + + if (!sl_wifi_is_interface_up(interface)) { + return SL_STATUS_WIFI_INTERFACE_NOT_UP; + } + + status = sl_si91x_driver_send_command(RSI_WLAN_REQ_TSF, + SI91X_WLAN_CMD_QUEUE, + NULL, + 0, + SL_SI91X_WAIT_FOR_RESPONSE(15000), + NULL, + &buffer); + if ((status != SL_STATUS_OK) && (buffer != NULL)) { + sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); + } + VERIFY_STATUS_AND_RETURN(status); + + sl_si91x_packet_t *packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); + memcpy(tsf, packet->data, packet->length); + sl_si91x_host_free_buffer(buffer, SL_WIFI_RX_FRAME_BUFFER); + return SL_STATUS_OK; +} + sl_status_t sl_wifi_set_mac_address(sl_wifi_interface_t interface, const sl_mac_address_t *mac_address) { UNUSED_PARAMETER(interface); diff --git a/components/service/http_client/si91x_socket/sl_http_client.c b/components/service/http_client/si91x_socket/sl_http_client.c index 3668963f..9d2fbdf9 100644 --- a/components/service/http_client/si91x_socket/sl_http_client.c +++ b/components/service/http_client/si91x_socket/sl_http_client.c @@ -343,7 +343,7 @@ sl_status_t sl_http_client_delete_header(sl_http_client_request_t *request, cons // Search key in linked list while ((current_header != NULL) && (strcmp(current_header->key, key) != 0)) { - current_header = current_header->next; + current_header = (sl_http_client_header_t *)current_header->next; } // If key not present in linked list @@ -375,7 +375,7 @@ sl_status_t sl_http_client_delete_all_headers(sl_http_client_request_t *request) while (current_header != NULL) { // Store next header link - next_header = current_header->next; + next_header = (sl_http_client_header_t *)current_header->next; // Remove node from list sl_slist_remove((sl_slist_node_t **)&request->extended_header, (sl_slist_node_t *)current_header); @@ -461,7 +461,7 @@ static void load_extended_headers_into_request_buffer(uint8_t *buffer, (*http_buffer_offset)++; // Point to next header - current_header = current_header->next; + current_header = (sl_http_client_header_t *)current_header->next; } } } diff --git a/components/service/mqtt/inc/sl_mqtt_client_types.h b/components/service/mqtt/inc/sl_mqtt_client_types.h index 3cc7db6f..c9a532b2 100644 --- a/components/service/mqtt/inc/sl_mqtt_client_types.h +++ b/components/service/mqtt/inc/sl_mqtt_client_types.h @@ -84,9 +84,11 @@ typedef struct { bool is_retained; ///< Flag whether to retain the will message or not. sl_mqtt_qos_t will_qos_level; ///< Quality of subscription. uint8_t *will_topic; ///< Name of will topic. - uint16_t will_topic_length; ///< Length of topic. - uint8_t *will_message; ///< Pointer to will message. - uint32_t will_message_length; ///< Length of the will message. + uint16_t + will_topic_length; ///< Length of topic. Length should not exceed 62 bytes including NULL termination character. + uint8_t *will_message; ///< Pointer to will message. + uint32_t + will_message_length; ///< Length of the will message. Length should not exceed 62 bytes including NULL termination character. } sl_mqtt_client_last_will_message_t; /// MQTT Client Message structure @@ -96,9 +98,10 @@ typedef struct { bool is_retained; ///< Retained flag of message as sent by the broker. bool is_duplicate_message; ///< Whether this is a duplicate message. uint8_t *topic; ///< Pointer to topic name. - uint16_t topic_length; ///< Length of the topic. - uint8_t *content; ///< Pointer to content. - uint32_t content_length; ///< Length of the content. + uint16_t + topic_length; ///< Length of the topic. Length should not exceed 202 bytes including NULL termination character. + uint8_t *content; ///< Pointer to content. + uint32_t content_length; ///< Length of the content. } sl_mqtt_client_message_t; /// MQTT Client broker information structure @@ -114,7 +117,7 @@ typedef struct { /// MQTT Client credentials structure typedef struct { uint16_t - username_length; ///< Length of the username. Length should not exceed 62 bytes including NULL termination character. + username_length; ///< Length of the username. Length should not exceed 122 bytes including NULL termination character. uint16_t password_length; ///< Length of the password. Length should not exceed 62 bytes including NULL termination character. uint8_t data[]; ///< A flexible array to store both username and password. @@ -175,8 +178,9 @@ typedef struct { sl_slist_node_t next_subscription; ///< Next node in the linked list. sl_mqtt_client_message_received_t topic_message_handler; ///< A function pointer to message handler. sl_mqtt_qos_t qos_of_subscription; ///< Quality of subscription. - uint16_t topic_length; ///< Length of the subscribed topic. - uint8_t topic[]; ///< A flexible array to store the topic. + uint16_t + topic_length; ///< Length of the subscribed topic. Length should not exceed 202 bytes including NULL termination character. + uint8_t topic[]; ///< A flexible array to store the topic. } sl_mqtt_client_topic_subscription_info_t; /// MQTT Client Handle structure diff --git a/components/service/network_manager/src/sl_net_for_lwip.c b/components/service/network_manager/src/sl_net_for_lwip.c index db5034b9..af4cf5d5 100644 --- a/components/service/network_manager/src/sl_net_for_lwip.c +++ b/components/service/network_manager/src/sl_net_for_lwip.c @@ -18,7 +18,7 @@ #include "sl_net_wifi_types.h" #include "sl_net.h" #include - +#include "sl_rsi_utility.h" #define INTERFACE_NAME_0 's' ///< Network interface name 0 #define INTERFACE_NAME_1 'l' ///< Network interface name 1 #define MAX_TRANSFER_UNIT 1500 @@ -163,6 +163,7 @@ sl_status_t sl_net_wifi_client_up(sl_net_interface_t interface, sl_net_profile_i sl_status_t sl_net_wifi_client_down(sl_net_interface_t interface) { + UNUSED_PARAMETER(interface); // DHCP stop and release the resources dhcp_release_and_stop(&wifi_client_context->netif); diff --git a/connectivity_firmware/SiWG917-B.2.10.0.0.4.rps b/connectivity_firmware/SiWG917-B.2.10.0.0.4.rps deleted file mode 100644 index 117c4844..00000000 Binary files a/connectivity_firmware/SiWG917-B.2.10.0.0.4.rps and /dev/null differ diff --git a/connectivity_firmware/SiWG917-B.2.10.1.1.0.2.rps b/connectivity_firmware/SiWG917-B.2.10.1.1.0.2.rps new file mode 100644 index 00000000..47ac67d4 Binary files /dev/null and b/connectivity_firmware/SiWG917-B.2.10.1.1.0.2.rps differ diff --git a/docs/release-notes/index_ncp.md b/docs/release-notes/index_ncp.md index 19224581..be9863fb 100644 --- a/docs/release-notes/index_ncp.md +++ b/docs/release-notes/index_ncp.md @@ -1,3 +1,852 @@ +# **WiSeConnect3\_SDK\_3.1.2 NCP Release Notes**    + +## **Release Details** + +|**Item**|**Details**| +| :- | :- | +|Release date|Jan 17th, 2024| +|SDK Version|3\.1.2| +|Firmware Version|1711\.2.10.1.1.0.2| +|Package Name|WiSeConnect3\_SDK\_3.1.2| +|Supported RTOS|FreeRTOS| +|Operating Modes Supported|Wi-Fi STA, Wi-Fi AP, Wi-Fi STA+BLE, Wi-Fi STA+AP| + +- SiWx917 release consists of two components + - Wireless Firmware -  SiWx917 Firmware Binary available as SiWG917-B.2.10.1.1.0.2.rps + - Wiseconnect3 Library - Wiseconnect3 SDK library runs on the external host in NCP mode. + +## **Supported Hardware OPNs** + +- Expansion kits: SiWx917-EB4346A (based on Radio board SiWx917-4346A + 8045A Co-Processor Adapter board) +- Expansion Kits: Si917-8036B (Beta version) +- IC OPNs: SiWN917M100LGTBA (Wi-Fi 6 NCP IC, QFN 7x7, 2.4 GHz, 4MB stacked flash, -40 to +85C​)  + +## **Supported Features** + +### **System** + +- **Operating Modes**  + - Wi-Fi STA (802.11ax, 802.11n), Wi-Fi 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + BLE +- **Security**  + - Secure Boot, Secure Key storage and HW device identity with PUF, Secure Zone, Secure XIP (Execution in place) from flash, Secure Attestation, Anti Rollback, Secure Debug. Flash Protection + - Secure firmware upgrade options: + - Firmware loading through UART, SPI Interface + - Secure Over the Air (OTA) Upgrade +- **Crypto Support** + - ` `Crypto API's for Hardware Accelerators: + - Advanced Encryption Standard (AES) 128/256/192, Secure Hash Algorithm (SHA) 256/384/512, Hash Message Authentication Code (HMAC), Random Number Generator (RNG), SHA3, AES-Galois Counter Mode (GCM)/ Cipher based Message Authentication Code (CMAC), ChaCha-poly, True Random Number Generator (TRNG) + - Software Accelerators: RSA, ECC  + - Integrated with mbed TLS  +- **System Power Save** + - Deep Sleep with RAM retention and without RAM retention  + - Wireless Power Save: Connected Sleep (Wi-Fi Standby Associated), BLE Advertising with powersave, BLE Scan with powersave ,  BLE connection with powersave. Only Max PSP power save mode is supported in BLE + +### **Wi-Fi** + +- **Wi-Fi Protocols** + - IEEE 802.11 b/g/n/ax (2.4GHz) +- **Access Point (AP) Mode** + - 4 Client Support, Hidden SSID Mode, Auto Channel Selection, Scan in AP mode + - Wi-Fi Security   + - WPA2 Personal, WPA3 Personal (H2E method only), WPA Mixed mode (WPA/WPA2)  +- **Wi-Fi Scan** + - Selective Scan, Active/Passive Scan +- **Wi-Fi STA (Security Modes)** + - Open Mode, WPA2 Personal, WPA2 Enhancements, WPA3 Personal, Mixed Mode (WPA/WPA2), WPA3 Personal Transition Mode (WPA2/WPA3) +- **WPA2 Enterprise security (STA)** + - Method + - PEAP/TTLS/TLS 1.0/TLS 1.2/FAST +- **Wi-Fi STA Rejoin** +- **Wi-Fi STA Roaming**  + - BG Scan, OKC (Opportunistic Key caching), PMK (Pairwise Master Key) caching, Pre-Authentication +- **Wi-Fi Protocol Power Save**  + - Deep sleep (unconnected state), Max PSP, Enhanced Max PSP, Fast PSP,** TWT +- **QoS** + - WMM-QoS +- **Wi-Fi 6 Feature** + - MUMIMO (DL), OFDMA (UL/DL), iTWT, TWT I-Frame & TWT Enhancements, BSS coloring, MBSSID +- **Wi-Fi Concurrency**  + - AP+STA (Same channel) +- **Wi-Fi Band/Channels** + - 2.4GHz CH1-11, 2.4GHz CH1-13, 2.4GHz CH1-14 (Japan) +- **Known Security Vulnerabilities Handled** + - WPA2 KRACK Attacks, Fragment and Forge Vulnerability + +### **Network stack** + +- **Core Networking Features** + - TCP/IP Bypass (LWIP as Hosted stack for reference), IPv4/IPv6/UDP/TCP/ARP/ICMP/ICMPv6 + - SSL client versions TLSV1.0, TLSV1.2, TLSV1.3  + - SSL server versions TLSV1.0 and TLSV1.2 + - DHCP (Client/Server)/ DHCPv6 Client +- **Advanced Network Features** + - HTTP Client/HTTPS Client//DNS Client/SNTP Client, Embedded MQTT/MQTT on host +- **Wi-Fi IoT Cloud Integration** + - AWS IOT Core +- BSD and IoT sockets application programming interface(API) + +### **BLE**  + +- GAP(Advertising, Scanning, initiation, Connection and Bonding) +- Generic Attribute Protocol(GATT) +- Attribute protocol(ATT) +- Security +- LL Privacy 1.2 +- Accept list +- Directed Advertising +- Extended Advertising +- Periodic Advertising +- Periodic Advertising scanning +- Extended Advertising scanning +- Periodic Advertising list +- LE periodic advertising synchronization +- LE PHY(1Mbps, 2Mbps) & Coded PHY(125Kbps, 500kbps) +- Simultaneous scanning on 1Mbps and Coded PHY +- LE dual role topology +- LE data packet length extensions(DLE) +- Asymmetric PHYs +- LE channel selection algorithm 2 (CSA#2) +- LE Secure connections +- Bluetooth 5.4 Qualified + +### **SDK** + +- Simplified and Unified DX for Wi-Fi API  +- Simplifies application development and presents clean and standardized APIs +- BSD and ARM IoT-compliant socket API +- Available through Simplicity Studio and GitHub + +### **Multi-protocol** + +- Wi-Fi STA + BLE + +### **PTA CoExistence** + +- 3 wire coex acting as Wi-Fi with external Bluetooth  +- 3 wire coex acting as Wi-Fi with external Zigbee/OT + +## **Changes in this release compared to v3.1.1-Doc Release** + +### **System** + +- WOW LAN is not supported. + +### **SDK** + +- **Enhancements** + - Resolved warnings in the featured and snippet demos. + - sl\_wifi\_get\_sta\_tsf() API added to get the station TSF time which is synchronized with connected AP beacon TSF. + - Added "update gain” demo for BLE. + - Added an option to test user gain table feature in "ble\_per" demo by enabling the “GAIN\_TABLE\_AND\_MAX\_POWER\_UPDATE\_ENABLE” macro. + - Removed unused input parameters in rsi\_ble\_set\_ble\_tx\_power() API. +- **Fixed Issues** + - Fixed issue with BSSID based connection. + - Fixed issue with the file descriptors set handling for socket select. + - Fixed issue with authentication and association timeout is not reflecting as per timeout configuration using sl\_si91x\_configure\_timeout() API + - Fixed profile id corruption issue for IPV6 demos.  + - Fixed application hang issue at the AE Clear Periodic Adv list API when used "ble\_ae\_central" example.  + - Fixed issue where BLE connect API is failing because of 0xFFFFFFE2(RSI\_ERROR\_RESPONSE\_TIMEOUT) error with ble\_central application. + +### **Wi-Fi/Network Stack** + +- **Enhancements** + - Added support for TSF time which is synchronized with connected AP beacon TSF. + - Improve PER performance at max input power levels for 11b. + - Improved ppm error across channels at room temperature. + - Updated regulatory tables of WLAN +- **Fixed Issues** + - Increased supported length for Embedded MQTT username up to 120 bytes and topic length up to 200 bytes. + - Added support to process long ICMP ping response up to packet size of 1472 Bytes for IPv4 and 1452 Bytes for IPv6. + - Issue with configuration of TCP MSS through setsockopt() has been fixed. + - Fixed Listen interval based power save issue when IPV6 mode is enabled + - Added fix for missing RSN IE in first few AP beacons + +### **BLE** + +- **Enhancements** + - Added Region based maximum power index support for both 0dBm & 10dDm LP chains. +- **Fixed Issues** + - Fixed regulatory output power violations with default region based settings in HP chain. + - Fixed an issue that caused the Set local name API to fail with the error code 0x4e66[Invalid Name length] when a local name given with 16 bytes of length. + +### **Multi-protocol** + +- **Enhancements** + - None +- **Fixed Issues** + - None + +## **Recommendations** + +### **System** + +- Set the recommended Power Save Profile (PSP) type to Enhanced Max PSP. +- Memory configuration for NCP mode is 672K\_M4SS\_0K. + +### **IDE for EFR host** + +- Simplicity Studio. This release is tested with SV5.8.0 version. +- Refer to the latest version of the NCP "Getting-Started-with-SiWx917" guide for more details + +### **Wi-Fi/Network Stack** + +- It is recommended to enable bit 16 of the 'Extended TCP IP Feature' bit map in the opermode command for all Wi-Fi Socket operations from the host to ensure graceful handling during asynchronous closures from the peer. +- For high throughput applications, aggregation (bit 2 of feature\_bit\_map) is recommended to be enabled in opermode. +- To reset TA (NWP), the application needs to call sl\_wifi\_deinit() followed by sl\_wifi\_init().  +- Users can enable SL\_SI91X\_EXT\_TCP\_IP\_SSL\_16K\_RECORD in 'Extended TCP IP Feature' bit map in opermode for (HTTPS server) supporting 16k record. +- **TWT** + - Recommendation is to use sl\_wifi\_target\_wake\_time\_auto\_selection() API for all TWT applications.  + - It is recommended to issue iTWT setup command once IP assignment, TCP connection, application specific socket connections are done. + - When using sl\_wifi\_enable\_target\_wake\_time API, increase TCP / ARP Timeouts at the remote side depending upon the configured TWT interval configured. It's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() as an alternative. + - In case of TWT in coex mode, when using sl\_wifi\_enable\_target\_wake\_time API, use TWT wake duration <= 16 ms and TWT wake interval >= 1 sec. If wake duration > 16 ms or TWT wake interval < 1sec, there might be performance issues. + - For iTWT GTK interval in AP should be configured to max possible value or zero. If GTK interval is not configurable on AP side, recommended TWT interval (in case of sl\_wifi\_enable\_target\_wake\_time API) or RX Latency (in case of sl\_wifi\_target\_wake\_time\_auto\_selection API) is less than 4sec. + - When sl\_wifi\_enable\_target\_wake\_time API is used, configuring TWT Wake interval beyond 1 min might lead to disconnections from the AP. Recommended to use TWT wake interval of less than or equal to 1 min. + - When using sl\_wifi\_enable\_target\_wake\_time API, it is recommended to set missed\_beacon\_count of sl\_wifi\_set\_advanced\_client\_configuration API greater than 2 times of the configured TWT Interval. +- Disable power save for high throughput applications or use FAST PSP power save mode as per application requirement. +- The application needs to ensure that it sets RTC with the correct timestamp before establishing the SSL/EAP connection. +- The minimum timeout value should not be less than 1 second for socket select and socket receive calls.  +- Embedded MQTT keep alive interval should be either 0 or a value greater than 35 seconds. +- Disable power save and suspend any active TWT sessions before triggering HTTP OTAF. +- Randomize the client port if using rapid connect/disconnect of the MQTT session on the same client port with the power save. + +### **BLE** + +- In BLE, the recommended range of Connection Interval in + - Power Save (BLE Only) - 100 ms to 1.28 s. +- In BLE, during Connection, the configuration of Scan Interval and Scan Window with the same value is not recommended. The suggested ratio of Scan Window to Scan Interval is 3:4. +- In BLE, if a device is acting as Central, the scan window (in set\_scan\_params and create\_connection commands) must be less than the existing Connection Interval. The suggested ratio of Scan Window to Connection Interval is 2:3. +- In BLE mode, if scanning and advertising are in progress on the SiWx91x module and it subsequently gets connected and moves to the central role, scanning stops else if it moves to the peripheral role, advertising stops. To further establish a connection to another peripheral device or to a central device, the application should give a command for starting advertising and scanning again. + +### **Multi-protocol** + +- For concurrent Wi-Fi + BLE, and while a Wi-Fi connection is active, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. +- Wi-Fi + BLE Advertising + - All standard advertising intervals are supported. As Wi-Fi throughput is increased, a slight difference in on-air advertisements compared to configured intervals may be observed. + - BLE advertising is skipped if the advertising interval collides with Wi-Fi activity. +- Wi-Fi + BLE scanning + - All standard scan intervals are supported. For better scan results, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. + - BLE scanning will be stopped for intervals that collide with Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Connections + - All standard connection intervals are supported. + - For a stable connection, use optimal connection intervals and max supervision timeout in the presence of Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Data Transfer + - To achieve higher throughput for both Wi-Fi and BLE, use medium connection intervals, such as 45 to 80 ms with maximum supervision timeout. + - Ensure Wi-Fi activity consumes lower intervals. + +## **Known Issues of WiSeConnect3\_SDK\_3.1.2 Release** + +### **System** + +- None + +### **SDK** + +- Enhanced sl\_wifi\_get\_firmware\_version() API to provide more details (ROM ID, chip ID, security version, etc) which is not backward compatible with firmwares older than 1711.2.10.1.0.0.4. Firmware binary notation does not include security version number. +- Observed not being able to receive UDP Rx TPUT print at Teraterm with IPV6 Throughput example +- Matter applications are experiencing compatibility issues with WiseConnect SDK 3.1.2. It is recommended to use WiseConnect SDK 3.1.1 for matter-related applications. This will be addressed in up coming release(s). + +### **Wi-Fi/Network Stack** + +**Wi-Fi STA** + +- STA Connection with the WPA3 Hunting and Pecking algorithm takes about 3-4 seconds. +- Observed connection failures with some APs in more channel congestion ~50-60% occupancy open lab environment. +- Region selection based on country IE in the beacon is not supported +- Observed intermittent beacon reception from Access Point ( beacon misses) in an extremely congested environment +- Note section in API documentation for sl\_wifi\_get\_sta\_tsf  needs to be corrected to "Returns error if station is not connected or at least one beacon is not received." + +**Access Point (AP) Mode** + +- Scan feature in AP mode not fully functional.  +- Fixed rate configuration in AP mode using sl\_wifi\_set\_transmit\_rate API is not being set as expected.  + +**WPA2 Enterprise security (STA)** + +- Observed issue with configuring certificate key and programming 4096 bit key and SHA384/SHA512 certificates. +- Observing DUT is throwing 0x1001c when configuring .data.certificate\_key as "123456789" +- Configuration issue to program PAC file for EAP FAST Manual mode +- Issue observed with WPA2 Enterprise Connectivity using Microsoft RADIUS Server. + +**Wi-Fi Concurrency ( AP + STA in same channel)** + +- Observed 3rd party STA association fail with 917 AP while 917 STA mode is connecting/reconnecting to configured 3rd party AP. Reconnect 3rd party STA to 917 AP in such scenarios.  + +**OFDMA (UL/DL)** + +- Less throughput observed in DL-OFDMA with some APs that enabled LDPC. + +**MUMIMO (DL)** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Performance, Interop issues with MU MIMO with certain APs.  +- Less throughput was observed in MU-MIMO with some APs that enabled LDPC. + +**TWT** + +- Variability with MQTT keep alive interval based on TWT wake up interval.    +- When sl\_wifi\_enable\_target\_wake\_time() API is used, occasional MQTT disconnections may be observed if TWT is configured with longer TWT intervals (>30secs) with embedded MQTT + TWT.  As an alternative, it's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() API, where these dependencies are internally handled. + +**Wi-Fi STA Rejoin** + +- observed Scanning (probe request) in all channels instead of the channels configured in selective channel(channel\_bitmap\_2g4) during rejoin process + +**IPv4/IPv6** + +- Observed issue with assigning static IP to DUT +- IP change notification is not indicated to the application + +**BSD Socket API** + +- Configuration issue to program TCP retry count (default 10) through setsockopt +- Every server socket created consumes a socket (maximum of 10 sockets supported) and every subsequent connection to server socket consumes an additional socket (from the same pool of 10 sockets), which limits the number of server connections supported. + +**SSL Client/Server** + +- Sometimes during SSL Handshake, ECC curve parameters generated are wrong, resulting in connection failure with BBD2 error. However, this recovers in the next attempt. +- Secure SSL renegotiation not supported in Embedded Networking Stack +- observed connection failures with ECDSA ciphers + +**HTTP Client/ HTTPS Client** + +- Observed occasional HTTPS continuous download failures when power save is enabled. Recommended to disable it before performing HTTPS continuous downloads +- Observed HTTPS post data is failing with error code: BBE2 (HTTP Failed). + +**SNTP** + +- Unable to get SNTP async events when coex mode and power save are enabled  + +**Throughputs & Performance** + +- Observed 20% less Wi-Fi throughput with SDK 3.x compare to target throughput (depends on host and host interface), SDK refinements are in progress + +**Secure Over the Air (OTA) Upgrade** + +- Observed firmware upgrade failures after multiple iterations +- Observed OTA failures with power save enabled, So recommended to disable power save during OTA +- Observed "0xffffffff" error at the remote end while doing firmware upgrade via TCP server using (featured) example with ubuntu 21.0x.  + +**Wi-Fi IOT Cloud integration (AWS IOT Core)** + +- Observed AWS MQTT keepalive transmission is not happening at expected intervals with power save enabled. + +**Wi-Fi Interoperability (IOP)** + +- Observed disconnections with Amplifi (AFI-INS-R) AP with Powersave enable +- TWT session is failing due to disconnections observed in DUT if rx\_latency  is set to 55 seconds and receive data is also set to 55 seconds on MI Xiaomi RA72 and Tplink AX53 AP's +- Observed less throughput(~1Mb) while running TCP RX with Max\_PSP powersave with DLink 810 AP +- Observed interop issue (random disconnections) with few APs (EERO 6+, EERO PRO 6E, Cisco Catalyst 9120AXID) +- Disconnections observed with Netgear RAX120 AP in WPA3 security + +### **BLE** + +**IOP** + +- BLE connection failure has been observed on a few mobile devices (Samsung S23& Oneplus 9pro) when Si917 device is configured as central. + +### **Multi-protocol** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Wi-Fi + BLE intermittent connection failures, disconnections, and data transfer stalls in the long run when power save is enabled. +- While executing Wi-Fi Commissioning using the wifi\_station\_ble\_provisioning example, BLE is disconnecting is observed with few boards. +- Observed "DUT is not disconnecting to the AP when initiating disconnection from EFR connect app screen using wifi\_station\_ble\_provisioning\_aws example + +### **Simplicity Studio and Commander (For EFR Host)** + +- All projects in the package are compatible with **GNU ARM V12.2.1** toolchain +- Project Configurator is not supported. + +## **Features in RoadMap** + +### **SDK** + +- WPS 2.0 PIN/PUSH, Network Manager Enhancements +- MDNS, HTTP Server, Azure MQTT Client, Websockets +- Matter integration with Embedded TCP/IP stack  +- Enhanced buffer management, Throughput optimization +- TLS over LWIP, Network layer applications (MQTT, HTTP, etc.) over LWIP. +- Debugging utilities + +### **System** + +- Secure communication over host interfaces (UART. SPI, SDIO) +- UART 2 Debug prints are supported only on ULP\_GPIO\_9. + +### **Wi-Fi/Network Stack** + +- Spatial Re-Use, BSS Max Idle +- Provisioning using Wi-Fi AP + +### **BLE** + +- Support for 8 Peripheral + 2 Central connections  +- Support for BLE Mesh(4 nodes only) for limited Mesh use case + +## **Limitations and Unsupported Features** + +### **System** + +- None + +### **SDK** + +- Baremetal mode is not supported. + +### **Wi-Fi/Network Stack** + +- TLS 1.3 Server is not supported +- 40 MHz bandwidth for 2.4 GHz band is not supported. +- A maximum of 3 SSL connections are supported in Wi-Fi alone mode. +- In SSL ECC Curve ID supported is 23. SSL handshake with 3rd party clients depends on the SSL ECC Curve ID. +- The number of Non-Transmitting BSSIDs processed is limited by the beacon length that can be processed by the stack (which is 1024 bytes). Beacons greater than 1024 Bytes in length will not be processed. +- UL MUMIMO is not supported. +- WPA3 AP supports only H2E algorithm. +- PMKSA caching is not supported in WPA3 AP mode. +- The maximum embedded MQTT Publish payload is 1 kbyte. +- Timeout value for socket select and socket receive calls of less than 1 second is not currently supported. + +### **BLE** + +- For BLE, if the connection is established with a small connection interval (less than 15 ms), simultaneous roles (i.e., Central + Scanning and Peripheral + Advertising) are not supported. +- BLE maximum two concurrent connections are supported, which can be either a connection to two peripheral devices, to one central and one peripheral device or two central devices. +- BLE Slave latency value is valid up to 32 only. +- BLE TX/RX throughput is less when tested with EFM as compared to EFR. +- Maximum supported AE data length is 200 bytes. +- Supports only two ADV\_EXT sets. +- Supports only two BLE connections (1 Central and 1 Peripheral) with AE. +- Advertising Extension feature is not supported in Coexistence. +- Isochronous channels feature is not supported.  +- Connection subrating feature is not supported.  +- LE power controller feature is not supported.  +- EATT feature is not supported. +- Periodic Advertising with response(PAwR) feature is not supported.  +- BLE Audio is not supported. +- The feature of dynamically changing the TX power when extended advertising is active is not supported. + +### **Multi-protocol** + +- Wi-Fi AP + BLE currently not supported + +
+ +# **WiSeConnect3\_SDK\_3.1.1-Hotfix NCP Release Notes** + +## **Release Details** + +|**Item**|**Details**| +| :- | :- | +|Release date|Jan 2nd, 2024| +|SDK Version|3\.1.1-Hotfix| +|Firmware Version|1711\.2.10.1.0.0.7| +|Package Name|WiSeConnect3\_SDK\_3.1.1-Hotfix| +|Supported RTOS|FreeRTOS| +|Operating Modes Supported|Wi-Fi STA, Wi-Fi AP, Wi-Fi STA+BLE, Wi-Fi STA+AP| + +- SiWx917 release consists of two components + - Wireless Firmware -  SiWx917 Firmware Binary available as SiWG917-B.2.10.1.0.0.x.rps + - Wiseconnect3 Library - Wiseconnect3 SDK library runs on the external host in NCP mode. + +## **Supported Hardware OPNs** + +- Expansion kits: SiWx917-EB4346A (based on Radio board SiWx917-4346A + 8045A Co-Processor Adapter board) +- Expansion Kits: Si917-8036B (Beta version) +- IC OPNs: SiWN917M100LGTBA (Wi-Fi 6 NCP IC, QFN 7x7, 2.4 GHz, 4MB stacked flash, -40 to +85C​)  + +## **Supported Features** + +### **System** + +- **Operating Modes**  + - Wi-Fi STA (802.11ax, 802.11n), Wi-Fi 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + BLE +- **Security**  + - Secure Boot, Secure Key storage and HW device identity with PUF, Secure Zone, Secure XIP (Execution in place) from flash, Secure Attestation, Anti Rollback, Secure Debug. Flash Protection + - Secure firmware upgrade options: + - Firmware loading through UART, SPI Interface + - Secure Over the Air (OTA) Upgrade +- **Crypto Support** + - Crypto API's for Hardware Accelerators: + - Advanced Encryption Standard (AES) 128/256/192, Secure Hash Algorithm (SHA) 256/384/512, Hash Message Authentication Code (HMAC), Random Number Generator (RNG), SHA3, AES-Galois Counter Mode (GCM)/ Cipher based Message Authentication Code (CMAC), ChaCha-poly, True Random Number Generator (TRNG) + - Software Accelerators: RSA, ECC  + - Integrated with mbed TLS  +- **System Power Save** + - Deep Sleep with RAM retention and without RAM retention  + - Wireless Power Save: Connected Sleep (Wi-Fi Standby Associated), BLE Advertising with powersave, BLE Scan with powersave ,  BLE connection with powersave. Only Max PSP power save mode is supported in BLE + +### **Wi-Fi** + +- **Wi-Fi Protocols** + - IEEE 802.11 b/g/n/ax (2.4GHz) +- **Access Point (AP) Mode** + - 4 Client Support, Hidden SSID Mode, Auto Channel Selection, Scan in AP mode + - Wi-Fi Security   + - WPA2 Personal, WPA3 Personal (H2E method only), WPA Mixed mode (WPA/WPA2)  +- **Wi-Fi Scan** + - Selective Scan, Active/Passive Scan +- **Wi-Fi STA (Security Modes)** + - Open Mode, WPA2 Personal, WPA2 Enhancements, WPA3 Personal, Mixed Mode (WPA/WPA2), WPA3 Personal Transition Mode (WPA2/WPA3) +- **WPA2 Enterprise security (STA)** + - Method + - PEAP/TTLS/TLS 1.0/TLS 1.2/FAST +- **Wi-Fi STA Rejoin** +- **Wi-Fi STA Roaming**  + - BG Scan, OKC (Opportunistic Key caching), PMK (Pairwise Master Key) caching, Pre-Authentication +- **Wi-Fi Protocol Power Save**  + - Deep sleep (unconnected state), Max PSP, Enhanced Max PSP, Fast PSP,** TWT +- **QoS** + - WMM-QoS +- **Wi-Fi 6 Feature** + - MUMIMO (DL), OFDMA (UL/DL), iTWT, TWT I-Frame & TWT Enhancements, BSS coloring, MBSSID +- **Wi-Fi Concurrency**  + - AP+STA (Same channel) +- **Wi-Fi Band/Channels** + - 2.4GHz CH1-11, 2.4GHz CH1-13, 2.4GHz CH1-14 (Japan) +- **Known Security Vulnerabilities Handled** + - WPA2 KRACK Attacks, Fragment and Forge Vulnerability + +### **Network stack** + +- **Core Networking Features** + - TCP/IP Bypass (LWIP as Hosted stack for reference), IPv4/IPv6/UDP/TCP/ARP/ICMP/ICMPv6 + - SSL client versions TLSV1.0, TLSV1.2, TLSV1.3  + - SSL server versions TLSV1.0 and TLSV1.2 + - DHCP (Client/Server)/ DHCPv6 Client +- **Advanced Network Features** + - HTTP Client/HTTPS Client//DNS Client/SNTP Client, Embedded MQTT/MQTT on host +- **Wi-Fi IoT Cloud Integration** + - AWS IOT Core +- BSD and IoT sockets application programming interface(API) + +### **BLE**  + +- GAP(Advertising, Scanning, initiation, Connection and Bonding) +- Generic Attribute Protocol(GATT) +- Attribute protocol(ATT) +- Security +- LL Privacy 1.2 +- Accept list +- Directed Advertising +- Extended Advertising +- Periodic Advertising +- Periodic Advertising scanning +- Extended Advertising scanning +- Periodic Advertising list +- LE periodic advertising synchronization +- LE PHY(1Mbps, 2Mbps) & Coded PHY(125Kbps, 500kbps) +- Simultaneous scanning on 1Mbps and Coded PHY +- LE dual role topology +- LE data packet length extensions(DLE) +- Asymmetric PHYs +- LE channel selection algorithm 2 (CSA#2) +- LE Secure connections +- Bluetooth 5.4 Qualified + +### **SDK** + +- Simplified and Unified DX for Wi-Fi API  +- Simplifies application development and presents clean and standardized APIs +- BSD and ARM IoT-compliant socket API +- Available through Simplicity Studio and GitHub + +### **Multi-protocol** + +- Wi-Fi STA + BLE + +### **PTA CoExistence** + +- 3 wire coex acting as Wi-Fi with external Bluetooth  +- 3 wire coex acting as Wi-Fi with external Zigbee/OT + +## **Changes in this release compared to v3.1.1-Doc Release** + +### **System** + +- None + +### **SDK** + +- None + +### **Wi-Fi/Network Stack** + +- **Fixed Issues** + - Updated WLAN regulatory power tables. + +### **BLE** + +- **Fixed Issues** + - Updated BLE regulatory power tables. + +### **Multi-protocol** + +- None + +## **Recommendations** + +### **System** + +- Set the recommended Power Save Profile (PSP) type to Enhanced Max PSP. +- Memory configuration for NCP mode is 672K\_M4SS\_0K. + +### **IDE for EFR host** + +- Simplicity Studio. This release is tested with SV5.8.0 version. +- Refer to the latest version of the NCP "Getting-Started-with-SiWx917" guide for more details + +### **Wi-Fi/Network Stack** + +- It is recommended to enable bit 16 of the 'Extended TCP IP Feature' bit map in the opermode command for all Wi-Fi Socket operations from the host to ensure graceful handling during asynchronous closures from the peer. +- For high throughput applications, aggregation (bit 2 of feature\_bit\_map) is recommended to be enabled in opermode. +- To reset TA (NWP), the application needs to call sl\_wifi\_deinit() followed by sl\_wifi\_init().  +- Users can enable SL\_SI91X\_EXT\_TCP\_IP\_SSL\_16K\_RECORD in 'Extended TCP IP Feature' bit map in opermode for (HTTPS server) supporting 16k record. +- **TWT** + - Recommendation is to use sl\_wifi\_target\_wake\_time\_auto\_selection() API for all TWT applications.  + - It is recommended to issue iTWT setup command once IP assignment, TCP connection, application specific socket connections are done. + - When using sl\_wifi\_enable\_target\_wake\_time API, increase TCP / ARP Timeouts at the remote side depending upon the configured TWT interval configured. It's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() as an alternative. + - In case of TWT in coex mode, when using sl\_wifi\_enable\_target\_wake\_time API, use TWT wake duration <= 16 ms and TWT wake interval >= 1 sec. If wake duration > 16 ms or TWT wake interval < 1sec, there might be performance issues. + - For iTWT GTK interval in AP should be configured to max possible value or zero. If GTK interval is not configurable on AP side, recommended TWT interval (in case of sl\_wifi\_enable\_target\_wake\_time API) or RX Latency (in case of sl\_wifi\_target\_wake\_time\_auto\_selection API) is less than 4sec. + - When sl\_wifi\_enable\_target\_wake\_time API is used, configuring TWT Wake interval beyond 1 min might lead to disconnections from the AP. Recommended to use TWT wake interval of less than or equal to 1 min. + - When using sl\_wifi\_enable\_target\_wake\_time API, it is recommended to set missed\_beacon\_count of sl\_wifi\_set\_advanced\_client\_configuration API greater than 2 times of the configured TWT Interval. +- Disable power save for high throughput applications or use FAST PSP power save mode as per application requirement. +- The application needs to ensure that it sets RTC with the correct timestamp before establishing the SSL/EAP connection. +- The minimum timeout value should not be less than 1 second for socket select and socket receive calls.  +- Embedded MQTT keep alive interval should be either 0 or a value greater than 35 seconds. +- Disable power save and suspend any active TWT sessions before triggering HTTP OTAF. +- Randomize the client port if using rapid connect/disconnect of the MQTT session on the same client port with the power save. + +### **BLE** + +- In BLE, the recommended range of Connection Interval in + - Power Save (BLE Only) - 100 ms to 1.28 s. +- In BLE, during Connection, the configuration of Scan Interval and Scan Window with the same value is not recommended. The suggested ratio of Scan Window to Scan Interval is 3:4. +- In BLE, if a device is acting as Central, the scan window (in set\_scan\_params and create\_connection commands) must be less than the existing Connection Interval. The suggested ratio of Scan Window to Connection Interval is 2:3. +- In BLE mode, if scanning and advertising are in progress on the SiWx91x module and it subsequently gets connected and moves to the central role, scanning stops else if it moves to the peripheral role, advertising stops. To further establish a connection to another peripheral device or to a central device, the application should give a command for starting advertising and scanning again. + +### **Multi-protocol** + +- For concurrent Wi-Fi + BLE, and while a Wi-Fi connection is active, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. +- Wi-Fi + BLE Advertising + - All standard advertising intervals are supported. As Wi-Fi throughput is increased, a slight difference in on-air advertisements compared to configured intervals may be observed. + - BLE advertising is skipped if the advertising interval collides with Wi-Fi activity. +- Wi-Fi + BLE scanning + - All standard scan intervals are supported. For better scan results, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. + - BLE scanning will be stopped for intervals that collide with Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Connections + - All standard connection intervals are supported. + - For a stable connection, use optimal connection intervals and max supervision timeout in the presence of Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Data Transfer + - To achieve higher throughput for both Wi-Fi and BLE, use medium connection intervals, such as 45 to 80 ms with maximum supervision timeout. + - Ensure Wi-Fi activity consumes lower intervals. + +## **Known Issues of WiSeConnect3\_SDK\_3.1.1 Release** + +### **System** + +- None + +### **SDK** + +- Observed issue, when NULL is passed for readfds, writefds, excepfds to socket, select.  +- Enhanced sl\_wifi\_get\_firmware\_version() API to provide more details (ROM ID, chip ID, security version, etc) which is not backward compatible with firmwares older than 1711.2.10.1.0.0.4. Firmware binary notation does not include security version number. +- Observed not being able to receive UDP Rx TPUT print at Teraterm with IPV6 Throughput example + +### **Wi-Fi/Network Stack** + +**Wi-Fi STA** + +- STA Connection with the WPA3 Hunting and Pecking algorithm takes about 3-4 seconds. +- Observed BSSID-based connection configuration is not reflecting to make a connection with the specified access point. +- Observed connection failures with some APs in more channel congestion ~50-60% occupancy open lab environment. +- Observed auth/assoc timeout is not reflecting as per timeout configuration using sl\_si91x\_configure\_timeout() API . +- Region selection based on country IE in the beacon is not supported +- Observed intermittent beacon reception from Access Point ( beacon misses) in an extremely congested environment + +**Access Point (AP) Mode** + +- Scan feature in AP mode not fully functional.  +- Fixed rate configuration in AP mode using sl\_wifi\_set\_transmit\_rate API is not being set as expected.  +- First few beacons (~ 10) don't include RSN IE + +**WPA2 Enterprise security (STA)** + +- Observed issue with configuring certificate key and programming 4096 bit key and SHA384/SHA512 certificates. +- Observing DUT is throwing 0x1001c when configuring .data.certificate\_key as "123456789" +- Configuration issue to program PAC file for EAP FAST Manual mode +- Issue observed with WPA2 Enterprise Connectivity using Microsoft RADIUS Server. + +**Wi-Fi Concurrency ( AP + STA in same channel)** + +- Observed 3rd party STA association fail with 917 AP while 917 STA mode is connecting/reconnecting to configured 3rd party AP. Reconnect 3rd party STA to 917 AP in such scenarios.  + +**OFDMA (UL/DL)** + +- Less throughput observed in DL-OFDMA with some APs that enabled LDPC. + +**MUMIMO (DL)** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Performance, Interop issues with MU MIMO with certain APs.  +- Less throughput was observed in MU-MIMO with some APs that enabled LDPC. + +**TWT** + +- Variability with MQTT keep alive interval based on TWT wake up interval.    +- When sl\_wifi\_enable\_target\_wake\_time() API is used, occasional MQTT disconnections may be observed if TWT is configured with longer TWT intervals (>30secs) with embedded MQTT + TWT.  As an alternative, it's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() API, where these dependencies are internally handled. + +**Wi-Fi STA Rejoin** + +- observed Scanning (probe request) in all channels instead of the channels configured in selective channel(channel\_bitmap\_2g4) during rejoin process + +**IPv4/IPv6** + +- Observed issue with assigning static IP to DUT +- IP change notification is not indicated to the application +- Observed sl\_net\_up returning 0x27 error code due to an issue in the handling of IPv6 address.  + +**BSD Socket API** + +- Configuration issue to program MSS (default 1460), TCP retry count (default 10) through setsockopt +- Every server socket created consumes a socket (maximum of 10 sockets supported) and every subsequent connection to server socket consumes an additional socket (from the same pool of 10 sockets), which limits the number of server connections supported. + +**SSL Client/Server** + +- Sometimes during SSL Handshake, ECC curve parameters generated are wrong, resulting in connection failure with BBD2 error. However, this recovers in the next attempt. +- Secure SSL renegotiation not supported in Embedded Networking Stack +- observed connection failures with ECDSA ciphers + +**HTTP Client/ HTTPS Client** + +- Observed occasional HTTPS continuous download failures when power save is enabled. Recommended to disable it before performing HTTPS continuous downloads +- Observed HTTPS post data is failing with error code: BBE2 (HTTP Failed). + +**SNTP** + +- Unable to get SNTP async events when coex mode and power save are enabled  + +**Throughputs & Performance** + +- Observed 20% less Wi-Fi throughput with SDK 3.x compare to target throughput (depends on host and host interface), SDK refinements are in progress + +**Secure Over the Air (OTA) Upgrade** + +- Observed firmware upgrade failures after multiple iterations +- Observed OTA failures with power save enabled, So recommended to disable power save during OTA +- Observed "0xffffffff" error at the remote end while doing firmware upgrade via TCP server using (featured) example with ubuntu 21.0x.  + +**Wi-Fi IOT Cloud integration (AWS IOT Core)** + +- Observed AWS MQTT keepalive transmission is not happening at expected intervals with power save enabled. + +**Wi-Fi Interoperability (IOP)** + +- Observed disconnections with Amplifi (AFI-INS-R) AP with Powersave enable +- TWT session is failing due to disconnections observed in DUT if rx\_latency  is set to 55 seconds and receive data is also set to 55 seconds on MI Xiaomi RA72 and Tplink AX53 AP's +- Observed less throughput(~1Mb) while running TCP RX with Max\_PSP powersave with DLink 810 AP +- Observed interop issue (random disconnections) with few APs (EERO 6+, EERO PRO 6E, Cisco Catalyst 9120AXID) +- Disconnections observed with Netgear RAX120 AP in WPA3 security + +### **BLE** + +**GAP** + +- When running the ble\_central application with power save enabled, it was observed that the BLE connect API is failing because of 0xFFFFFFE2(RSI\_ERROR\_RESPONSE\_TIMEOUT) error. +- When BLE local name is provided with a 16-byte length, the Set local name API fails with error code: 0x4e66[Invalid Name length]. + +**Advertising Extension** + +- When running the ble\_ae\_central example, observed an application hang issue at the AE Clear Periodic Adv list API.  + +**DTM/PER** + +- Recommend to limit BLE Tx Maximum power to 16 dBm.  Please don't use for 127 power\_index for BLE HP release with this release. + +**IOP** + +- BLE connection failure has been observed on a few mobile devices (Samsung S23& Oneplus 9pro) when Si917 device is configured as central. + +### **Multi-protocol** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Wi-Fi + BLE intermittent connection failures, disconnections, and data transfer stalls in the long run when power save is enabled. +- While executing Wi-Fi Commissioning using the wifi\_station\_ble\_provisioning example, BLE is disconnecting is observed with few boards. +- Observed "DUT is not disconnecting to the AP when initiating disconnection from EFR connect app screen using wifi\_station\_ble\_provisioning\_aws example + +### **Simplicity Studio and Commander (For EFR Host)** + +- All projects in the package are compatible with **GNU ARM V12.2.1** toolchain +- Project Configurator is not supported. + +## **Features in RoadMap** + +### **SDK** + +- WPS 2.0 PIN/PUSH, Network Manager Enhancements +- MDNS, HTTP Server, Azure MQTT Client, Websockets +- Matter integration with Embedded TCP/IP stack  +- Enhanced buffer management, Throughput optimization +- TLS over LWIP, Network layer applications (MQTT, HTTP, etc.) over LWIP. +- Debugging utilities + +### **System** + +- Secure communication over host interfaces (UART. SPI, SDIO) +- UART 2 Debug prints are supported only on ULP\_GPIO\_9. + +### **Wi-Fi/Network Stack** + +- Spatial Re-Use, BSS Max Idle +- Provisioning using Wi-Fi AP + +### **BLE** + +- Support for 8 Peripheral + 2 Central connections  +- Support for BLE Mesh(4 nodes only) for limited Mesh use case + +## **Limitations and Unsupported Features** + +### **System** + +- None + +### **SDK** + +- Baremetal mode is not supported. + +### **Wi-Fi/Network Stack** + +- TLS 1.3 Server is not supported +- 40 MHz bandwidth for 2.4 GHz band is not supported. +- A maximum of 3 SSL connections are supported in Wi-Fi alone mode. +- In SSL ECC Curve ID supported is 23. SSL handshake with 3rd party clients depends on the SSL ECC Curve ID. +- The number of Non-Transmitting BSSIDs processed is limited by the beacon length that can be processed by the stack (which is 1024 bytes). Beacons greater than 1024 Bytes in length will not be processed. +- UL MUMIMO is not supported. +- WPA3 AP supports only H2E algorithm. +- PMKSA caching is not supported in WPA3 AP mode. +- The maximum embedded MQTT Publish payload is 1 kbyte. +- Timeout value for socket select and socket receive calls of less than 1 second is not currently supported. + +### **BLE** + +- For BLE, if the connection is established with a small connection interval (less than 15 ms), simultaneous roles (i.e., Central + Scanning and Peripheral + Advertising) are not supported. +- BLE maximum two concurrent connections are supported, which can be either a connection to two peripheral devices, to one central and one peripheral device or two central devices. +- BLE Slave latency value is valid up to 32 only. +- BLE TX/RX throughput is less when tested with EFM as compared to EFR. +- Maximum supported AE data length is 200 bytes. +- Supports only two ADV\_EXT sets. +- Supports only two BLE connections (1 Central and 1 Peripheral) with AE. +- Advertising Extension feature is not supported in Coexistence. +- Isochronous channels feature is not supported.  +- Connection subrating feature is not supported.  +- LE power controller feature is not supported.  +- EATT feature is not supported. +- Periodic Advertising with response(PAwR) feature is not supported.  +- BLE Audio is not supported. +- The feature of dynamically changing the TX power when extended advertising is active is not supported. + +### **Multi-protocol** + +- Wi-Fi AP + BLE currently not supported + +
+ # **WiSeConnect3\_SDK\_3.1.1-Doc NCP Release Notes** ## **Release Details** diff --git a/docs/release-notes/index_soc.md b/docs/release-notes/index_soc.md index 67e8dd36..df0aa901 100644 --- a/docs/release-notes/index_soc.md +++ b/docs/release-notes/index_soc.md @@ -1,3 +1,1070 @@ +# **WiSeConnect3\_SDK\_3.1.2 SoC Release Notes** + +## **Release Details** + +|**Item**|**Details**| +| :- | :- | +|Release date|Jan 17th, 2024| +|SDK Version|3\.1.2| +|Firmware Version|1711\.2.10.1.1.0.2| +|Release Package Name|WiSeConnect3\_SDK\_3.1.2| +|Supported RTOS|FreeRTOS| +|Operating Modes Supported|Wi-Fi STA, Wi-Fi AP, Wi-Fi STA+BLE, Wi-Fi STA+AP| + +- SiWx917 release consists of two components: + - Wireless Firmware - SiWx917 Firmware Binary available as SiWG917-B.2.10.1.1.0.2.rps + - Wiseconnect3 Library - Wiseconnect3 SDK library runs on internal Cortex M4 + +**NOTE:** Mandatory to upgrade the earlier version of boards (Si917-6031A Prokit or 4338A boards) or 917 Silicon ICs with instructions as outlined in this document "SiWG917–TA\_Flash\_Memory\_Map\_ChangeGuide\_v1.3.pdf" for more details.   + +## **Supported Hardware** + +|**Hardware**|**OPN**| +| :- | :- | +|Silicon (IC OPN)|SiWG917M111MGTBA| +|Development Kits|

Pro Kit: SiWx917-PK6031A, Si917-PK6031A.

(Pro Kit includes Mother board "SI-MB4002A" + Radio board)

Radio boards: SiWx917-RB4338A, Si917-RB4338A

| + +## **Supported Features**  + +### **System** + +- **Operating Modes**  + - Wi-Fi STA (802.11ax, 802.11n), Wi-Fi 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + BLE +- **Security**  + - Secure Boot, Secure Key storage and HW device identity with PUF, Secure Zone, Secure XIP (Execution in place) from flash, Secure Attestation, Anti Rollback, Secure Debug. Flash Protection.  + - Secure firmware upgrade options: + - Firmware loading support by Commander Tool through Jlink Debugger. Jlink connected to Serial Wire Debug (SWD)  + - Firmware loading via ISP using UART (Commander or Serial terminal), SPI Interface + - Secure Over the Air (OTA) Upgrade +- **Crypto Support** + - ` `Crypto API's for Hardware Accelerators: + - Advanced Encryption Standard (AES) 128/256/192, Secure Hash Algorithm (SHA) 256/384/512, Hash Message Authentication Code (HMAC), Random Number Generator (RNG), SHA3, AES-Galois Counter Mode (GCM)/ Cipher based Message Authentication Code (CMAC), ChaCha-poly, True Random Number Generator (TRNG) + - Software Accelerators: RSA, ECC  + - Integrated with mbed TLS. + - TRNG, AES, SHA, HMAC, GCM, Chacha-poly, ECDH and AES-CCM hardware crypto engine is integrated with PSA crypto. +- **System Power Save** + - Deep Sleep with RAM retention and without RAM retention.  + - Wireless Power Save: Connected Sleep (Wi-Fi Standby Associated), BLE Advertising with powersave, BLE Scan with powersave ,  BLE connection with powersave. Only Max PSP power save mode is supported in BLE.  + +### **MCU** + +- **Memory** + - Common Flash: Single shared Flash for both Cortex-M4 and NWP (Wireless Processor) +- **Power States** + - Active: PS4, PS3, PS2, and PS1  + - Standby: PS4, PS3, and PS2 + - Sleep: PS4, PS3 and PS2 + - Deep Sleep(Shutdown): PS0 +- **Peripherals** + - High Performance (HP)- ADC, CALENDAR, CONFIG TIMER(CT), EFUSE, EGPIO, GSPI, I2C, I2S, MCPWM, SDIO Secondary, SIO, SSI, SYSRTC, UART, uDMA, USART, WDT**  + - Ultra Low Power (ULP) - ULP\_TIMER, ULP\_UART, ULP\_I2C, ULP\_I2S, ULP\_uDMA and ULP\_SSI +- **Services** + - Sleep Timer, IOSTREAM, Power Manager, SensorHub, NVM3 +- **Development Pro-Kit Peripheral Support** + - LED, Button, MEMLCD, Joystick, RHT Sensor + +### **Development Environment** + +- Simplicity Studio IDE (SV5.8.0 version) and Debugger Integration.   Refer to the latest version of the SoC "Getting-Started-with-SiWx917" guide for more details.  +- Simplicity Commander to supports Flash loading, provision of MBR programming, security key management, and calibration support for crystal and gain offsets. refer "siwx917-soc-manufacturing-utility-user-guide" for more details.**  +- Advanced Energy Monitoring (AEM) to measure ultra-low power capability on Development boards (Pro Kit). + +### **Wi-Fi** + +- **Wi-Fi Protocols** + - IEEE 802.11 b/g/n/ax (2.4GHz) +- **Access Point (AP) Mode** + - 4 Client Support, Hidden SSID Mode, Auto Channel Selection, Scan in AP mode + - Wi-Fi Security   + - WPA2 Personal, WPA3 Personal (H2E method only), WPA Mixed mode (WPA/WPA2)  +- **Wi-Fi Scan** + - Selective Scan, Active/Passive Scan +- **Wi-Fi STA (Security Modes)** + - Open Mode, WPA2 Personal, WPA2 Enhancements, WPA3 Personal, Mixed Mode (WPA/WPA2), WPA3 Personal Transition Mode (WPA2/WPA3) +- **WPA2 Enterprise security (STA)** + - Method + - PEAP/TTLS/TLS 1.0/TLS 1.2/FAST +- **Wi-Fi STA Rejoin** +- **Wi-Fi STA Roaming** + - BG Scan, OKC (Opportunistic Key caching), PMK (Pairwise Master Key) caching, Pre-Authentication +- **Wi-Fi Protocol Power Save**  + - Deep sleep (unconnected state), Max PSP, Enhanced Max PSP, Fast PSP,** TWT +- **QoS** + - WMM-QoS +- **Wi-Fi 6 Feature** + - MUMIMO (DL), OFDMA (UL/DL), iTWT, TWT I-Frame & TWT Enhancements, BSS coloring, MBSSID +- **Wi-Fi Concurrency**  + - AP+STA (Same channel) +- **Wi-Fi Band/Channels** + - 2.4GHz CH1-11, 2.4GHz CH1-13, 2.4GHz CH1-14 (Japan) +- **Known Security Vulnerabilities Handled** + - WPA2 KRACK Attacks, Fragment and Forge Vulnerability + +### **Network Stack** + +- **Core Networking Features** + - TCP/IP Bypass (LWIP as Hosted stack for reference), IPv4/IPv6/UDP/TCP/ARP/ICMP/ICMPv6 + - SSL client versions TLSV1.0, TLSV1.2, TLSV1.3  + - SSL server versions TLSV1.0 and TLSV1.2 + - DHCP (Client/Server)/ DHCPv6 Client +- **Advanced Network Features** + - HTTP Client/HTTPS Client//DNS Client/SNTP Client, Embedded MQTT/MQTT on host +- **Wi-Fi IoT Cloud Integration** + - AWS IOT Core +- BSD and IoT sockets application programming interface(API) + +### **BLE**  + +- GAP(Advertising, Scanning, initiation, Connection and Bonding) +- Generic Attribute Protocol(GATT) +- Attribute protocol(ATT) +- Security +- LL Privacy 1.2 +- Accept list +- Directed Advertising +- Extended Advertising +- Periodic Advertising +- Periodic Advertising scanning +- Extended Advertising scanning +- Periodic Advertising list +- LE periodic advertising synchronization +- LE PHY(1Mbps, 2Mbps) & Coded PHY(125Kbps, 500kbps) +- Simultaneous scanning on 1Mbps and Coded PHY +- LE dual role topology +- LE data packet length extensions(DLE) +- Asymmetric PHYs +- LE channel selection algorithm 2 (CSA#2) +- LE Secure connections +- Bluetooth 5.4 Qualified + +### **SDK** + +- Simplified and Unified DX for Wi-Fi API and Platform APIs +- Simplifies application development and presents clean and standardized APIs +- UC (Universal Configurator) enables componentization, simplifying configuration of peripherals and examples +- BSD and ARM IoT-compliant socket API +- Available through Simplicity Studio and GitHub + +### **Multi-protocol** + +- Wi-Fi STA + BLE + +### **PTA/Coexistence** + +- 3 wire coex acting as Wi-Fi with external Bluetooth +- 3 wire coex acting as Wi-Fi with external Zigbee/OT + +## **Changes in this release compared to v3.1.1-Doc Release** + +### **System** + +None + +### **MCU** + +- **Enhancements** + - Provided API for configuring ULP GPIO pin functionality on SoC GPIO pin. +- **Fixed Issues** + - Improved Joystick interface noise filtering. + - Provided fix for SYSRTC callback unregister for Capture channel. + - Provided resolution for SI70xx RHT sensor no\_hold\_read feature. + - Provided unregister callback API in all the Peripheral deinit API. + +### **SDK** + +- **Enhancements** + - Resolved warnings in the featured and snippet demos. + - sl\_wifi\_get\_sta\_tsf() API added to get the station TSF time which is synchronized with connected AP beacon TSF. + - Added “update gain” demo for BLE. + - Added an option to test user gain table feature in "ble\_per" demo by enabling the “GAIN\_TABLE\_AND\_MAX\_POWER\_UPDATE\_ENABLE” macro. + - Removed unused input parameters in rsi\_ble\_set\_ble\_tx\_power() API. +- **Fixed Issues** + - Fixed issue with BSSID based connection. + - Fixed issue with the file descriptors set handling for socket select. + - Fixed issue with authentication and association timeout is not reflecting as per timeout configuration using sl\_si91x\_configure\_timeout() API + - Fixed profile id corruption issue for IPV6 demos.  + - Fixed application hang issue at the AE Clear Periodic Adv list API when used "ble\_ae\_central" example.  + - Fixed issue where BLE connect API is failing because of 0xFFFFFFE2(RSI\_ERROR\_RESPONSE\_TIMEOUT) error with ble\_central application. + - Fixed HID data transfer issue when power save is enabled.  + +### **Wi-Fi/Network Stack** + +- **Enhancements** + - Added support for TSF time which is synchronized with connected AP beacon TSF. + - Improve PER performance at max input power levels for 11b. + - Improved ppm error across channels at room temperature. + - Added Wi-Fi regulatory table for ACx. + - Updated regulatory tables of WLAN. +- **Fixed Issues** + - Increased supported length for Embedded MQTT username up to 120 bytes and topic length up to 200 bytes. + - Added support to process long ICMP ping response upto packet size of 1472 Bytes for IPv4 and 1452 Bytes for IPv6. + - Issue with configuration of TCP MSS through setsockopt() has been fixed. + - Fixed Listen interval based power save issue when IPV6 mode is enabled + - Added fix for missing RSN IE in first few AP beacons. + +### **BLE** + +- **Enhancements** + - Added Region based maximum power index support for both 0dBm & 10dDm LP chains. +- **Fixed Issues** + - Fixed regulatory output power violations with default region based settings in HP chain. + - Fixed an issue that caused the Set local name API to fail with the error code 0x4e66[Invalid Name length] when a local name given with 16 bytes of length. + +### **Multi-protocol** + +- **Enhancements** + - None +- **Fixed Issues** + - None + +## **Recommendations** + +### **System** + +- The current revision of SiWx917 has: + - RAM memory of 672k bytes which can be shared between TA and M4 processors in SoC mode.  + - The below configurations are applicable in SoC mode and can be configured based on the application requirement. EXT\_FEAT\_352K\_M4SS\_320K is the default configuration, based on requirement EXT\_FEAT\_480K\_M4SS\_192K configuration is selected for SoC mode multi-protocol examples. + - EXT\_FEAT\_480K\_M4SS\_192K - This mode configures TA with 480k and M4 with 192K bytes of memory + - EXT\_FEAT\_416K\_M4SS\_256K - This mode configures TA with 416k and M4 with 256K bytes of memory + - EXT\_FEAT\_352K\_M4SS\_320K - This mode configures TA with 352k and M4 with 320K bytes of memory + - SoC mode should not use 672k\_M4SS\_0K memory configuration. +- Set the recommended Power Save Profile (PSP) type to Enhanced Max PSP. +- There are 2 Versions of Pro-Kits/Radio boards.  Si917-6031A based on Si917-4338A and SiWx917-6031A based on SiWx917-4338A. To get optimal power numbers, enable macro "SL\_SI91X\_ENABLE\_LOWPWR\_RET\_LDO" pre-processor define for ICs or while using SiWx917-6031A Pro-kit, SiWx917-4338A version of boards. This macro should be disabled for earlier variant of board (Si917-6031A, Si917-4338A). +- With RAM configuration (EXT\_FEAT\_352K\_M4SS\_320K), only 352K memory is available to TA  which limits the features supported, Recommended to enable EXT\_FEAT\_416K\_M4SS\_256K in Wi-Fi + BLE Multi protocol mode to enable more Network features. +- For EXT\_FEAT\_416K\_M4SS\_256K  and EXT\_FEAT\_480K\_M4SS\_192K memory configurations, it is recommended to retain both TA and M4 RAMs in power save. + +### **Wi-Fi/Network Stack** + +- It is recommended to enable bit 16 of the 'Extended TCP IP Feature' bit map in the opermode command for all Wi-Fi Socket operations from the host to ensure graceful handling during asynchronous closures from the peer. +- For high throughput applications, aggregation (bit 2 of feature\_bit\_map) is recommended to be enabled in opermode.  +- To reset TA (NWP), the application needs to call sl\_wifi\_deinit() followed by sl\_wifi\_init(). Users must ensure that no execution happens from flash at this point of time. (Refer to example applications)  +- Users can enable SL\_SI91X\_EXT\_TCP\_IP\_SSL\_16K\_RECORD in 'Extended TCP IP Feature' bit map in opermode for (HTTPS server) supporting 16k record. +- **TWT** + - Recommendation is to use sl\_wifi\_target\_wake\_time\_auto\_selection() API for all TWT applications.  + - It is recommended to issue iTWT setup command once IP assignment, TCP connection, application specific socket connections are done. + - When using sl\_wifi\_enable\_target\_wake\_time API, increase TCP / ARP Timeouts at the remote side depending upon the configured TWT interval configured. It's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() as an alternative. + - In case of TWT in coex mode, when using sl\_wifi\_enable\_target\_wake\_time API, use TWT wake duration <= 16 ms and TWT wake interval >= 1 sec. If wake duration > 16 ms or TWT wake interval < 1sec, there might be performance issues. + - For iTWT GTK interval in AP should be configured to max possible value or zero. If GTK interval is not configurable on AP side, recommended TWT interval (in case of sl\_wifi\_enable\_target\_wake\_time API) or RX Latency (in case of sl\_wifi\_target\_wake\_time\_auto\_selection API) is less than 4sec. + - When sl\_wifi\_enable\_target\_wake\_time API is used, configuring TWT Wake interval beyond 1 min might lead to disconnections from the AP. Recommended to use TWT wake interval of less than or equal to 1 min. + - When using sl\_wifi\_enable\_target\_wake\_time API, it is recommended to set missed\_beacon\_count of sl\_wifi\_set\_advanced\_client\_configuration API greater than 2 times of the configured TWT Interval. +- Disable power save for high throughput applications or use FAST PSP power save mode as per application requirement. +- The application needs to ensure that it sets RTC with the correct timestamp before establishing the SSL/EAP connection. +- The minimum timeout value should not be less than 1 second for socket select and socket receive calls.  +- Embedded MQTT keep alive interval should be either 0 or a value greater than 35 seconds. +- Disable power save and suspend any active TWT sessions before triggering HTTP OTAF. +- Randomize the client port if using rapid connect/disconnect of the MQTT session on the same client port with the power save. + +### **BLE** + +- In BLE, the recommended range of Connection Interval in + - Power Save (BLE Only) - 100 ms to 1.28 s. +- In BLE, during Connection, the configuration of Scan Interval and Scan Window with the same value is not recommended. The suggested ratio of Scan Window to Scan Interval is 3:4. +- In BLE, if a device is acting as Central, the scan window (in set\_scan\_params and create\_connection commands) must be less than the existing Connection Interval. The suggested ratio of Scan Window to Connection Interval is 2:3. +- In BLE mode, if scanning and advertising are in progress on the SiWx91x module and it subsequently gets connected and moves to the central role, scanning stops else if it moves to the peripheral role, advertising stops. To further establish a connection to another peripheral device or to a central device, the application should give a command for starting advertising and scanning again. + +### **Multi-protocol** + +- For concurrent Wi-Fi + BLE, and while a Wi-Fi connection is active, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. +- Wi-Fi + BLE Advertising + - All standard advertising intervals are supported. As Wi-Fi throughput is increased, a slight difference in on-air advertisements compared to configured intervals may be observed. + - BLE advertising is skipped if the advertising interval collides with Wi-Fi activity. +- Wi-Fi + BLE scanning + - All standard scan intervals are supported. For better scan results, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. + - BLE scanning will be stopped for intervals that collide with Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Connections + - All standard connection intervals are supported. + - For a stable connection, use optimal connection intervals and max supervision timeout in the presence of Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Data Transfer + - To achieve higher throughput for both Wi-Fi and BLE, use medium connection intervals, such as 45 to 80 ms with maximum supervision timeout. + - Ensure Wi-Fi activity consumes lower intervals. + +## **Known Issues of WiSeConnect3\_SDK\_3.1.2 Release** + +### **MCU** + +**SensorHub** + +- SensorHub does not support, SPI-based sensors and ADC multi-channel.  + +**SSI** + +- SSI Dual and Quad mode are not functional.  +- SSI primary: mode3(TI) is not working as expected.  +- SSI Primary will not be operable at 40 MHz  + +**I2C** + +- I2C High speed and Fastplus modes are not working at specification speed + +**UART** + +- Flow control is not supported in USART and IOSTREAM applications + +**ADC** + +- In ADC Multichannel, sampling rate is limited to less than 15Ksps. Number of samples is less than 500 and with a maximum of 4 channel +- In ADC Multichannel, when using different sampling rates for different channels behavior is not as expected + +**CT (Config Timer)** + +- Config Timer(CT) support as an external event, in 32-bit mode, and DMA are not working as expected + +**PWM** + +- PWM Special event trigger for synchronizing analog-to-digital conversions is not working + +**SYSRTC** + +- SYSRTC with RO clock is not functioning + +**Power Manager** + +- The wakeup sources ULP-SSI, BOD, Comparator, and SysRTC are not working in the Power Manager service + +### **SDK** + +- Observed Wi-Fi connection is successful even after deleting the stored network credentials using sl\_net\_delete\_credential and responding with SL\_NET\_INVALID\_CREDENTIAL\_TYPE for sl\_net\_get\_credential. +- Observed sl\_net\_deinit is not returning any response for both "SL\_NET\_WIFI\_AP\_INTERFACE" and "SL\_NET\_WIFI\_CLIENT\_INTERFACE" interfaces, which requires to execute deinit code path to RAM in case of common flash. +- Enhanced sl\_wifi\_get\_firmware\_version() API to provide more details (ROM ID, chip ID, security version, etc) which is not backward compatible with firmwares older than 1711.2.10.1.0.0.4. Firmware binary notation does not include security version number. +- Matter applications are experiencing compatibility issues with WiseConnect SDK 3.1.2. It is recommended to use WiseConnect SDK 3.1.1 for matter-related applications. This will be addressed in up coming release(s). + +### **Wi-Fi/Network Stack** + +**Wi-Fi STA** + +- STA Connection with the WPA3 Hunting and Pecking algorithm takes about 3-4 seconds. +- Observed connection failures with some AP's in more channel congestion ~50-60% occupancy open lab environment. +- Region selection based on country IE in the beacon is not supported +- Observed intermittent beacon reception from Access Point ( beacon misses) in an extremely congested environment +- Note section in API documentation for sl\_wifi\_get\_sta\_tsf  needs to be corrected to "Returns error if station is not connected or at least one beacon is not received." + +**Access Point (AP) Mode** + +- Scan feature in AP mode not fully functional.  +- Fixed rate configuration in AP mode using sl\_wifi\_set\_transmit\_rate API is not being set as expected.  + +**WPA2 Enterprise security (STA)** + +- Observed connection issue with configuring certificate key and programming 4096 bit key and SHA384/SHA512 certificates. +- Observing DUT is throwing 0x1001c when configuring .data.certificate\_key as "123456789". +- Configuration issue to program PAC file for EAP FAST Manual mode. +- Issue observed with WPA2 Enterprise Connectivity using Microsoft RADIUS Server. + +**Wi-Fi Concurrency (AP + STA in same channel)** + +- Observed 3rd party STA association fail with 917 AP while 917 STA mode is connecting/reconnecting to configured 3rd party AP. Reconnect 3rd party STA to 917 AP in such scenarios.  + +**OFDMA (UL/DL)** + +- Less throughput observed in DL-OFDMA with some APs that enabled LDPC. + +**MUMIMO (DL)** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Performance, Interop issues with MU MIMO with certain APs.  +- Less throughput observed in MU-MIMO with some APs that enabled LDPC. + +**TWT** + +- Variability with MQTT keep alive interval based on TWT wake up interval.   +- When sl\_wifi\_enable\_target\_wake\_time() API is used, occasional MQTT disconnections may be observed if TWT is configured with longer TWT intervals (>30secs) with embedded MQTT + TWT.  As an alternative, it's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() API, where these dependencies are internally handled. + +**Wi-Fi STA Rejoin** + +- Observed Scanning (probe request) in all channels instead of the channels configured in selective channel(channel\_bitmap\_2g4) during rejoin process.  + +**IPv4/IPv6** + +- Observed issue with assigning static IP to DUT +- IP change notification is not indicated to the application.  + +**BSD Socket API** + +- Configuration issue to program TCP retry count (default 10) through setsockopt +- Every server socket created consumes a socket (maximum of 10 sockets supported) and every subsequent connection to server socket consumes an additional socket (from the same pool of 10 sockets), which limits the number of server connections supported. + +**SSL Client/Server** + +- Sometimes during SSL Handshake, ECC curve parameters generated are wrong, resulting in connection failure with BBD2 error. However, this recovers in the next attempt. +- Secure SSL renegotiation is not supported in the Embedded Networking Stack +- Observed connection failures with ECDSA ciphers. + +**HTTP Client/ HTTPS Client** + +- Observed occasional HTTPS continuous download failures when power save is enabled. Recommended to disable it before performing HTTPS continuous downloads +- Observed HTTPS post data is failing with error code: BBE2 (HTTP Failed). + +**SNTP** + +- Unable to get SNTP async events when Coex mode and power save are enabled  + +**Throughputs & Performance** + +- Wi-Fi alone throughput is about SDK 3.x (42Mbps). SDK refinements are in progress to further improve Wi-Fi Standalone and Coex Throughputs.  + +**Secure Over the Air (OTA) Upgrade** + +- Observed firmware upgrade failures after multiple iterations. +- Observed OTA failures with powersave enable, So recommended to disable powersave during OTA.  +- Observed "0xffffffff" error at the remote end while doing firmware upgrade via TCP server using (featured) example with ubuntu 21.0x.  + +**Wi-Fi IOT Cloud integration (AWS IOT Core)** + +- Observed AWS MQTT keepalive transmission is not happening at expected intervals with power save enabled. + +**Wi-Fi Interoperability (IOP)** + +- Observed disconnections with Amplifi (AFI-INS-R) AP with powersave enable +- TWT session is failing due to disconnections observed in DUT if rx\_latency is set to 55 seconds and receive data is also set to 55 seconds on MI Xiaomi RA72 and Tplink AX53 AP's +- Observed less throughput(~1Mb) while running TCP RX with Max\_PSP powersave with DLink 810 AP +- Observed interop issue (random disconnections) with few APs (EERO 6+, EERO PRO 6E, Cisco Catalyst 9120AXID) +- Disconnections observed with Netgear RAX120 AP in WPA3 Security + +### **BLE** + +**GAP**  + +- BLE reconnection is not working in ble\_multiconnection\_gatt demo when power save is enabled in SoC.  +- When power save is enabled in the SoC, the DUT hangs with the ble\_multiconnection\_gatt demo while performing continuous Tx/Rx notifications. + +**DTM/PER** + +- Recommend to limit BLE Tx Maximum power to 18 dBm.  Please don't use for 127 power\_index for BLE HP chain with this release. + +**IOP** + +- BLE connection failure has been observed on a few mobile devices (Samsung S23& Oneplus 9pro) when the Si917 device is configured as central. + +### **Multi-protocol** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Wi-Fi + BLE intermittent connection failures, disconnections, and data transfer stalls in the long run when power save is enabled. +- Observed "DUT is not disconnecting to the AP when initiating disconnection from EFR connect app screen using wifi\_station\_ble\_provisioning\_aws example + +### **System** + +- Observed random hang issues with encrypted firmwares on some earlier variant of boards  (Si917-6031A, Si917-4338A) with powersave enable. + +### **Simplicity Studio and Commander**  + +- Simplicity commander does not support options under "Debug Lock tools". +- All projects in the package are compatible with **GNU ARM V12.2.1** toolchain + +## **Planned Roadmap Features** + +### **SDK** + +- WPS 2.0 PIN/PUSH, Network Manager Enhancements +- MDNS, HTTP Server, Azure MQTT Client, Websockets +- Matter integration with Embedded TCP/IP stack  +- Enhanced buffer management, Throughput optimization +- TLS over LWIP, Network layer applications (MQTT, HTTP, etc.) over LWIP. +- Debugging utilities, UC Configurator for Wireless configurations + +### **System** + +- Secure communication over CPC (UART & SDIO interfaces) + +### **MCU** + +- Pin Tool for MCU  +- Dual Flash: Separate flash for Cortex M4 and Wireless Processor +- Peripherals: Analog Comparator, DAC, Temp Sensor, Capacitive Touch Sensor, OPAMP, HSPI, GPDMA, QEI, RNG, IR decoder, CRC and BOD +- Software-configurable MCU application memory options (192 or 256 or 320 kB) +- RTOS support for MCU Peripheral examples +- SensorHub: Support for SDC\_ADC and CLOUD connectivity +- SIO support for features Pattern matching, DMA flow control, self-loop mechanism and as a clock qualifier +- Support for I2S PCM functionality +- Stacked and external PSRAM: Pseudo Static RAM for storing application data and executing SoC applications.  + +### **Wi-Fi/Network Stack** + +- Spatial Re-Use, BSS Max Idle +- Provisioning using Wi-Fi AP + +### **BLE** + +- Support for 8 Peripheral + 2 Central connections  +- Support for BLE Mesh (4 nodes only) for limited Mesh use case + +## **Limitations and Unsupported Features**   + +### **System** + +- None + +### **SDK** + +- Baremetal mode is not supported. + +### **Wi-Fi/Network Stack** + +- TLS 1.3 Server is not supported. +- 40 MHz bandwidth for 2.4 GHz band is not supported. +- Max 3 SSL sockets in Wi-Fi only mode, 2 SSL Socket in Wi-Fi + BLE based on RAM memory configuration selected.  +- In SSL ECC Curve ID supported is 23. SSL handshake with 3rd party clients depends on the SSL ECC Curve ID. +- The number of Non-Transmitting BSSIDs processed is limited by the beacon length that can be processed by the stack (which is 1024 bytes). Beacons greater than 1024 Bytes in length will not be processed. +- Multiprotocol (STA +BLE) + EAP Security modes supported only with Memory configurations EXT\_FEAT\_416K\_M4SS\_256K and EXT\_FEAT\_480K\_M4SS\_192K. +- UL MUMIMO is not supported. +- WPA3 AP supports only H2E algorithm. +- PMKSA caching is not supported in WPA3 AP mode. +- Maximum embedded MQTT Publish payload is 1 kbyte. +- Timeout value for socket select and socket receive calls of less than 1 second is not currently supported. + +### **BLE** + +- For BLE, if the connection is established with a small connection interval (less than 15 ms), simultaneous roles (i.e., Central + Scanning and Peripheral + Advertising) are not supported. +- BLE maximum two concurrent connections are supported, which can be either a connection to two peripheral devices, to one central and one peripheral device or two central devices. +- BLE Slave latency value is valid up to 32 only. +- Maximum supported AE data length is 200 bytes. +- Supports only two ADV\_EXT sets. +- Supports only two BLE connections (1 Central and 1 Peripheral) with AE. +- Advertising Extension feature is not supported in Coexistence. +- The  ae\_central & ae\_peripheral applications are not supported with TA\_352K\_M4\_320K RAM configuration. +- Two BLE connections are not supported with M4 powersave. It only supports a single connection.  +- Isochronous channels feature is not supported.  +- Connection subrating feature is not supported.  +- LE power controller feature is not supported. +- EATT feature is not supported. +- Periodic Advertising with a response feature is not supported.  +- BLE Audio is not supported. +- The feature of dynamically changing the TX power when extended advertising is active is not supported. + +### **MCU** + +- SensorHub supports PS1-power state with ADC sensor. In this mode, other sensors operation is not supported.  + +### **Multi-protocol** + +- Wi-Fi AP + BLE currently not supported.  + +
+ +# **WiSeConnect3\_SDK\_3.1.1-Hotfix SoC Release Notes** + +## **Release Details** + +|**Item**|**Details**| +| :- | :- | +|Release date|Jan 2nd, 2024| +|SDK Version|3\.1.1-Hotfix| +|Firmware Version|1711\.2.10.1.0.0.7| +|Release Package Name|WiSeConnect3\_SDK\_3.1.1-Hotfix| +|Supported RTOS|FreeRTOS| +|Operating Modes Supported|Wi-Fi STA, Wi-Fi AP, Wi-Fi STA+BLE, Wi-Fi STA+AP| + +- SiWx917 release consists of two components: + - Wireless Firmware - SiWx917 Firmware Binary available as SiWG917-B.2.10.1.0.0.x.rps + - Wiseconnect3 Library - Wiseconnect3 SDK library runs on internal Cortex M4 + +**NOTE:** Mandatory to upgrade the earlier version of boards (Si917-6031A Prokit or 4338A boards) or 917 Silicon ICs with instructions as outlined in this document "SiWG917–TA\_Flash\_Memory\_Map\_Change\_Guide\_v1.3.pdf" for more details.   + +## **Supported Hardware** + + +|**Hardware**|**OPN**| +| :- | :- | +|Silicon (IC OPN)|SiWG917M111MGTBAR| +|Development Kits|

Pro Kit: SiWx917-PK6031A, Si917-PK6031A.

(Pro Kit includes Mother board "SI-MB4002A" + Radio board)

Radio boards: SiWx917-RB4338A, Si917-RB4338A

| + +## **Supported Features**  + +### **System** + +- **Operating Modes**  + - Wi-Fi STA (802.11ax, 802.11n), Wi-Fi 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + 802.11n AP, Wi-Fi STA (802.11ax, 802.11n) + BLE +- **Security**  + - Secure Boot, Secure Key storage and HW device identity with PUF, Secure Zone, Secure XIP (Execution in place) from flash, Secure Attestation, Anti Rollback, Secure Debug. Flash Protection.  + - Secure firmware upgrade options: + - Firmware loading support by Commander Tool through Jlink Debugger. Jlink connected to Serial Wire Debug (SWD)  + - Firmware loading via ISP using UART (Commander or Serial terminal), SPI Interface + - Secure Over the Air (OTA) Upgrade +- **Crypto Support** + - Crypto API's for Hardware Accelerators: + - Advanced Encryption Standard (AES) 128/256/192, Secure Hash Algorithm (SHA) 256/384/512, Hash Message Authentication Code (HMAC), Random Number Generator (RNG), SHA3, AES-Galois Counter Mode (GCM)/ Cipher based Message Authentication Code (CMAC), ChaCha-poly, True Random Number Generator (TRNG) + - Software Accelerators: RSA, ECC  + - Integrated with mbed TLS. + - TRNG, AES, SHA, HMAC, GCM, Chacha-poly, ECDH and AES-CCM hardware crypto engine is integrated with PSA crypto. +- **System Power Save** + - Deep Sleep with RAM retention and without RAM retention.  + - Wireless Power Save: Connected Sleep (Wi-Fi Standby Associated), BLE Advertising with powersave, BLE Scan with powersave ,  BLE connection with powersave. Only Max PSP power save mode is supported in BLE.  + +### **MCU** + +- **Memory** + - Common Flash: Single shared Flash for both Cortex-M4 and NWP (Wireless Processor) +- **Power States** + - Active: PS4, PS3, PS2, and PS1  + - Standby: PS4, PS3, and PS2 + - Sleep: PS4, PS3 and PS2 + - Deep Sleep(Shutdown): PS0 +- **Peripherals** + - High Performance (HP)- ADC, CALENDAR, CONFIG TIMER(CT), EFUSE, EGPIO, GSPI, I2C, I2S, MCPWM, SDIO Secondary, SIO, SSI, SYSRTC, UART, uDMA, USART, WDT**  + - Ultra Low Power (ULP) - ULP\_TIMER, ULP\_UART, ULP\_I2C, ULP\_I2S, ULP\_uDMA and ULP\_SSI +- **Services** + - Sleep Timer, IOSTREAM, Power Manager, SensorHub, NVM3 +- **Development Pro-Kit Peripheral Support** + - LED, Button, MEMLCD, Joystick, RHT Sensor + +### **Development Environment** + +- Simplicity Studio IDE (SV5.8.0 version) and Debugger Integration.   Refer to the latest version of the SoC "Getting-Started-with-SiWx917" guide for more details.  +- Simplicity Commander to supports Flash loading, provision of MBR programming, security key management, and calibration support for crystal and gain offsets. refer "siwx917-soc-manufacturing-utility-user-guide" for more details.**  +- Advanced energy measurement for ultra-low power capability available on Development boards (Pro Kit) + +### **Wi-Fi** + +- **Wi-Fi Protocols** + - IEEE 802.11 b/g/n/ax (2.4GHz) +- **Access Point (AP) Mode** + - 4 Client Support, Hidden SSID Mode, Auto Channel Selection, Scan in AP mode + - Wi-Fi Security   + - WPA2 Personal, WPA3 Personal (H2E method only), WPA Mixed mode (WPA/WPA2)  +- **Wi-Fi Scan** + - Selective Scan, Active/Passive Scan +- **Wi-Fi STA (Security Modes)** + - Open Mode, WPA2 Personal, WPA2 Enhancements, WPA3 Personal, Mixed Mode (WPA/WPA2), WPA3 Personal Transition Mode (WPA2/WPA3) +- **WPA2 Enterprise security (STA)** + - Method + - PEAP/TTLS/TLS 1.0/TLS 1.2/FAST +- **Wi-Fi STA Rejoin** +- **Wi-Fi STA Roaming** + - BG Scan, OKC (Opportunistic Key caching), PMK (Pairwise Master Key) caching, Pre-Authentication +- **Wi-Fi Protocol Power Save**  + - Deep sleep (unconnected state), Max PSP, Enhanced Max PSP, Fast PSP,** TWT +- **QoS** + - WMM-QoS +- **Wi-Fi 6 Feature** + - MUMIMO (DL), OFDMA (UL/DL), iTWT, TWT I-Frame & TWT Enhancements, BSS coloring, MBSSID +- **Wi-Fi Concurrency**  + - AP+STA (Same channel) +- **Wi-Fi Band/Channels** + - 2.4GHz CH1-11, 2.4GHz CH1-13, 2.4GHz CH1-14 (Japan) +- **Known Security Vulnerabilities Handled** + - WPA2 KRACK Attacks, Fragment and Forge Vulnerability + +### **Network Stack** + +- **Core Networking Features** + - TCP/IP Bypass (LWIP as Hosted stack for reference), IPv4/IPv6/UDP/TCP/ARP/ICMP/ICMPv6 + - SSL client versions TLSV1.0, TLSV1.2, TLSV1.3  + - SSL server versions TLSV1.0 and TLSV1.2 + - DHCP (Client/Server)/ DHCPv6 Client +- **Advanced Network Features** + - HTTP Client/HTTPS Client//DNS Client/SNTP Client, Embedded MQTT/MQTT on host +- **Wi-Fi IoT Cloud Integration** + - AWS IOT Core +- BSD and IoT sockets application programming interface(API) + +### **BLE**  + +- GAP(Advertising, Scanning, initiation, Connection and Bonding) +- Generic Attribute Protocol(GATT) +- Attribute protocol(ATT) +- Security +- LL Privacy 1.2 +- Accept list +- Directed Advertising +- Extended Advertising +- Periodic Advertising +- Periodic Advertising scanning +- Extended Advertising scanning +- Periodic Advertising list +- LE periodic advertising synchronization +- LE PHY(1Mbps, 2Mbps) & Coded PHY(125Kbps, 500kbps) +- Simultaneous scanning on 1Mbps and Coded PHY +- LE dual role topology +- LE data packet length extensions(DLE) +- Asymmetric PHYs +- LE channel selection algorithm 2 (CSA#2) +- LE Secure connections +- Bluetooth 5.4 Qualified + +### **SDK** + +- Simplified and Unified DX for Wi-Fi API and Platform APIs +- Simplifies application development and presents clean and standardized APIs +- UC (Universal Configurator) enables componentization, simplifying configuration of peripherals and examples +- BSD and ARM IoT-compliant socket API +- Available through Simplicity Studio and GitHub + +### **Multi-protocol** + +- Wi-Fi STA + BLE + +### **PTA/Coexistence** + +- 3 wire coex acting as Wi-Fi with external Bluetooth +- 3 wire coex acting as Wi-Fi with external Zigbee/OT + +## **Changes in this release compared to v3.1.1-Doc Release** + +### **System** + +- None + +### **MCU** + +- None + +### **SDK** + +- None + +### **Wi-Fi/Network Stack** + +- **Fixed Issues** + - Updated WLAN regulatory power tables. + +### **BLE** + +- **Fixed Issues** + - Updated BLE regulatory power tables. + +### **Multi-protocol** + +- None + +## **Recommendations** + +### **System** + +- The current revision of SiWx917 has: + - RAM memory of 672k bytes which can be shared between TA and M4 processors in SoC mode.  + - The below configurations are applicable in SoC mode and can be configured based on the application requirement. EXT\_FEAT\_352K\_M4SS\_320K is the default configuration, based on requirement EXT\_FEAT\_480K\_M4SS\_192K configuration is selected for SoC mode multi-protocol examples. + - EXT\_FEAT\_480K\_M4SS\_192K - This mode configures TA with 480k and M4 with 192K bytes of memory + - EXT\_FEAT\_416K\_M4SS\_256K - This mode configures TA with 416k and M4 with 256K bytes of memory + - EXT\_FEAT\_352K\_M4SS\_320K - This mode configures TA with 352k and M4 with 320K bytes of memory + - SoC mode should not use 672k\_M4SS\_0K memory configuration. +- Set the recommended Power Save Profile (PSP) type to Enhanced Max PSP. +- There are 2 Versions of Pro-Kits/Radio boards.  Si917-6031A based on Si917-4338A and SiWx917-6031A based on SiWx917-4338A. To get optimal power numbers, enable macro "SL\_SI91X\_ENABLE\_LOWPWR\_RET\_LDO" pre-processor define for ICs or while using SiWx917-6031A Pro-kit, SiWx917-4338A version of boards. This macro should be disabled for earlier variant of board (Si917-6031A, Si917-4338A). +- With RAM configuration (EXT\_FEAT\_352K\_M4SS\_320K), only 352K memory is available to TA  which limits the features supported, Recommended to enable EXT\_FEAT\_416K\_M4SS\_256K in Wi-Fi + BLE Multi protocol mode to enable more Network features. +- For EXT\_FEAT\_416K\_M4SS\_256K and EXT\_FEAT\_480K\_M4SS\_192K memory configurations, it is recommended to retain both TA and M4 RAMs in power save. + +### **Wi-Fi/Network Stack** + +- It is recommended to enable bit 16 of the 'Extended TCP IP Feature' bit map in the opermode command for all Wi-Fi Socket operations from the host to ensure graceful handling during asynchronous closures from the peer. +- For high throughput applications, aggregation (bit 2 of feature\_bit\_map) is recommended to be enabled in opermode.  +- To reset TA (NWP), the application needs to call sl\_wifi\_deinit() followed by sl\_wifi\_init(). Users must ensure that no execution happens from flash at this point of time. (Refer to example applications)  +- Users can enable SL\_SI91X\_EXT\_TCP\_IP\_SSL\_16K\_RECORD in 'Extended TCP IP Feature' bit map in opermode for (HTTPS server) supporting 16k record. +- **TWT** + - Recommendation is to use sl\_wifi\_target\_wake\_time\_auto\_selection() API for all TWT applications.  + - It is recommended to issue iTWT setup command once IP assignment, TCP connection, application specific socket connections are done. + - When using sl\_wifi\_enable\_target\_wake\_time API, increase TCP / ARP Timeouts at the remote side depending upon the configured TWT interval configured. It's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() as an alternative. + - In case of TWT in coex mode, when using sl\_wifi\_enable\_target\_wake\_time API, use TWT wake duration <= 16 ms and TWT wake interval >= 1 sec. If wake duration > 16 ms or TWT wake interval < 1sec, there might be performance issues. + - For iTWT GTK interval in AP should be configured to max possible value or zero. If GTK interval is not configurable on AP side, recommended TWT interval (in case of sl\_wifi\_enable\_target\_wake\_time API) or RX Latency (in case of sl\_wifi\_target\_wake\_time\_auto\_selection API) is less than 4sec. + - When sl\_wifi\_enable\_target\_wake\_time API is used, configuring TWT Wake interval beyond 1 min might lead to disconnections from the AP. Recommended to use TWT wake interval of less than or equal to 1 min. + - When using sl\_wifi\_enable\_target\_wake\_time API, it is recommended to set missed\_beacon\_count of sl\_wifi\_set\_advanced\_client\_configuration API greater than 2 times of the configured TWT Interval. +- Disable power save for high throughput applications or use FAST PSP power save mode as per application requirement. +- The application needs to ensure that it sets RTC with the correct timestamp before establishing the SSL/EAP connection. +- The minimum timeout value should not be less than 1 second for socket select and socket receive calls.  +- Embedded MQTT keep alive interval should be either 0 or a value greater than 35 seconds. +- Disable power save and suspend any active TWT sessions before triggering HTTP OTAF. +- Randomize the client port if using rapid connect/disconnect of the MQTT session on the same client port with the power save. + +### **BLE** + +- In BLE, the recommended range of Connection Interval in + - Power Save (BLE Only) - 100 ms to 1.28 s. +- In BLE, during Connection, the configuration of Scan Interval and Scan Window with the same value is not recommended. The suggested ratio of Scan Window to Scan Interval is 3:4. +- In BLE, if a device is acting as Central, the scan window (in set\_scan\_params and create\_connection commands) must be less than the existing Connection Interval. The suggested ratio of Scan Window to Connection Interval is 2:3. +- In BLE mode, if scanning and advertising are in progress on the SiWx91x module and it subsequently gets connected and moves to the central role, scanning stops else if it moves to the peripheral role, advertising stops. To further establish a connection to another peripheral device or to a central device, the application should give a command for starting advertising and scanning again. + +### **Multi-protocol** + +- For concurrent Wi-Fi + BLE, and while a Wi-Fi connection is active, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. +- Wi-Fi + BLE Advertising + - All standard advertising intervals are supported. As Wi-Fi throughput is increased, a slight difference in on-air advertisements compared to configured intervals may be observed. + - BLE advertising is skipped if the advertising interval collides with Wi-Fi activity. +- Wi-Fi + BLE scanning + - All standard scan intervals are supported. For better scan results, we recommend setting the ratio of the BLE scan window to BLE scan interval to 1:3 or 1:4. + - BLE scanning will be stopped for intervals that collide with Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Connections + - All standard connection intervals are supported. + - For a stable connection, use optimal connection intervals and max supervision timeout in the presence of Wi-Fi activity. +- Wi-Fi + BLE Central/Peripheral Data Transfer + - To achieve higher throughput for both Wi-Fi and BLE, use medium connection intervals, such as 45 to 80 ms with maximum supervision timeout. + - Ensure Wi-Fi activity consumes lower intervals. + +## **Known Issues of WiSeConnect3\_SDK\_3.1.1 Release** + +### **MCU** + +**SensorHub** + +- SensorHub does not support, SPI-based sensors and ADC multi-channel.  + +**SSI** + +- SSI Dual and Quad mode are not functional.  +- SSI primary: mode3(TI) is not working as expected.  +- SSI Primary will not be operable at 40 MHz.  + +**I2C** + +- I2C High speed and Fastplus modes are not working at specification speed + +**NVM3** + +- When installing Sleeptimer and NVM3 in Studio, is not working as expected. As a workaround these components must be added to project SLCP + +**UART** + +- Flow control is not supported in USART and IOSTREAM applications + +**ADC** + +- In ADC Multichannel, sampling rate is limited to less than 15Ksps. Number of samples is less than 500 and with a maximum of 4 channel +- In ADC Multichannel, when using different sampling rates for different channels behavior is not as expected + +**CT (Config Timer)** + +- Config Timer(CT) support as an external event, in 32-bit mode, and DMA are not working as expected + +**PWM** + +- PWM Special event trigger for synchronizing analog-to-digital conversions is not working + +**SYSRTC** + +- SYSRTC with RO clock is not functioning + +**Power Manager** + +- The wakeup sources ULP-SSI, BOD, Comparator, and SysRTC are not working in the Power Manager service + +### **SDK** + +- Observed Wi-Fi connection is successful even after deleting the stored network credentials using sl\_net\_delete\_credential and responding with SL\_NET\_INVALID\_CREDENTIAL\_TYPE for sl\_net\_get\_credential. +- Observed sl\_net\_deinit is not returning any response for both "SL\_NET\_WIFI\_AP\_INTERFACE" and "SL\_NET\_WIFI\_CLIENT\_INTERFACE" interfaces, which requires to execute deinit code path to RAM in case of common flash. +- Observed issue when NULL is passed for readfds, writefds, excepfds to socket select.  +- Enhanced sl\_wifi\_get\_firmware\_version() API to provide more details (ROM ID, chip ID, security version, etc) which is not backward compatible with firmwares older than 1711.2.10.1.0.0.4. Firmware binary notation does not include security version number. + +### **Wi-Fi/Network Stack** + +**Wi-Fi STA** + +- STA Connection with the WPA3 Hunting and Pecking algorithm takes about 3-4 seconds. +- Observed BSSID-based connection configuration is not reflecting to make a connection with specific access point. +- Observed connection failures with some AP's in more channel congestion ~50-60% occupancy open lab environment. +- Region selection based on country IE in the beacon is not supported +- Observed auth/assoc timeout is not reflecting as per timeout configuration using sl\_si91x\_configure\_timeout() API  +- Observed intermittent beacon reception from Access Point ( beacon misses) in an extremely congested environment + +**Access Point (AP) Mode** + +- Scan feature in AP mode not fully functional.  +- Fixed rate configuration in AP mode using sl\_wifi\_set\_transmit\_rate API is not being set as expected.  +- First few beacons (~ 10) don't include RSN IE + +**WPA2 Enterprise security (STA)** + +- Observed connection issue with configuring certificate key and programming 4096 bit key and SHA384/SHA512 certificates. +- Observing DUT is throwing 0x1001c when configuring .data.certificate\_key as "123456789". +- Configuration issue to program PAC file for EAP FAST Manual mode. +- Issue observed with WPA2 Enterprise Connectivity using Microsoft RADIUS Server. + +**Wi-Fi Concurrency (AP + STA in same channel)** + +- Observed 3rd party STA association fail with 917 AP while 917 STA mode is connecting/reconnecting to configured 3rd party AP. Reconnect 3rd party STA to 917 AP in such scenarios.  + +**OFDMA (UL/DL)** + +- Less throughput observed in DL-OFDMA with some APs that enabled LDPC. + +**MUMIMO (DL)** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Performance, Interop issues with MU MIMO with certain APs.  +- Less throughput observed in MU-MIMO with some APs that enabled LDPC. + +**TWT** + +- Variability with MQTT keep alive interval based on TWT wake up interval.   +- When sl\_wifi\_enable\_target\_wake\_time() API is used, occasional MQTT disconnections may be observed if TWT is configured with longer TWT intervals (>30secs) with embedded MQTT + TWT.  As an alternative, it's highly recommended to use sl\_wifi\_target\_wake\_time\_auto\_selection() API, where these dependencies are internally handled. + +**Wi-Fi STA Rejoin** + +- Observed Scanning (probe request) in all channels instead of the channels configured in selective channel(channel\_bitmap\_2g4) during rejoin process.  + +**IPv4/IPv6** + +- Observed issue with assigning static IP to DUT +- IP change notification is not indicated to the application.  +- Observed sl\_net\_up returning 0x27 error code due to an issue in the handling of IPv6 address.  + +**BSD Socket API** + +- Configuration issue to program MSS (default 1460), TCP retry count (default 10) through setsockopt +- Every server socket created consumes a socket (maximum of 10 sockets supported) and every subsequent connection to server socket consumes an additional socket (from the same pool of 10 sockets), which limits the number of server connections supported. + +**SSL Client/Server** + +- Sometimes during SSL Handshake, ECC curve parameters generated are wrong, resulting in connection failure with BBD2 error. However, this recovers in the next attempt. +- Secure SSL renegotiation is not supported in the Embedded Networking Stack +- Observed connection failures with ECDSA ciphers. + +**HTTP Client/ HTTPS Client** + +- Observed occasional HTTPS continuous download failures when power save is enabled. Recommended to disable it before performing HTTPS continuous downloads +- Observed HTTPS post data is failing with error code: BBE2 (HTTP Failed). + +**SNTP** + +- Unable to get SNTP async events when Coex mode and power save are enabled  + +**Throughputs & Performance** + +- Wi-Fi alone throughput is about SDK 3.x (42Mbps). SDK refinements are in progress to further improve Wi-Fi Standalone and Coex Throughputs.  + +**Secure Over the Air (OTA) Upgrade** + +- Observed firmware upgrade failures after multiple iterations. +- Observed OTA failures with powersave enable, So recommended to disable powersave during OTA.  +- Observed "0xffffffff" error at the remote end while doing firmware upgrade via TCP server using (featured) example with ubuntu 21.0x.  + +**Wi-Fi IOT Cloud integration (AWS IOT Core)** + +- Observed AWS MQTT keepalive transmission is not happening at expected intervals with power save enabled. + +**Wi-Fi Interoperability (IOP)** + +- Observed disconnections with Amplifi (AFI-INS-R) AP with powersave enable +- TWT session is failing due to disconnections observed in DUT if rx\_latency is set to 55 seconds and receive data is also set to 55 seconds on MI Xiaomi RA72 and Tplink AX53 AP's +- Observed less throughput(~1Mb) while running TCP RX with Max\_PSP powersave with DLink 810 AP +- Observed interop issue (random disconnections) with few APs (EERO 6+, EERO PRO 6E, Cisco Catalyst 9120AXID) +- Disconnections observed with Netgear RAX120 AP in WPA3 Security + +### **BLE** + +**GATT Profile** + +- HID profile data transfer is not working when power save is enabled in SoC.  + +**GAP**  + +- BLE reconnection is not working in ble\_multiconnection\_gatt demo when power save is enabled in SoC.  +- When power save is enabled in the SoC, the DUT hangs with the ble\_multiconnection\_gatt demo while performing continuous Tx/Rx notifications. +- When running the ble\_central application with power save enabled, it was observed that the BLE connect API is failing because of 0xFFFFFFE2(RSI\_ERROR\_RESPONSE\_TIMEOUT) error. +- When BLE local name is provided with a 16-byte length, the Set local name API fails with error code: 0x4e66[Invalid Name length]. + +**Advertising Extension** + +- When running the ble\_ae\_central example, observed an application hang issue at the AE Clear Periodic Adv list API.  + +**DTM/PER** + +- Recommend to limit BLE Tx Maximum power to 16 dBm.  Please don't use for 127 power\_index for BLE HP release with this release. + +**IOP** + +- BLE connection failure has been observed on a few mobile devices (Samsung S23& Oneplus 9pro) when the Si917 device is configured as central. + +### **Multi-protocol** + +- For Coex Scenario Wi-Fi + BLE, BLE Data transfer, MU retries (~50-60%) observed while running DL MU-MIMO test.  +- Observed Wi-Fi + BLE intermittent connection failures, disconnections, and data transfer stalls in the long run when power save is enabled. +- Observed "DUT is not disconnecting to the AP when initiating disconnection from EFR connect app screen using wifi\_station\_ble\_provisioning\_aws example + +### **System** + +- Observed random hang issues with encrypted firmwares on some earlier variant of boards  (Si917-6031A, Si917-4338A) with powersave enable. + +### **Simplicity Studio and Commander**  + +- Simplicity commander does not support options under "Debug Lock tools". +- All projects in the package are compatible with **GNU ARM V12.2.1** toolchain + +## **Planned Roadmap Features** + +### **SDK** + +- WPS 2.0 PIN/PUSH, Network Manager Enhancements +- MDNS, HTTP Server, Azure MQTT Client, Websockets +- Matter integration with Embedded TCP/IP stack  +- Enhanced buffer management, Throughput optimization +- TLS over LWIP, Network layer applications (MQTT, HTTP, etc.) over LWIP. +- Debugging utilities, UC Configurator for Wireless configurations + +### **System** + +- Secure communication over CPC (UART & SDIO interfaces) + +### **MCU** + +- Pin Tool for MCU  +- Dual Flash: Separate flash for Cortex M4 and Wireless Processor +- Peripherals: Analog Comparator, DAC, Temp Sensor, Capacitive Touch Sensor, OPAMP, HSPI, GPDMA, QEI, RNG, IR decoder, CRC and BOD +- Software-configurable MCU application memory options (192 or 256 or 320 kB) +- RTOS support for MCU Peripheral examples +- SensorHub: Support for SDC\_ADC and CLOUD connectivity +- SIO support for features Pattern matching, DMA flow control, self-loop mechanism and as a clock qualifier +- Support for I2S PCM functionality +- Stacked and external PSRAM: Pseudo Static RAM for storing application data and executing SoC applications.  + +### **Wi-Fi/Network Stack** + +- Spatial Re-Use, BSS Max Idle +- Provisioning using Wi-Fi AP + +### **BLE** + +- Support for 8 Peripheral + 2 Central connections  +- Support for BLE Mesh (4 nodes only) for limited Mesh use case + +## **Limitations and Unsupported Features**   + +### **System** + +- None + +### **SDK** + +- Baremetal mode is not supported. + +### **Wi-Fi/Network Stack** + +- TLS 1.3 Server is not supported. +- 40 MHz bandwidth for 2.4 GHz band is not supported. +- Max 3 SSL sockets in Wi-Fi only mode, 2 SSL Socket in Wi-Fi + BLE based on RAM memory configuration selected.  +- In SSL ECC Curve ID supported is 23. SSL handshake with 3rd party clients depends on the SSL ECC Curve ID. +- The number of Non-Transmitting BSSIDs processed is limited by the beacon length that can be processed by the stack (which is 1024 bytes). Beacons greater than 1024 Bytes in length will not be processed. +- Multiprotocol (STA +BLE) + EAP Security modes supported only with Memory configurations EXT\_FEAT\_416K\_M4SS\_256K and EXT\_FEAT\_480K\_M4SS\_192K. +- UL MUMIMO is not supported. +- WPA3 AP supports only H2E algorithm. +- PMKSA caching is not supported in WPA3 AP mode. +- Maximum embedded MQTT Publish payload is 1 kbyte. +- Timeout value for socket select and socket receive calls of less than 1 second is not currently supported. + +### **BLE** + +- For BLE, if the connection is established with a small connection interval (less than 15 ms), simultaneous roles (i.e., Central + Scanning and Peripheral + Advertising) are not supported. +- BLE maximum two concurrent connections are supported, which can be either a connection to two peripheral devices, to one central and one peripheral device or two central devices. +- BLE Slave latency value is valid up to 32 only. +- Maximum supported AE data length is 200 bytes. +- Supports only two ADV\_EXT sets. +- Supports only two BLE connections (1 Central and 1 Peripheral) with AE. +- Advertising Extension feature is not supported in Coexistence. +- The  ae\_central & ae\_peripheral applications are not supported with TA\_352K\_M4\_320K RAM configuration. +- Two BLE connections are not supported with M4 powersave. It only supports a single connection.  +- Isochronous channels feature is not supported.  +- Connection subrating feature is not supported.  +- LE power controller feature is not supported. +- EATT feature is not supported. +- Periodic Advertising with a response feature is not supported.  +- BLE Audio is not supported. +- The feature of dynamically changing the TX power when extended advertising is active is not supported. + +### **MCU** + +- SensorHub supports PS1-power state with ADC sensor. In this mode, other sensors operation is not supported.  + +### **Multi-protocol** + +- Wi-Fi AP + BLE currently not supported.  + +
+ # **WiSeConnect3\_SDK\_3.1.1-Doc SoC Release Notes** ## **Release Details** diff --git a/examples/featured/aws_device_shadow/aws_device_shadow_ncp.slcp b/examples/featured/aws_device_shadow/aws_device_shadow_ncp.slcp index 04aa81cf..3228d31c 100644 --- a/examples/featured/aws_device_shadow/aws_device_shadow_ncp.slcp +++ b/examples/featured/aws_device_shadow/aws_device_shadow_ncp.slcp @@ -14,7 +14,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,6 +48,8 @@ component: toolchain_settings: - option: gcc_linker_option value: "-u _printf_float" + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' @@ -77,4 +79,4 @@ other_file: ui_hints: highlight: - path: readme.md - focus: true + focus: true \ No newline at end of file diff --git a/examples/featured/aws_device_shadow/aws_device_shadow_soc.slcp b/examples/featured/aws_device_shadow/aws_device_shadow_soc.slcp index 8adb9fe3..2b5de007 100644 --- a/examples/featured/aws_device_shadow/aws_device_shadow_soc.slcp +++ b/examples/featured/aws_device_shadow/aws_device_shadow_soc.slcp @@ -14,7 +14,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -45,7 +45,9 @@ component: from: wiseconnect3_sdk - id: aws_sdk from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/ble_per/app.c b/examples/featured/ble_per/app.c index 1841e9a3..c8c3f5c3 100644 --- a/examples/featured/ble_per/app.c +++ b/examples/featured/ble_per/app.c @@ -117,6 +117,143 @@ #define DUTY_CYCLING_ENABLE 1 #define ENABLE_POWER_SAVE 0 //! Set to 1 for powersave mode +#define GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE 0 //! To update gain table and max tx power and offsets + +#if GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE + +#define FCC 0 +#define ETSI 1 +#define TELEC 2 +#define WORLDWIDE 3 +#define KCC 4 + +#define BLE_GAIN_TABLE_MAXPOWER_UPDATE 0 +#define BLE_GAIN_TABLE_OFFSET_UPDATE 1 +#define BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE 2 +#define BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE 3 + +// clang-format off +//! structure for the MAXPOWER +uint8_t Si917_BLE_REGION_BASED_MAXPOWER_XX[16] = {//{{{ + // BLE Max Power Index, + FCC, 16, + ETSI, 8, + TELEC, 10, + WORLDWIDE, 16, + KCC, 10, +};//}}} + +//! structure for the MAXPOWER OFFSET +uint8_t Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX[128] = {//{{{ + 5,//NUM_OF_REGIONS + FCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 125kbps 500kbps + 255, 0, 0, 6, 0, + 0, 0, 0, 6, 0, + 38, 0, 2, 6, 0, + 39, 0, 16, 6, 0, + ETSI, + 4,//NUM_OF_CHANNELS + 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0, + TELEC, + 4,//NUM_OF_CHANNELS + 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0, + WORLDWIDE, + 4,//NUM_OF_CHANNELS + 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0, + KCC, + 4,//NUM_OF_CHANNELS + 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0 +};//}}} + +//! structure for the LP_CHAIN 0dBm OFFSET +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX[128] = {//{{{ + 5,//NUM_OF_REGIONS + FCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 125kbps 500kbps + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 8, 31, 31, + ETSI, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, + TELEC, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, + WORLDWIDE, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, + KCC, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, +};//}}} + +//! structure for the LP_CHAIN 10dBm OFFSET +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX[128] = {//{{{ + 5,//NUM_OF_REGIONS + FCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 125kbps 500kbps + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 35, 63, 63, + ETSI, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, + TELEC, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, + WORLDWIDE, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, + KCC, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, +};//}}} + +// clang-format on +#endif + //! Application global parameters. static rsi_bt_resp_get_local_name_t rsi_app_resp_get_local_name = { 0 }; static uint8_t rsi_app_resp_get_dev_addr[RSI_DEV_ADDR_LEN] = { 0 }; @@ -130,7 +267,7 @@ static const sl_wifi_device_configuration_t config = { .band = SL_SI91X_WIFI_BAND_2_4GHZ, .region_code = US, .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, - .coex_mode = SL_SI91X_BLE_MODE, + .coex_mode = SL_SI91X_WLAN_BLE_MODE, #ifdef SLI_SI91X_MCU_INTERFACE .feature_bit_map = (SL_SI91X_FEAT_WPS_DISABLE | RSI_FEATURE_BIT_MAP), #else @@ -148,11 +285,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (RSI_BT_FEATURE_BITMAP -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (RSI_BT_FEATURE_BITMAP), #ifdef RSI_PROCESS_MAX_RX_DATA .ext_tcp_ip_feature_bit_map = (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_MAX_RECV_LENGTH), @@ -231,6 +364,22 @@ void ble_per(void *unused) } LOG_PRINT("\r\nWireless Initialization Success\n"); + //! set region support + status = sl_si91x_set_device_region(config.boot_config.oper_mode, config.band, config.region_code); + if (status != SL_STATUS_OK) { + LOG_PRINT("\r\nSet Region Failed, Error Code : %ld\r\n", status); + } else { + LOG_PRINT("\r\nSet Region Success\r\n"); + } + + //! WLAN radio deinit + status = sl_si91x_disable_radio(); + if (status != SL_STATUS_OK) { + LOG_PRINT("\r\n Failed to disable WLAN radio, Error Code : %ld\r\n", status); + } else { + LOG_PRINT("\r\n Disable WLAN radio success\r\n"); + } + //! Firmware version Prints status = sl_wifi_get_firmware_version(&version); if (status != SL_STATUS_OK) { @@ -265,6 +414,54 @@ void ble_per(void *unused) } LOG_PRINT("Local name set to: %s\n", rsi_app_resp_get_local_name.name); +#if GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE + + //! structure update for the MAXPOWER + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(0, + sizeof(Si917_BLE_REGION_BASED_MAXPOWER_XX), + Si917_BLE_REGION_BASED_MAXPOWER_XX, + BLE_GAIN_TABLE_MAXPOWER_UPDATE); + if (status != RSI_SUCCESS) { + LOG_PRINT("\r\n Failed to update gain table for max power with status = %lx\r\n", status); + } else { + LOG_PRINT("\r\n Updation of gain table max tx power command is successful \r\n"); + } + + //! structure update for the MAXPOWER OFFSET + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(0, + sizeof(Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX), + Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX, + BLE_GAIN_TABLE_OFFSET_UPDATE); + if (status != RSI_SUCCESS) { + LOG_PRINT("\r\n Failed to update gain table offset with status = %lx\r\n", status); + } else { + LOG_PRINT("\r\n Updation of gain table offset command is successful \r\n"); + } + + //! structure update for the LP_CHAIN 0dBm OFFSET + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(0, + sizeof(Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX), + Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX, + BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE); + if (status != RSI_SUCCESS) { + LOG_PRINT("\r\n Failed to update gain table LP-Chain 0dBm offset with status = %lx\r\n", status); + } else { + LOG_PRINT("\r\n Updation of gain table LP-Chain 0dBm offset command is successful \r\n"); + } + + //! structure update for the LP_CHAIN 10dBm OFFSET + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(0, + sizeof(Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX), + Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX, + BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE); + if (status != RSI_SUCCESS) { + LOG_PRINT("\r\n Failed to update gain table LP-Chain 10dBm offset with status = %lx\r\n", status); + } else { + LOG_PRINT("\r\n Updation of gain table LP-Chain 10dBm offset command is successful \r\n"); + } + +#endif + if (RSI_CONFIG_PER_MODE == RSI_BLE_PER_TRANSMIT_MODE) { rsi_ble_per_tx.cmd_ix = BLE_TRANSMIT_CMD_ID; rsi_ble_per_tx.transmit_enable = ENABLE; diff --git a/examples/featured/ble_per/ble_per_ncp.slcp b/examples/featured/ble_per/ble_per_ncp.slcp index 74be3d92..716076f8 100644 --- a/examples/featured/ble_per/ble_per_ncp.slcp +++ b/examples/featured/ble_per/ble_per_ncp.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -51,6 +51,8 @@ component: toolchain_settings: - option: gcc_linker_option value: "-u _printf_float" + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/ble_per/ble_per_psram.slcp b/examples/featured/ble_per/ble_per_psram.slcp index f0b6ca03..3d27753d 100644 --- a/examples/featured/ble_per/ble_per_psram.slcp +++ b/examples/featured/ble_per/ble_per_psram.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -73,7 +73,9 @@ component: from: wiseconnect3_sdk - id: udma_linker_config from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/ble_per/ble_per_soc.slcp b/examples/featured/ble_per/ble_per_soc.slcp index 8f0bec82..1f0e0e10 100644 --- a/examples/featured/ble_per/ble_per_soc.slcp +++ b/examples/featured/ble_per/ble_per_soc.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -64,7 +64,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/ble_per/readme.md b/examples/featured/ble_per/readme.md index 5b2437f5..6bfad96b 100644 --- a/examples/featured/ble_per/readme.md +++ b/examples/featured/ble_per/readme.md @@ -177,6 +177,161 @@ The application can be configured to suit your requirements and development envi #define LOOP_BACK_MODE_DISABLE 0 ``` + Set below macro to update Max TX power and offset +```c +#define GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE 1 //! To update gain table and max tx power and offsets +``` + + The API used to update the gain table is: +```c +int32_t rsi_bt_cmd_update_gain_table_offset_or_max_pwr(uint8_t node_id, + uint8_t payload_len, + uint8_t *payload, + uint8_t req_type) +``` +--- +**Note!** +* This command must be used immediately after opermode request +* Internally, the firmware maintains two tables + * Gain table holding Max Tx power values for all regions + * Gain table with Max power vs offset values for each channel of all regions +* There are 5 regions supported and are FCC, ETSI, TELEC, KCC, WORLDWIDE. These FCC/ETSI/TELEC/KCC gain table max power level and offset values should be loaded in end-to-end mode via BLE User Gain table. This has to be called upon every boot-up since this information is not saved inside flash. SoC uses these tables in FCC/ETSI/TELEC/KCC to limit power and not to violate allowed limits. +* For Worldwide region firmware uses Worldwide values for Tx. For other regions(FCC/ETSI/TELEC/KCC), Firmware uses min value out of Worldwide & Region based values for Tx. Also there will be part to part variation across chips and offsets are estimated during manufacturing flow which will be applied as correction factor during normal mode of operation. +* This frame has to be used by customers who has done FCC/ETSI/TELEC/KCC certification with their own antenna. All other customers should not use this. Inappropriate use of this frame may result in violation of FCC/ETSI/TELEC/KCC or any certifications and Silicon labs is not liable for that. + +--- + +* BLE power offset like , <1M_OFFSET>, <2M_OFFSET>, <500kbps_oFFSET>, <125kbps_oFFSET> + +--- + +**req_type** can be set to one of the following macros : +```c +#define BLE_GAIN_TABLE_MAXPOWER_UPDATE 0 +#define BLE_GAIN_TABLE_OFFSET_UPDATE 1 +#define BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE 2 +#define BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE 3 +``` +**node_id** refers to BLE Node id : +```c +#define BLE_NODE 0 // For selecting BLE node +``` + +The following arrays will be used to update_gain_table based on `node_id` and `req_type`. + +| `node_id` | `req_type` | Payload Array | +| ---------- | ----------------------------- | ------------------------------------------------ | +| `BLE_NODE` | `UPDATE_GAIN_TABLE_MAX_POWER` | `Si917_BLE_REGION_BASED_MAXPOWER_XX` | +| `BLE_NODE` | `UPDATE_GAIN_TABLE_OFFSET` | `Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX` | +| `BLE_NODE` | `BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE` | `Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX` | +| `BLE_NODE` | `BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE` | `Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX` | + +**Gain Table Max Power Array Format** + +```c +uint8_t _Si917_BLE_REGION_BASED_MAXPOWER_XX[] = {}; //! Fill the user gain table max power values in the below mentioned way. + +[] = { + , , + , , + . + . + , + }; +``` + +**Gain Table Offset Array Format** +```c +uint8_t _Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET[] = {}; // Fill the user gain table offset values as shown. + +
[] = { + , + , , + , , , , + , , , , + . + . + , , + , , + , , , , + , , , , + . + . + , , , , + . + . + , , + , , , , + , , , , + . + . + , , , , + }; + +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX[] = {}; // Fill the user gain table offset values as shown. + +
[] = { + , + , , + , , , , + , , , , + . + . + , , + , , + , , , , + , , , , + . + . + , , , , + . + . + , , + , , , , + , , , , + . + . + , , , , + }; + +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX[] = {}; // Fill the user gain table offset values as shown. + +
[] = { + , + , , + , , , , + , , , , + . + . + , , + , , + , , , , + , , , , + . + . + , , , , + . + . + , , + , , , , + , , , , + . + . + , , , , + }; + +``` + +**Region Name and Values** + +| Region Name | Value | +|--------------|---------| +| `FCC` | `0` | +| `ETSI` | `1` | +| `TELEC` | `2` | +| `WORLDWIDE` | `3` | +| `KCC` | `4` | + - Open `ble_config.h` file and update/modify following macros, ```c diff --git a/examples/featured/firmware_update/firmware_update_ncp.slcp b/examples/featured/firmware_update/firmware_update_ncp.slcp index b44d927c..16faad63 100644 --- a/examples/featured/firmware_update/firmware_update_ncp.slcp +++ b/examples/featured/firmware_update/firmware_update_ncp.slcp @@ -15,7 +15,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/firmware_update/firmware_update_soc.slcp b/examples/featured/firmware_update/firmware_update_soc.slcp index 37648c1f..3a349d61 100644 --- a/examples/featured/firmware_update/firmware_update_soc.slcp +++ b/examples/featured/firmware_update/firmware_update_soc.slcp @@ -15,7 +15,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,7 +52,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/powersave_standby_associated/powersave_standby_associated_ncp.slcp b/examples/featured/powersave_standby_associated/powersave_standby_associated_ncp.slcp index ec597290..d28cccf8 100644 --- a/examples/featured/powersave_standby_associated/powersave_standby_associated_ncp.slcp +++ b/examples/featured/powersave_standby_associated/powersave_standby_associated_ncp.slcp @@ -15,7 +15,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/featured/powersave_standby_associated/powersave_standby_associated_psram.slcp b/examples/featured/powersave_standby_associated/powersave_standby_associated_psram.slcp index e7c27f04..fd89f8c0 100644 --- a/examples/featured/powersave_standby_associated/powersave_standby_associated_psram.slcp +++ b/examples/featured/powersave_standby_associated/powersave_standby_associated_psram.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -67,7 +67,9 @@ component: template_contribution: - name: psram_powersave_handle value: true -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/featured/powersave_standby_associated/powersave_standby_associated_soc.slcp b/examples/featured/powersave_standby_associated/powersave_standby_associated_soc.slcp index d8a208e8..de81541f 100644 --- a/examples/featured/powersave_standby_associated/powersave_standby_associated_soc.slcp +++ b/examples/featured/powersave_standby_associated/powersave_standby_associated_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -55,7 +55,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/featured/wlan_throughput/wlan_throughput_ncp.slcp b/examples/featured/wlan_throughput/wlan_throughput_ncp.slcp index 1f757714..94c95ef9 100644 --- a/examples/featured/wlan_throughput/wlan_throughput_ncp.slcp +++ b/examples/featured/wlan_throughput/wlan_throughput_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -54,6 +54,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/featured/wlan_throughput/wlan_throughput_psram.slcp b/examples/featured/wlan_throughput/wlan_throughput_psram.slcp index 2f573d13..32d155dd 100644 --- a/examples/featured/wlan_throughput/wlan_throughput_psram.slcp +++ b/examples/featured/wlan_throughput/wlan_throughput_psram.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -62,6 +62,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/featured/wlan_throughput/wlan_throughput_soc.slcp b/examples/featured/wlan_throughput/wlan_throughput_soc.slcp index 248f3c1f..08b1bb1a 100644 --- a/examples/featured/wlan_throughput/wlan_throughput_soc.slcp +++ b/examples/featured/wlan_throughput/wlan_throughput_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -58,6 +58,8 @@ requires: toolchain_settings: - option: gcc_linker_option value: -u _printf_float + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/si91x_soc/crypto/si91x_psa_aes/si91x_psa_aes.slcp b/examples/si91x_soc/crypto/si91x_psa_aes/si91x_psa_aes.slcp index 5680236e..2d4e39d8 100644 --- a/examples/si91x_soc/crypto/si91x_psa_aes/si91x_psa_aes.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_aes/si91x_psa_aes.slcp @@ -61,7 +61,7 @@ ui_hints: focus: true sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] post_build: path: ../../../../utilities/postbuild_profile/wiseconnect_soc.slpb diff --git a/examples/si91x_soc/crypto/si91x_psa_asymmetric_key_storage/si91x_psa_asymmetric_key_storage.slcp b/examples/si91x_soc/crypto/si91x_psa_asymmetric_key_storage/si91x_psa_asymmetric_key_storage.slcp index b561c88f..0a0f65aa 100644 --- a/examples/si91x_soc/crypto/si91x_psa_asymmetric_key_storage/si91x_psa_asymmetric_key_storage.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_asymmetric_key_storage/si91x_psa_asymmetric_key_storage.slcp @@ -29,7 +29,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 component: - id: sl_system - id: freertos diff --git a/examples/si91x_soc/crypto/si91x_psa_ccm/si91x_psa_ccm.slcp b/examples/si91x_soc/crypto/si91x_psa_ccm/si91x_psa_ccm.slcp index ae8b0f62..101f9b67 100644 --- a/examples/si91x_soc/crypto/si91x_psa_ccm/si91x_psa_ccm.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_ccm/si91x_psa_ccm.slcp @@ -28,7 +28,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 component: - id: sl_system - id: freertos diff --git a/examples/si91x_soc/crypto/si91x_psa_chachapoly/si91x_psa_chachapoly.slcp b/examples/si91x_soc/crypto/si91x_psa_chachapoly/si91x_psa_chachapoly.slcp index 51d4336c..13d8e320 100644 --- a/examples/si91x_soc/crypto/si91x_psa_chachapoly/si91x_psa_chachapoly.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_chachapoly/si91x_psa_chachapoly.slcp @@ -28,7 +28,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 component: - id: sl_system - id: freertos diff --git a/examples/si91x_soc/crypto/si91x_psa_ecdh/si91x_psa_ecdh.slcp b/examples/si91x_soc/crypto/si91x_psa_ecdh/si91x_psa_ecdh.slcp index 67b2c211..9d41c624 100644 --- a/examples/si91x_soc/crypto/si91x_psa_ecdh/si91x_psa_ecdh.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_ecdh/si91x_psa_ecdh.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: psa_ecdh.c diff --git a/examples/si91x_soc/crypto/si91x_psa_gcm/si91x_psa_gcm.slcp b/examples/si91x_soc/crypto/si91x_psa_gcm/si91x_psa_gcm.slcp index 41f2a7df..4e242c55 100644 --- a/examples/si91x_soc/crypto/si91x_psa_gcm/si91x_psa_gcm.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_gcm/si91x_psa_gcm.slcp @@ -28,7 +28,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 component: - id: sl_system - id: freertos diff --git a/examples/si91x_soc/crypto/si91x_psa_hmac/si91x_psa_hmac.slcp b/examples/si91x_soc/crypto/si91x_psa_hmac/si91x_psa_hmac.slcp index 6ff1b929..d2f0fa92 100644 --- a/examples/si91x_soc/crypto/si91x_psa_hmac/si91x_psa_hmac.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_hmac/si91x_psa_hmac.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: psa_hmac_app.c diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/app.c b/examples/si91x_soc/crypto/si91x_psa_multithread/app.c new file mode 100644 index 00000000..80644a03 --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/app.c @@ -0,0 +1,215 @@ +/***************************************************************************/ /** + * @file + * @brief Example Application + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#include "app.h" +#include "psa_multithread_app.h" +#include "sl_si91x_crypto_thread.h" + +#include +#include "cmsis_os2.h" +#include "sl_net.h" +#include "sl_wifi.h" +#include "sl_status.h" + +#define SAME_CRYPTO_ACCELERATORS +// #define DIFFERENT_CRYPTO_ACCELERATORS + +/****************************************************** + * Variable Definitions + ******************************************************/ + +osStatus_t os_status; +static osThreadId_t threadId0; +static osThreadId_t threadId1; +static osThreadId_t threadId2; + +const osThreadAttr_t thread_attributes = { + .name = "app", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityLow, + .tz_module = 0, + .reserved = 0, +}; + +const osThreadAttr_t thread_attributes_1 = { + .name = "sha_app", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityLow4, + .tz_module = 0, + .reserved = 0, +}; + +const osThreadAttr_t thread_attributes_2 = { + .name = "aes_app", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityLow4, + .tz_module = 0, + .reserved = 0, +}; + +const osThreadAttr_t thread_attributes_3 = { + .name = "sha_app_2", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityLow4, + .tz_module = 0, + .reserved = 0, +}; + +static const sl_wifi_device_configuration_t client_configuration = { + .boot_option = LOAD_NWP_FW, + .mac_address = NULL, + .band = SL_SI91X_WIFI_BAND_2_4GHZ, + .region_code = US, + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_ONLY_MODE, + .feature_bit_map = (SL_SI91X_FEAT_SECURITY_PSK | SL_SI91X_FEAT_AGGREGATION +#ifdef SLI_SI91X_MCU_INTERFACE + | SL_SI91X_FEAT_WPS_DISABLE +#endif + ), + .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT), + .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID), + .ext_custom_feature_bit_map = ( +#ifdef SLI_SI91X_MCU_INTERFACE + SL_SI91X_RAM_LEVEL_NWP_ADV_MCU_BASIC +#else + SL_SI91X_RAM_LEVEL_NWP_ALL_MCU_ZERO +#endif +#ifdef SLI_SI917 + | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 +#endif + ), + .bt_feature_bit_map = 0, + .ext_tcp_ip_feature_bit_map = 0, + .ble_feature_bit_map = 0, + .ble_ext_feature_bit_map = 0, + .config_feature_bit_map = 0 } +}; + +/****************************************************** + * Function Declarations + ******************************************************/ +static void application_start(void *argument); + +/****************************************************** + * Function Definitions + ******************************************************/ +void app_init(void) +{ + osThreadNew((osThreadFunc_t)application_start, NULL, &thread_attributes); +} + +static void application_start(void *argument) +{ + threadId0 = osThreadGetId(); + UNUSED_PARAMETER(argument); + + sl_status_t status = sl_net_init(SL_NET_WIFI_CLIENT_INTERFACE, &client_configuration, NULL, NULL); + if (status != SL_STATUS_OK) { + printf("Failed to start Wi-Fi client interface: 0x%lx\r\n", status); + return; + } + printf("\r\nWi-Fi Init Success\r\n"); + + psa_status_t ret; + ret = psa_crypto_init(); + if (ret != PSA_SUCCESS) { + printf("PSA Crypto Init failed with status : %ld\r\n", ret); + } else { + printf("PSA Crypto Init Success\r\n"); + } + + if (osThreadNew((osThreadFunc_t)sha_app_process, NULL, &thread_attributes_1) == NULL) { + printf("\r\n SHA App1 fail \r\n"); + return; + } + printf("\r\n SHA_APP1_Task created \r\n"); + +#if defined(DIFFERENT_CRYPTO_ACCELERATORS) + if (osThreadNew((osThreadFunc_t)aes_app_process, NULL, &thread_attributes_2) == NULL) { + printf("\r\n AES App2 fail \r\n"); + return; + } + printf("\r\n AES_APP2_Task created \r\n"); +#endif + +#if defined(SAME_CRYPTO_ACCELERATORS) + if (osThreadNew((osThreadFunc_t)sha_app_process_2, NULL, &thread_attributes_3) == NULL) { + printf("\r\n SHA App2 fail \r\n"); + return; + } + printf("\r\n SHA_APP2_Task created \r\n"); +#endif + + os_status = osThreadSuspend(threadId0); +} + +/***************************************************************************/ /** + * Application state machine, called infinitely. + ******************************************************************************/ +void sha_app_process(void) +{ + threadId1 = osThreadGetId(); + sha_app_process_action(); + printf("\r\n SHA operation done\r\n"); + os_status = osThreadSuspend(threadId1); +} + +void aes_app_process(void) +{ + threadId2 = osThreadGetId(); + aes_app_process_action(PSA_ALG_ECB_NO_PADDING); + printf("\r\n AES operation done\r\n"); + os_status = osThreadSuspend(threadId2); +} + +void sha_app_process_2(void) +{ + threadId2 = osThreadGetId(); + sha_app_process_action(); + printf("\r\n SHA operation done\r\n"); + os_status = osThreadSuspend(threadId2); +} diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/app.h b/examples/si91x_soc/crypto/si91x_psa_multithread/app.h new file mode 100644 index 00000000..57eeddc7 --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/app.h @@ -0,0 +1,35 @@ +/***************************************************************************/ /** + * @file app.h + * @brief Top level application functions + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef APP_H +#define APP_H + +#include "psa/crypto.h" +#include + +/***************************************************************************/ /** + * Initialize application. + ******************************************************************************/ +void app_init(void); + +/***************************************************************************/ /** + * App ticking function. + ******************************************************************************/ +void sha_app_process(void); +void aes_app_process(void); +void sha_app_process_2(void); +#endif // APP_H diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/main.c b/examples/si91x_soc/crypto/si91x_psa_multithread/main.c new file mode 100644 index 00000000..2e967838 --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/main.c @@ -0,0 +1,58 @@ +/***************************************************************************** + * @file main.c + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "sl_component_catalog.h" +#include "sl_system_init.h" +#include "app.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif +#if defined(SL_CATALOG_KERNEL_PRESENT) +#include "sl_system_kernel.h" +#else // SL_CATALOG_KERNEL_PRESENT +#include "sl_system_process_action.h" +#endif // SL_CATALOG_KERNEL_PRESENT + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that if the kernel is present, processing task(s) will be created by + // this call. + sl_system_init(); + + // Initialize the application. For example, create periodic timer(s) or + // task(s) if the kernel is present. + app_init(); + +#if defined(SL_CATALOG_KERNEL_PRESENT) + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +#else // SL_CATALOG_KERNEL_PRESENT + while (1) { + // Do not remove this call: Silicon Labs components process action routine + // must be called from the super loop. + sl_system_process_action(); + + // Application process. + app_process_action(); + +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + // Let the CPU go to sleep if the system allows it. + sl_power_manager_sleep(); +#endif + } +#endif // SL_CATALOG_KERNEL_PRESENT +} diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/psa_multithread_app.c b/examples/si91x_soc/crypto/si91x_psa_multithread/psa_multithread_app.c new file mode 100644 index 00000000..b1652715 --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/psa_multithread_app.c @@ -0,0 +1,142 @@ +/******************************************************************************* + * @file psa_multithread_app.c + * @brief + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "psa_multithread_app.h" +#include "sl_si91x_crypto_thread.h" +#include "psa/crypto.h" +#include "app.h" +#include + +static psa_key_id_t key_id; +static psa_status_t status; + +/* Test vector (AES) for AES-128 key */ +uint8_t aes_key_16[KEY_SIZE_16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; + +static const unsigned char res_test_data[AES_TEST_CT_MAX_LEN] = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, + 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a }; + +static const unsigned char msg_test_data[AES_TEST_PT_MAX_LEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; + +void test_psa_sha_256() +{ + psa_status_t ret; + + //! Test message for streaming + const char test_msg[] = { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }; + + //! Expected SHA256 hash value of test message + uint8_t expect_sha256_hash[] = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, + 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, + 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 }; + + //! Hash Buffer + uint8_t hash_buf[SL_SI91x_SHA_256_DIGEST_LEN] = { 0 }; + + //! Hash length + size_t hash_len; + + ret = psa_hash_compute(PSA_ALG_SHA_256, + (const unsigned char *)test_msg, + strlen(test_msg), + hash_buf, + sizeof(hash_buf), + &hash_len); + + // Compare with the expected result + if (ret != 0) { + printf("\n SHA 256 Operation Failed Status 0x%lx \n", ret); + } else if (ret == 0 && memcmp(hash_buf, expect_sha256_hash, sizeof(expect_sha256_hash)) == 0) { + printf("\n SHA 256 Operation Success Status 0x%lx \n", ret); + } else { + printf("\n SHA 256 Compare with expected value failed \n"); + } +} + +void sha_app_process_action() +{ + test_psa_sha_256(); +} + +void test_psa_aes(psa_algorithm_t alg) +{ + + size_t out_len; + + uint8_t encryption_output[PAYLOAD_SIZE]; + uint8_t decryption_output[PAYLOAD_SIZE]; + + /* Encryption */ + status = psa_cipher_encrypt(key_id, + alg, + msg_test_data, + sizeof(msg_test_data), + encryption_output, + sizeof(encryption_output), + &out_len); + + if ((status == 0) && (memcmp(encryption_output, res_test_data, sizeof(msg_test_data)) == 0)) { + printf("\n Encryption Success \r\n"); + } else { + printf("\n Encryption Failed with error: %ld\r\n", status); + } + + /* Decryption */ + status = psa_cipher_decrypt(key_id, + alg, + encryption_output, + sizeof(encryption_output), + decryption_output, + sizeof(decryption_output), + &out_len); + if ((status == 0) && (memcmp(decryption_output, msg_test_data, sizeof(decryption_output)) == 0)) { + printf("\n Decryption Success \n"); + } else { + printf("\n Decryption Failed with error: %ld\r\n", status); + } + + /* Destroy a volatile plain key for AES */ + status = psa_destroy_key(key_id); + if (status != PSA_SUCCESS) { + printf("Destroy key failed with error: %ld\r\n", status); + } +} + +void aes_app_process_action(psa_algorithm_t alg) +{ + psa_key_attributes_t key_attr; + + // Set up attributes for a AES key + key_attr = psa_key_attributes_init(); + psa_set_key_type(&key_attr, PSA_KEY_TYPE_AES); + psa_set_key_usage_flags(&key_attr, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT); + psa_set_key_algorithm(&key_attr, PSA_ALG_ECB_NO_PADDING); + + /* Import a volatile plain key for AES */ + status = psa_import_key(&key_attr, aes_key_16, sizeof(aes_key_16), &key_id); + + /* Check for import key status */ + if (status == PSA_SUCCESS) { + printf("\n Key import Success \r\n"); + + } else { + printf("\n Key import Failed with error: %ld\r\n", status); + } + + test_psa_aes(alg); +} diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/psa_multithread_app.h b/examples/si91x_soc/crypto/si91x_psa_multithread/psa_multithread_app.h new file mode 100644 index 00000000..9891f083 --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/psa_multithread_app.h @@ -0,0 +1,45 @@ +/******************************************************************************* + * @file psa_multithread_app.h + * @brief + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef PSA_MULTITHREAD_APP_H +#define PSA_MULTITHREAD_APP_H + +#include "psa/crypto.h" +#include "sl_si91x_sha.h" +#include "sl_si91x_aes.h" +#include "sl_si91x_psa_sha.h" +#include "sl_si91x_psa_aes.h" + +/***************************************************************************/ /** + * Macros and Typedefs + ******************************************************************************/ +/// Cipher message buffer size (IV + Ciphertext) +#define KEY_SIZE_16 16 +#define PAYLOAD_SIZE 16 +#define CIPHER_TEXT_SIZE 32 +#define AES_TEST_CT_MAX_LEN 16 +#define AES_TEST_PT_MAX_LEN 16 + +/***************************************************************************/ /** + * Function declarations + ******************************************************************************/ +void aes_app_process_action(psa_algorithm_t alg); +void sha_app_process_action(); +void test_psa_sha_256(); +void test_psa_aes(psa_algorithm_t alg); + +#endif /* PSA_MULTITHREAD_APP_H */ diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/readme.md b/examples/si91x_soc/crypto/si91x_psa_multithread/readme.md new file mode 100644 index 00000000..aef4b5bf --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/readme.md @@ -0,0 +1,51 @@ +# PSA MULTITHREAD for SI91X + +## Introduction +- This application contains an example code to demonstrate the use of thread-safe mechanism while using crypto hardware accelerators. + +## Setting Up + - To use this application following Hardware, Software and the Project Setup is required + +### Hardware Requirements + - Windows PC + - Silicon Labs [Si917 Evaluation Kit WSTK + BRD4325A] + +![Figure: Introduction](resources/readme/image508a.png) + +### Software Requirements + - GSDK version 4.4.0 + - Si91x SDK + - Embedded Development Environment + - For Silicon Labs Si91x, use the latest version of Simplicity Studio (refer **"Download and Install Simplicity Studio"** section in **getting-started-with-siwx917-soc** guide at **release_package/docs/index.html**) + +## Project Setup +- **Silicon Labs Si91x** refer **"Download SDKs"**, **"Add SDK to Simplicity Studio"**, **"Connect SiWx917"**, **"Open Example Project in Simplicity Studio"** section in **getting-started-with-siwx917-soc** guide at **release_package/docs/index.html** to work with Si91x and Simplicity Studio + +## Build +- Compile the application in Simplicity Studio using build icon + +![Figure: Build run and Debug](resources/readme/image508c.png) + +## Device Programming +- To program the device ,refer **"Burn M4 Binary"** section in **getting-started-with-siwx917-soc** guide at **release_package/docs/index.html** to work with Si91x and Simplicity Studio + +## Executing the Application +- The current implementation executes AES-ECB single-part encryption and decryption for AES. +- The current implementation executes the SHA 256 hashing. + +## Configuration +- With default configuration, the application executes SHA and AES in two threads one after another. +- Uncomment SAME_CRYPTO_ACCELERATORS and comment DIFFERENT_CRYPTO_ACCELERATORS in app.c to execute sha operation in both threads. +- Set the priority of threads (thread0, thread1, thread2) to low, low4, low4 respectively to execute sha and aes applications one after another. +- Set the priority of threads (thread0, thread1, thread2) to low4, low, low respectively to execute the sha and aes application threads parallely in round-robin mode. + +## Expected Results +- The Encryption/Decryption function should produce the expected results. +- The SHA hashing should produce the expected result. +- The two threads should use semaphores for crypto accelerator functionalities. + +## Resources + +* [AN1311: Integrating Crypto Functionality Using PSA Crypto Compared to Mbed TLS Guide](https://www.silabs.com/documents/public/application-notes/an1311-mbedtls-psa-crypto-porting-guide.pdf) + +* [AN1135: Using Third Generation Non-Volatile Memory (NVM3) Data Storage](https://www.silabs.com/documents/public/application-notes/an1135-using-third-generation-nonvolatile-memory.pdf) \ No newline at end of file diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/resources/readme/image508a.png b/examples/si91x_soc/crypto/si91x_psa_multithread/resources/readme/image508a.png new file mode 100644 index 00000000..25b66fae Binary files /dev/null and b/examples/si91x_soc/crypto/si91x_psa_multithread/resources/readme/image508a.png differ diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/resources/readme/image508c.png b/examples/si91x_soc/crypto/si91x_psa_multithread/resources/readme/image508c.png new file mode 100644 index 00000000..537bff5b Binary files /dev/null and b/examples/si91x_soc/crypto/si91x_psa_multithread/resources/readme/image508c.png differ diff --git a/examples/si91x_soc/crypto/si91x_psa_multithread/si91x_psa_multithread.slcp b/examples/si91x_soc/crypto/si91x_psa_multithread/si91x_psa_multithread.slcp new file mode 100644 index 00000000..a770d2f8 --- /dev/null +++ b/examples/si91x_soc/crypto/si91x_psa_multithread/si91x_psa_multithread.slcp @@ -0,0 +1,72 @@ +project_name: si91x_psa_multithread +label: SI91x - SoC PSA MULTITHREAD +description: | + This example project demonstrates the use of thread-safe mechanism in crypto hardware accelerators in SI91x. +category: example|crypto +package: platform +quality: production +filter: + - name: Wireless Technology + value: + - Wi-Fi + - name: Project Difficulty + value: + - Beginner +sdk: + id: gecko_sdk + version: 4.4.0 +readme: + - path: readme.md +source: + - path: main.c + - path: psa_multithread_app.c + - path: app.c +include: + - path: . + file_list: + - path: psa_multithread_app.h + - path: app.h +component: + - id: sl_system + - id: freertos + - id: mbedtls_slcrypto + - id: psa_crypto + - id: psa_driver + - id: psa_crypto_trng + - id: psa_crypto_cipher_ecb + - id: psa_crypto_cipher_cbc + - id: psa_crypto_cipher_ctr + - id: psa_crypto_sha1 + - id: psa_crypto_sha224 + - id: psa_crypto_sha256 + - id: psa_crypto_sha384 + - id: psa_crypto_sha512 + - id: sl_si91x_crypto_multithread + from: wiseconnect3_sdk + - id: syscalls + from: wiseconnect3_sdk + - id: si917_memory_default_config + from: wiseconnect3_sdk + - id: wifi + from: wiseconnect3_sdk + - id: sl_si91x_internal_stack + from: wiseconnect3_sdk + - id: wifi_resources + from: wiseconnect3_sdk + - id: network_manager + from: wiseconnect3_sdk + - id: basic_network_config_manager + from: wiseconnect3_sdk +other_file: + - path: resources/readme/image508a.png + - path: resources/readme/image508c.png +ui_hints: + highlight: + - path: readme.md + focus: true +sdk_extension: + - id: wiseconnect3_sdk + version: 3.1.2 +toolchain_settings: [] +post_build: + path: ../../../../utilities/postbuild_profile/wiseconnect_soc.slpb diff --git a/examples/si91x_soc/crypto/si91x_psa_sha/si91x_psa_sha.slcp b/examples/si91x_soc/crypto/si91x_psa_sha/si91x_psa_sha.slcp index 890292ac..40ef3688 100644 --- a/examples/si91x_soc/crypto/si91x_psa_sha/si91x_psa_sha.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_sha/si91x_psa_sha.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: psa_sha_app.c diff --git a/examples/si91x_soc/crypto/si91x_psa_symmetric_key_storage/si91x_psa_symmetric_key_storage.slcp b/examples/si91x_soc/crypto/si91x_psa_symmetric_key_storage/si91x_psa_symmetric_key_storage.slcp index 61f06b03..1b8bc067 100644 --- a/examples/si91x_soc/crypto/si91x_psa_symmetric_key_storage/si91x_psa_symmetric_key_storage.slcp +++ b/examples/si91x_soc/crypto/si91x_psa_symmetric_key_storage/si91x_psa_symmetric_key_storage.slcp @@ -29,7 +29,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 define: - name: SL_SI91X_PRINT_DBG_LOG component: diff --git a/examples/si91x_soc/hello_world/si91x_hello_world.slcp b/examples/si91x_soc/hello_world/si91x_hello_world.slcp index c081d9f6..b46768e0 100644 --- a/examples/si91x_soc/hello_world/si91x_hello_world.slcp +++ b/examples/si91x_soc/hello_world/si91x_hello_world.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/peripheral/memlcd_baremetal/memlcd_baremetal.slcp b/examples/si91x_soc/peripheral/memlcd_baremetal/memlcd_baremetal.slcp index 5957b6ea..c6589a4f 100644 --- a/examples/si91x_soc/peripheral/memlcd_baremetal/memlcd_baremetal.slcp +++ b/examples/si91x_soc/peripheral/memlcd_baremetal/memlcd_baremetal.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/peripheral/psram_blinky/psram_blinky.slcp b/examples/si91x_soc/peripheral/psram_blinky/psram_blinky.slcp index 0e61e290..7aa604ae 100644 --- a/examples/si91x_soc/peripheral/psram_blinky/psram_blinky.slcp +++ b/examples/si91x_soc/peripheral/psram_blinky/psram_blinky.slcp @@ -12,7 +12,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/peripheral/psram_driver_example/main.c b/examples/si91x_soc/peripheral/psram_driver_example/main.c index 4dcce13f..f1e29311 100644 --- a/examples/si91x_soc/peripheral/psram_driver_example/main.c +++ b/examples/si91x_soc/peripheral/psram_driver_example/main.c @@ -81,105 +81,102 @@ int main() status = sl_si91x_psram_uninit(); status = sl_si91x_psram_init(); - while (1) { + /* Write and read in Auto mode ---------------------------------------------*/ - /* Write and read in Auto mode ---------------------------------------------*/ - - /// Auto Write to PSRAM base address - for (uint32_t index = 0; index < BIT_8_READ_WRITE_LENGTH; index++) { - psramBufWrtPtr[index] = testBuf[index]; - } - - memset(verifyBuf, 0, READ_WRITE_LENGTH); /// Clearing the buffer + /// Auto Write to PSRAM base address + for (uint32_t index = 0; index < BIT_8_READ_WRITE_LENGTH; index++) { + psramBufWrtPtr[index] = testBuf[index]; + } - /// Auto Read from PSRAM base address - for (uint32_t index = 0; index < BIT_8_READ_WRITE_LENGTH; index++) { - verifyBuf[index] = psramBufWrtPtr[index]; - } + memset(verifyBuf, 0, READ_WRITE_LENGTH); /// Clearing the buffer - for (size_t i = 0; i < BIT_8_READ_WRITE_LENGTH; i++) { - if (testBuf[i] != verifyBuf[i]) { - status_flag = 1; - } - } + /// Auto Read from PSRAM base address + for (uint32_t index = 0; index < BIT_8_READ_WRITE_LENGTH; index++) { + verifyBuf[index] = psramBufWrtPtr[index]; + } - if (status_flag) { - DEBUGOUT("\r\nAuto read Write Failed\r\n"); - status_flag = 0; - } else { - DEBUGOUT("\r\nAuto Write and auto read successful from PSRAM\r\n"); + for (size_t i = 0; i < BIT_8_READ_WRITE_LENGTH; i++) { + if (testBuf[i] != verifyBuf[i]) { + status_flag = 1; } + } - /* Write and read in manual blocking mode ----------------------------------*/ + if (status_flag) { + DEBUGOUT("\r\nAuto Read Write Failed\r\n"); + status_flag = 0; + } else { + DEBUGOUT("\r\nAuto Write and Read successful from PSRAM\r\n"); + } - /// Manual write to PSRAM base address - sl_si91x_psram_manual_write_in_blocking_mode(PSRAM_BASE_ADDRESS, - (void *)testBuf, - sizeof(uint8_t), - BIT_8_READ_WRITE_LENGTH); + /* Write and read in manual blocking mode ----------------------------------*/ - memset(verifyBuf, 0, READ_WRITE_LENGTH); /// Clearing the buffer + /// Manual write to PSRAM base address + sl_si91x_psram_manual_write_in_blocking_mode(PSRAM_BASE_ADDRESS, + (void *)testBuf, + sizeof(uint8_t), + BIT_8_READ_WRITE_LENGTH); - /// Manual read from PSRAM base address - sl_si91x_psram_manual_read_in_blocking_mode(PSRAM_BASE_ADDRESS, - verifyBuf, - sizeof(uint8_t), - BIT_8_READ_WRITE_LENGTH); + memset(verifyBuf, 0, READ_WRITE_LENGTH); /// Clearing the buffer - for (size_t i = 0; i < BIT_8_READ_WRITE_LENGTH; i++) { - if (testBuf[i] != verifyBuf[i]) { - status_flag = 1; - } - } + /// Manual read from PSRAM base address + sl_si91x_psram_manual_read_in_blocking_mode(PSRAM_BASE_ADDRESS, verifyBuf, sizeof(uint8_t), BIT_8_READ_WRITE_LENGTH); - if (status_flag) { - DEBUGOUT("\r\nManual read Write Failed\r\n"); - status_flag = 0; - } else { - DEBUGOUT("\r\nManual Write and auto read successful from PSRAM\r\n"); + for (size_t i = 0; i < BIT_8_READ_WRITE_LENGTH; i++) { + if (testBuf[i] != verifyBuf[i]) { + status_flag = 1; } + } - /* Write and read in manual dma mode ---------------------------------------*/ + if (status_flag) { + DEBUGOUT("\r\nManual Read Write Failed\r\n"); + status_flag = 0; + } else { + DEBUGOUT("\r\nManual Write and Read successful from PSRAM\r\n"); + } - volatile sl_psram_dma_status_type_t xferStatus = 0; + /* Write and read in manual dma mode ---------------------------------------*/ - /// Manual write in dma mode - sl_si91x_psram_manual_write_in_dma_mode(PSRAM_BASE_ADDRESS, - (void *)testBuf, - sizeof(uint8_t), - BIT_8_READ_WRITE_LENGTH, - &xferStatus); + volatile sl_psram_dma_status_type_t xferStatus = 0; - while (!xferStatus) { - /// Wait till dma done - } + /// Manual write in dma mode + sl_si91x_psram_manual_write_in_dma_mode(PSRAM_BASE_ADDRESS, + (void *)testBuf, + sizeof(uint8_t), + BIT_8_READ_WRITE_LENGTH, + (sl_psram_dma_status_type_t *)&xferStatus); - memset(verifyBuf, 0, READ_WRITE_LENGTH); /// Clearing the buffer + while (!xferStatus) { + /// Wait till dma done + } - /// Manual read in dma mode - sl_si91x_psram_manual_read_in_dma_mode(PSRAM_BASE_ADDRESS, - verifyBuf, - sizeof(uint8_t), - BIT_8_READ_WRITE_LENGTH, - &xferStatus); + memset(verifyBuf, 0, READ_WRITE_LENGTH); /// Clearing the buffer - while (!xferStatus) { - /// Wait till dma done - } + /// Manual read in dma mode + sl_si91x_psram_manual_read_in_dma_mode(PSRAM_BASE_ADDRESS, + verifyBuf, + sizeof(uint8_t), + BIT_8_READ_WRITE_LENGTH, + (sl_psram_dma_status_type_t *)&xferStatus); - for (size_t i = 0; i < BIT_8_READ_WRITE_LENGTH; i++) { - if (testBuf[i] != verifyBuf[i]) { - status_flag = 1; - } - } + while (!xferStatus) { + /// Wait till dma done + } - if (status_flag) { - DEBUGOUT("\r\nManual read Write with DMA Failed\r\n"); - status_flag = 0; - } else { - DEBUGOUT("\r\nManual Write and auto read with DMA successful from PSRAM\r\n"); + for (size_t i = 0; i < BIT_8_READ_WRITE_LENGTH; i++) { + if (testBuf[i] != verifyBuf[i]) { + status_flag = 1; } + } - DEBUGOUT("\r\n*************************************************************\r\n\n\n"); + if (status_flag) { + DEBUGOUT("\r\nManual Read Write with DMA Failed\r\n"); + status_flag = 0; + } else { + DEBUGOUT("\r\nManual Write and Read with DMA successful from PSRAM\r\n"); } + + DEBUGOUT("\r\n*************************************************************\r\n\n\n"); + + while (1) + ; } diff --git a/examples/si91x_soc/peripheral/psram_driver_example/psram_driver_example.slcp b/examples/si91x_soc/peripheral/psram_driver_example/psram_driver_example.slcp index 37d14dcf..13eab8b4 100644 --- a/examples/si91x_soc/peripheral/psram_driver_example/psram_driver_example.slcp +++ b/examples/si91x_soc/peripheral/psram_driver_example/psram_driver_example.slcp @@ -14,7 +14,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c toolchain_settings: [] diff --git a/examples/si91x_soc/peripheral/sl_si91x_adc/sl_si91x_adc.slcp b/examples/si91x_soc/peripheral/sl_si91x_adc/sl_si91x_adc.slcp index 0fac546a..0a176d55 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_adc/sl_si91x_adc.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_adc/sl_si91x_adc.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: adc_example.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/readme.md b/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/readme.md index 24283f74..f5740c63 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/readme.md @@ -68,12 +68,12 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Application Configuration Parameters - Configure UC from the slcp component. -- Open **sl_si91x_adc.slcp** project file select **software component** tab and search for **ADC** in search bar. +- Open **sl_si91x_adc_multichannel.slcp** project file select **software component** tab and search for **ADC** in search bar. - Using configuration wizard one can configure different parameters. Below are the 2 configuration screens where user can select as per requirement. - **ADC Peripheral Common Configuration** - - Number of channel: By default channel is set to '1'. When the channel number is changed, then care must be taken to create instance of that respective channel number. Otherwise, an error is thrown. + - Number of channel: In multichannel mode by default number of channel is '4'. When the number of channel is changed, then care must be taken to create instance of that respective channel number. Otherwise, an error is thrown. - ADC operation mode: There are 2 modes, FIFO mode and Static mode. By default it is in FIFO mode. When static mode is set, sample length should be '1'. ![Figure: Introduction](resources/uc_screen/sl_adc_common_uc_screen.png) @@ -126,10 +126,9 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: -1. Adjust the number of channel as 4 in ADC Peripheral Common Configuration UC. -2. Compile and run the application. -3. When the application runs, it starts ADC conversion. -4. After completion of conversion ADC input, it will print all the captured samples data in console by connecting vcom. +1. Compile and run the application. +2. When the application runs, it starts ADC conversion. +3. After completion of conversion ADC input, it will print all the captured samples data in console by connecting vcom. - **Channel 0 pin connections** - When configured Single ended mode connect the positive analog input to ULP_GPIO_1 and GND to ULP_GPIO_7 @@ -146,7 +145,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise > **Note:** > -- Users who only want to utilize two channels can uninstall channels two and three from the software components on sl_si91x_ulp_adc_multichannel_2.slcp. By default, four channels instances will be created. +- Users who only want to utilize two channels can uninstall channels two and three from the software components on sl_si91x_adc_multichannel.slcp. By default, four channels instances will be created. - This application only applicable for FIFO mode. - Sample rate should be either same for all channels or 1/2, 1/4, 1/16.(for example if channel_0 sample rate is 10000sps, then channel_1 = 10000/2 sps, channel_2 = 10000/4 sps, channel_3 = 10000/16 sps) - User can configure input selection GPIO in channel configuration file ($path: $project/config/specific channel config file) if default GPIO is work around. diff --git a/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/sl_si91x_adc_multichannel.slcp b/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/sl_si91x_adc_multichannel.slcp index 353dd65b..260de0d6 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/sl_si91x_adc_multichannel.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_adc_multichannel/sl_si91x_adc_multichannel.slcp @@ -12,7 +12,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: adc_multichannel_example.c - path: app.c @@ -38,6 +38,9 @@ component: from: wiseconnect3_sdk define: - name: GAIN_OFFSET_CAL_EN +configuration: + - name: NUMBER_OF_CHANNEL + value: '4' other_file: - path: resources/readme/setupdiagram.png - path: resources/readme/sl_adc_output.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_blinky/sl_si91x_blinky.slcp b/examples/si91x_soc/peripheral/sl_si91x_blinky/sl_si91x_blinky.slcp index de2e11d9..69e842ce 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_blinky/sl_si91x_blinky.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_blinky/sl_si91x_blinky.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_button_baremetal/sl_si91x_button_baremetal.slcp b/examples/si91x_soc/peripheral/sl_si91x_button_baremetal/sl_si91x_button_baremetal.slcp index fee12feb..fcf7db42 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_button_baremetal/sl_si91x_button_baremetal.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_button_baremetal/sl_si91x_button_baremetal.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_calendar/sl_si91x_calendar.slcp b/examples/si91x_soc/peripheral/sl_si91x_calendar/sl_si91x_calendar.slcp index c522b43b..8a35f681 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_calendar/sl_si91x_calendar.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_calendar/sl_si91x_calendar.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 readme: - path: readme.md source: diff --git a/examples/si91x_soc/peripheral/sl_si91x_config_timer/config_timer_example.c b/examples/si91x_soc/peripheral/sl_si91x_config_timer/config_timer_example.c index d2dd993f..c994b7a5 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_config_timer/config_timer_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_config_timer/config_timer_example.c @@ -345,15 +345,8 @@ void on_config_timer_callback(void *callback_flag) } // Checking interrupt count if (interrupt_count >= TENTH_INTERRUPT_COUNT) { - // Unregistering timer callback and disabling interrupt - status = sl_si91x_config_timer_unregister_callback(&ct_interrupt_flags); - if (status != SL_STATUS_OK) { - DEBUGOUT("sl_si91x_config_timer_timeout_callback_unregister : Invalid " - "Parameters Error Code : %lu \n", - status); - } // De-initializing config-timer - DEBUGOUT("CT Callback unregistered & de-inits timer after 10th interrupt\n"); + DEBUGOUT("Config timer de-inits and unregistered callback after 10th interrupt\n"); sl_si91x_config_timer_deinit(); } #endif diff --git a/examples/si91x_soc/peripheral/sl_si91x_config_timer/readme.md b/examples/si91x_soc/peripheral/sl_si91x_config_timer/readme.md index 9fc45bc5..97c13762 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_config_timer/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_config_timer/readme.md @@ -52,7 +52,7 @@ - After intialization, the desired counter parameters are configured using \ref sl_si91x_ct_set_configuration() API, the parameters are set through UC. - Match count for both the counters are configured using same @ref sl_si91x_ct_set_match_count() API. - Initial duty cycle is set for PWM channels \ref RSI_MCPWM_SetDutyCycle() API. - - The desired OCU parameters are configured using \ref sl_si91x_ct_set_ocu_configuration() API, the parameters are set using UC. For getting these configurations through UC enable OCU-configuration button on UC. + - The desired OCU parameters are configured using \ref sl_si91x_ct_set_ocu_configuration() API. - The desired OCU controls for both counters, are configured using API \ref sl_si91x_config_timer_set_ocu_control(), by changing the counter number. - Registers callback for enabling peak interrupt, for counter-1 using \ref sl_si91x_ct_register_callback() API. - Starts both the counters using API \ref sl_si91x_ct_start_on_software_trigger(), by changing the counter number. @@ -70,9 +70,8 @@ - Starts counter-0 using \ref sl_si91x_ct_start_on_software_trigger() API. - **Callback Function** - ULP_GPIO_1 pin gets toggled on every interrupt occurring at every millisecond and increments interrupt count. - - When interrupt count is greater than ten, then unregisters timer callback and disables interrupt through \ref sl_si91x_ct_unregister_timeout_callback() API. - - At last timer is deinitialized through \ref sl_si91x_config_timer_deinit() API. - + - When interrupt count is greater than ten, then timer is deinitialized, callback is unregistered and disables interrupt through \ref sl_si91x_config_timer_deinit() API. + ## Prerequisites/Setup Requirements ### Hardware Requirements @@ -109,7 +108,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise #define CT_COUNTER_MODE_USECASE 1 - To run normal counter code ``` -- Also enable CT-configuration & OCU-configuration buttons on UC for using PWM mode usecase. +- Also enable CT-configuration for using PWM mode usecase. - Configure the following macros in config_timer_example.c file to change match value for counter-mode usecase, update/modify following macros if required. ```C @@ -118,7 +117,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Use following CT configurations to run application in Normal counter mode usecase (using Counter-0 or Counter-1). - > ![Figure: Pin configuration](resources/uc_screen/uc_screen_1.png) + > ![Figure: Pin configuration](resources/uc_screen/uc_screen.png) - Change following macros in config_timer_example.c file to change counter-number used for counter-mode usecase, by default application is using counter-0 to use counter-1 change it to 'SL_COUNTER_1'. @@ -126,9 +125,9 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise #define CT_COUNTER_USED SL_COUNTER_0 - For using counter-0 ``` -- Use following OCU Configuraions, along with default CT configurations to run the application in PWM mode usecase. +- Use following CT Configuraions, to run the application in PWM mode usecase. - > ![Figure: Pin configuration](resources/uc_screen/uc_screen_2.png) + > ![Figure: Pin configuration](resources/uc_screen/uc_screen.png) ### Pin Configuration for pwm-mode usecase @@ -146,49 +145,8 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - \ref SL_COUNTER1_DIRECTION_MACRO , for possible values refer \ref sl_counter1_direction_t - \ref SL_COUNTER0_PERIODIC_ENABLE_MACRO, true to enable Counter0 Periodic mode & false to skip Counter0 Periodic mode. - \ref SL_COUNTER1_PERIODIC_ENABLE_MACRO, true to enable Counter1 Periodic mode & false to skip Counter1 Periodic mode. -- \ref SL_COUNTER0_SOFT_RESET_ENABLE_MACRO, true to enable Counter0 soft reset & false to skip Counter0 soft reset. -- \ref SL_COUNTER1_SOFT_RESET_ENABLE_MACRO, true to Counter1 soft reset & false to skip Counter1 soft reset. -- \ref SL_COUNTER0_TRIGGER_ENABLE_MACRO, true to enable Counter0 software trigger & false to skip Counter0 software trigger. -- \ref SL_COUNTER1_TRIGGER_ENABLE_MACRO, true to enable Counter1 software trigger & false to skip Counter1 software trigger. - \ref SL_COUNTER0_SYNC_TRIGGER_ENABLE_MACRO, true to enable Counter0 sync trigger & false to skip Counter0 sync trigger. - \ref SL_COUNTER1_SYNC_TRIGGER_ENABLE_MACRO, true to enable Counter1 sync trigger & false to skip Counter1 sync trigger. -- \ref SL_COUNTER0_BUFFER_ENABLE_MACRO, true to enable Counter0 buffer & false to skip Counter0 buffer. -- \ref SL_COUNTER1_BUFFER_ENABLE_MACRO, true to enable Counter1 buffer & false to skip Counter1 buffer. - -### Macros for CT Interrupt Flags - -- \ref SL_CT_EVENT_INTR_0_FLAG_MACRO, true to enable interrupt on event occurrence & false to skip interrupt on event occurrence. -- \ref SL_CT_FIFO_0_FULL_FLAG_MACRO, true to enable interrupt on FIFO FULL & false to skip interrupt on FIFO FULL. -- \ref SL_CT_COUNTER_0_IS_ZERO_FLAG_MACRO, true to enable interrupt on zero value & false to skip interrupt on zero value. -- \ref SL_CT_COUNTER_0_IS_PEAK_FLAG_MACRO, true to enable interrupt on match value & false to skip interrupt on match value. -- \ref SL_CT_EVENT_INTR_1_FLAG_MACRO, true to enable interrupt on event occurrence & false to skip interrupt on event occurrence. -- \ref SL_CT_FIFO_1_FULL_FLAG_MACRO, true to enable interrupt on FIFO FULL & false to skip interrupt on FIFO FULL. -- \ref SL_CT_COUNTER_1_IS_ZERO_FLAG_MACRO, true to enable interrupt on zero value & false to skip interrupt on zero value. -- \ref SL_CT_COUNTER_1_IS_PEAK_FLAG_MACRO, true to enable interrupt on match value & false to skip interrupt on match value. - -### Macros for OCU Configuration - -- \ref SL_COUNTER0_OCU_OUTPUT_ENABLE_MACRO, true to enable Counter0 OCU Output & false to skip Counter0 OCU Output. -- \ref SL_COUNTER0_OCU_DMA_ENABLE_MACRO, true to enable Counter0 OCU DMA & false to skip Counter0 OCU DMA. -- \ref SL_COUNTER0_OCU_8BIT_MODE_ENABLE_MACRO, true to enable Counter0 OCU 8-bit mode & false to skip Counter0 OCU 8-bit mode. -- \ref SL_COUNTER0_OCU_SYNC_ENABLE_MACRO, true to enable Counter0 OCU sync & false to skip Counter0 OCU sync. -- \ref SL_COUNTER1_OCU_OUTPUT_ENABLE_MACRO, true to enable Counter1 OCU Output & false to skip Counter1 OCU Output. -- \ref SL_COUNTER1_OCU_DMA_ENABLE_MACRO, true to enable Counter1 OCU DMA & false to skip Counter1 OCU DMA. -- \ref SL_COUNTER1_OCU_8BIT_ENABLE_MACRO, true to enable Counter1 OCU 8-bit mode & false to skip Counter1 OCU 8-bit mode. -- \ref SL_COUNTER1_OCU_SYNC_ENABLE_MACRO, true to enable Counter1 OCU sync & false to skip Counter1 OCU sync. -- \ref SL_OCU_OUTPUT0_TOGGLE_HIGH_MACRO, true to enable OCU output0 Toggle HIGH & false to skip OCU output1 Toggle HIGH. -- \ref SL_OCU_OUTPUT0_TOGGLE_LOW_MACRO, true to enable OCU output0 Toggle LOW & false to skip OCU output0 Toggle LOW. -- \ref SL_OCU_OUTPUT1_TOGGLE_HIGH_MACRO, true to enable OCU output1 Toggle HIGH & false to skip OCU output1 Toggle LOW. -- \ref SL_OCU_OUTPUT1_TOGGLE_LOW_MACRO, true to enable OCU output1 interrupt on match value & false to skip OCU output1 interrupt on match value. - -### Macros for WFG Configuration - -- \ref SL_OUTPUT0_TOGGLE0_MACRO, true to enable output-0 toggle-LOW & false to skip output-0 toggle-LOW. -- \ref SL_OUTPUT0_TOGGLE1_MACRO, true to enable output-0 toggle-HIGH & false to skip output-0 toggle-HIGH. -- \ref SL_TOGGLE_COUNTER0_PEAK_MACRO, true to enable Toggle counter-0 peak & false to skip Toggle counter-0 peak. -- \ref SL_OUTPUT1_TOGGLE0_MACRO, true to enable output-1 toggle-LOW & false to skip output-1 toggle-LOW. -- \ref SL_OUTPUT1_TOGGLE1_MACRO, true to enable output-1 toggle-HIGH & false to skip output-1 toggle-HIGH. -- \ref SL_TOGGLE_COUNTER1_PEAK_MACRO, true to enable Toggle counter-1 peak & false to skip Toggle counter-1 peak. ## Test the Application diff --git a/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen.png b/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen.png new file mode 100644 index 00000000..24695e0e Binary files /dev/null and b/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen.png differ diff --git a/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen_1.png b/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen_1.png deleted file mode 100644 index 38b96aec..00000000 Binary files a/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen_1.png and /dev/null differ diff --git a/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen_2.png b/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen_2.png deleted file mode 100644 index 9d80cbce..00000000 Binary files a/examples/si91x_soc/peripheral/sl_si91x_config_timer/resources/uc_screen/uc_screen_2.png and /dev/null differ diff --git a/examples/si91x_soc/peripheral/sl_si91x_config_timer/sl_si91x_config_timer.slcp b/examples/si91x_soc/peripheral/sl_si91x_config_timer/sl_si91x_config_timer.slcp index b3ffd4b1..4f901ec9 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_config_timer/sl_si91x_config_timer.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_config_timer/sl_si91x_config_timer.slcp @@ -29,8 +29,7 @@ component: from: wiseconnect3_sdk other_file: - path: resources/readme/image502e.png - - path: resources/uc_screen/uc_screen_1.png - - path: resources/uc_screen/uc_screen_2.png + - path: resources/uc_screen/uc_screen.png - path: resources/readme/setupdiagram.png - path: resources/readme/outputConsoleI_CT.png - path: resources/readme/outputConsoleI_CT_OCU.png @@ -40,6 +39,6 @@ ui_hints: focus: true sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 post_build: path: ../../../../utilities/postbuild_profile/wiseconnect_soc.slpb diff --git a/examples/si91x_soc/peripheral/sl_si91x_dma/sl_si91x_dma.slcp b/examples/si91x_soc/peripheral/sl_si91x_dma/sl_si91x_dma.slcp index 681f4154..1ff28695 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_dma/sl_si91x_dma.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_dma/sl_si91x_dma.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 readme: - path: readme.md source: @@ -34,7 +34,6 @@ other_file: - path: resources/readme/setupdiagram.png - path: resources/uc_screen/ucScreenDMA.png define: - - name: SL_SI91X_DMA - name: __STATIC_INLINE value: static inline provides: diff --git a/examples/si91x_soc/peripheral/sl_si91x_driver_gpio/sl_si91x_driver_gpio.slcp b/examples/si91x_soc/peripheral/sl_si91x_driver_gpio/sl_si91x_driver_gpio.slcp index 35b92d03..537a09cd 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_driver_gpio/sl_si91x_driver_gpio.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_driver_gpio/sl_si91x_driver_gpio.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_efuse/sl_si91x_efuse.slcp b/examples/si91x_soc/peripheral/sl_si91x_efuse/sl_si91x_efuse.slcp index cd05b01c..15540e85 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_efuse/sl_si91x_efuse.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_efuse/sl_si91x_efuse.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: cmsis_common diff --git a/examples/si91x_soc/peripheral/sl_si91x_gpio/sl_si91x_gpio.slcp b/examples/si91x_soc/peripheral/sl_si91x_gpio/sl_si91x_gpio.slcp index 316f6b3f..d7b412cb 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_gpio/sl_si91x_gpio.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_gpio/sl_si91x_gpio.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_gspi/gspi_example.c b/examples/si91x_soc/peripheral/sl_si91x_gspi/gspi_example.c index f273e8da..98f03bc5 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_gspi/gspi_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_gspi/gspi_example.c @@ -22,36 +22,36 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 1024 // Size of buffer -#define INTF_PLL_CLK 180000000 // Intf pll clock frequency -#define INTF_PLL_REF_CLK 40000000 // Intf pll reference clock frequency -#define SOC_PLL_CLK 20000000 // Soc pll clock frequency -#define SOC_PLL_REF_CLK 40000000 // Soc pll reference clock frequency -#define INTF_PLL_500_CTRL_VALUE 0xD900 // Intf pll control value -#define SOC_PLL_MM_COUNT_LIMIT 0xA4 // Soc pll count limit -#define DVISION_FACTOR 0 // Division factor -#define SWAP_READ_DATA 1 // true to enable and false to disable swap read -#define SWAP_WRITE_DATA 0 // true to enable and false to disable swap write -#define GSPI_BITRATE 10000000 // Bitrate for setting the clock division factor -#define GSPI_BIT_WIDTH 8 // Default Bit width -#define MAX_BIT_WIDTH 16 // Maximum Bit width +#define GSPI_BUFFER_SIZE 1024 // Size of buffer +#define GSPI_INTF_PLL_CLK 180000000 // Intf pll clock frequency +#define GSPI_INTF_PLL_REF_CLK 40000000 // Intf pll reference clock frequency +#define GSPI_SOC_PLL_CLK 20000000 // Soc pll clock frequency +#define GSPI_SOC_PLL_REF_CLK 40000000 // Soc pll reference clock frequency +#define GSPI_INTF_PLL_500_CTRL_VALUE 0xD900 // Intf pll control value +#define GSPI_SOC_PLL_MM_COUNT_LIMIT 0xA4 // Soc pll count limit +#define GSPI_DVISION_FACTOR 0 // Division factor +#define GSPI_SWAP_READ_DATA 1 // true to enable and false to disable swap read +#define GSPI_SWAP_WRITE_DATA 0 // true to enable and false to disable swap write +#define GSPI_BITRATE 10000000 // Bitrate for setting the clock division factor +#define GSPI_BIT_WIDTH 8 // Default Bit width +#define GSPI_MAX_BIT_WIDTH 16 // Maximum Bit width /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -static uint16_t data_in[BUFFER_SIZE]; -static uint16_t data_out[BUFFER_SIZE]; -static uint16_t division_factor = 1; +static uint16_t gspi_data_in[GSPI_BUFFER_SIZE]; +static uint16_t gspi_data_out[GSPI_BUFFER_SIZE]; +static uint16_t gspi_division_factor = 1; static sl_gspi_handle_t gspi_driver_handle = NULL; //Enum for different transmission scenarios typedef enum { - SL_TRANSFER_DATA, - SL_RECEIVE_DATA, - SL_SEND_DATA, - SL_TRANSMISSION_COMPLETED, + SL_GSPI_TRANSFER_DATA, + SL_GSPI_RECEIVE_DATA, + SL_GSPI_SEND_DATA, + SL_GSPI_TRANSMISSION_COMPLETED, } gspi_mode_enum_t; -static gspi_mode_enum_t current_mode = SL_TRANSFER_DATA; +static gspi_mode_enum_t current_mode = SL_GSPI_TRANSFER_DATA; /******************************************************************************* ********************** Local Function prototypes *************************** @@ -79,12 +79,12 @@ void gspi_example_init(void) config.bitrate = GSPI_BITRATE; config.clock_mode = SL_GSPI_MODE_0; config.slave_select_mode = SL_GSPI_MASTER_HW_OUTPUT; - config.swap_read = SWAP_READ_DATA; - config.swap_write = SWAP_WRITE_DATA; + config.swap_read = GSPI_SWAP_READ_DATA; + config.swap_write = GSPI_SWAP_WRITE_DATA; // Filling the data out array with integer values - for (uint16_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = i; + for (uint16_t i = 0; i < GSPI_BUFFER_SIZE; i++) { + gspi_data_out[i] = i; } do { // Version information of GSPI driver @@ -140,18 +140,18 @@ void gspi_example_init(void) // Fetching and printing the current frame length DEBUGOUT("Current Frame Length is %lu \n", sl_si91x_gspi_get_frame_length()); if (sl_si91x_gspi_get_frame_length() > GSPI_BIT_WIDTH) { - division_factor = sizeof(data_out[0]); + gspi_division_factor = sizeof(gspi_data_out[0]); } // As per the macros enabled in the header file, it will configure the current mode. if (SL_USE_TRANSFER) { - current_mode = SL_TRANSFER_DATA; + current_mode = SL_GSPI_TRANSFER_DATA; break; } if (SL_USE_RECEIVE) { - current_mode = SL_RECEIVE_DATA; + current_mode = SL_GSPI_RECEIVE_DATA; break; } - current_mode = SL_SEND_DATA; + current_mode = SL_GSPI_SEND_DATA; } while (false); } /******************************************************************************* @@ -166,15 +166,18 @@ void gspi_example_process_action(void) // Assuming all the macros are enabled, after transfer, receive will be executed and after receive // send will be executed. switch (current_mode) { - case SL_TRANSFER_DATA: + case SL_GSPI_TRANSFER_DATA: if (begin_transmission == true) { // Validation for executing the API only once sl_si91x_gspi_set_slave_number(GSPI_SLAVE_0); - status = sl_si91x_gspi_transfer_data(gspi_driver_handle, data_out, data_in, sizeof(data_out) / division_factor); + status = sl_si91x_gspi_transfer_data(gspi_driver_handle, + gspi_data_out, + gspi_data_in, + sizeof(gspi_data_out) / gspi_division_factor); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_gspi_transfer_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; break; } DEBUGOUT("GSPI transfer begin successfully \n"); @@ -183,34 +186,34 @@ void gspi_example_process_action(void) if (transfer_complete) { transfer_complete = false; DEBUGOUT("GSPI transfer completed successfully \n"); - // After comparing the loopback transfer, it compares the data_out and - // data_in. + // After comparing the loopback transfer, it compares the gspi_data_out and + // gspi_data_in. compare_loop_back_data(); if (SL_USE_RECEIVE) { // If receive macro is enabled, current mode is set to receive - current_mode = SL_RECEIVE_DATA; + current_mode = SL_GSPI_RECEIVE_DATA; begin_transmission = true; break; } if (SL_USE_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; + current_mode = SL_GSPI_SEND_DATA; begin_transmission = true; break; } // If above macros are not enabled, current mode is set to complete - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; } break; - case SL_RECEIVE_DATA: + case SL_GSPI_RECEIVE_DATA: if (begin_transmission == true) { // Validation for executing the API only once sl_si91x_gspi_set_slave_number(GSPI_SLAVE_0); - status = sl_si91x_gspi_receive_data(gspi_driver_handle, data_in, sizeof(data_in)); + status = sl_si91x_gspi_receive_data(gspi_driver_handle, gspi_data_in, sizeof(gspi_data_in)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_gspi_receive_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; break; } DEBUGOUT("GSPI receive begin successfully \n"); @@ -223,38 +226,39 @@ void gspi_example_process_action(void) transfer_complete = false; if (SL_USE_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; + current_mode = SL_GSPI_SEND_DATA; begin_transmission = true; DEBUGOUT("GSPI receive completed \n"); break; } DEBUGOUT("GSPI receive completed \n"); // If send macro is not enabled, current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; } #else // If DMA is not enabled, it will wait till the rx_count is equal to number of // data to be received. - if (rx_count < sizeof(data_in)) { + if (rx_count < sizeof(gspi_data_in)) { rx_count = sl_si91x_gspi_get_rx_data_count(gspi_driver_handle); break; } if (SL_USE_SEND) { - current_mode = SL_SEND_DATA; + current_mode = SL_GSPI_SEND_DATA; begin_transmission = true; } #endif // SL_GSPI_DMA_CONFIG_ENABLE DEBUGOUT("GSPI receive completed \n"); break; - case SL_SEND_DATA: + case SL_GSPI_SEND_DATA: if (begin_transmission) { // Validation for executing the API only once sl_si91x_gspi_set_slave_number(GSPI_SLAVE_0); - status = sl_si91x_gspi_send_data(gspi_driver_handle, data_out, sizeof(data_out) / division_factor); + status = + sl_si91x_gspi_send_data(gspi_driver_handle, gspi_data_out, sizeof(gspi_data_out) / gspi_division_factor); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_gspi_send_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; break; } DEBUGOUT("GSPI send begin successfully \n"); @@ -266,21 +270,21 @@ void gspi_example_process_action(void) // If DMA is enabled, it will wait untill transfer_complete flag is set. transfer_complete = false; // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; } #else // If DMA is not enabled, it will wait till the tx_count is equal to number of // data to be send. - if (tx_count < sizeof(data_out)) { + if (tx_count < sizeof(gspi_data_out)) { tx_count = sl_si91x_gspi_get_tx_data_count(); break; } // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_GSPI_TRANSMISSION_COMPLETED; #endif // SL_GSPI_DMA_CONFIG_ENABLE DEBUGOUT("GSPI send completed \n"); break; - case SL_TRANSMISSION_COMPLETED: + case SL_GSPI_TRANSMISSION_COMPLETED: break; } } @@ -300,13 +304,13 @@ static sl_status_t init_clock_configuration_structure(sl_gspi_clock_config_t *cl if (clock_config == NULL) { status = SL_STATUS_NULL_POINTER; } else { - clock_config->soc_pll_mm_count_value = SOC_PLL_MM_COUNT_LIMIT; - clock_config->intf_pll_500_control_value = INTF_PLL_500_CTRL_VALUE; - clock_config->intf_pll_clock = INTF_PLL_CLK; - clock_config->intf_pll_reference_clock = INTF_PLL_REF_CLK; - clock_config->soc_pll_clock = SOC_PLL_CLK; - clock_config->soc_pll_reference_clock = SOC_PLL_REF_CLK; - clock_config->division_factor = DVISION_FACTOR; + clock_config->soc_pll_mm_count_value = GSPI_SOC_PLL_MM_COUNT_LIMIT; + clock_config->intf_pll_500_control_value = GSPI_INTF_PLL_500_CTRL_VALUE; + clock_config->intf_pll_clock = GSPI_INTF_PLL_CLK; + clock_config->intf_pll_reference_clock = GSPI_INTF_PLL_REF_CLK; + clock_config->soc_pll_clock = GSPI_SOC_PLL_CLK; + clock_config->soc_pll_reference_clock = GSPI_SOC_PLL_REF_CLK; + clock_config->division_factor = GSPI_DVISION_FACTOR; status = SL_STATUS_OK; } return status; @@ -329,17 +333,17 @@ static void compare_loop_back_data(void) uint32_t frame_length = 0; uint16_t mask = (uint16_t)~0; frame_length = sl_si91x_gspi_get_frame_length(); - mask = mask >> (MAX_BIT_WIDTH - frame_length); - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - data_in[data_index] &= mask; - data_out[data_index] &= mask; + mask = mask >> (GSPI_MAX_BIT_WIDTH - frame_length); + for (data_index = 0; data_index < GSPI_BUFFER_SIZE; data_index++) { + gspi_data_in[data_index] &= mask; + gspi_data_out[data_index] &= mask; // If the data in and data out are same, it will be continued else, the for // loop will be break. - if (data_in[data_index] != data_out[data_index]) { + if (gspi_data_in[data_index] != gspi_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == GSPI_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); diff --git a/examples/si91x_soc/peripheral/sl_si91x_gspi/sl_si91x_gspi.slcp b/examples/si91x_soc/peripheral/sl_si91x_gspi/sl_si91x_gspi.slcp index 33f57326..f1741d5c 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_gspi/sl_si91x_gspi.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_gspi/sl_si91x_gspi.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -27,14 +27,6 @@ component: from: wiseconnect3_sdk - id: sl_gspi from: wiseconnect3_sdk - - id: sl_dma - from: wiseconnect3_sdk -define: - - name: GSPI_MULTI_SLAVE - - name: GSPI_CONFIG - - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: SL_SI91X_GSPI_DMA - - name: SL_SI91X_DMA other_file: - path: resources/readme/image505d.png - path: resources/readme/setupdiagram.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/i2c_follower_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/i2c_follower_example.c index 9dc2da37..c7787bec 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/i2c_follower_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/i2c_follower_example.c @@ -25,32 +25,32 @@ ******************************************************************************/ #define NON_BLOCKING_APPLICATION DISABLE // Enable this macro when transfer type is DMA #define BLOCKING_APPLICATION ENABLE // Enable this macro when transfer type is Interrupt type -#define I2C_INSTANCE_USED 0 // update this macro with i2c instance number used for application +#define I2C_INSTANCE_USED 2 // update this macro with i2c instance number used for application #define OWN_I2C_ADDR 0x50 // Own I2C address #define ZERO_ADDRESS_VALUE 0x00 // for zero address value #define MAX_BUFFER_SIZE_BLOCKING 80000 // Maximum buffer size for RX and TX length when transferring without DMA #define MAX_BUFFER_SIZE_NON_BLOCKING 30000 // Maximum buffer size for RX and TX length when transferring with DMA -#define SIZE_BUFFERS 15 // Size of data buffer -#define RX_LENGTH SIZE_BUFFERS // Number of bytes to receive -#define TX_LENGTH SIZE_BUFFERS // Number of bytes to send -#define OFFSET_LENGTH 1 // Offset length -#define INTERNAL_PULLUP 1 // Internal Pull-up enable -#define TX_FIFO_THRESHOLD 0 // FIFO threshold -#define RX_FIFO_THRESHOLD 0 // FIFO threshold -#define INITIAL_VALUE 0 // for 0 initial value -#define ONE 0x1 // for value one -#define INSTANCE_ZERO 0 // For 0 value -#define INSTANCE_ONE 1 // For 0 value -#define INSTANCE_TWO 2 // For 0 value +#define I2C_SIZE_BUFFERS 15 // Size of data buffer +#define I2C_RX_LENGTH I2C_SIZE_BUFFERS // Number of bytes to receive +#define I2C_TX_LENGTH I2C_SIZE_BUFFERS // Number of bytes to send +#define I2C_OFFSET_LENGTH 1 // Offset length +#define I2C_INTERNAL_PULLUP 1 // Internal Pull-up enable +#define I2C_TX_FIFO_THRESHOLD 0 // FIFO threshold +#define I2C_RX_FIFO_THRESHOLD 0 // FIFO threshold +#define INITIAL_VALUE 0 // for 0 initial value +#define ONE 0x1 // for value one +#define INSTANCE_ZERO 0 // For 0 value +#define INSTANCE_ONE 1 // For 0 value +#define INSTANCE_TWO 2 // For 0 value /******************************************************************************* ****************************** Data Types *********************************** ******************************************************************************/ // Enum for different transmission scenarios typedef enum { - SEND_DATA, // Send mode - RECEIVE_DATA, // Receive mode - TRANSMISSION_COMPLETED, // Transmission completed mode + I2C_SEND_DATA, // Send mode + I2C_RECEIVE_DATA, // Receive mode + I2C_TRANSMISSION_COMPLETED, // Transmission completed mode } i2c_action_enum_t; /******************************************************************************* @@ -59,18 +59,18 @@ typedef enum { sl_i2c_status_t i2c_status; sl_i2c_instance_t i2c_instance = I2C_INSTANCE_USED; #if NON_BLOCKING_APPLICATION -volatile uint8_t read_buffer[SIZE_BUFFERS]; +volatile uint8_t i2c_read_buffer[I2C_SIZE_BUFFERS]; #else -static uint8_t read_buffer[SIZE_BUFFERS + OFFSET_LENGTH]; +static uint8_t i2c_read_buffer[I2C_SIZE_BUFFERS + I2C_OFFSET_LENGTH]; #endif #if NON_BLOCKING_APPLICATION -static uint32_t write_buffer[SIZE_BUFFERS]; +static uint32_t i2c_write_buffer[I2C_SIZE_BUFFERS]; #else -static uint8_t write_buffer[SIZE_BUFFERS]; +static uint8_t i2c_write_buffer[I2C_SIZE_BUFFERS]; #endif -static i2c_action_enum_t current_mode = RECEIVE_DATA; -boolean_t send_data_flag = false; -boolean_t receive_data_flag = false; +static i2c_action_enum_t current_mode = I2C_RECEIVE_DATA; +boolean_t i2c_send_data_flag = false; +boolean_t i2c_receive_data_flag = false; boolean_t i2c_transfer_complete = false; boolean_t i2c_7bit_address_transfer_complete = false; boolean_t i2c_10bit_address_transfer_complete = false; @@ -131,7 +131,7 @@ void i2c_follower_example_init(void) DEBUGOUT("Successfully configured i2c follower address\n"); } // Configuring RX and TX FIFO thresholds - i2c_status = sl_i2c_driver_configure_fifo_threshold(i2c_instance, TX_FIFO_THRESHOLD, RX_FIFO_THRESHOLD); + i2c_status = sl_i2c_driver_configure_fifo_threshold(i2c_instance, I2C_TX_FIFO_THRESHOLD, I2C_RX_FIFO_THRESHOLD); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_configure_fifo_threshold : Invalid Parameters, Error Code : %u \n", i2c_status); } else { @@ -153,11 +153,11 @@ void i2c_follower_example_init(void) } #endif // Generating a buffer with values that needs to be sent. - for (uint32_t loop = INITIAL_VALUE; loop < SIZE_BUFFERS; loop++) { - write_buffer[loop] = (uint8_t)(loop + ONE); - read_buffer[loop] = INITIAL_VALUE; + for (uint32_t loop = INITIAL_VALUE; loop < I2C_SIZE_BUFFERS; loop++) { + i2c_write_buffer[loop] = (uint8_t)(loop + ONE); + i2c_read_buffer[loop] = INITIAL_VALUE; } - receive_data_flag = true; + i2c_receive_data_flag = true; } /******************************************************************************* @@ -170,11 +170,12 @@ void i2c_follower_example_process_action(void) // First follower receives data from leader, using I2C receive // Then follower send same data back to master, using I2C send. switch (current_mode) { - case RECEIVE_DATA: - if (receive_data_flag) { + case I2C_RECEIVE_DATA: + if (i2c_receive_data_flag) { // Validation for executing the API only once. #if (BLOCKING_APPLICATION) - i2c_status = sl_i2c_driver_receive_data_blocking(i2c_instance, ZERO_ADDRESS_VALUE, read_buffer, RX_LENGTH); + i2c_status = + sl_i2c_driver_receive_data_blocking(i2c_instance, ZERO_ADDRESS_VALUE, i2c_read_buffer, I2C_RX_LENGTH); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_receive_data_blocking : Invalid Parameters, " "Error Code : %u \n", @@ -184,8 +185,8 @@ void i2c_follower_example_process_action(void) #if (NON_BLOCKING_APPLICATION) i2c_status = sl_i2c_driver_receive_data_non_blocking(i2c_instance, ZERO_ADDRESS_VALUE, - read_buffer, - RX_LENGTH, + i2c_read_buffer, + I2C_RX_LENGTH, &p_dma_config); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_receive_data_non_blocking : Invalid Parameters, " @@ -193,13 +194,13 @@ void i2c_follower_example_process_action(void) i2c_status); } #endif - receive_data_flag = false; + i2c_receive_data_flag = false; } // It waits till i2c_transfer_complete is true in callback. if (i2c_transfer_complete) { i2c_transfer_complete = false; - send_data_flag = true; - current_mode = SEND_DATA; + i2c_send_data_flag = true; + current_mode = I2C_SEND_DATA; } #if (NON_BLOCKING_APPLICATION) if (i2c_driver_dma_error) { @@ -208,11 +209,12 @@ void i2c_follower_example_process_action(void) } #endif break; - case SEND_DATA: - if (send_data_flag) { + case I2C_SEND_DATA: + if (i2c_send_data_flag) { // Validation for executing the API only once. #if (BLOCKING_APPLICATION) - i2c_status = sl_i2c_driver_send_data_blocking(i2c_instance, ZERO_ADDRESS_VALUE, write_buffer, TX_LENGTH); + i2c_status = + sl_i2c_driver_send_data_blocking(i2c_instance, ZERO_ADDRESS_VALUE, i2c_write_buffer, I2C_TX_LENGTH); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_send_data_blocking : Invalid Parameters, " "Error Code : %u \n", @@ -222,8 +224,8 @@ void i2c_follower_example_process_action(void) #if (NON_BLOCKING_APPLICATION) i2c_status = sl_i2c_driver_send_data_non_blocking(i2c_instance, ZERO_ADDRESS_VALUE, - write_buffer, - TX_LENGTH, + i2c_write_buffer, + I2C_TX_LENGTH, &p_dma_config); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_send_data_non_blocking : Invalid Parameters, " @@ -231,13 +233,13 @@ void i2c_follower_example_process_action(void) i2c_status); } #endif - send_data_flag = false; + i2c_send_data_flag = false; } // It waits till i2c_transfer_complete is true in callback. if (i2c_transfer_complete) { - send_data_flag = true; + i2c_send_data_flag = true; i2c_transfer_complete = false; - current_mode = TRANSMISSION_COMPLETED; + current_mode = I2C_TRANSMISSION_COMPLETED; // After the receive is completed, input and output data is compared and // output is printed on console. compare_data(); @@ -249,7 +251,7 @@ void i2c_follower_example_process_action(void) } #endif break; - case TRANSMISSION_COMPLETED: + case I2C_TRANSMISSION_COMPLETED: // De-initializing i2c instance and unregistering callback i2c_status = sl_i2c_driver_deinit(i2c_instance); if (i2c_status != SL_I2C_SUCCESS) { @@ -271,14 +273,14 @@ void i2c_follower_example_process_action(void) static void compare_data(void) { uint32_t data_index = 0; - for (data_index = 0; data_index < SIZE_BUFFERS; data_index++) { - // If the read_buffer and buffer are same, it will be continued else, the + for (data_index = 0; data_index < I2C_SIZE_BUFFERS; data_index++) { + // If the i2c_read_buffer and buffer are same, it will be continued else, the // for loop will be break. - if (write_buffer[data_index] != read_buffer[data_index]) { + if (i2c_write_buffer[data_index] != i2c_read_buffer[data_index]) { break; } } - if (data_index == SIZE_BUFFERS) { + if (data_index == I2C_SIZE_BUFFERS) { DEBUGOUT("Leader-Follower read-write Data comparison is successful, Test " "Case Passed \n"); } else { diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/readme.md b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/readme.md index f02ac4fb..7ddbc8c0 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/readme.md @@ -49,12 +49,12 @@ - Now follower address has to configure its own address through \ref sl_i2c_driver_set_follower_address API. - Now transmit and receive FIFO threshold values are configured using \ref sl_i2c_driver_configure_fifo_threshold API. - Now write_buffer is filled with some data which needs to be sent to the leader. -- Current_mode enum is set to RECEIVE_DATA, it receives data from leader through \ref sl_i2c_driver_receive_data_blocking (for blocking Application) or through \ref sl_i2c_driver_receive_data_non_blocking (for Non-blocking Application). +- Current_mode enum is set to I2C_RECEIVE_DATA, it receives data from leader through \ref sl_i2c_driver_receive_data_blocking (for blocking Application) or through \ref sl_i2c_driver_receive_data_non_blocking (for Non-blocking Application). - After that it will wait till all the data is received by leader. -- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to SEND_DATA. +- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to I2C_SEND_DATA. - Then it calls send_data API to send data to leader through \ref sl_i2c_driver_send_data_blocking (for blocking Application) or through \ref sl_i2c_driver_send_data_non_blocking (for Non-blocking Application). - After calling send_data, it will wait till all the data is transmitted to leader device. -- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to TRANSMISSION_COMPLETED. +- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to I2C_TRANSMISSION_COMPLETED. - Now it compares the data which is received from the leader device to the data which it has sent. - If the send & receive data is same, it will print 'Test Case Passed' on the console. @@ -97,7 +97,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Application Configuration Parameters - Open **sl_si91x_i2c_driver_follower.slcp** project file select **software component**tab and search for **i2c** in search bar. -- Click on **I2C0** and configure the I2C0 instance as per configuration parameters given in wizard. +- Click on **I2C2** and configure the I2C2 instance as per configuration parameters given in wizard. - For using any other I2C instance user has to add that I2C instance by clicking on **I2C Instance** from configuration wizard and then clicking on **Add New Instance** - For creating I2C instances write 'I2C0', 'I2C1' or 'I2C2' on the wizard for respective instance and then click on **Done** - After creation of instances separate configuration files are get generated in **config folder**. @@ -113,10 +113,10 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise #define BLOCKING_APPLICATION // Enable it for enabling I2C transfer using interrupt Application #define NON_BLOCKING_APPLICATION // Enable it for enabling I2C transfer using interrupt Application #define OWN_I2C_ADDR // Update I2C own address - #define SIZE_BUFFERS // To change the number of bytes to send and receive.Its value should be less than maximum buffer size macro value. + #define I2C_SIZE_BUFFERS // To change the number of bytes to send and receive.Its value should be less than maximum buffer size macro value. ``` -> **Note:** Enable either BLOCKING application or NON-BLOCKING application macro, at a time. Change the value of following macros in path: /$project/config/RTE_Device_917.h +> **Note:** Enable either BLOCKING application or NON-BLOCKING application macro, at a time. For I2C0 instance change the value of following macros in path: /$project/config/RTE_Device_917.h ```c #define RTE_I2C0_SCL_PORT_ID 0 // SCL pin port id @@ -161,10 +161,10 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: 1. Compile and run the application. -2. Connect SCL(GPIO_7) and SDA(GPIO_6) pins with the leader device. +2. Connect SCL(ULP_GPIO_7) and SDA(ULP_GPIO_6) pins with the leader device. 3. When the application runs, it receives and send data. 4. After the transfer is completed, it validates the data and prints "Test Case Passed" on the console. 5. Connect Analyzer channels to respective I2C instance SDA & SCA pins to observe the data on lines. 6. After successful program execution the prints in serial console looks as shown below. - ![Figure: Introduction](resources/readme/output.png) + ![Figure: Output](resources/readme/output.png) diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/resources/uc_screen/i2c_uc_screen.png b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/resources/uc_screen/i2c_uc_screen.png index b8fbc56e..13ce2f7f 100644 Binary files a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/resources/uc_screen/i2c_uc_screen.png and b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/resources/uc_screen/i2c_uc_screen.png differ diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/sl_si91x_i2c_driver_follower.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/sl_si91x_i2c_driver_follower.slcp index 7f8357bf..440d6d3f 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/sl_si91x_i2c_driver_follower.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_follower/sl_si91x_i2c_driver_follower.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -34,11 +34,9 @@ component: - id: i2c_instance from: wiseconnect3_sdk instance: - - i2c0 + - i2c2 define: - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: SL_SI91X_DMA - - name: SL_SI91X_I2C_DMA other_file: - path: resources/readme/setupdiagram.png - path: resources/readme/image506d.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/i2c_leader_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/i2c_leader_example.c index d6ca678f..84565f68 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/i2c_leader_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/i2c_leader_example.c @@ -25,29 +25,29 @@ ******************************************************************************/ #define NON_BLOCKING_APPLICATION DISABLE // Enable this macro when transfer type is DMA #define BLOCKING_APPLICATION ENABLE // Enable this macro when transfer type is Interrupt type -#define I2C_INSTANCE_USED 0 // update this macro with i2c instance number used for application +#define I2C_INSTANCE_USED 2 // update this macro with i2c instance number used for application #define FOLLOWER_I2C_ADDR 0x50 // I2C follower address #define MAX_BUFFER_SIZE_BLOCKING 80000 // Maximum buffer size for RX and TX length when transferring without DMA #define MAX_BUFFER_SIZE_NON_BLOCKING 30000 // Maximum buffer size for RX and TX length when transferring with DMA -#define SIZE_BUFFERS 15 // Size of data buffer -#define RX_LENGTH SIZE_BUFFERS // Number of bytes to receive -#define TX_LENGTH SIZE_BUFFERS // Number of bytes to send -#define OFFSET_LENGTH 1 // Offset length -#define TX_FIFO_THRESHOLD 0 // FIFO threshold -#define RX_FIFO_THRESHOLD 0 // FIFO threshold -#define INITIAL_VALUE 0 // for 0 initial value -#define ONE 0x1 // for value one -#define INSTANCE_ZERO 0 // For 0 value -#define INSTANCE_ONE 1 // For 0 value -#define INSTANCE_TWO 2 // For 0 value +#define I2C_SIZE_BUFFERS 15 // Size of data buffer +#define I2C_RX_LENGTH I2C_SIZE_BUFFERS // Number of bytes to receive +#define I2C_TX_LENGTH I2C_SIZE_BUFFERS // Number of bytes to send +#define I2C_OFFSET_LENGTH 1 // Offset length +#define I2C_TX_FIFO_THRESHOLD 0 // FIFO threshold +#define I2C_RX_FIFO_THRESHOLD 0 // FIFO threshold +#define INITIAL_VALUE 0 // for 0 initial value +#define ONE 0x1 // for value one +#define INSTANCE_ZERO 0 // For 0 value +#define INSTANCE_ONE 1 // For 0 value +#define INSTANCE_TWO 2 // For 0 value /******************************************************************************* ****************************** Data Types *********************************** ******************************************************************************/ // Enum for different transmission scenarios typedef enum { - SEND_DATA, // Send mode - RECEIVE_DATA, // Receive mode - TRANSMISSION_COMPLETED, // Transmission completed mode + I2C_SEND_DATA, // Send mode + I2C_RECEIVE_DATA, // Receive mode + I2C_TRANSMISSION_COMPLETED, // Transmission completed mode } i2c_action_enum_t; /******************************************************************************* @@ -56,18 +56,18 @@ typedef enum { sl_i2c_status_t i2c_status; sl_i2c_instance_t i2c_instance = I2C_INSTANCE_USED; #if NON_BLOCKING_APPLICATION -static uint8_t read_buffer[SIZE_BUFFERS]; +static uint8_t i2c_read_buffer[I2C_SIZE_BUFFERS]; #else -static uint8_t read_buffer[SIZE_BUFFERS + OFFSET_LENGTH]; +static uint8_t i2c_read_buffer[I2C_SIZE_BUFFERS + I2C_OFFSET_LENGTH]; #endif #if NON_BLOCKING_APPLICATION -volatile uint32_t write_buffer[SIZE_BUFFERS]; +volatile uint32_t i2c_write_buffer[I2C_SIZE_BUFFERS]; #else -static uint8_t write_buffer[SIZE_BUFFERS]; +static uint8_t i2c_write_buffer[I2C_SIZE_BUFFERS]; #endif -static i2c_action_enum_t current_mode = SEND_DATA; -boolean_t send_data_flag = false; -boolean_t receive_data_flag = false; +static i2c_action_enum_t current_mode = I2C_SEND_DATA; +boolean_t i2c_send_data_flag = false; +boolean_t i2c_receive_data_flag = false; boolean_t i2c_transfer_complete = false; boolean_t i2c_7bit_address_transfer_complete = false; boolean_t i2c_10bit_address_transfer_complete = false; @@ -120,7 +120,7 @@ void i2c_leader_example_init(void) DEBUGOUT("Successfully initialized and configured i2c leader\n"); } // Configuring RX and TX FIFO thresholds - i2c_status = sl_i2c_driver_configure_fifo_threshold(i2c_instance, TX_FIFO_THRESHOLD, RX_FIFO_THRESHOLD); + i2c_status = sl_i2c_driver_configure_fifo_threshold(i2c_instance, I2C_TX_FIFO_THRESHOLD, I2C_RX_FIFO_THRESHOLD); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_configure_fifo_threshold : Invalid Parameters, Error Code : %u \n", i2c_status); } else { @@ -142,11 +142,11 @@ void i2c_leader_example_init(void) } #endif // Generating a buffer with values that needs to be sent. - for (uint32_t loop = INITIAL_VALUE; loop < SIZE_BUFFERS; loop++) { - write_buffer[loop] = (uint8_t)(loop + ONE); - read_buffer[loop] = INITIAL_VALUE; + for (uint32_t loop = INITIAL_VALUE; loop < I2C_SIZE_BUFFERS; loop++) { + i2c_write_buffer[loop] = (uint8_t)(loop + ONE); + i2c_read_buffer[loop] = INITIAL_VALUE; } - send_data_flag = true; + i2c_send_data_flag = true; } /******************************************************************************* @@ -159,11 +159,11 @@ void i2c_leader_example_process_action(void) // First leader sends data to follower, using I2C send // Then leader receives same data from follower, using I2C receive. switch (current_mode) { - case SEND_DATA: - if (send_data_flag) { + case I2C_SEND_DATA: + if (i2c_send_data_flag) { // Validation for executing the API only once. #if (BLOCKING_APPLICATION) - i2c_status = sl_i2c_driver_send_data_blocking(i2c_instance, FOLLOWER_I2C_ADDR, write_buffer, TX_LENGTH); + i2c_status = sl_i2c_driver_send_data_blocking(i2c_instance, FOLLOWER_I2C_ADDR, i2c_write_buffer, I2C_TX_LENGTH); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_send_data_blocking : Invalid Parameters, " "Error Code : %u \n", @@ -171,21 +171,24 @@ void i2c_leader_example_process_action(void) } #endif #if (NON_BLOCKING_APPLICATION) - i2c_status = - sl_i2c_driver_send_data_non_blocking(i2c_instance, FOLLOWER_I2C_ADDR, write_buffer, TX_LENGTH, &p_dma_config); + i2c_status = sl_i2c_driver_send_data_non_blocking(i2c_instance, + FOLLOWER_I2C_ADDR, + i2c_write_buffer, + I2C_TX_LENGTH, + &p_dma_config); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_send_data_non_blocking : Invalid Parameters, " "Error Code : %u \n", i2c_status); } #endif - send_data_flag = false; + i2c_send_data_flag = false; } // It waits till i2c_transfer_complete is true in callback. if (i2c_transfer_complete) { - receive_data_flag = true; + i2c_receive_data_flag = true; i2c_transfer_complete = false; - current_mode = RECEIVE_DATA; + current_mode = I2C_RECEIVE_DATA; } #if (NON_BLOCKING_APPLICATION) if (i2c_driver_dma_error) { @@ -194,11 +197,12 @@ void i2c_leader_example_process_action(void) } #endif break; - case RECEIVE_DATA: - if (receive_data_flag) { + case I2C_RECEIVE_DATA: + if (i2c_receive_data_flag) { // Validation for executing the API only once. #if (BLOCKING_APPLICATION) - i2c_status = sl_i2c_driver_receive_data_blocking(i2c_instance, FOLLOWER_I2C_ADDR, read_buffer, RX_LENGTH); + i2c_status = + sl_i2c_driver_receive_data_blocking(i2c_instance, FOLLOWER_I2C_ADDR, i2c_read_buffer, I2C_RX_LENGTH); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_receive_data_blocking : Invalid Parameters, Error " "Code : %u \n", @@ -208,8 +212,8 @@ void i2c_leader_example_process_action(void) #if (NON_BLOCKING_APPLICATION) i2c_status = sl_i2c_driver_receive_data_non_blocking(i2c_instance, FOLLOWER_I2C_ADDR, - read_buffer, - RX_LENGTH, + i2c_read_buffer, + I2C_RX_LENGTH, &p_dma_config); if (i2c_status != SL_I2C_SUCCESS) { DEBUGOUT("sl_i2c_driver_receive_data_non_blocking : Invalid Parameters, Error " @@ -217,13 +221,13 @@ void i2c_leader_example_process_action(void) i2c_status); } #endif - receive_data_flag = false; + i2c_receive_data_flag = false; } // It waits till i2c_transfer_complete is true in callback. if (i2c_transfer_complete) { - send_data_flag = true; + i2c_send_data_flag = true; i2c_transfer_complete = false; - current_mode = TRANSMISSION_COMPLETED; + current_mode = I2C_TRANSMISSION_COMPLETED; // After the receive is completed, input and output data is compared and // output is printed on console. compare_data(); @@ -235,7 +239,7 @@ void i2c_leader_example_process_action(void) } #endif break; - case TRANSMISSION_COMPLETED: + case I2C_TRANSMISSION_COMPLETED: // De-initializing i2c instance and unregistering callback i2c_status = sl_i2c_driver_deinit(i2c_instance); if (i2c_status != SL_I2C_SUCCESS) { @@ -257,14 +261,14 @@ void i2c_leader_example_process_action(void) static void compare_data(void) { uint32_t data_index = 0; - for (data_index = 0; data_index < SIZE_BUFFERS; data_index++) { - // If the read_buffer and buffer are same, it will be continued else, the + for (data_index = 0; data_index < I2C_SIZE_BUFFERS; data_index++) { + // If the i2c_read_buffer and buffer are same, it will be continued else, the // for loop will be break. - if (write_buffer[data_index] != read_buffer[data_index]) { + if (i2c_write_buffer[data_index] != i2c_read_buffer[data_index]) { break; } } - if (data_index == SIZE_BUFFERS) { + if (data_index == I2C_SIZE_BUFFERS) { DEBUGOUT("Leader-Follower read-write Data comparison is successful, Test " "Case Passed \n"); } else { diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/readme.md b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/readme.md index aca1b799..0fe45d70 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/readme.md @@ -47,12 +47,12 @@ - It also initializes DMA, if transfer type is 'Using DMA'. - Now transmit and receive FIFO threshold values are configured using \ref sl_i2c_driver_configure_fifo_threshold API. - Now write_buffer is filled with some data which needs to be sent to the follower. -- Current_mode enum is set to SEND_DATA and it calls send_data API to send data to follower & configures follower address through \ref sl_i2c_driver_send_data_blocking (for blocking Application) or through \ref sl_i2c_driver_send_data_non_blocking (for Non-blocking Application). +- Current_mode enum is set to I2C_SEND_DATA and it calls send_data API to send data to follower & configures follower address through \ref sl_i2c_driver_send_data_blocking (for blocking Application) or through \ref sl_i2c_driver_send_data_non_blocking (for Non-blocking Application). - After that it will wait till all the data is transferred to the follower device. -- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to RECEIVE_DATA. +- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to I2C_RECEIVE_DATA. - Then it receives data from follower through \ref sl_i2c_driver_receive_data_blocking (for blocking Application) or through \ref sl_i2c_driver_receive_data_non_blocking (for Non-blocking Application). - After calling receive_data, it will wait till all the data is received from the follower device. -- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to TRANSMISSION_COMPLETED. +- Once the i2c callback function sets transfer_complete flag, it changes current_mode enum to I2C_TRANSMISSION_COMPLETED. - Now it compares the data which is received from the follower device to the data which it has sent. - If the data is same, it will print Test Case Passed on the console. @@ -95,7 +95,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Application Configuration Parameters - Open sl_si91x_i2c_driver_leader.slcp project file select software component tab and search for i2c in search bar. -- Click on **I2C0** and configure the I2C0 instance as per configuration parameters given in wizard. +- Click on **I2C2** and configure the I2C2 instance as per configuration parameters given in wizard. - For using any other I2C instance user has to add that I2C instance by clicking on **I2C Instance** from configuration wizard and then clicking on **Add New Instance** - For creating I2C instances write 'I2C0', 'I2C1' or 'I2C2' on the wizard for respective instance and then click on **Done** - After creation of instances separate configuration files are get generated in **config folder**. @@ -111,10 +111,10 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise #define BLOCKING_APPLICATION // Enable it for enabling I2C transfer using interrupt Application #define NON_BLOCKING_APPLICATION // Enable it for enabling I2C transfer using interrupt Application #define FOLLOWER_I2C_ADDR // Update I2C follower address - #define SIZE_BUFFERS // To change the number of bytes to send and receive.Its value should be less than maximum buffer size macro value. + #define I2C_SIZE_BUFFERS // To change the number of bytes to send and receive.Its value should be less than maximum buffer size macro value. ``` -> **Note:** Enable either BLOCKING application or NON-BLOCKING application macro, at a time. Change the value of following macros in path: /$project/config/RTE_Device_917.h +> **Note:** Enable either BLOCKING application or NON-BLOCKING application macro, at a time. For I2C0 instance change the value of following macros in path: /$project/config/RTE_Device_917.h ```c #define RTE_I2C0_SCL_PORT_ID 0 // SCL pin port id @@ -123,6 +123,8 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise > **Note:** After above configurations connect SCL and SDA pins of Leader and follower then run the application and observe the results by connecting SDA and SCL pins to logic Analyzer(Also enable glitch filter for SCL channel with time period 100ns, to avoid glitches). +- For getting proper speeds with fast and fast plus modes, please use external pullup of around 1.8K +- For high speed mode data transfer external pullup is must. - Configure the UC as mentioned below. ![Figure: Introduction](resources/uc_screen/i2c_uc_screen.png) @@ -159,11 +161,11 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: 1. Compile and run the application. -2. Connect SCL(GPIO_7) and SDA(GPIO_6) pins with the follower device. +2. Connect SCL(ULP_GPIO_7) and SDA(ULP_GPIO_6) pins with the follower device. 3. When the application runs, it receives and send data. 4. After the transfer is completed, it validates the data and prints "Test Case Passed" on the console. 5. Will get "Test Case Passed" print on console. 6. Connect Analyzer channels to respective I2C instance SDA & SCA pins to observe the data on lines. 7. After successful program execution the prints in serial console looks as shown below. - ![Figure: Introduction](resources/readme/output.png) + ![Figure: Output](resources/readme/output.png) diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/resources/uc_screen/i2c_uc_screen.png b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/resources/uc_screen/i2c_uc_screen.png index b8fbc56e..13ce2f7f 100644 Binary files a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/resources/uc_screen/i2c_uc_screen.png and b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/resources/uc_screen/i2c_uc_screen.png differ diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/sl_si91x_i2c_driver_leader.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/sl_si91x_i2c_driver_leader.slcp index ad4680f7..d9ea475d 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/sl_si91x_i2c_driver_leader.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_driver_leader/sl_si91x_i2c_driver_leader.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -34,10 +34,7 @@ component: - id: i2c_instance from: wiseconnect3_sdk instance: - - i2c0 -define: - - name: SL_SI91X_DMA - - name: SL_SI91X_I2C_DMA + - i2c2 other_file: - path: resources/readme/setupdiagram.png - path: resources/readme/image507d.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/i2c_follower_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/i2c_follower_example.c index dcadd408..47f081cf 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/i2c_follower_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/i2c_follower_example.c @@ -43,15 +43,19 @@ #define ULP_GPIO_SDA 10 // SDA ULP GPIO Pin number #define ULP_GPIO_SCL 11 // SCL ULP GPIO Pin number #define INTERNAL_PULLUP 1 // Internal Pull-up enable -#define I2C_INSTANCE 0 // I2C Instance for Pin configuration -#define I2C I2C0 // I2C Instance +#define I2C_INSTANCE 2 // I2C Instance for Pin configuration +#define I2C I2C2 // I2C Instance #define MAX_7BIT_ADDRESS 127 // Maximum 7-bit address #define REFERENCE_CLOCK_FREQUENCY (32000000u) // Reference clock frequency #define HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY (40000000u) // High speed mode reference clock frequency #define I2C_STANDARD_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c standard mode #define I2C_FAST_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c Fast mode #define I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c fast plus mode -#define I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c high speed mode +#define I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY (180000000u) // clock frequency for i2c high speed mode +#define ULP_CLOCK_DIV_FACTOR 0 // division factor value for ULP clock +#define ULP_PRO_CLOCK_DIV_FACTOR 0 // division factor value for ULP pro clock +#define EVEN_DIVISION_FACTOR 0 // ulp clock division factor type +#define DELAY_DISABLE 0 // to disable delay function callback for ulp pro clock /******************************************************************************* ****************************** Data Types *********************************** ******************************************************************************/ @@ -74,22 +78,16 @@ typedef enum { *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ #if (I2C_INSTANCE == 0) -// SCL, GPIO: 75, Exapansion Header: 5 -// SDA, GPIO: 74, Exapansion Header: 3 static I2C_PIN scl = { RTE_I2C0_SCL_PORT, RTE_I2C0_SCL_PIN, RTE_I2C0_SCL_MUX, RTE_I2C0_SCL_PAD }; static I2C_PIN sda = { RTE_I2C0_SDA_PORT, RTE_I2C0_SDA_PIN, RTE_I2C0_SDA_MUX, RTE_I2C0_SDA_PAD }; #endif #if (I2C_INSTANCE == 1) -// SCL, GPIO: 50, Board Pin: P19 -// SDA, GPIO: 51, Board Pin: P20 static I2C_PIN scl = { RTE_I2C1_SCL_PORT, RTE_I2C1_SCL_PIN, RTE_I2C1_SCL_MUX, RTE_I2C1_SCL_PAD }; static I2C_PIN sda = { RTE_I2C1_SDA_PORT, RTE_I2C1_SDA_PIN, RTE_I2C1_SDA_MUX, RTE_I2C1_SDA_PAD }; #endif #if (I2C_INSTANCE == 2) -// SCL, ULP_GPIO: 5, Exapansion Header: 13 -// SDA, ULP_GPIO: 4, Exapansion Header: 11 static I2C_PIN scl = { RTE_I2C2_SCL_PORT, RTE_I2C2_SCL_PIN, RTE_I2C2_SCL_MUX, 0 }; static I2C_PIN sda = { RTE_I2C2_SDA_PORT, RTE_I2C2_SDA_PIN, RTE_I2C2_SDA_MUX, 0 }; #endif @@ -146,14 +144,24 @@ void i2c_follower_example_init(void) if (config.clhr == SL_I2C_FAST_PLUS_BUS_SPEED) { RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); RSI_CLK_SetSocPllFreq(M4CLK, I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY, REFERENCE_CLOCK_FREQUENCY); - RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); - config.freq = I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY; + RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0); + if (I2C == I2C2) { + RSI_ULPSS_ClockConfig(M4CLK, ENABLE, ULP_CLOCK_DIV_FACTOR, EVEN_DIVISION_FACTOR); + RSI_ULPSS_UlpProcClkConfig(ULPCLK, ULP_PROC_SOC_CLK, ULP_PRO_CLOCK_DIV_FACTOR, DELAY_DISABLE); + DEBUGINIT(); + } + config.freq = sl_si91x_i2c_get_frequency(I2C); } if (config.clhr == SL_I2C_HIGH_BUS_SPEED) { RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); RSI_CLK_SetSocPllFreq(M4CLK, I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY, HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY); RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0); - config.freq = I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY; + if (I2C == I2C2) { + RSI_ULPSS_ClockConfig(M4CLK, ENABLE, ULP_CLOCK_DIV_FACTOR, EVEN_DIVISION_FACTOR); + RSI_ULPSS_UlpProcClkConfig(ULPCLK, ULP_PROC_SOC_CLK, ULP_PRO_CLOCK_DIV_FACTOR, DELAY_DISABLE); + DEBUGINIT(); + } + config.freq = sl_si91x_i2c_get_frequency(I2C); } config.mode = SL_I2C_FOLLOWER_MODE; // Passing the structure and i2c instance for the initialization. @@ -807,4 +815,4 @@ void I2C2_IRQHandler(void) sl_si91x_i2c_clear_interrupts(I2C2, SL_I2C_EVENT_RESTART_DET); return; } -} +} \ No newline at end of file diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/readme.md b/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/readme.md index a8b48884..e53bee46 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/readme.md @@ -103,8 +103,8 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Configure the following macros in i2c_follower_example.c file and update/modify following macros if required. ```C - #define I2C_INSTANCE 0 // I2C Instance for Pin configuration - #define I2C I2C0 // I2C Instance + #define I2C_INSTANCE 2 // I2C Instance for Pin configuration + #define I2C I2C2 // I2C Instance ``` - `Available Configurations`: Apart from I2C0, other configurations are given below. @@ -112,11 +112,11 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ```C #define I2C_INSTANCE 1 // I2C Instance for Pin configuration #define I2C I2C1 // I2C Instance - #define I2C_INSTANCE 2 // I2C Instance for Pin configuration - #define I2C I2C2 // I2C Instance + #define I2C_INSTANCE 0 // I2C Instance for Pin configuration + #define I2C I2C0 // I2C Instance ``` -- Change the value of following macros in config/RTE_Device_917.h +- Change the value of following macros in config/RTE_Device_917.h for I2C0 ```c #define RTE_I2C0_SCL_PORT_ID 0 // SCL pin port id @@ -155,10 +155,10 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: 1. Compile and run the application. -2. Connect GPIO_6(P19) and GPIO_7(P20) with the leader device. in the case of I2C0. +2. Connect ULP_GPIO_6 and ULP_GPIO_7 with the leader device for I2C2. 3. When the application runs, it receives and sends data. 4. After the transfer is completed, it validates the data and prints on the console. 5. Will get "Test Case Pass" print on console. 6. After successful program execution the prints in serial console looks as shown below. - ![Figure: Introduction](resources/readme/output.png) \ No newline at end of file + ![Figure: Output](resources/readme/output.png) \ No newline at end of file diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/sl_si91x_i2c_follower.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/sl_si91x_i2c_follower.slcp index 029f0f36..9a236d7e 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/sl_si91x_i2c_follower.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_follower/sl_si91x_i2c_follower.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/i2c_leader_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/i2c_leader_example.c index fb9a156f..289f882f 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/i2c_leader_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/i2c_leader_example.c @@ -1,5 +1,5 @@ /***************************************************************************/ /** - * @file i2c_example.c + * @file i2c_leader_example.c * @brief I2C examples functions ******************************************************************************* * # License @@ -40,8 +40,8 @@ #define BIT_SET 1 // Set bit #define STOP_BIT 9 // Bit to send stop command #define RW_MASK_BIT 8 // Bit to mask read and write -#define I2C_INSTANCE 0 // I2C Instance for Pin configuration -#define I2C I2C0 // I2C Instance +#define I2C_INSTANCE 2 // I2C Instance for Pin configuration +#define I2C I2C2 // I2C Instance #define MAX_7BIT_ADDRESS 127 // Maximum 7-bit address #define REFERENCE_CLOCK_FREQUENCY (32000000u) // Reference clock frequency #define HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY (40000000u) // Reference clock frequency @@ -49,6 +49,10 @@ #define I2C_FAST_MODE_CLOCK_FREQUENCY (32000000u) // clock frequency for i2c Fast mode #define I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c fast plus mode #define I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY (80000000u) // clock frequency for i2c high speed mode +#define ULP_CLOCK_DIV_FACTOR 0 // division factor value for ULP clock +#define ULP_PRO_CLOCK_DIV_FACTOR 0 // division factor value for ULP pro clock +#define EVEN_DIVISION_FACTOR 0 // ulp clock division factor type +#define DELAY_DISABLE 0 // to disable delay function callback for ulp pro clock /******************************************************************************* ****************************** Data Types *********************************** ******************************************************************************/ @@ -71,22 +75,16 @@ typedef enum { *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ #if (I2C_INSTANCE == 0) -// SCL, GPIO: 75, Exapansion Header: 5 -// SDA, GPIO: 75, Exapansion Header: 3 static I2C_PIN scl = { RTE_I2C0_SCL_PORT, RTE_I2C0_SCL_PIN, RTE_I2C0_SCL_MUX, RTE_I2C0_SCL_PAD }; static I2C_PIN sda = { RTE_I2C0_SDA_PORT, RTE_I2C0_SDA_PIN, RTE_I2C0_SDA_MUX, RTE_I2C0_SDA_PAD }; #endif #if (I2C_INSTANCE == 1) -// SCL, GPIO: 50, Board Pin: P19 -// SDA, GPIO: 51, Board Pin: P20 static I2C_PIN scl = { RTE_I2C1_SCL_PORT, RTE_I2C1_SCL_PIN, RTE_I2C1_SCL_MUX, RTE_I2C1_SCL_PAD }; static I2C_PIN sda = { RTE_I2C1_SDA_PORT, RTE_I2C1_SDA_PIN, RTE_I2C1_SDA_MUX, RTE_I2C1_SDA_PAD }; #endif #if (I2C_INSTANCE == 2) -// SCL, ULP_GPIO: 5, Exapansion Header: 13 -// SDA, ULP_GPIO: 4, Exapansion Header: 11 static I2C_PIN scl = { RTE_I2C2_SCL_PORT, RTE_I2C2_SCL_PIN, RTE_I2C2_SCL_MUX, 0 }; static I2C_PIN sda = { RTE_I2C2_SDA_PORT, RTE_I2C2_SDA_PIN, RTE_I2C2_SDA_MUX, 0 }; #endif @@ -143,14 +141,24 @@ void i2c_leader_example_init(void) if (config.clhr == SL_I2C_FAST_PLUS_BUS_SPEED) { RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); RSI_CLK_SetSocPllFreq(M4CLK, I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY, REFERENCE_CLOCK_FREQUENCY); - RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); - config.freq = I2C_FAST_PLUS_MODE_CLOCK_FREQUENCY; + RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0); + if (I2C == I2C2) { + RSI_ULPSS_ClockConfig(M4CLK, ENABLE, ULP_CLOCK_DIV_FACTOR, EVEN_DIVISION_FACTOR); + RSI_ULPSS_UlpProcClkConfig(ULPCLK, ULP_PROC_SOC_CLK, ULP_PRO_CLOCK_DIV_FACTOR, DELAY_DISABLE); + DEBUGINIT(); + } + config.freq = sl_si91x_i2c_get_frequency(I2C); } if (config.clhr == SL_I2C_HIGH_BUS_SPEED) { RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0); RSI_CLK_SetSocPllFreq(M4CLK, I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY, HIGH_SPEED_REFERENCE_CLOCK_FREQUENCY); RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0); - config.freq = I2C_HIGH_SPEED_MODE_CLOCK_FREQUENCY; + if (I2C == I2C2) { + RSI_ULPSS_ClockConfig(M4CLK, ENABLE, ULP_CLOCK_DIV_FACTOR, EVEN_DIVISION_FACTOR); + RSI_ULPSS_UlpProcClkConfig(ULPCLK, ULP_PROC_SOC_CLK, ULP_PRO_CLOCK_DIV_FACTOR, DELAY_DISABLE); + DEBUGINIT(); + } + config.freq = sl_si91x_i2c_get_frequency(I2C); } config.mode = SL_I2C_LEADER_MODE; // Passing the structure and i2c instance for the initialization. @@ -836,4 +844,4 @@ void I2C2_IRQHandler(void) sl_si91x_i2c_clear_interrupts(I2C2, SL_I2C_EVENT_RESTART_DET); return; } -} +} \ No newline at end of file diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/readme.md b/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/readme.md index eda2016d..474663ec 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/readme.md @@ -95,8 +95,8 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Configure the following macros in i2c_leader_example.c file and update/modify following macros if required. ```C - #define I2C_INSTANCE 0 // I2C Instance for Pin configuration - #define I2C I2C0 // I2C Instance + #define I2C_INSTANCE 2 // I2C Instance for Pin configuration + #define I2C I2C2 // I2C Instance ``` - `Available Configurations`: Apart from I2C0, other configurations are given below. @@ -104,8 +104,8 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ```C #define I2C_INSTANCE 1 // I2C Instance for Pin configuration #define I2C I2C1 // I2C Instance - #define I2C_INSTANCE 2 // I2C Instance for Pin configuration - #define I2C I2C2 // I2C Instance + #define I2C_INSTANCE 0 // I2C Instance for Pin configuration + #define I2C I2C0 // I2C Instance ``` - Change the value of following macros in config/RTE_Device_917.h @@ -114,6 +114,8 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise #define RTE_I2C0_SCL_PORT_ID 0 // SCL pin port id #define RTE_I2C0_SDA_PORT_ID 0 //SDA pin port id ``` +- For getting proper speeds with fast and fast plus modes, please use external pullup of around 1.8K +- For high speed mode data transfer external pullup is must. ### Pin Configuration @@ -147,11 +149,11 @@ Follow the steps below for successful execution of the application: ## Test the Application 1. Compile and run the application. -2. Connect GPIO_6 and GPIO_7 with the follower device. in the case of I2C0. +2. Connect ULP_GPIO_6 and ULP_GPIO_7 with the follower device for I2C2 3. When the application runs, it sends and receives data. 4. After the transfer is completed, it validates the data and prints on the console. 5. Will get "Test Case Pass" print on console. 6. Both write and read 15 bytes of data should be same. 7. After successful program execution the prints in serial console looks as shown below. - ![Figure: Introduction](resources/readme/output.png) + ![Figure: Output](resources/readme/output.png) diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/sl_si91x_i2c_leader.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/sl_si91x_i2c_leader.slcp index 416945dc..b786ad6a 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/sl_si91x_i2c_leader.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2c_leader/sl_si91x_i2c_leader.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/i2s_loopback_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/i2s_loopback_example.c index ce7731ae..cea3e911 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/i2s_loopback_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/i2s_loopback_example.c @@ -25,17 +25,17 @@ ******************************************************************************/ #define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ #define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz -#define BUFFER_SIZE 1024 // Transmit/Receive buffer size +#define I2S_BUFFER_SIZE 1024 // Transmit/Receive buffer size #define I2S_INSTANCE 0 // I2S instance /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -uint16_t data_in[BUFFER_SIZE]; -uint16_t data_out[BUFFER_SIZE]; +uint16_t i2s_data_in[I2S_BUFFER_SIZE]; +uint16_t i2s_data_out[I2S_BUFFER_SIZE]; static sl_i2s_handle_t i2s_driver_handle = NULL; -static uint8_t send_complete = 0; -static uint8_t receive_complete = 0; +static uint8_t i2s_send_complete = 0; +static uint8_t i2s_receive_complete = 0; static sl_i2s_xfer_config_t i2s_xfer_config = { 0 }; /******************************************************************************* @@ -63,8 +63,8 @@ void i2s_example_init(void) i2s_xfer_config.data_size = SL_I2S_DATA_SIZE32; // Filling the data out array with integer values - for (uint32_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = i; + for (uint32_t i = 0; i < I2S_BUFFER_SIZE; i++) { + i2s_data_out[i] = i; } do { //Fetch I2S driver version @@ -121,13 +121,13 @@ void i2s_example_init(void) } DEBUGOUT("I2S receive config success\r\n"); //Configure I2S receive DMA channel - if (sl_si91x_i2s_receive_data(i2s_driver_handle, data_in, BUFFER_SIZE)) { + if (sl_si91x_i2s_receive_data(i2s_driver_handle, i2s_data_in, I2S_BUFFER_SIZE)) { DEBUGOUT("I2S receive start fail\r\n"); break; } DEBUGOUT("I2S receive start success\r\n"); //Configure I2S transmit DMA channel - if (sl_si91x_i2s_transmit_data(i2s_driver_handle, data_out, BUFFER_SIZE)) { + if (sl_si91x_i2s_transmit_data(i2s_driver_handle, i2s_data_out, I2S_BUFFER_SIZE)) { DEBUGOUT("I2S transmit start fail\r\n"); break; } @@ -139,19 +139,19 @@ void i2s_example_init(void) ******************************************************************************/ void i2s_example_process_action(void) { - if ((send_complete && receive_complete)) { + if ((i2s_send_complete && i2s_receive_complete)) { //Data has been transferred and received successfully //Validate the transmit and receive data count - if ((sl_si91x_i2s_get_transmit_data_count(i2s_driver_handle) == BUFFER_SIZE) - && (sl_si91x_i2s_get_receive_data_count(i2s_driver_handle) == BUFFER_SIZE)) { + if ((sl_si91x_i2s_get_transmit_data_count(i2s_driver_handle) == I2S_BUFFER_SIZE) + && (sl_si91x_i2s_get_receive_data_count(i2s_driver_handle) == I2S_BUFFER_SIZE)) { //I2S transfer completed DEBUGOUT("I2S transfer complete\r\n"); //Compare transmit data and receive data compare_loop_back_data(); } //reset send and receive complete status flags - send_complete = 0; - receive_complete = 0; + i2s_send_complete = 0; + i2s_receive_complete = 0; } } @@ -196,14 +196,14 @@ static int32_t clock_configuration_pll(void) static void compare_loop_back_data(void) { uint16_t data_index = 0; - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { + for (data_index = 0; data_index < I2S_BUFFER_SIZE; data_index++) { // If the data in and data out are same, it will be continued else, the for // loop will be break. - if (data_in[data_index] != data_out[data_index]) { + if (i2s_data_in[data_index] != i2s_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == I2S_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); @@ -221,10 +221,10 @@ static void callback_event(uint32_t event) { switch (event) { case SL_I2S_SEND_COMPLETE: - send_complete = 1; + i2s_send_complete = 1; break; case SL_I2S_RECEIVE_COMPLETE: - receive_complete = 1; + i2s_receive_complete = 1; break; case SL_I2S_TX_UNDERFLOW: break; diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/sl_si91x_i2s_loopback.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/sl_si91x_i2s_loopback.slcp index f2271c26..4ab672a0 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/sl_si91x_i2s_loopback.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_loopback/sl_si91x_i2s_loopback.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -27,8 +27,6 @@ component: from: wiseconnect3_sdk - id: sl_i2s from: wiseconnect3_sdk - - id: sl_dma - from: wiseconnect3_sdk define: - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - name: SYSCALLS_WRITE diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/i2s_lowpower_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/i2s_lowpower_example.c index 0ac04a96..8772336d 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/i2s_lowpower_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/i2s_lowpower_example.c @@ -23,23 +23,23 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ -#define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz -#define BUFFER_SIZE 1024 // Transmit/Receive buffer size -#define I2S_INSTANCE 1 // I2S instance -#define ULP_BANK_OFFSET 0x800 -#define TX_BUF_MEMORY (ULP_SRAM_START_ADDR + (1 * ULP_BANK_OFFSET)) -#define RX_BUF_MEMORY (ULP_SRAM_START_ADDR + (2 * ULP_BANK_OFFSET)) +#define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ +#define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz +#define I2S_LOWPOWER_BUFFER_SIZE 1024 // Transmit/Receive buffer size +#define I2S_INSTANCE 1 // I2S instance +#define ULP_BANK_OFFSET 0x800 +#define TX_BUF_MEMORY (ULP_SRAM_START_ADDR + (1 * ULP_BANK_OFFSET)) +#define RX_BUF_MEMORY (ULP_SRAM_START_ADDR + (2 * ULP_BANK_OFFSET)) /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -uint8_t data_in[BUFFER_SIZE]; -uint8_t data_out[BUFFER_SIZE]; -static sl_i2s_handle_t i2s_driver_handle = NULL; -static uint8_t send_complete = 0; -static uint8_t receive_complete = 0; -static sl_i2s_xfer_config_t i2s_xfer_config = { 0 }; +uint8_t i2s_lowpower_data_in[I2S_LOWPOWER_BUFFER_SIZE]; +uint8_t i2s_lowpower_data_out[I2S_LOWPOWER_BUFFER_SIZE]; +static sl_i2s_handle_t i2s_driver_handle = NULL; +static uint8_t i2s_lowpower_send_complete = 0; +static uint8_t i2s_lowpower_receive_complete = 0; +static sl_i2s_xfer_config_t i2s_xfer_config = { 0 }; /******************************************************************************* ********************** Local Function prototypes *************************** @@ -55,8 +55,6 @@ static void compare_loop_back_data(void); void i2s_lowpower_example_init(void) { sl_status_t status; - sl_i2s_version_t i2s_version; - sl_i2s_status_t i2s_status; //Initialize I2S transfer structure i2s_xfer_config.mode = SL_I2S_MASTER; i2s_xfer_config.protocol = SL_I2S_PROTOCOL; i2s_xfer_config.resolution = SL_I2S_RESOLUTION; @@ -68,10 +66,10 @@ void i2s_lowpower_example_init(void) DEBUGINIT(); // Filling the data out array with integer values - for (uint32_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = i; + for (uint32_t i = 0; i < I2S_LOWPOWER_BUFFER_SIZE; i++) { + i2s_lowpower_data_out[i] = i; } - memcpy((uint8_t *)TX_BUF_MEMORY, data_out, BUFFER_SIZE); + memcpy((uint8_t *)TX_BUF_MEMORY, i2s_lowpower_data_out, I2S_LOWPOWER_BUFFER_SIZE); do { //Initialize I2S peripheral and store driver handle in i2s_driver_handle status = sl_si91x_i2s_init(I2S_INSTANCE, &i2s_driver_handle); @@ -109,13 +107,13 @@ void i2s_lowpower_example_init(void) } DEBUGOUT("I2S receive config success\r\n"); //Configure I2S receive DMA channel - if (sl_si91x_i2s_receive_data(i2s_driver_handle, (uint8_t *)RX_BUF_MEMORY, BUFFER_SIZE)) { + if (sl_si91x_i2s_receive_data(i2s_driver_handle, (uint8_t *)RX_BUF_MEMORY, I2S_LOWPOWER_BUFFER_SIZE)) { DEBUGOUT("I2S receive start fail\r\n"); break; } DEBUGOUT("I2S receive start success\r\n"); //Configure I2S transmit DMA channel - if (sl_si91x_i2s_transmit_data(i2s_driver_handle, (uint8_t *)TX_BUF_MEMORY, BUFFER_SIZE)) { + if (sl_si91x_i2s_transmit_data(i2s_driver_handle, (uint8_t *)TX_BUF_MEMORY, I2S_LOWPOWER_BUFFER_SIZE)) { DEBUGOUT("I2S transmit start fail\r\n"); break; } @@ -127,20 +125,20 @@ void i2s_lowpower_example_init(void) ******************************************************************************/ void i2s_lowpower_example_process_action(void) { - if ((send_complete && receive_complete)) { - memcpy(data_in, (uint8_t *)RX_BUF_MEMORY, BUFFER_SIZE); + if ((i2s_lowpower_send_complete && i2s_lowpower_receive_complete)) { + memcpy(i2s_lowpower_data_in, (uint8_t *)RX_BUF_MEMORY, I2S_LOWPOWER_BUFFER_SIZE); //Data has been transferred and received successfully //Validate the transmit and receive data count - if ((sl_si91x_i2s_get_transmit_data_count(i2s_driver_handle) == BUFFER_SIZE) - && (sl_si91x_i2s_get_receive_data_count(i2s_driver_handle) == BUFFER_SIZE)) { + if ((sl_si91x_i2s_get_transmit_data_count(i2s_driver_handle) == I2S_LOWPOWER_BUFFER_SIZE) + && (sl_si91x_i2s_get_receive_data_count(i2s_driver_handle) == I2S_LOWPOWER_BUFFER_SIZE)) { //I2S transfer completed DEBUGOUT("I2S transfer complete\r\n"); //Compare transmit data and receive data compare_loop_back_data(); } //reset send and receive complete status flags - send_complete = 0; - receive_complete = 0; + i2s_lowpower_send_complete = 0; + i2s_lowpower_receive_complete = 0; } } @@ -154,14 +152,14 @@ void i2s_lowpower_example_process_action(void) static void compare_loop_back_data(void) { uint16_t data_index = 0; - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { + for (data_index = 0; data_index < I2S_LOWPOWER_BUFFER_SIZE; data_index++) { // If the data in and data out are same, it will be continued else, the for // loop will be break. - if (data_in[data_index] != data_out[data_index]) { + if (i2s_lowpower_data_in[data_index] != i2s_lowpower_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == I2S_LOWPOWER_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); @@ -179,10 +177,10 @@ static void callback_event(uint32_t event) { switch (event) { case SL_I2S_SEND_COMPLETE: - send_complete = 1; + i2s_lowpower_send_complete = 1; break; case SL_I2S_RECEIVE_COMPLETE: - receive_complete = 1; + i2s_lowpower_receive_complete = 1; break; case SL_I2S_TX_UNDERFLOW: break; diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/sl_si91x_i2s_low_power.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/sl_si91x_i2s_low_power.slcp index 2fc4e1cd..235222db 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/sl_si91x_i2s_low_power.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_low_power/sl_si91x_i2s_low_power.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -28,8 +28,6 @@ component: from: wiseconnect3_sdk - id: sl_i2s from: wiseconnect3_sdk - - id: sl_dma - from: wiseconnect3_sdk requires: - name: ulp_mode_execution define: diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/i2s_primary_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/i2s_primary_example.c index d5e4c86e..9dac272a 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/i2s_primary_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/i2s_primary_example.c @@ -23,19 +23,19 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ -#define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz -#define BUFFER_SIZE 1024 // Transmit/Receive buffer size -#define I2S_INSTANCE 0 // I2S instance +#define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ +#define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz +#define I2S_PRIMARY_BUFFER_SIZE 1024 // Transmit/Receive buffer size +#define I2S_INSTANCE 0 // I2S instance /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -uint16_t data_in[BUFFER_SIZE]; -uint16_t data_out[BUFFER_SIZE]; +uint16_t i2s_primary_data_in[I2S_PRIMARY_BUFFER_SIZE]; +uint16_t i2s_primary_data_out[I2S_PRIMARY_BUFFER_SIZE]; static sl_i2s_handle_t i2s_driver_handle = NULL; -static uint8_t send_complete = 0; -static uint8_t receive_complete = 0; +static uint8_t i2s_primary_send_complete = 0; +static uint8_t i2s_primary_receive_complete = 0; static sl_i2s_xfer_config_t i2s_xfer_config = { 0 }; typedef enum { SEND_DATA, RECEIVE_DATA, WAIT_STATE, INVALID_STATE } transfer_state_t; @@ -55,11 +55,10 @@ void i2s_example_init(void) { sl_status_t status; sl_i2s_version_t i2s_version; - sl_i2s_status_t i2s_status; // Filling the data out array with integer values - for (uint32_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = i; + for (uint32_t i = 0; i < I2S_PRIMARY_BUFFER_SIZE; i++) { + i2s_primary_data_out[i] = i; } do { //Fetch I2S driver version @@ -125,7 +124,7 @@ void i2s_example_process_action(void) DEBUGOUT("I2S transmit config success\r\n"); } //Configure I2S transmit DMA channel - if (sl_si91x_i2s_transmit_data(i2s_driver_handle, data_out, BUFFER_SIZE)) { + if (sl_si91x_i2s_transmit_data(i2s_driver_handle, i2s_primary_data_out, I2S_PRIMARY_BUFFER_SIZE)) { DEBUGOUT("I2S transmit start fail\r\n"); state = INVALID_STATE; break; @@ -155,7 +154,7 @@ void i2s_example_process_action(void) DEBUGOUT("I2S receive config success\r\n"); } //Configure I2S receive DMA channel - if (sl_si91x_i2s_receive_data(i2s_driver_handle, data_in, BUFFER_SIZE)) { + if (sl_si91x_i2s_receive_data(i2s_driver_handle, i2s_primary_data_in, I2S_PRIMARY_BUFFER_SIZE)) { DEBUGOUT("I2S receive start fail\r\n"); state = INVALID_STATE; break; @@ -167,16 +166,16 @@ void i2s_example_process_action(void) break; case WAIT_STATE: - if (send_complete) { + if (i2s_primary_send_complete) { DEBUGOUT("Data send successfully\r\n"); - send_complete = 0; - state = RECEIVE_DATA; + i2s_primary_send_complete = 0; + state = RECEIVE_DATA; sl_si91x_i2s_end_transfer(i2s_driver_handle, SL_I2S_SEND_ABORT); } - if (receive_complete) { + if (i2s_primary_receive_complete) { DEBUGOUT("Data received successfully\r\n"); compare_loop_back_data(); - receive_complete = 0; + i2s_primary_receive_complete = 0; } break; @@ -226,14 +225,14 @@ static int32_t clock_configuration_pll(void) static void compare_loop_back_data(void) { uint16_t data_index = 0; - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { + for (data_index = 0; data_index < I2S_PRIMARY_BUFFER_SIZE; data_index++) { // If the data in and data out are same, it will be continued else, the for // loop will be break. - if (data_in[data_index] != data_out[data_index]) { + if (i2s_primary_data_in[data_index] != i2s_primary_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == I2S_PRIMARY_BUFFER_SIZE) { DEBUGOUT("Data comparison successful\n"); } else { DEBUGOUT("Data comparison failed\n"); @@ -251,10 +250,10 @@ static void callback_event(uint32_t event) { switch (event) { case SL_I2S_SEND_COMPLETE: - send_complete = 1; + i2s_primary_send_complete = 1; break; case SL_I2S_RECEIVE_COMPLETE: - receive_complete = 1; + i2s_primary_receive_complete = 1; break; case SL_I2S_TX_UNDERFLOW: break; diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/sl_si91x_i2s_primary.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/sl_si91x_i2s_primary.slcp index 32d2790c..eec5b23b 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/sl_si91x_i2s_primary.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_primary/sl_si91x_i2s_primary.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -27,8 +27,6 @@ component: from: wiseconnect3_sdk - id: sl_i2s from: wiseconnect3_sdk - - id: sl_dma - from: wiseconnect3_sdk define: - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - name: SYSCALLS_WRITE diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/i2s_secondary_example.c b/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/i2s_secondary_example.c index acdfdfc6..dad8fb6d 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/i2s_secondary_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/i2s_secondary_example.c @@ -23,20 +23,20 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ -#define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz -#define BUFFER_SIZE 1024 // Transmit/Receive buffer size -#define I2S_INSTANCE 0 // I2S instance +#define SOC_PLL_REF_FREQUENCY 40000000 // PLL input REFERENCE clock 40MHZ +#define PS4_SOC_FREQ 180000000 // PLL out clock 180MHz +#define I2S_SECONDARY_BUFFER_SIZE 1024 // Transmit/Receive buffer size +#define I2S_INSTANCE 0 // I2S instance /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -uint16_t data_in[BUFFER_SIZE]; -uint16_t data_out[BUFFER_SIZE]; -static sl_i2s_handle_t i2s_driver_handle = NULL; -static uint8_t send_complete = 0; -static uint8_t receive_complete = 0; -static sl_i2s_xfer_config_t i2s_xfer_config = { 0 }; +uint16_t i2s_secondary_data_in[I2S_SECONDARY_BUFFER_SIZE]; +uint16_t i2s_secondary_data_out[I2S_SECONDARY_BUFFER_SIZE]; +static sl_i2s_handle_t i2s_driver_handle = NULL; +static uint8_t i2s_secondary_send_complete = 0; +static uint8_t i2s_secondary_receive_complete = 0; +static sl_i2s_xfer_config_t i2s_xfer_config = { 0 }; typedef enum { SEND_DATA, RECEIVE_DATA, WAIT_STATE, INVALID_STATE } transfer_state_t; /******************************************************************************* @@ -55,11 +55,10 @@ void i2s_example_init(void) { sl_status_t status; sl_i2s_version_t i2s_version; - sl_i2s_status_t i2s_status; // Filling the data out array with integer values - for (uint32_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = i; + for (uint32_t i = 0; i < I2S_SECONDARY_BUFFER_SIZE; i++) { + i2s_secondary_data_out[i] = i; } do { //Fetch I2S driver version @@ -125,7 +124,7 @@ void i2s_example_process_action(void) DEBUGOUT("I2S transmit config success\r\n"); } //Configure I2S transmit DMA channel - if (sl_si91x_i2s_transmit_data(i2s_driver_handle, data_out, BUFFER_SIZE)) { + if (sl_si91x_i2s_transmit_data(i2s_driver_handle, i2s_secondary_data_out, I2S_SECONDARY_BUFFER_SIZE)) { DEBUGOUT("I2S transmit start fail\r\n"); state = INVALID_STATE; break; @@ -155,7 +154,7 @@ void i2s_example_process_action(void) DEBUGOUT("I2S receive config success\r\n"); } //Configure I2S receive DMA channel - if (sl_si91x_i2s_receive_data(i2s_driver_handle, data_in, BUFFER_SIZE)) { + if (sl_si91x_i2s_receive_data(i2s_driver_handle, i2s_secondary_data_in, I2S_SECONDARY_BUFFER_SIZE)) { DEBUGOUT("I2S receive start fail\r\n"); state = INVALID_STATE; break; @@ -167,16 +166,16 @@ void i2s_example_process_action(void) break; case WAIT_STATE: - if (send_complete) { + if (i2s_secondary_send_complete) { DEBUGOUT("Data send successfully\r\n"); - send_complete = 0; + i2s_secondary_send_complete = 0; sl_si91x_i2s_end_transfer(i2s_driver_handle, SL_I2S_SEND_ABORT); } - if (receive_complete) { + if (i2s_secondary_receive_complete) { DEBUGOUT("Data received successfully\r\n"); compare_loop_back_data(); - receive_complete = 0; - state = SEND_DATA; + i2s_secondary_receive_complete = 0; + state = SEND_DATA; } break; @@ -226,14 +225,14 @@ static int32_t clock_configuration_pll(void) static void compare_loop_back_data(void) { uint16_t data_index = 0; - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { + for (data_index = 0; data_index < I2S_SECONDARY_BUFFER_SIZE; data_index++) { // If the data in and data out are same, it will be continued else, the for // loop will be break. - if (data_in[data_index] != data_out[data_index]) { + if (i2s_secondary_data_in[data_index] != i2s_secondary_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == I2S_SECONDARY_BUFFER_SIZE) { DEBUGOUT("Data comparison successful\n"); } else { DEBUGOUT("Data comparison failed\n"); @@ -251,10 +250,10 @@ static void callback_event(uint32_t event) { switch (event) { case SL_I2S_SEND_COMPLETE: - send_complete = 1; + i2s_secondary_send_complete = 1; break; case SL_I2S_RECEIVE_COMPLETE: - receive_complete = 1; + i2s_secondary_receive_complete = 1; break; case SL_I2S_TX_UNDERFLOW: break; diff --git a/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/sl_si91x_i2s_secondary.slcp b/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/sl_si91x_i2s_secondary.slcp index 541b2108..43e6f06a 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/sl_si91x_i2s_secondary.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_i2s_secondary/sl_si91x_i2s_secondary.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -27,8 +27,6 @@ component: from: wiseconnect3_sdk - id: sl_i2s from: wiseconnect3_sdk - - id: sl_dma - from: wiseconnect3_sdk define: - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - name: SYSCALLS_WRITE diff --git a/examples/si91x_soc/peripheral/sl_si91x_joystick/sl_si91x_joystick.slcp b/examples/si91x_soc/peripheral/sl_si91x_joystick/sl_si91x_joystick.slcp index cfcfee44..473d4a6e 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_joystick/sl_si91x_joystick.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_joystick/sl_si91x_joystick.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: joystick_example.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_pwm/sl_si91x_pwm.slcp b/examples/si91x_soc/peripheral/sl_si91x_pwm/sl_si91x_pwm.slcp index 1598b050..4b132341 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_pwm/sl_si91x_pwm.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_pwm/sl_si91x_pwm.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_sdio_secondary/sl_si91x_sdio_secondary.slcp b/examples/si91x_soc/peripheral/sl_si91x_sdio_secondary/sl_si91x_sdio_secondary.slcp index af9dcf91..1c01057b 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_sdio_secondary/sl_si91x_sdio_secondary.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_sdio_secondary/sl_si91x_sdio_secondary.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: sdio_secondary_example.c - path: sdio_secondary_example.h diff --git a/examples/si91x_soc/peripheral/sl_si91x_si70xx/si70xx_example.c b/examples/si91x_soc/peripheral/sl_si91x_si70xx/si70xx_example.c index 509415f6..bb2795d7 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_si70xx/si70xx_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_si70xx/si70xx_example.c @@ -18,6 +18,7 @@ #include "sl_si91x_si70xx.h" #include "si70xx_example.h" #include "sl_sleeptimer.h" +#include "sl_si91x_driver_gpio.h" /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ @@ -26,6 +27,7 @@ #define I2C SL_I2C2 // I2C 2 instance #define USER_REG_1 0xBA // writing data into user register #define DELAY_PERIODIC_MS1 2000 //sleeptimer1 periodic timeout in ms +#define UULP_GPIO_1_PIN 1 // UULP GPIO pin number 1(sensor enable) /******************************************************************************* ****************************** Data Types *********************************** ******************************************************************************/ @@ -61,6 +63,36 @@ void si70xx_example_init(void) i2c_config.operating_mode = SL_I2C_STANDARD_MODE; i2c_config.i2c_callback = i2c_leader_callback; do { + if (sl_si91x_gpio_driver_get_uulp_npss_pin(UULP_GPIO_1_PIN) != 1) { + // Enable GPIO ULP_CLK + status = sl_si91x_gpio_driver_enable_clock((sl_si91x_gpio_select_clock_t)ULPCLK_GPIO); // Enable GPIO ULP_CLK + if (status != SL_STATUS_OK) { + DEBUGOUT("sl_si91x_gpio_driver_enable_clock, Error code: %lu", status); + break; + } + DEBUGOUT("GPIO driver clock enable is successful \n"); + // Set NPSS GPIO pin MUX + status = sl_si91x_gpio_driver_set_uulp_npss_pin_mux(UULP_GPIO_1_PIN, NPSS_GPIO_PIN_MUX_MODE0); + if (status != SL_STATUS_OK) { + DEBUGOUT("sl_si91x_gpio_driver_set_uulp_npss_pin_mux, Error code: %lu", status); + break; + } + DEBUGOUT("GPIO driver uulp pin mux selection is successful \n"); + // Set NPSS GPIO pin direction + status = sl_si91x_gpio_driver_set_uulp_npss_direction(UULP_GPIO_1_PIN, (sl_si91x_gpio_direction_t)GPIO_OUTPUT); + if (status != SL_STATUS_OK) { + DEBUGOUT("sl_si91x_gpio_driver_set_uulp_npss_direction, Error code: %lu", status); + break; + } + DEBUGOUT("GPIO driver uulp pin direction selection is successful \n"); + // Set UULP GPIO pin + status = sl_si91x_gpio_driver_set_uulp_npss_pin_value(UULP_GPIO_1_PIN, SET); + if (status != SL_STATUS_OK) { + DEBUGOUT("sl_si91x_gpio_driver_set_uulp_npss_pin_value, Error code: %lu", status); + break; + } + DEBUGOUT("GPIO driver set uulp pin value is successful \n"); + } //Start 2000 ms periodic timer sl_sleeptimer_start_periodic_timer_ms(&timer1, DELAY_PERIODIC_MS1, @@ -209,4 +241,4 @@ static void on_timeout_timer1(sl_sleeptimer_timer_handle_t *handle, void *data) (void)&handle; (void)&data; delay_timeout = true; -} \ No newline at end of file +} diff --git a/examples/si91x_soc/peripheral/sl_si91x_si70xx/sl_si91x_si70xx.slcp b/examples/si91x_soc/peripheral/sl_si91x_si70xx/sl_si91x_si70xx.slcp index 51cb9f24..fd76838d 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_si70xx/sl_si91x_si70xx.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_si70xx/sl_si91x_si70xx.slcp @@ -44,6 +44,6 @@ ui_hints: focus: true sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 post_build: path: ../../../../utilities/postbuild_profile/wiseconnect_soc.slpb diff --git a/examples/si91x_soc/peripheral/sl_si91x_sio/sio_example.c b/examples/si91x_soc/peripheral/sl_si91x_sio/sio_example.c index f2270b6f..244b6cbb 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_sio/sio_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_sio/sio_example.c @@ -28,10 +28,10 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 10 // Data buffer size -#define CS_NUMBER 0 // Chip select number -#define MSB_FIRST 1 // Select MSB first -#define SYS_CLOCK 180000000 // System clock +#define SIO_BUFFER_SIZE 10 // Data buffer size +#define CS_NUMBER 0 // Chip select number +#define MSB_FIRST 1 // Select MSB first +#define SYS_CLOCK 180000000 // System clock // SIO-SPI Configuration parameters #define SIO_SPI_CLK_FREQUENCY 1000000 // SIO-SPI 1Mhz clock frequency @@ -51,14 +51,14 @@ typedef enum { /******************************************************************************* *************************** LOCAL VARIABLES ********************************* ******************************************************************************/ -uint8_t data_out[BUFFER_SIZE] = { 0 }, buffer_in[BUFFER_SIZE]; -uint16_t data_in[BUFFER_SIZE] = { 0 }, buffer_out[BUFFER_SIZE]; -volatile boolean_t send_complete = false, receive_complete = false; -static boolean_t begin_transmission = true; +uint8_t sio_data_out[SIO_BUFFER_SIZE] = { 0 }, sio_buffer_in[SIO_BUFFER_SIZE]; +uint16_t sio_data_in[SIO_BUFFER_SIZE] = { 0 }, sio_buffer_out[SIO_BUFFER_SIZE]; +volatile boolean_t sio_send_complete = false, sio_receive_complete = false; +static boolean_t sio_begin_transmission = true; extern sl_sio_spi_callback_t spi_user_callback; extern uint32_t SystemCoreClock; -uint8_t tx_data[BUFFER_SIZE] = { 0 }; -uint8_t rx_data[BUFFER_SIZE] = { 0 }; +uint8_t tx_data[SIO_BUFFER_SIZE] = { 0 }; +uint8_t rx_data[SIO_BUFFER_SIZE] = { 0 }; extern uint8_t bit_length; /******************************************************************************* ********************** Local Function prototypes *************************** @@ -74,8 +74,8 @@ sio_uart_mode_enum_t current_mode = SL_SEND_DATA; stc_sio_spi_cfg_t pstcSpiConfig = { 0 }; stc_sio_spi_xfer_t pstcSpiXfer = { 0 }; extern stc_sio_uart_config_t UartInitstc; -uint8_t tx_buffer[BUFFER_SIZE] = { 0 }; -uint8_t rx_buffer[BUFFER_SIZE] = { 0 }; +uint8_t tx_buffer[SIO_BUFFER_SIZE] = { 0 }; +uint8_t rx_buffer[SIO_BUFFER_SIZE] = { 0 }; extern sl_sio_spi_t sl_sio_spi_init; extern sl_sio_uart_t sl_sio_uart_init; /******************************************************************************* @@ -95,11 +95,11 @@ void sio_example_init(void) do { // Initialize SIO SPI instance if (SL_SIO_SPI == 1) { - for (uint16_t i = 0; i < BUFFER_SIZE; i++) { - buffer_in[i] = (uint8_t)(i + 1); + for (uint16_t i = 0; i < SIO_BUFFER_SIZE; i++) { + sio_buffer_in[i] = (uint8_t)(i + 1); } - for (uint16_t i = 0; i < BUFFER_SIZE; i++) { - data_in[i] = (uint8_t)(i + 1); + for (uint16_t i = 0; i < SIO_BUFFER_SIZE; i++) { + sio_data_in[i] = (uint8_t)(i + 1); } // Initialize the SIO status = sl_si91x_sio_init(); @@ -194,7 +194,7 @@ void sio_example_init(void) // Initialize SIO UART instance if (SL_SIO_UART == 1) { // Filling the tx_buffer array with integer values - for (uint16_t i = 0; i < BUFFER_SIZE; i++) { + for (uint16_t i = 0; i < SIO_BUFFER_SIZE; i++) { tx_buffer[i] = (uint8_t)i; } // SIO UART configuration structure @@ -285,7 +285,7 @@ void sio_example_init(void) break; } DEBUGOUT("SIO unmask shift interrupt is successful \n"); - status = sl_si91x_sio_uart_read(rx_buffer, BUFFER_SIZE); + status = sl_si91x_sio_uart_read(rx_buffer, SIO_BUFFER_SIZE); if (status != SL_STATUS_OK) { DEBUGOUT("sl_si91x_sio_uart_read: Error Code : %lu \n", status); break; @@ -308,7 +308,7 @@ void sio_example_process_action(void) if (SL_SIO_SPI == 1) { switch (current_mode) { case SL_SEND_DATA: - if (begin_transmission == true) { + if (sio_begin_transmission == true) { // Assert the SIO SPI chip select status = sl_si91x_sio_spi_cs_assert(pstcSpiConfig.u8SpiCsCh); if (status != SL_STATUS_OK) { @@ -319,16 +319,16 @@ void sio_example_process_action(void) } DEBUGOUT("SIO SPI chip select assert successfully \n"); if (bit_length == 8) { - pstcSpiXfer.rxBuff = data_out; - pstcSpiXfer.txBuff = buffer_in; + pstcSpiXfer.rxBuff = sio_data_out; + pstcSpiXfer.txBuff = sio_buffer_in; } else { - pstcSpiXfer.rxBuff = buffer_out; - pstcSpiXfer.txBuff = data_in; + pstcSpiXfer.rxBuff = sio_buffer_out; + pstcSpiXfer.txBuff = sio_data_in; } // SPI Transfer configuration - pstcSpiXfer.rxCount = BUFFER_SIZE; + pstcSpiXfer.rxCount = SIO_BUFFER_SIZE; pstcSpiXfer.sselNum = CS_NUMBER; - pstcSpiXfer.txCount = BUFFER_SIZE; + pstcSpiXfer.txCount = SIO_BUFFER_SIZE; pstcSpiXfer.u8BitLen = SIO_SPI_BIT_LEN; pstcSpiXfer.u8Status = SioSpiIdle; pstcSpiXfer.pfnCb = spi_user_callback; @@ -342,20 +342,20 @@ void sio_example_process_action(void) DEBUGOUT("sl_si91x_sio_spi_transfer: Error Code : %lu \n", status); } DEBUGOUT("SIO SPI transfer begin successfully \n"); - begin_transmission = false; + sio_begin_transmission = false; } // Waiting till the send is completed - if (send_complete) { - // Update send_complete flag with 0. - send_complete = false; + if (sio_send_complete) { + // Update sio_send_complete flag with 0. + sio_send_complete = false; DEBUGOUT("SIO SPI transfer completed \n"); // De-assert SIO-SPI chip select sl_si91x_sio_spi_cs_deassert(pstcSpiConfig.u8SpiCsCh); current_mode = SL_SEND_DATA; - // After comparing the loopback transfer, it compares the data_out and - // data_outin. + // After comparing the loopback transfer, it compares the sio_data_out and + // sio_data_in. compare_loop_back_data(); - begin_transmission = true; + sio_begin_transmission = true; } break; case SL_TRANSMISSION_COMPLETED: @@ -370,18 +370,18 @@ void sio_example_process_action(void) if (SL_SIO_UART == 1) { switch (current_mode) { case SL_RECEIVE_DATA: - if (receive_complete == true) { - receive_complete = false; + if (sio_receive_complete == true) { + sio_receive_complete = false; DEBUGOUT("SIO UART receive completed \n"); // After comparing the loopback transfer, it compares the tx_buffer and // rx_buffer. compare_uart_loop_back_data(); - begin_transmission = true; - current_mode = SL_SEND_DATA; + sio_begin_transmission = true; + current_mode = SL_SEND_DATA; } break; case SL_SEND_DATA: - if (begin_transmission == true) { + if (sio_begin_transmission == true) { // Validation for executing the API only once status = sl_si91x_sio_uart_send(tx_buffer, (sizeof(tx_buffer) / sizeof(tx_buffer[0]))); if (status != SL_STATUS_OK) { @@ -392,8 +392,8 @@ void sio_example_process_action(void) break; } DEBUGOUT("SIO UART send begin successfully \n"); - begin_transmission = false; - current_mode = SL_RECEIVE_DATA; + sio_begin_transmission = false; + current_mode = SL_RECEIVE_DATA; DEBUGOUT("SIO UART send completed \n"); } break; @@ -414,12 +414,12 @@ static void compare_uart_loop_back_data(void) uint16_t data_index = 0; // Check for tx_buffe and rx_buffer are same, if same then comparison // will continue till end of the buffer - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { + for (data_index = 0; data_index < SIO_BUFFER_SIZE; data_index++) { if (rx_buffer[data_index] != tx_buffer[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == SIO_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, UART Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, UART Loop Back Test failed \n"); @@ -433,23 +433,23 @@ static void compare_uart_loop_back_data(void) static void compare_loop_back_data(void) { uint16_t data_index = 0; - // Check for buffer_in and data_out are same, if same then comparison + // Check for sio_buffer_in and sio_data_out are same, if same then comparison // will continue till end of the buffer if (bit_length == 8) { - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - if (buffer_in[data_index] != data_out[data_index]) { + for (data_index = 0; data_index < SIO_BUFFER_SIZE; data_index++) { + if (sio_buffer_in[data_index] != sio_data_out[data_index]) { break; } } } if (bit_length == 16) { - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - if (data_in[data_index] != buffer_out[data_index]) { + for (data_index = 0; data_index < SIO_BUFFER_SIZE; data_index++) { + if (sio_data_in[data_index] != sio_buffer_out[data_index]) { break; } } } - if (data_index == BUFFER_SIZE) { + if (data_index == SIO_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); @@ -463,7 +463,7 @@ void sio_spi_callback(en_sio_spi_events_t event) { switch (event) { case SL_SIO_SPI_TX_DONE: // SIO SPI send complete - send_complete = true; + sio_send_complete = true; break; case SL_SIO_SPI_RX_DONE: // SIO SPI receive complete break; @@ -480,7 +480,7 @@ void sio_uart_callback(en_sio_Uart_events_t event, uint16_t rev_char) case SL_SIO_UART_TX_DONE: // SIO UART transfer complete event break; case SL_SIO_UART_RX_DONE: // SIO UART receive complete event - receive_complete = true; + sio_receive_complete = true; sl_si91x_sio_uart_rx_done(); break; case SL_SIO_UART_PARITY_ERR: // SIO UART parity error event diff --git a/examples/si91x_soc/peripheral/sl_si91x_sio/sl_si91x_sio.slcp b/examples/si91x_soc/peripheral/sl_si91x_sio/sl_si91x_sio.slcp index 0e6f8222..15fddae4 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_sio/sl_si91x_sio.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_sio/sl_si91x_sio.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/readme.md b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/readme.md index 63fb94c6..e6674443 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/readme.md @@ -65,26 +65,26 @@ > > #define SOC_PLL_CLK 20000000 // SOC PLL Clock frequency. -- If **SL_USE_TRANSFER** macro is enabled, it will transfer the data, i.e. send and receive data in full duplex mode. +- If **SSI_MASTER_TRANSFER** macro is enabled, it will transfer the data, i.e. send and receive data in full duplex mode. - - The current_mode enum is set to SL_TRANSFER_DATA and calls the \ref sl_si91x_ssi_transfer_data API which expects data_out, data_in and number of data bytes to be transferred for sending and receiving data simultaneously (full duplex). + - The current_mode enum is set to SSI_MASTER_TRANSFER_DATA and calls the \ref sl_si91x_ssi_transfer_data API which expects data_out, data_in and number of data bytes to be transferred for sending and receiving data simultaneously (full duplex). - This test can also be performed in loopback state, i.e. connect MISO and MOSI pins. - The example code waits till the transfer is completed, when the transfer complete event is generated, it compares the sent and received data. - The result is printed on the console. - - Now the current_mode enum is updated as per the macros enabled i.e., either SL_USE_SEND or SL_USE_RECEIVE. - - If no other macros are enabled, the current_mode is updated to SL_TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated as per the macros enabled i.e., either SSI_MASTER_SEND or SSI_MASTER_RECEIVE. + - If no other macros are enabled, the current_mode is updated to SSI_MASTER_TRANSMISSION_COMPLETED. -- If **SL_USE_RECEIVE** macro is enabled, it only receives the data from slave - SPI slave must be connected, it cannot be tested in loopback mode. +- If **SSI_MASTER_RECEIVE** macro is enabled, it only receives the data from slave - SPI slave must be connected, it cannot be tested in loopback mode. - - The current_mode is set to the SL_RECEIVE_DATA and calls the \ref sl_si91x_ssi_receive_data API which expects data_in (empty buffer) and number of data bytes to be received. + - The current_mode is set to the SSI_MASTER_RECEIVE_DATA and calls the \ref sl_si91x_ssi_receive_data API which expects data_in (empty buffer) and number of data bytes to be received. - It waits till the receive is completed i.e., transfer complete event is generated. - - Now the current_mode enum is updated as per the macros enabled i.e., SL_USE_SEND. - - If no other macros are enabled, the current_mode is updated to SL_TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated as per the macros enabled i.e., SSI_MASTER_SEND. + - If no other macros are enabled, the current_mode is updated to SSI_MASTER_TRANSMISSION_COMPLETED. -- If **SL_USE_SEND** macro is enabled, it only sends the data to slave, SPI slave must be connected, it cannot be tested in loopback mode. - - The current_mode enum is set to SL_SEND_DATA and calls the \ref sl_si91x_ssi_send_data API which expects data_out (data buffer that needs to be sent) and number of bytes to send. +- If **SSI_MASTER_SEND** macro is enabled, it only sends the data to slave, SPI slave must be connected, it cannot be tested in loopback mode. + - The current_mode enum is set to SSI_MASTER_SEND_DATA and calls the \ref sl_si91x_ssi_send_data API which expects data_out (data buffer that needs to be sent) and number of bytes to send. - It waits till the send is completed i.e., transfer complete event is generated. - - Now the current_mode enum is updated to TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated to SSI_MASTER_TRANSMISSION_COMPLETED. ## Prerequisites/Setup Requirements @@ -118,11 +118,11 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Application Configuration Parameters - Configure UC from the slcp component. - - ![Figure: UC image](resources/uc_screen/ssi_uc_screen.png) - - Open **sl_si91x_ssi_master.slcp** project file select **software component** tab and search for **SSI** in search bar. - Using configuration wizard one can configure different parameters like: + + ![Figure: UC image](resources/uc_screen/ssi_uc_screen.png) + - **SSI Configuration** - Frame Format: SSI Frame Format can be configured, i.e., - Mode 0: Clock Polarity is zero and Clock Phase is zero. @@ -145,17 +145,17 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Configure the following macros in ssi_master_example.h file and update/modify following macros if required. -- `USE_TRANSFER`: This macro is enabled default, it sends and receives data in full duplex. +- `SSI_MASTER_TRANSFER`: This macro is enabled default, it sends and receives data in full duplex. ```C - #define SL_USE_TRANSFER ENABLE // To use the transfer API + #define SSI_MASTER_TRANSFER ENABLE // To use the transfer API ``` -- `USE_SEND (or) USE_RECEIVE`: If USE_RECEIVE (or) USE_SEND is enabled, SSI slave will receive and send data in half duplex respectively. +- `SSI_MASTER_SEND (or) SSI_MASTER_RECEIVE`: If SSI_MASTER_RECEIVE (or) SSI_MASTER_SEND is enabled, SSI slave will receive and send data in half duplex respectively. ```C - #define SL_USE_SEND DISABLE // To use the send API - #define SL_USE_RECEIVE DISABLE // To use the receive API + #define SSI_MASTER_SEND DISABLE // To use the send API + #define SSI_MASTER_RECEIVE DISABLE // To use the receive API ``` ### Pin Configuration diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/sl_si91x_ssi_master.slcp b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/sl_si91x_ssi_master.slcp index 79f510e5..893c3344 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/sl_si91x_ssi_master.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/sl_si91x_ssi_master.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system @@ -27,10 +27,6 @@ component: from: wiseconnect3_sdk - id: sl_ssi from: wiseconnect3_sdk -define: - - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: SPI_MULTI_SLAVE - - name: SSI_CONFIG other_file: - path: resources/readme/image510d.png - path: resources/readme/setupdiagram.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.c b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.c index 6bfae5aa..bc467b5f 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.c @@ -24,45 +24,45 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 1024 // Length of data to be sent through SPI -#define DIVISION_FACTOR 0 // Division Factor -#define INTF_PLL_CLK 180000000 // PLL Clock frequency -#define INTF_PLL_REF_CLK 40000000 // PLL Ref Clock frequency -#define SOC_PLL_CLK 20000000 // SOC PLL Clock frequency -#define SOC_PLL_REF_CLK 40000000 // SOC PLL REFERENCE CLOCK frequency -#define INTF_PLL_500_CTRL_VALUE 0xD900 // Interface PLL control value -#define SOC_PLL_MM_COUNT_LIMIT 0xA4 // SOC PLL count limit -#define SSI_BIT_WIDTH 8 // SSI bit width -#define SSI_BAUDRATE 10000000 // SSI baudrate -#define MAX_BIT_WIDTH 16 // Maximum Bit width -#define RECEIVE_SAMPLE_DELAY 0 // By default sample delay is 0 +#define SSI_MASTER_BUFFER_SIZE 1024 // Length of data to be sent through SPI +#define SSI_MASTER_DIVISION_FACTOR 0 // Division Factor +#define SSI_MASTER_INTF_PLL_CLK 180000000 // PLL Clock frequency +#define SSI_MASTER_INTF_PLL_REF_CLK 40000000 // PLL Ref Clock frequency +#define SSI_MASTER_SOC_PLL_CLK 20000000 // SOC PLL Clock frequency +#define SSI_MASTER_SOC_PLL_REF_CLK 40000000 // SOC PLL REFERENCE CLOCK frequency +#define SSI_MASTER_INTF_PLL_500_CTRL_VALUE 0xD900 // Interface PLL control value +#define SSI_MASTER_SOC_PLL_MM_COUNT_LIMIT 0xA4 // SOC PLL count limit +#define SSI_MASTER_BIT_WIDTH 8 // SSI bit width +#define SSI_MASTER_BAUDRATE 10000000 // SSI baudrate +#define SSI_MASTER_MAX_BIT_WIDTH 16 // Maximum Bit width +#define SSI_MASTER_RECEIVE_SAMPLE_DELAY 0 // By default sample delay is 0 /******************************************************************************* ********************** Local Function prototypes *************************** ******************************************************************************/ -static sl_status_t init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config); -static void callback_event_handler(uint32_t event); -static void compare_loopback_data(void); +static sl_status_t ssi_master_init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config); +static void ssi_master_callback_event_handler(uint32_t event); +static void ssi_master_compare_loopback_data(void); /******************************************************************************* ********************** Local variables ************************************* ******************************************************************************/ -static uint8_t data_out[BUFFER_SIZE] = { '\0' }; -static uint8_t data_in[BUFFER_SIZE] = { '\0' }; -static sl_ssi_handle_t ssi_driver_handle = NULL; -boolean_t transfer_complete = false; -boolean_t begin_transmission = true; -static uint16_t size_factor = 1; -static uint32_t slave_number = SSI_SLAVE_0; +static uint8_t ssi_master_tx_buffer[SSI_MASTER_BUFFER_SIZE] = { '\0' }; +static uint8_t ssi_master_rx_buffer[SSI_MASTER_BUFFER_SIZE] = { '\0' }; +static sl_ssi_handle_t ssi_driver_handle = NULL; +boolean_t ssi_master_transfer_complete = false; +boolean_t ssi_master_begin_transmission = true; +static uint16_t size_factor = 1; +static uint32_t ssi_slave_number = SSI_SLAVE_0; /// @brief Enumeration for different transmission scenarios typedef enum { - SL_TRANSFER_DATA, - SL_RECEIVE_DATA, - SL_SEND_DATA, - SL_TRANSMISSION_COMPLETED, + SSI_MASTER_TRANSFER_DATA, + SSI_MASTER_RECEIVE_DATA, + SSI_MASTER_SEND_DATA, + SSI_MASTER_TRANSMISSION_COMPLETED, } ssi_mode_enum_t; -static ssi_mode_enum_t current_mode = SL_TRANSFER_DATA; +static ssi_mode_enum_t ssi_master_current_mode = SSI_MASTER_TRANSFER_DATA; /******************************************************************************* ************************** GLOBAL FUNCTIONS ******************************* @@ -76,39 +76,39 @@ void ssi_master_example_init(void) { uint16_t i = 0; sl_status_t sl_status = 0; - sl_ssi_clock_config_t clock_config; - sl_ssi_version_t version; + sl_ssi_clock_config_t ssi_clock_config; + sl_ssi_version_t ssi_version; // Configuring the user configuration structure - sl_ssi_control_config_t config; - config.bit_width = SSI_BIT_WIDTH; - config.device_mode = SL_SSI_MASTER_ACTIVE; - config.clock_mode = SL_SSI_PERIPHERAL_CPOL0_CPHA0; - config.baud_rate = SSI_BAUDRATE; - config.receive_sample_delay = RECEIVE_SAMPLE_DELAY; + sl_ssi_control_config_t ssi_master_config; + ssi_master_config.bit_width = SSI_MASTER_BIT_WIDTH; + ssi_master_config.device_mode = SL_SSI_MASTER_ACTIVE; + ssi_master_config.clock_mode = SL_SSI_PERIPHERAL_CPOL0_CPHA0; + ssi_master_config.baud_rate = SSI_MASTER_BAUDRATE; + ssi_master_config.receive_sample_delay = SSI_MASTER_RECEIVE_SAMPLE_DELAY; // Filled data into input buffer - for (i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)(i + 1); + for (i = 0; i < SSI_MASTER_BUFFER_SIZE; i++) { + ssi_master_tx_buffer[i] = (uint8_t)(i + 1); } do { // Version information of SSI driver - version = sl_si91x_ssi_get_version(); + ssi_version = sl_si91x_ssi_get_version(); DEBUGOUT("SSI version is fetched successfully \n"); - DEBUGOUT("API version is %d.%d.%d\n", version.release, version.major, version.minor); + DEBUGOUT("API version is %d.%d.%d\n", ssi_version.release, ssi_version.major, ssi_version.minor); // Clock Config for the SSI driver - sl_status = init_clock_configuration_structure(&clock_config); + sl_status = ssi_master_init_clock_configuration_structure(&ssi_clock_config); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Clock get Configuration Failed, Error Code : %lu \n", sl_status); break; } DEBUGOUT("SSI Clock get Configuration Success\n"); - sl_status = sl_si91x_ssi_configure_clock(&clock_config); + sl_status = sl_si91x_ssi_configure_clock(&ssi_clock_config); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Clock Configuration Failed, Error Code : %lu \n", sl_status); break; } DEBUGOUT("SSI Clock Configuration Success \n"); // Initialize the SSI driver - sl_status = sl_si91x_ssi_init(config.device_mode, &ssi_driver_handle); + sl_status = sl_si91x_ssi_init(ssi_master_config.device_mode, &ssi_driver_handle); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Initialization Failed, Error Code : %lu \n", sl_status); break; @@ -116,14 +116,14 @@ void ssi_master_example_init(void) DEBUGOUT("SSI Initialization Success \n"); // Configure the SSI to Master, 16-bit mode @10000 kBits/sec - sl_status = sl_si91x_ssi_set_configuration(ssi_driver_handle, &config, slave_number); + sl_status = sl_si91x_ssi_set_configuration(ssi_driver_handle, &ssi_master_config, ssi_slave_number); if (sl_status != SL_STATUS_OK) { DEBUGOUT("Failed to Set Configuration Parameters to SSI, Error Code : %lu \n", sl_status); break; } DEBUGOUT("Set Configuration Parameters to SSI \n"); // Register the user callback - sl_status = sl_si91x_ssi_register_event_callback(ssi_driver_handle, callback_event_handler); + sl_status = sl_si91x_ssi_register_event_callback(ssi_driver_handle, ssi_master_callback_event_handler); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI register event callback Failed, Error Code : %lu \n", sl_status); break; @@ -133,19 +133,19 @@ void ssi_master_example_init(void) DEBUGOUT("Current Clock division factor is %lu \n", sl_si91x_ssi_get_clock_division_factor(ssi_driver_handle)); // Fetching and printing the current frame length DEBUGOUT("Current Frame Length is %lu \n", sl_si91x_ssi_get_frame_length(ssi_driver_handle)); - if (sl_si91x_ssi_get_frame_length(ssi_driver_handle) >= SSI_BIT_WIDTH) { - size_factor = sizeof(data_out[0]); + if (sl_si91x_ssi_get_frame_length(ssi_driver_handle) >= SSI_MASTER_BIT_WIDTH) { + size_factor = sizeof(ssi_master_tx_buffer[0]); } // As per the macros enabled in the header file, it will configure the current mode. - if (SL_USE_TRANSFER) { - current_mode = SL_TRANSFER_DATA; + if (SSI_MASTER_TRANSFER) { + ssi_master_current_mode = SSI_MASTER_TRANSFER_DATA; break; } - if (SL_USE_SEND) { - current_mode = SL_SEND_DATA; + if (SSI_MASTER_SEND) { + ssi_master_current_mode = SSI_MASTER_SEND_DATA; break; } - current_mode = SL_RECEIVE_DATA; + ssi_master_current_mode = SSI_MASTER_RECEIVE_DATA; } while (false); } /******************************************************************************* @@ -158,127 +158,131 @@ void ssi_master_example_process_action(void) // In this switch case, according to the macros enabled in header file, it starts to execute the APIs // Assuming all the macros are enabled, after transfer, receive will be executed and after receive // send will be executed. - switch (current_mode) { - case SL_TRANSFER_DATA: - if (begin_transmission == true) { + switch (ssi_master_current_mode) { + case SSI_MASTER_TRANSFER_DATA: + if (ssi_master_begin_transmission == true) { // Validation for executing the API only once - sl_si91x_ssi_set_slave_number(slave_number); - status = sl_si91x_ssi_transfer_data(ssi_driver_handle, data_out, data_in, sizeof(data_out) / size_factor); + sl_si91x_ssi_set_slave_number(ssi_slave_number); + status = sl_si91x_ssi_transfer_data(ssi_driver_handle, + ssi_master_tx_buffer, + ssi_master_rx_buffer, + sizeof(ssi_master_tx_buffer) / size_factor); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_transfer_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_master_current_mode = SSI_MASTER_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI transfer begin successfully \n"); - begin_transmission = false; + ssi_master_begin_transmission = false; } - if (transfer_complete) { - transfer_complete = false; + if (ssi_master_transfer_complete) { + ssi_master_transfer_complete = false; DEBUGOUT("SSI transfer completed successfully \n"); // After comparing the loopback transfer, it compares the data_out and // data_in. - compare_loopback_data(); - if (SL_USE_SEND) { + ssi_master_compare_loopback_data(); + if (SSI_MASTER_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; - begin_transmission = true; + ssi_master_current_mode = SSI_MASTER_SEND_DATA; + ssi_master_begin_transmission = true; break; } - if (SL_USE_RECEIVE) { + if (SSI_MASTER_RECEIVE) { // If receive macro is enabled, current mode is set to receive - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + ssi_master_current_mode = SSI_MASTER_RECEIVE_DATA; + ssi_master_begin_transmission = true; break; } // If above macros are not enabled, current mode is set to complete - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_master_current_mode = SSI_MASTER_TRANSMISSION_COMPLETED; } break; - case SL_SEND_DATA: - if (begin_transmission) { + case SSI_MASTER_SEND_DATA: + if (ssi_master_begin_transmission) { // Validation for executing the API only once - sl_si91x_ssi_set_slave_number(slave_number); - status = sl_si91x_ssi_send_data(ssi_driver_handle, data_out, sizeof(data_out) / size_factor); + sl_si91x_ssi_set_slave_number(ssi_slave_number); + status = + sl_si91x_ssi_send_data(ssi_driver_handle, ssi_master_tx_buffer, sizeof(ssi_master_tx_buffer) / size_factor); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_send_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_master_current_mode = SSI_MASTER_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI send begin successfully \n"); - begin_transmission = false; + ssi_master_begin_transmission = false; } //Waiting till the send is completed - if (transfer_complete) { + if (ssi_master_transfer_complete) { // If DMA is enabled, it will wait untill transfer_complete flag is set. - transfer_complete = false; - if (SL_USE_RECEIVE) { + ssi_master_transfer_complete = false; + if (SSI_MASTER_RECEIVE) { // If send macro is enabled, current mode is set to send - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + ssi_master_current_mode = SSI_MASTER_RECEIVE_DATA; + ssi_master_begin_transmission = true; DEBUGOUT("SSI send completed \n"); break; } DEBUGOUT("SSI send completed \n"); // If send macro is not enabled, current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_master_current_mode = SSI_MASTER_TRANSMISSION_COMPLETED; } break; - case SL_RECEIVE_DATA: - if (begin_transmission == true) { + case SSI_MASTER_RECEIVE_DATA: + if (ssi_master_begin_transmission == true) { // Validation for executing the API only once - sl_si91x_ssi_set_slave_number(slave_number); - status = sl_si91x_ssi_receive_data(ssi_driver_handle, data_in, sizeof(data_in)); + sl_si91x_ssi_set_slave_number(ssi_slave_number); + status = sl_si91x_ssi_receive_data(ssi_driver_handle, ssi_master_rx_buffer, sizeof(ssi_master_rx_buffer)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_receive_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_master_current_mode = SSI_MASTER_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI receive begin successfully \n"); - begin_transmission = false; + ssi_master_begin_transmission = false; //Waiting till the receive is completed } - if (transfer_complete) { + if (ssi_master_transfer_complete) { // If DMA is enabled, it will wait untill transfer_complete flag is set. - transfer_complete = false; + ssi_master_transfer_complete = false; DEBUGOUT("SSI receive completed \n"); - compare_loopback_data(); + ssi_master_compare_loopback_data(); // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_master_current_mode = SSI_MASTER_TRANSMISSION_COMPLETED; } break; - case SL_TRANSMISSION_COMPLETED: + case SSI_MASTER_TRANSMISSION_COMPLETED: break; } } /******************************************************************************* - * @fn compare_loopback_data() + * @fn ssi_master_compare_loopback_data() * @brief Internal private Function which validates input and output buffers * and decides whether the test case passed/failed. * @return None *******************************************************************************/ -static void compare_loopback_data(void) +static void ssi_master_compare_loopback_data(void) { // If the data width is not standard (8-bit) then the data should be masked. // The extra bits of the integer should be always zero. // For example, if bit width is 7, then from 8-15 all bits should be zero in a 16 bit integer. // So mask has value according to the data width and it is applied to the data. - uint16_t data_index; - uint8_t frame_length = 0; - uint16_t mask = (uint16_t)~0; - frame_length = sl_si91x_ssi_get_frame_length(ssi_driver_handle); - mask = mask >> (MAX_BIT_WIDTH - frame_length); - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - data_in[data_index] &= mask; - data_out[data_index] &= mask; - if (data_out[data_index] != data_in[data_index]) { + uint16_t ssi_data_index; + uint8_t ssi_frame_length = 0; + uint16_t ssi_mask = (uint16_t)~0; + ssi_frame_length = sl_si91x_ssi_get_frame_length(ssi_driver_handle); + ssi_mask = ssi_mask >> (SSI_MASTER_MAX_BIT_WIDTH - ssi_frame_length); + for (ssi_data_index = 0; ssi_data_index < SSI_MASTER_BUFFER_SIZE; ssi_data_index++) { + ssi_master_rx_buffer[ssi_data_index] &= ssi_mask; + ssi_master_tx_buffer[ssi_data_index] &= ssi_mask; + if (ssi_master_tx_buffer[ssi_data_index] != ssi_master_rx_buffer[ssi_data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (ssi_data_index == SSI_MASTER_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); @@ -286,39 +290,39 @@ static void compare_loopback_data(void) } /******************************************************************************* - * To set the values in the clock config structure + * To set the values in the SSI Master clock config structure * * @param[in] clock config structure * @return SL_STATUS_OK if set was fine, SL_STATUS_NULL_POINTER if NULL ptr * passed in. * * *******************************************************************************/ -static sl_status_t init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config) +static sl_status_t ssi_master_init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config) { if (clock_config == NULL) { return SL_STATUS_NULL_POINTER; } - clock_config->soc_pll_mm_count_value = SOC_PLL_MM_COUNT_LIMIT; - clock_config->intf_pll_500_control_value = INTF_PLL_500_CTRL_VALUE; - clock_config->intf_pll_clock = INTF_PLL_CLK; - clock_config->intf_pll_reference_clock = INTF_PLL_REF_CLK; - clock_config->soc_pll_clock = SOC_PLL_CLK; - clock_config->soc_pll_reference_clock = SOC_PLL_REF_CLK; - clock_config->division_factor = DIVISION_FACTOR; + clock_config->soc_pll_mm_count_value = SSI_MASTER_SOC_PLL_MM_COUNT_LIMIT; + clock_config->intf_pll_500_control_value = SSI_MASTER_INTF_PLL_500_CTRL_VALUE; + clock_config->intf_pll_clock = SSI_MASTER_INTF_PLL_CLK; + clock_config->intf_pll_reference_clock = SSI_MASTER_INTF_PLL_REF_CLK; + clock_config->soc_pll_clock = SSI_MASTER_SOC_PLL_CLK; + clock_config->soc_pll_reference_clock = SSI_MASTER_SOC_PLL_REF_CLK; + clock_config->division_factor = SSI_MASTER_DIVISION_FACTOR; return SL_STATUS_OK; } /******************************************************************************* - * @brief SSI callback handler - * @param[in]event SSI transmit and receive events + * @brief SSI Master callback handler + * @param[in]event SSI Master transmit and receive events * @return None *******************************************************************************/ -static void callback_event_handler(uint32_t event) +static void ssi_master_callback_event_handler(uint32_t event) { switch (event) { case SSI_EVENT_TRANSFER_COMPLETE: - transfer_complete = true; + ssi_master_transfer_complete = true; break; case SSI_EVENT_DATA_LOST: diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.h b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.h index ef98193a..f2b5ff3a 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.h +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_master/ssi_master_example.h @@ -18,9 +18,9 @@ #ifndef SL_SI91X_SSI_MASTER_EXAMPLE_H_ #define SL_SI91X_SSI_MASTER_EXAMPLE_H_ -#define SL_USE_TRANSFER ENABLE -#define SL_USE_SEND DISABLE -#define SL_USE_RECEIVE DISABLE +#define SSI_MASTER_TRANSFER ENABLE +#define SSI_MASTER_SEND DISABLE +#define SSI_MASTER_RECEIVE DISABLE // ----------------------------------------------------------------------------- // Prototypes @@ -46,4 +46,4 @@ void ssi_master_example_init(void); ******************************************************************************/ void ssi_master_example_process_action(void); -#endif /* SL_SI91X_SSI_MASTER_EXAMPLE_H_ */ \ No newline at end of file +#endif /* SL_SI91X_SSI_MASTER_EXAMPLE_H_ */ diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/readme.md b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/readme.md index 3cdee005..efc68b33 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/readme.md @@ -59,26 +59,26 @@ - The State machine code is implemented for transfer, send and receive data, the current mode is determined by ssi_mode_enum_t which is declared in ssi_slave_example.c file. - According to the macro which is enabled, the example code executes the transfer of data: -- If **SL_USE_TRANSFER** macro is enabled, it will transfer the data, i.e. send and receive data in full duplex mode. +- If **SSI_SLAVE_TRANSFER** macro is enabled, it will transfer the data, i.e. send and receive data in full duplex mode. - - The current_mode enum is set to SL_TRANSFER_DATA and calls the \ref sl_si91x_ssi_transfer_data API which expects data_out, data_in and number of data bytes to be transferred for sending and receiving data simultaneously (full duplex). + - The current_mode enum is set to SSI_SLAVE_TRANSFER_DATA and calls the \ref sl_si91x_ssi_transfer_data API which expects data_out, data_in and number of data bytes to be transferred for sending and receiving data simultaneously (full duplex). - This test can also be performed in loopback state, i.e. connect MISO and MOSI pins. - The example code waits till the transfer is completed, when the transfer complete event is generated, it compares the sent and received data. - The result is printed on the console. - - Now the current_mode enum is updated as per the macros enabled i.e., either SL_USE_SEND or SL_USE_RECEIVE. - - If no other macros are enabled, the current_mode is updated to SL_TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated as per the macros enabled i.e., either SSI_SLAVE_SEND or SSI_SLAVE_RECEIVE. + - If no other macros are enabled, the current_mode is updated to SSI_SLAVE_TRANSMISSION_COMPLETED. -- If **SL_USE_SEND** macro is enabled, it only sends the data to slave, SPI slave must be connected, it cannot be tested in loopback mode. +- If **SSI_SLAVE_SEND** macro is enabled, it only sends the data to slave, SPI slave must be connected, it cannot be tested in loopback mode. - - The current_mode enum is set to SL_SEND_DATA and calls the \ref sl_si91x_ssi_send_data API which expects data_out (data buffer that needs to be sent) and number of bytes to send. + - The current_mode enum is set to SSI_SLAVE_SEND_DATA and calls the \ref sl_si91x_ssi_send_data API which expects data_out (data buffer that needs to be sent) and number of bytes to send. - It waits till the send is completed i.e., transfer complete event is generated. - - Now the current_mode enum is updated to TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated to SSI_SLAVE_TRANSMISSION_COMPLETED. -- If **SL_USE_RECEIVE** macro is enabled, it only receives the data from slave - SPI slave must be connected, it cannot be tested in loopback mode. - - The current_mode is set to the SL_RECEIVE_DATA and calls the \ref sl_si91x_ssi_receive_data API which expects data_in (empty buffer) and number of data bytes to be received. +- If **SSI_SLAVE_RECEIVE** macro is enabled, it only receives the data from slave - SPI slave must be connected, it cannot be tested in loopback mode. + - The current_mode is set to the SSI_SLAVE_RECEIVE_DATA and calls the \ref sl_si91x_ssi_receive_data API which expects data_in (empty buffer) and number of data bytes to be received. - It waits till the receive is completed i.e., transfer complete event is generated. - - Now the current_mode enum is updated as per the macros enabled i.e., SL_USE_SEND. - - If no other macros are enabled, the current_mode is updated to SL_TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated as per the macros enabled i.e., SSI_SLAVE_SEND. + - If no other macros are enabled, the current_mode is updated to SSI_SLAVE_TRANSMISSION_COMPLETED. ## Prerequisites/Setup Requirements @@ -112,11 +112,11 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Application Configuration Parameters - Configure UC from the slcp component. - - ![Figure: UC image](resources/uc_screen/ssi_uc_screen.png) - - Open **sl_si91x_ssi_slave.slcp** project file select **software component** tab and search for **SSI** in search bar. - Using configuration wizard one can configure different parameters like: + + ![Figure: UC image](resources/uc_screen/ssi_uc_screen.png) + - **SSI Configuration** - Frame Format: SSI Frame Format can be configured, i.e., - Mode 0: Clock Polarity is zero and Clock Phase is zero. @@ -139,17 +139,17 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Configure the following macros in ssi_slave_example.h file and update/modify following macros if required. -- `USE_TRANSFER`: This macro is enabled default, it sends and receives data in full duplex. +- `SSI_SLAVE_TRANSFER`: This macro is enabled default, it sends and receives data in full duplex. ```C - #define SL_USE_TRANSFER ENABLE // To use the transfer API + #define SSI_SLAVE_TRANSFER ENABLE // To use the transfer API ``` -- `USE_SEND (or) USE_RECEIVE`: If USE_RECEIVE (or) USE_SEND is enabled, SSI slave will receive and send data in half duplex respectively. +- `SSI_SLAVE_SEND (or) SSI_SLAVE_RECEIVE`: If SSI_SLAVE_RECEIVE (or) SSI_SLAVE_SEND is enabled, SSI slave will receive and send data in half duplex respectively. ```C - #define SL_USE_SEND DISABLE // To use the send API - #define SL_USE_RECEIVE DISABLE // To use the receive API + #define SSI_SLAVE_SEND DISABLE // To use the send API + #define SSI_SLAVE_RECEIVE DISABLE // To use the receive API ``` ### Pin Configuration diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/sl_si91x_ssi_slave.slcp b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/sl_si91x_ssi_slave.slcp index 42f7ac81..cef1f9e1 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/sl_si91x_ssi_slave.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/sl_si91x_ssi_slave.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system @@ -27,10 +27,9 @@ component: from: wiseconnect3_sdk - id: sl_ssi from: wiseconnect3_sdk -define: - - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: SPI_MULTI_SLAVE - - name: SSI_CONFIG +configuration: + - name: SL_SSI_DEVICE_MODE + value: SL_SSI_SLAVE_ACTIVE other_file: - path: resources/readme/setupdiagram.png - path: resources/readme/image511d.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.c b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.c index 12bf72b3..ccab3aad 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.c @@ -24,44 +24,44 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 1024 // Length of data to be sent through SPI -#define DIVISION_FACTOR 0 // Division Factor -#define INTF_PLL_CLK 180000000 // PLL Clock frequency -#define INTF_PLL_REF_CLK 40000000 // PLL Ref Clock frequency -#define SOC_PLL_CLK 20000000 // SOC PLL Clock frequency -#define SOC_PLL_REF_CLK 40000000 // SOC PLL REFERENCE CLOCK frequency -#define INTF_PLL_500_CTRL_VALUE 0xD900 // Interface PLL control value -#define SOC_PLL_MM_COUNT_LIMIT 0xA4 // SOC PLL count limit -#define SSI_BIT_WIDTH 8 // SSI bit width -#define SSI_BAUDRATE 10000000 // SSI baudrate -#define MAX_BIT_WIDTH 16 // Maximum Bit width +#define SSI_SLAVE_BUFFER_SIZE 1024 // Length of data to be sent through SPI +#define SSI_SLAVE_DIVISION_FACTOR 0 // Division Factor +#define SSI_SLAVE_INTF_PLL_CLK 180000000 // PLL Clock frequency +#define SSI_SLAVE_INTF_PLL_REF_CLK 40000000 // PLL Ref Clock frequency +#define SSI_SLAVE_SOC_PLL_CLK 20000000 // SOC PLL Clock frequency +#define SSI_SLAVE_SOC_PLL_REF_CLK 40000000 // SOC PLL REFERENCE CLOCK frequency +#define SSI_SLAVE_INTF_PLL_500_CTRL_VALUE 0xD900 // Interface PLL control value +#define SSI_SLAVE_SOC_PLL_MM_COUNT_LIMIT 0xA4 // SOC PLL count limit +#define SSI_SLAVE_BIT_WIDTH 8 // SSI bit width +#define SSI_SLAVE_BAUDRATE 10000000 // SSI baudrate +#define SSI_SLAVE_MAX_BIT_WIDTH 16 // Maximum Bit width /******************************************************************************* ********************** Local Function prototypes *************************** ******************************************************************************/ -static sl_status_t init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config); -static void callback_event_handler(uint32_t event); -static void compare_loopback_data(void); +static sl_status_t ssi_slave_init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config); +static void ssi_slave_callback_event_handler(uint32_t event); +static void ssi_slave_compare_loopback_data(void); /******************************************************************************* ********************** Local variables ************************************* ******************************************************************************/ -static uint8_t data_out[BUFFER_SIZE] = { '\0' }; -static uint8_t data_in[BUFFER_SIZE] = { '\0' }; -static sl_ssi_handle_t ssi_driver_handle = NULL; -boolean_t transfer_complete = false; -boolean_t begin_transmission = true; -static uint16_t size_factor = 1; -static uint32_t slave_number = SSI_SLAVE_0; +static uint8_t ssi_slave_tx_buffer[SSI_SLAVE_BUFFER_SIZE] = { '\0' }; +static uint8_t ssi_slave_rx_buffer[SSI_SLAVE_BUFFER_SIZE] = { '\0' }; +static sl_ssi_handle_t ssi_driver_handle = NULL; +boolean_t ssi_slave_transfer_complete = false; +boolean_t ssi_slave_begin_transmission = true; +static uint16_t size_factor = 1; +static uint32_t ssi_slave_number = SSI_SLAVE_0; /// @brief Enumeration for different transmission scenarios typedef enum { - SL_TRANSFER_DATA, - SL_RECEIVE_DATA, - SL_SEND_DATA, - SL_TRANSMISSION_COMPLETED, + SSI_SLAVE_TRANSFER_DATA, + SSI_SLAVE_RECEIVE_DATA, + SSI_SLAVE_SEND_DATA, + SSI_SLAVE_TRANSMISSION_COMPLETED, } ssi_mode_enum_t; -static ssi_mode_enum_t current_mode = SL_TRANSFER_DATA; +static ssi_mode_enum_t ssi_slave_current_mode = SSI_SLAVE_TRANSFER_DATA; /******************************************************************************* ************************** GLOBAL FUNCTIONS ******************************* @@ -75,53 +75,53 @@ void ssi_slave_example_init(void) { uint16_t i = 0; sl_status_t sl_status = 0; - sl_ssi_clock_config_t clock_config; - sl_ssi_version_t version; + sl_ssi_clock_config_t ssi_clock_config; + sl_ssi_version_t ssi_version; // Configuring the user configuration structure - sl_ssi_control_config_t config; - config.bit_width = SSI_BIT_WIDTH; - config.device_mode = SL_SSI_SLAVE_ACTIVE; - config.clock_mode = SL_SSI_PERIPHERAL_CPOL0_CPHA0; - config.baud_rate = SSI_BAUDRATE; + sl_ssi_control_config_t ssi_slave_config; + ssi_slave_config.bit_width = SSI_SLAVE_BIT_WIDTH; + ssi_slave_config.device_mode = SL_SSI_SLAVE_ACTIVE; + ssi_slave_config.clock_mode = SL_SSI_PERIPHERAL_CPOL0_CPHA0; + ssi_slave_config.baud_rate = SSI_SLAVE_BAUDRATE; // Filled data into input buffer - for (i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)(i + 1); + for (i = 0; i < SSI_SLAVE_BUFFER_SIZE; i++) { + ssi_slave_tx_buffer[i] = (uint8_t)(i + 1); } do { // Version information of SSI driver - version = sl_si91x_ssi_get_version(); + ssi_version = sl_si91x_ssi_get_version(); DEBUGOUT("SSI version is fetched successfully \n"); - DEBUGOUT("API version is %d.%d.%d\n", version.release, version.major, version.minor); + DEBUGOUT("API version is %d.%d.%d\n", ssi_version.release, ssi_version.major, ssi_version.minor); // Clock Config for the SSI driver - sl_status = init_clock_configuration_structure(&clock_config); + sl_status = ssi_slave_init_clock_configuration_structure(&ssi_clock_config); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Clock get Configuration Failed, Error Code : %lu \n", sl_status); break; } DEBUGOUT("SSI Clock get Configuration Success \n"); - sl_status = sl_si91x_ssi_configure_clock(&clock_config); + sl_status = sl_si91x_ssi_configure_clock(&ssi_clock_config); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Clock Configuration Failed, Error Code : %lu \n", sl_status); break; } DEBUGOUT("SSI Clock Configuration Success\r\n"); // Initialize the SSI driver - sl_status = sl_si91x_ssi_init(config.device_mode, &ssi_driver_handle); + sl_status = sl_si91x_ssi_init(ssi_slave_config.device_mode, &ssi_driver_handle); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Initialization Failed, Error Code : %lu \n", sl_status); break; } DEBUGOUT("SSI Initialization Success \n"); // Configure the SSI to Master, 16-bit mode @10000 kBits/sec - sl_status = sl_si91x_ssi_set_configuration(ssi_driver_handle, &config, slave_number); + sl_status = sl_si91x_ssi_set_configuration(ssi_driver_handle, &ssi_slave_config, ssi_slave_number); if (sl_status != SL_STATUS_OK) { DEBUGOUT("Failed to Set Configuration Parameters to SSI, Error Code : %lu \n", sl_status); break; } DEBUGOUT("Set Configuration Parameters to SSI\r\n"); // Register the user callback - sl_status = sl_si91x_ssi_register_event_callback(ssi_driver_handle, callback_event_handler); + sl_status = sl_si91x_ssi_register_event_callback(ssi_driver_handle, ssi_slave_callback_event_handler); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI register event callback Failed, Error Code : %lu \n", sl_status); break; @@ -131,19 +131,19 @@ void ssi_slave_example_init(void) DEBUGOUT("Current Clock division factor is %lu \n", sl_si91x_ssi_get_clock_division_factor(ssi_driver_handle)); // Fetching and printing the current frame length DEBUGOUT("Current Frame Length is %lu \n", sl_si91x_ssi_get_frame_length(ssi_driver_handle)); - if (sl_si91x_ssi_get_frame_length(ssi_driver_handle) >= SSI_BIT_WIDTH) { - size_factor = sizeof(data_out[0]); + if (sl_si91x_ssi_get_frame_length(ssi_driver_handle) >= SSI_SLAVE_BIT_WIDTH) { + size_factor = sizeof(ssi_slave_tx_buffer[0]); } // As per the macros enabled in the header file, it will configure the current mode. - if (SL_USE_TRANSFER) { - current_mode = SL_TRANSFER_DATA; + if (SSI_SLAVE_TRANSFER) { + ssi_slave_current_mode = SSI_SLAVE_TRANSFER_DATA; break; } - if (SL_USE_RECEIVE) { - current_mode = SL_RECEIVE_DATA; + if (SSI_SLAVE_RECEIVE) { + ssi_slave_current_mode = SSI_SLAVE_RECEIVE_DATA; break; } - current_mode = SL_SEND_DATA; + ssi_slave_current_mode = SSI_SLAVE_SEND_DATA; } while (false); } /******************************************************************************* @@ -156,95 +156,99 @@ void ssi_slave_example_process_action(void) // In this switch case, according to the macros enabled in header file, it starts to execute the APIs // Assuming all the macros are enabled, after transfer, receive will be executed and after receive // send will be executed. - switch (current_mode) { - case SL_TRANSFER_DATA: - if (begin_transmission == true) { + switch (ssi_slave_current_mode) { + case SSI_SLAVE_TRANSFER_DATA: + if (ssi_slave_begin_transmission == true) { // Validation for executing the API only once - status = sl_si91x_ssi_transfer_data(ssi_driver_handle, data_out, data_in, sizeof(data_out) / size_factor); + status = sl_si91x_ssi_transfer_data(ssi_driver_handle, + ssi_slave_tx_buffer, + ssi_slave_rx_buffer, + sizeof(ssi_slave_tx_buffer) / size_factor); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_transfer_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_slave_current_mode = SSI_SLAVE_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI transfer begin successfully \n"); - begin_transmission = false; + ssi_slave_begin_transmission = false; } - if (transfer_complete) { - transfer_complete = false; + if (ssi_slave_transfer_complete) { + ssi_slave_transfer_complete = false; DEBUGOUT("SSI transfer completed successfully \n"); // After comparing the loopback transfer, it compares the data_out and // data_in. - compare_loopback_data(); - if (SL_USE_RECEIVE) { + ssi_slave_compare_loopback_data(); + if (SSI_SLAVE_RECEIVE) { // If receive macro is enabled, current mode is set to receive - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + ssi_slave_current_mode = SSI_SLAVE_RECEIVE_DATA; + ssi_slave_begin_transmission = true; break; } - if (SL_USE_SEND) { + if (SSI_SLAVE_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; - begin_transmission = true; + ssi_slave_current_mode = SSI_SLAVE_SEND_DATA; + ssi_slave_begin_transmission = true; break; } // If above macros are not enabled, current mode is set to complete - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_slave_current_mode = SSI_SLAVE_TRANSMISSION_COMPLETED; } break; - case SL_RECEIVE_DATA: - if (begin_transmission == true) { + case SSI_SLAVE_RECEIVE_DATA: + if (ssi_slave_begin_transmission == true) { // Validation for executing the API only once - status = sl_si91x_ssi_receive_data(ssi_driver_handle, data_in, sizeof(data_in)); + status = sl_si91x_ssi_receive_data(ssi_driver_handle, ssi_slave_rx_buffer, sizeof(ssi_slave_rx_buffer)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_receive_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_slave_current_mode = SSI_SLAVE_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI receive begin successfully \n"); - begin_transmission = false; + ssi_slave_begin_transmission = false; //Waiting till the receive is completed } - if (transfer_complete) { + if (ssi_slave_transfer_complete) { // If DMA is enabled, it will wait untill transfer_complete flag is set. - transfer_complete = false; - if (SL_USE_SEND) { + ssi_slave_transfer_complete = false; + if (SSI_SLAVE_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; - begin_transmission = true; + ssi_slave_current_mode = SSI_SLAVE_SEND_DATA; + ssi_slave_begin_transmission = true; DEBUGOUT("SSI receive completed \n"); break; } DEBUGOUT("SSI receive completed \n"); // If send macro is not enabled, current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_slave_current_mode = SSI_SLAVE_TRANSMISSION_COMPLETED; } break; - case SL_SEND_DATA: - if (begin_transmission) { + case SSI_SLAVE_SEND_DATA: + if (ssi_slave_begin_transmission) { // Validation for executing the API only once - status = sl_si91x_ssi_send_data(ssi_driver_handle, data_out, sizeof(data_out) / size_factor); + status = + sl_si91x_ssi_send_data(ssi_driver_handle, ssi_slave_tx_buffer, sizeof(ssi_slave_tx_buffer) / size_factor); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_send_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_slave_current_mode = SSI_SLAVE_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI send begin successfully \n"); - begin_transmission = false; + ssi_slave_begin_transmission = false; } //Waiting till the send is completed - if (transfer_complete) { + if (ssi_slave_transfer_complete) { // If DMA is enabled, it will wait untill transfer_complete flag is set. - transfer_complete = false; + ssi_slave_transfer_complete = false; DEBUGOUT("SSI send completed \n"); - compare_loopback_data(); + ssi_slave_compare_loopback_data(); // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + ssi_slave_current_mode = SSI_SLAVE_TRANSMISSION_COMPLETED; } break; - case SL_TRANSMISSION_COMPLETED: + case SSI_SLAVE_TRANSMISSION_COMPLETED: break; } } @@ -255,25 +259,25 @@ void ssi_slave_example_process_action(void) * and decides whether the test case passed/failed. * @return None *******************************************************************************/ -static void compare_loopback_data(void) +static void ssi_slave_compare_loopback_data(void) { // If the data width is not standard (8-bit) then the data should be masked. // The extra bits of the integer should be always zero. // For example, if bit width is 7, then from 8-15 all bits should be zero in a 16 bit integer. // So mask has value according to the data width and it is applied to the data. - int data_index; - uint8_t frame_length = 0; - uint16_t mask = ~0; - frame_length = sl_si91x_ssi_get_frame_length(ssi_driver_handle); - mask = mask >> (MAX_BIT_WIDTH - frame_length); - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - data_in[data_index] &= mask; - data_out[data_index] &= mask; - if (data_out[data_index] != data_in[data_index]) { + int ssi_data_index; + uint8_t ssi_frame_length = 0; + uint16_t ssi_mask = ~0; + ssi_frame_length = sl_si91x_ssi_get_frame_length(ssi_driver_handle); + ssi_mask = ssi_mask >> (SSI_SLAVE_MAX_BIT_WIDTH - ssi_frame_length); + for (ssi_data_index = 0; ssi_data_index < SSI_SLAVE_BUFFER_SIZE; ssi_data_index++) { + ssi_slave_rx_buffer[ssi_data_index] &= ssi_mask; + ssi_slave_tx_buffer[ssi_data_index] &= ssi_mask; + if (ssi_slave_tx_buffer[ssi_data_index] != ssi_slave_rx_buffer[ssi_data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (ssi_data_index == SSI_SLAVE_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Test case Passed \n"); } else { DEBUGOUT("Data comparison failed, Test case failed \n"); @@ -288,19 +292,19 @@ static void compare_loopback_data(void) * passed in. * * *******************************************************************************/ -static sl_status_t init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config) +static sl_status_t ssi_slave_init_clock_configuration_structure(sl_ssi_clock_config_t *clock_config) { if (clock_config == NULL) { return SL_STATUS_NULL_POINTER; } - clock_config->soc_pll_mm_count_value = SOC_PLL_MM_COUNT_LIMIT; - clock_config->intf_pll_500_control_value = INTF_PLL_500_CTRL_VALUE; - clock_config->intf_pll_clock = INTF_PLL_CLK; - clock_config->intf_pll_reference_clock = INTF_PLL_REF_CLK; - clock_config->soc_pll_clock = SOC_PLL_CLK; - clock_config->soc_pll_reference_clock = SOC_PLL_REF_CLK; - clock_config->division_factor = DIVISION_FACTOR; + clock_config->soc_pll_mm_count_value = SSI_SLAVE_SOC_PLL_MM_COUNT_LIMIT; + clock_config->intf_pll_500_control_value = SSI_SLAVE_INTF_PLL_500_CTRL_VALUE; + clock_config->intf_pll_clock = SSI_SLAVE_INTF_PLL_CLK; + clock_config->intf_pll_reference_clock = SSI_SLAVE_INTF_PLL_REF_CLK; + clock_config->soc_pll_clock = SSI_SLAVE_SOC_PLL_CLK; + clock_config->soc_pll_reference_clock = SSI_SLAVE_SOC_PLL_REF_CLK; + clock_config->division_factor = SSI_SLAVE_DIVISION_FACTOR; return SL_STATUS_OK; } @@ -309,11 +313,11 @@ static sl_status_t init_clock_configuration_structure(sl_ssi_clock_config_t *clo * @param[in]event SSI transmit and receive events * @return None *******************************************************************************/ -static void callback_event_handler(uint32_t event) +static void ssi_slave_callback_event_handler(uint32_t event) { switch (event) { case SSI_EVENT_TRANSFER_COMPLETE: - transfer_complete = true; + ssi_slave_transfer_complete = true; break; case SSI_EVENT_DATA_LOST: diff --git a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.h b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.h index a62ecbd2..b93bba67 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.h +++ b/examples/si91x_soc/peripheral/sl_si91x_ssi_slave/ssi_slave_example.h @@ -18,9 +18,9 @@ #ifndef SL_SI91X_SSI_EXAMPLE_H_ #define SL_SI91X_SSI_EXAMPLE_H_ -#define SL_USE_TRANSFER ENABLE -#define SL_USE_SEND DISABLE -#define SL_USE_RECEIVE DISABLE +#define SSI_SLAVE_TRANSFER ENABLE +#define SSI_SLAVE_SEND DISABLE +#define SSI_SLAVE_RECEIVE DISABLE // ----------------------------------------------------------------------------- // Prototypes @@ -46,4 +46,4 @@ void ssi_slave_example_init(void); ******************************************************************************/ void ssi_slave_example_process_action(void); -#endif /* SL_SI91X_SSI_EXAMPLE_H_ */ \ No newline at end of file +#endif /* SL_SI91X_SSI_EXAMPLE_H_ */ diff --git a/examples/si91x_soc/peripheral/sl_si91x_sysrtc/readme.md b/examples/si91x_soc/peripheral/sl_si91x_sysrtc/readme.md index 0b6c39d6..d15cf78e 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_sysrtc/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_sysrtc/readme.md @@ -56,6 +56,7 @@ - Starts counter through \ref sl_si91x_sysrtc_start - After starting waits unless counter reaches compare value for 1-second and then sets SYSRTC register capture input high through \ref sl_si91x_sysrtc_sets_register_capture_input API. - A capture interrupt is generated and toggles LED1 one time. +- And SYSRTC is de-initialized through \ref sl_si91x_sysrtc_deinit ### If no channels enabled through UC @@ -82,7 +83,7 @@ Refer [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-star ### Setup Diagram -> ![Figure: Introduction](resources/readme/setupdiagram.png) +> ![Figure: Setup Diagram](resources/readme/setupdiagram.png) ## Getting Started @@ -132,7 +133,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise 2. When the application runs, LED1(GPIO_10) will be toggled five times at 1sec periodic rate. 3. After successful program execution the prints in serial console looks as shown below. - ![Figure: Introduction](resources/readme/output.png) + ![Figure: Output](resources/readme/output.png) > **Note:** > diff --git a/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sl_si91x_sysrtc.slcp b/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sl_si91x_sysrtc.slcp index 7c5a06be..aafc078e 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sl_si91x_sysrtc.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sl_si91x_sysrtc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system @@ -38,10 +38,6 @@ other_file: - path: resources/readme/setupdiagram.png - path: resources/readme/image509d.png - path: resources/readme/output.png -define: - - name: SLI_SI91X_MCU_COMMON_FLASH_MODE - - name: SI91X_SYSRTC_COUNT - value: "1" ui_hints: highlight: - path: readme.md diff --git a/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sysrtc_example.c b/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sysrtc_example.c index 6df84f39..949d5e48 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sysrtc_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_sysrtc/sysrtc_example.c @@ -169,7 +169,7 @@ void sysrtc_example_init(void) sl_si91x_sysrtc_set_count(counter_value1); //Setting compare value. status = sl_si91x_sysrtc_set_compare_value(SL_SYSRTC_GROUP, COMPARE_CHANNEL, compare_value); - DEBUGOUT("\r\nSYSRTC group 0 compare value set successfully\r\n"); + DEBUGOUT("\r\nSYSRTC group compare value set successfully\r\n"); // Starting Sysrtc sl_si91x_sysrtc_start(); DEBUGOUT("\nStarted SYSRTC successfully\n"); @@ -253,8 +253,8 @@ void sysrtc_callback(void *callback_flags) // To toggle LED1 state = !state; sl_si91x_led_toggle(RTE_LED1_PIN); +#if ((SL_SYSRTC_COMPARE_CHANNEL0_ENABLE) || (SL_SYSRTC_COMPARE_CHANNEL1_ENABLE)) // Reading current count -#if ((SL_SYSRTC_COMPARE_CHANNEL0_ENABLE == 1) || (SL_SYSRTC_COMPARE_CHANNEL1_ENABLE == 1)) status = sl_si91x_sysrtc_get_count(¤t_count); // Setting compare value again after every interrupt, to get next interrupt sl_si91x_sysrtc_set_compare_value(SL_SYSRTC_GROUP, COMPARE_CHANNEL, (current_count + compare_value)); @@ -262,10 +262,14 @@ void sysrtc_callback(void *callback_flags) if (interrupt_count == TENTH_INTERRUPT) { //Stopping the timer instance, after five LED toggles. sl_si91x_sysrtc_stop(); - // Unregister callback and disabling interrupts - status = sl_si91x_sysrtc_unregister_callback(SL_SYSRTC_GROUP, &interrupt_enabled); - // Deinit sysrtc + // Deinit sysrtc and unregistering callback sl_si91x_sysrtc_deinit(); } #endif +#if (SL_SYSRTC_CAPTURE_CHANNEL0_ENABLE) + //Stopping the timer instance, after capture interrupt. + sl_si91x_sysrtc_stop(); + // Deinit sysrtc and unregistering callback + sl_si91x_sysrtc_deinit(); +#endif } diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_adc/sl_si91x_ulp_adc.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_adc/sl_si91x_ulp_adc.slcp index ee55042d..a0c919bf 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_adc/sl_si91x_ulp_adc.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_adc/sl_si91x_ulp_adc.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: sl_ulp_adc_example.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/readme.md b/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/readme.md index 01a39c71..4cf11e17 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/readme.md @@ -68,12 +68,12 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Application Configuration Parameters - Configure UC from the slcp component. -- Open **sl_si91x_adc.slcp** project file select **software component** tab and search for **ADC** in search bar. +- Open **sl_si91x_ulp_adc_multichannel.slcp** project file select **software component** tab and search for **ADC** in search bar. - Using configuration wizard one can configure different parameters. Below are the 2 configuration screens where user can select as per requirement. - **ADC Peripheral Common Configuration** - - Number of channel: By default channel is set to '1'. When the channel number is changed, then care must be taken to create instance of that respective channel number. Otherwise, an error is thrown. + - Number of channel: In multichannel mode by default number of channel is '4'. When the number of channel is changed, then care must be taken to create instance of that respective channel number. Otherwise, an error is thrown. - ADC operation mode: There are 2 modes, FIFO mode and Static mode. By default it is in FIFO mode. When static mode is set, sample length should be '1'. ![Figure: Introduction](resources/uc_screen/sl_adc_common_uc_screen.png) @@ -126,10 +126,9 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: -1. Adjust the number of channel as 4 in ADC Peripheral Common Configuration UC. -2. Compile and run the application. -3. When the application runs, it starts ADC conversion. -4. After completion of conversion ADC input, it will print all the captured samples data in console by connecting vcom. +1. Compile and run the application. +2. When the application runs, it starts ADC conversion. +3. After completion of conversion ADC input, it will print all the captured samples data in console by connecting vcom. - **Channel 0 pin connections** - When configured Single ended mode connect the positive analog input to ULP_GPIO_1 and GND to ULP_GPIO_7 @@ -146,7 +145,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise > **Note:** > -- Users who only want to utilize two channels can uninstall channels two and three from the software components on sl_si91x_ulp_adc_multichannel_2.slcp. By default, four channels instances will be created. +- Users who only want to utilize two channels can uninstall channels two and three from the software components on sl_si91x_ulp_adc_multichannel.slcp. By default, four channels instances will be created. - For channel 2 and channel 3 GPIO will choose as ULP GPIO's in ULP mode of ADC multichannel. - This application only applicable for FIFO mode. - Sample rate should be either same for all channels or 1/2, 1/4, 1/16.(for example if channel_0 sample rate is 10000sps, then channel_1 = 10000/2 sps, channel_2 = 10000/4 sps, channel_3 = 10000/16 sps). diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/sl_si91x_ulp_adc_multichannel.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/sl_si91x_ulp_adc_multichannel.slcp index 643079aa..a8c545c0 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/sl_si91x_ulp_adc_multichannel.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_adc_multichannel/sl_si91x_ulp_adc_multichannel.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: sl_ulp_adc_multichannel_example.c - path: app.c @@ -40,6 +40,9 @@ requires: - name: ulp_mode_execution define: - name: GAIN_OFFSET_CAL_EN +configuration: + - name: NUMBER_OF_CHANNEL + value: '4' template_contribution: - name: ulp_platform priority: 0 diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_calendar/sl_si91x_ulp_calendar.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_calendar/sl_si91x_ulp_calendar.slcp index 5f40c5d3..1001df2c 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_calendar/sl_si91x_ulp_calendar.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_calendar/sl_si91x_ulp_calendar.slcp @@ -20,7 +20,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_dma/sl_si91x_ulp_dma.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_dma/sl_si91x_ulp_dma.slcp index b7f44e9f..dcdebd0c 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_dma/sl_si91x_ulp_dma.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_dma/sl_si91x_ulp_dma.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_gpio/sl_si91x_ulp_gpio.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_gpio/sl_si91x_ulp_gpio.slcp index a5e10098..8487a09a 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_gpio/sl_si91x_ulp_gpio.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_gpio/sl_si91x_ulp_gpio.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/sl_si91x_ulp_i2c_leader.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/sl_si91x_ulp_i2c_leader.slcp index 7989787c..94ef5a2d 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/sl_si91x_ulp_i2c_leader.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/sl_si91x_ulp_i2c_leader.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/ulp_i2c_leader_example.c b/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/ulp_i2c_leader_example.c index 048632bc..2a219210 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/ulp_i2c_leader_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_i2c_leader/ulp_i2c_leader_example.c @@ -25,24 +25,24 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define SIZE_BUFFERS 15 // Size of buffer -#define FOLLOWER_I2C_ADDR 0x50 // EEPROM I2C address -#define RX_LENGTH SIZE_BUFFERS // Number of bytes to receive -#define TX_LENGTH SIZE_BUFFERS // Number of bytes to send -#define OFFSET_LENGTH 1 // Offset length -#define FIFO_THRESHOLD 0x0 // FIFO threshold -#define ZERO_FLAG 0 // Zero flag, No argument -#define PINMUX_MODE 6 // I2C pinmux mode -#define PORT_ZERO 0 // Port zero -#define HP_MAX_GPIO 64 // High Power GPIO Maximum number -#define LAST_DATA_COUNT 0 // Last read-write count -#define DATA_COUNT 1 // Last second data count for verification -#define BIT_SET 1 // Set bit -#define STOP_BIT 9 // Bit to send stop command -#define RW_MASK_BIT 8 // Bit to mask read and write -#define I2C_INSTANCE 2 // I2C Instance for Pin configuration -#define I2C I2C2 // I2C Instance -#define MAX_7BIT_ADDRESS 127 // Maximum 7-bit address +#define ULP_I2C_SIZE_BUFFERS 15 // Size of buffer +#define FOLLOWER_I2C_ADDR 0x50 // EEPROM I2C address +#define ULP_I2C_RX_LENGTH ULP_I2C_SIZE_BUFFERS // Number of bytes to receive +#define ULP_I2C_TX_LENGTH ULP_I2C_SIZE_BUFFERS // Number of bytes to send +#define ULP_I2C_OFFSET_LENGTH 1 // Offset length +#define ULP_I2C_FIFO_THRESHOLD 0x0 // FIFO threshold +#define ZERO_FLAG 0 // Zero flag, No argument +#define PINMUX_MODE 6 // I2C pinmux mode +#define PORT_ZERO 0 // Port zero +#define HP_MAX_GPIO 64 // High Power GPIO Maximum number +#define LAST_DATA_COUNT 0 // Last read-write count +#define DATA_COUNT 1 // Last second data count for verification +#define BIT_SET 1 // Set bit +#define STOP_BIT 9 // Bit to send stop command +#define RW_MASK_BIT 8 // Bit to mask read and write +#define I2C_INSTANCE 2 // I2C Instance for Pin configuration +#define I2C I2C2 // I2C Instance +#define MAX_7BIT_ADDRESS 127 // Maximum 7-bit address /******************************************************************************* ****************************** Data Types *********************************** @@ -57,50 +57,44 @@ typedef const struct { // Enum for different transmission scenarios typedef enum { - SEND_DATA, // Send mode - RECEIVE_DATA, // Receive mode - TRANSMISSION_COMPLETED, // Transmission completed mode + ULP_I2C_SEND_DATA, // Send mode + ULP_I2C_RECEIVE_DATA, // Receive mode + ULP_I2C_TRANSMISSION_COMPLETED, // Transmission completed mode } i2c_mode_enum_t; /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ #if (I2C_INSTANCE == 0) -// SCL, GPIO: 75, Exapansion Header: 5 -// SDA, GPIO: 75, Exapansion Header: 3 static I2C_PIN scl = { RTE_I2C0_SCL_PORT, RTE_I2C0_SCL_PIN, RTE_I2C0_SCL_MUX, RTE_I2C0_SCL_PAD }; static I2C_PIN sda = { RTE_I2C0_SDA_PORT, RTE_I2C0_SDA_PIN, RTE_I2C0_SDA_MUX, RTE_I2C0_SDA_PAD }; #endif #if (I2C_INSTANCE == 1) -// SCL, GPIO: 50, Board Pin: P19 -// SDA, GPIO: 51, Board Pin: P20 static I2C_PIN scl = { RTE_I2C1_SCL_PORT, RTE_I2C1_SCL_PIN, RTE_I2C1_SCL_MUX, RTE_I2C1_SCL_PAD }; static I2C_PIN sda = { RTE_I2C1_SDA_PORT, RTE_I2C1_SDA_PIN, RTE_I2C1_SDA_MUX, RTE_I2C1_SDA_PAD }; #endif #if (I2C_INSTANCE == 2) -// SCL, ULP_GPIO: 5, Exapansion Header: 13 -// SDA, ULP_GPIO: 4, Exapansion Header: 11 static I2C_PIN scl = { RTE_I2C2_SCL_PORT, RTE_I2C2_SCL_PIN, RTE_I2C2_SCL_MUX, 0 }; static I2C_PIN sda = { RTE_I2C2_SDA_PORT, RTE_I2C2_SDA_PIN, RTE_I2C2_SDA_MUX, 0 }; #endif -static i2c_mode_enum_t current_mode = SEND_DATA; -boolean_t i2c_send_complete = false; -boolean_t i2c_receive_complete = false; -boolean_t send_data_flag = false; -boolean_t receive_data_flag = false; +static i2c_mode_enum_t current_mode = ULP_I2C_SEND_DATA; +boolean_t ulp_i2c_send_complete = false; +boolean_t ulp_i2c_receive_complete = false; +boolean_t ulp_i2c_send_data_flag = false; +boolean_t ulp_i2c_receive_data_flag = false; -static uint32_t write_number = 0; -static uint32_t write_count = 0; -static uint32_t read_number = 0; -static uint32_t read_count = 0; -static uint8_t *write_data; -static uint8_t *read_data; +static uint32_t ulp_i2c_write_number = 0; +static uint32_t ulp_i2c_write_count = 0; +static uint32_t ulp_i2c_read_number = 0; +static uint32_t ulp_i2c_read_count = 0; +static uint8_t *ulp_i2c_write_data; +static uint8_t *ulp_i2c_read_data; -static uint8_t read_buffer[SIZE_BUFFERS + OFFSET_LENGTH]; -static uint8_t write_buffer[SIZE_BUFFERS]; +static uint8_t ulp_i2c_read_buffer[ULP_I2C_SIZE_BUFFERS + ULP_I2C_OFFSET_LENGTH]; +static uint8_t ulp_i2c_write_buffer[ULP_I2C_SIZE_BUFFERS]; /******************************************************************************* ********************** Local Function prototypes *************************** @@ -146,11 +140,11 @@ void i2c_leader_example_init(void) pin_configurations(); DEBUGOUT("Pins are configured successfully \n"); // Generating a buffer with values that needs to be sent. - for (uint32_t loop = 0; loop < SIZE_BUFFERS; loop++) { - write_buffer[loop] = (loop + 0x1); - read_buffer[loop] = 0; + for (uint32_t loop = 0; loop < ULP_I2C_SIZE_BUFFERS; loop++) { + ulp_i2c_write_buffer[loop] = (loop + 0x1); + ulp_i2c_read_buffer[loop] = 0; } - send_data_flag = true; + ulp_i2c_send_data_flag = true; } /******************************************************************************* @@ -163,35 +157,35 @@ void i2c_leader_example_process_action(void) // After that offset address is sent to the follower device. // Now data is read from the EEPROM using I2C recevie. switch (current_mode) { - case SEND_DATA: - if (send_data_flag) { + case ULP_I2C_SEND_DATA: + if (ulp_i2c_send_data_flag) { // Validation for executing the API only once. - i2c_send_data(write_buffer, TX_LENGTH + OFFSET_LENGTH, FOLLOWER_I2C_ADDR); - send_data_flag = false; + i2c_send_data(ulp_i2c_write_buffer, ULP_I2C_TX_LENGTH + ULP_I2C_OFFSET_LENGTH, FOLLOWER_I2C_ADDR); + ulp_i2c_send_data_flag = false; } - if (i2c_send_complete) { - // It waits till i2c_send_complete is true in IRQ handler. - current_mode = RECEIVE_DATA; - receive_data_flag = true; - i2c_send_complete = false; + if (ulp_i2c_send_complete) { + // It waits till ulp_i2c_send_complete is true in IRQ handler. + current_mode = ULP_I2C_RECEIVE_DATA; + ulp_i2c_receive_data_flag = true; + ulp_i2c_send_complete = false; } break; - case RECEIVE_DATA: - if (receive_data_flag) { + case ULP_I2C_RECEIVE_DATA: + if (ulp_i2c_receive_data_flag) { // Validation for executing the API only once. - i2c_receive_data(read_buffer, RX_LENGTH + OFFSET_LENGTH, FOLLOWER_I2C_ADDR); - receive_data_flag = false; + i2c_receive_data(ulp_i2c_read_buffer, ULP_I2C_RX_LENGTH + ULP_I2C_OFFSET_LENGTH, FOLLOWER_I2C_ADDR); + ulp_i2c_receive_data_flag = false; } - if (i2c_receive_complete) { - // It waits till i2c_receive_complete is true in IRQ handler. - current_mode = TRANSMISSION_COMPLETED; - i2c_receive_complete = false; + if (ulp_i2c_receive_complete) { + // It waits till ulp_i2c_receive_complete is true in IRQ handler. + current_mode = ULP_I2C_TRANSMISSION_COMPLETED; + ulp_i2c_receive_complete = false; // After the receive is completed, input and output data is compared and // output is printed on console. compare_data(); } break; - case TRANSMISSION_COMPLETED: + case ULP_I2C_TRANSMISSION_COMPLETED: break; default: break; @@ -213,9 +207,9 @@ static void i2c_send_data(const uint8_t *data, uint32_t data_length, uint16_t fo // Disables the interrupts. sl_si91x_i2c_disable_interrupts(I2C, ZERO_FLAG); // Updates the variables which are required for trasmission. - write_data = (uint8_t *)data; - write_count = 0; - write_number = data_length; + ulp_i2c_write_data = (uint8_t *)data; + ulp_i2c_write_count = 0; + ulp_i2c_write_number = data_length; // Disables the I2C peripheral. sl_si91x_i2c_disable(I2C); // Checking is address is 7-bit or 10bit @@ -225,7 +219,7 @@ static void i2c_send_data(const uint8_t *data, uint32_t data_length, uint16_t fo // Setting the follower address recevied in parameter structure. sl_si91x_i2c_set_follower_address(I2C, follower_address, is_10bit_addr); // Configures the FIFO threshold. - sl_si91x_i2c_set_tx_threshold(I2C, FIFO_THRESHOLD); + sl_si91x_i2c_set_tx_threshold(I2C, ULP_I2C_FIFO_THRESHOLD); // Enables the I2C peripheral. sl_si91x_i2c_enable(I2C); // Configures the transmit empty interrupt. @@ -249,9 +243,9 @@ static void i2c_receive_data(uint8_t *data, uint32_t data_length, uint16_t follo // Disables the interrupts. sl_si91x_i2c_disable_interrupts(I2C, ZERO_FLAG); // Updates the variables which are required for trasmission. - read_data = (uint8_t *)data; - read_count = 0; - read_number = data_length; + ulp_i2c_read_data = (uint8_t *)data; + ulp_i2c_read_count = 0; + ulp_i2c_read_number = data_length; // Disables the I2C peripheral. sl_si91x_i2c_disable(I2C); // Checking is address is 7-bit or 10bit @@ -261,7 +255,7 @@ static void i2c_receive_data(uint8_t *data, uint32_t data_length, uint16_t follo // Setting the follower address recevied in parameter structure. sl_si91x_i2c_set_follower_address(I2C, follower_address, is_10bit_addr); // Configures the FIFO threshold. - sl_si91x_i2c_set_rx_threshold(I2C, FIFO_THRESHOLD); + sl_si91x_i2c_set_rx_threshold(I2C, ULP_I2C_FIFO_THRESHOLD); // Enables the I2C peripheral. sl_si91x_i2c_enable(I2C); // Sets the direction to read. @@ -320,14 +314,14 @@ static void i2c_clock_init(I2C_TypeDef *i2c) static void compare_data(void) { uint32_t data_index = 0; - for (data_index = 0; data_index < SIZE_BUFFERS; data_index++) { - // If the read_buffer and buffer are same, it will be continued else, the for + for (data_index = 0; data_index < ULP_I2C_SIZE_BUFFERS; data_index++) { + // If the ulp_i2c_read_buffer and buffer are same, it will be continued else, the for // loop will be break. - if (write_buffer[data_index] != read_buffer[data_index]) { + if (ulp_i2c_write_buffer[data_index] != ulp_i2c_read_buffer[data_index]) { break; } } - if (data_index == SIZE_BUFFERS) { + if (data_index == ULP_I2C_SIZE_BUFFERS) { DEBUGOUT("Leader-Follower read-write Data comparison is successful, Test Case Passed \n"); } else { DEBUGOUT("Leader-Follower read-write Data comparison is not successful, Test Case Failed \n"); @@ -413,18 +407,18 @@ static void pin_configurations(void) ******************************************************************************/ static void handle_leader_transmit_irq(void) { - if (write_number > LAST_DATA_COUNT) { - if (write_number == DATA_COUNT) { - I2C->IC_DATA_CMD = (uint32_t)write_data[write_count] | (BIT_SET << STOP_BIT); + if (ulp_i2c_write_number > LAST_DATA_COUNT) { + if (ulp_i2c_write_number == DATA_COUNT) { + I2C->IC_DATA_CMD = (uint32_t)ulp_i2c_write_data[ulp_i2c_write_count] | (BIT_SET << STOP_BIT); } else { - sl_si91x_i2c_tx(I2C, write_data[write_count]); + sl_si91x_i2c_tx(I2C, ulp_i2c_write_data[ulp_i2c_write_count]); } - write_count++; - write_number--; + ulp_i2c_write_count++; + ulp_i2c_write_number--; } else { sl_si91x_i2c_clear_interrupts(I2C, SL_I2C_EVENT_TRANSMIT_EMPTY); sl_si91x_i2c_disable_interrupts(I2C, ZERO_FLAG); - i2c_send_complete = true; + ulp_i2c_send_complete = true; } } @@ -438,23 +432,23 @@ static void handle_leader_transmit_irq(void) ******************************************************************************/ static void handle_leader_receive_irq(void) { - if (read_number > LAST_DATA_COUNT) { - read_data[read_count] = I2C->IC_DATA_CMD_b.DAT; - read_count++; - read_number--; - if (read_number == DATA_COUNT) { + if (ulp_i2c_read_number > LAST_DATA_COUNT) { + ulp_i2c_read_data[ulp_i2c_read_count] = I2C->IC_DATA_CMD_b.DAT; + ulp_i2c_read_count++; + ulp_i2c_read_number--; + if (ulp_i2c_read_number == DATA_COUNT) { // If the last byte is there to receive, and in leader mode, it needs to send // the stop byte. I2C->IC_DATA_CMD = (BIT_SET << RW_MASK_BIT) | (BIT_SET << STOP_BIT); } - if (read_number > DATA_COUNT) { + if (ulp_i2c_read_number > DATA_COUNT) { I2C->IC_DATA_CMD = (BIT_SET << RW_MASK_BIT); } } - if (read_number == LAST_DATA_COUNT) { + if (ulp_i2c_read_number == LAST_DATA_COUNT) { sl_si91x_i2c_clear_interrupts(I2C, SL_I2C_EVENT_RECEIVE_FULL); sl_si91x_i2c_disable_interrupts(I2C, ZERO_FLAG); - i2c_receive_complete = true; + ulp_i2c_receive_complete = true; } } diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/readme.md b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/readme.md index 99a76edc..922ea5aa 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/readme.md @@ -58,26 +58,26 @@ - The State machine code is implemented for transfer, send and receive data, the current mode is determined by ssi_mode_enum_t which is declared in ulp_ssi_master_example.c file. - According to the macro which is enabled, the example code executes the transfer of data: -- If **SL_USE_TRANSFER** macro is enabled, it will transfer the data, i.e. send and receive data in full duplex mode. +- If **ULP_SSI_MASTER_TRANSFER** macro is enabled, it will transfer the data, i.e. send and receive data in full duplex mode. - - The current_mode enum is set to SL_TRANSFER_DATA and calls the \ref sl_si91x_ssi_transfer_data API which expects data_out, data_in and number of data bytes to be transferred for sending and receiving data simultaneously (full duplex). + - The current_mode enum is set to ULP_SSI_MASTER_TRANSFER_DATA and calls the \ref sl_si91x_ssi_transfer_data API which expects data_out, data_in and number of data bytes to be transferred for sending and receiving data simultaneously (full duplex). - This test can also be performed in loopback state, i.e. connect MISO and MOSI pins. - The example code waits till the transfer is completed, when the transfer complete event is generated, it compares the sent and received data. - The result is printed on the console. - - Now the current_mode enum is updated as per the macros enabled i.e., either SL_USE_SEND or SL_USE_RECEIVE. - - If no other macros are enabled, the current_mode is updated to SL_TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated as per the macros enabled i.e., either ULP_SSI_MASTER_SEND or ULP_SSI_MASTER_RECEIVE. + - If no other macros are enabled, the current_mode is updated to ULP_SSI_MASTER_TRANSMISSION_COMPLETED. -- If **SL_USE_RECEIVE** macro is enabled, it only receives the data from slave - SPI slave must be connected, it cannot be tested in loopback mode. +- If **ULP_SSI_MASTER_RECEIVE** macro is enabled, it only receives the data from slave - SPI slave must be connected, it cannot be tested in loopback mode. - - The current_mode is set to the SL_RECEIVE_DATA and calls the \ref sl_si91x_ssi_receive_data API which expects data_in (empty buffer) and number of data bytes to be received. + - The current_mode is set to the ULP_SSI_MASTER_RECEIVE_DATA and calls the \ref sl_si91x_ssi_receive_data API which expects data_in (empty buffer) and number of data bytes to be received. - It waits till the receive is completed i.e., transfer complete event is generated. - - Now the current_mode enum is updated as per the macros enabled i.e., SL_USE_SEND. - - If no other macros are enabled, the current_mode is updated to SL_TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated as per the macros enabled i.e., ULP_SSI_MASTER_SEND. + - If no other macros are enabled, the current_mode is updated to ULP_SSI_MASTER_TRANSMISSION_COMPLETED. -- If **SL_USE_SEND** macro is enabled, it only sends the data to slave, SPI slave must be connected, it cannot be tested in loopback mode. - - The current_mode enum is set to SL_SEND_DATA and calls the \ref sl_si91x_ssi_send_data API which expects data_out (data buffer that needs to be sent) and number of bytes to send. +- If **ULP_SSI_MASTER_SEND** macro is enabled, it only sends the data to slave, SPI slave must be connected, it cannot be tested in loopback mode. + - The current_mode enum is set to ULP_SSI_MASTER_SEND_DATA and calls the \ref sl_si91x_ssi_send_data API which expects data_out (data buffer that needs to be sent) and number of bytes to send. - It waits till the send is completed i.e., transfer complete event is generated. - - Now the current_mode enum is updated to TRANSMISSION_COMPLETED. + - Now the current_mode enum is updated to ULP_SSI_MASTER_TRANSMISSION_COMPLETED. ## Prerequisites/Setup Requirements @@ -110,12 +110,11 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ## Application Build Environment - Configure UC from the slcp component. +- Open **sl_si91x_ulp_ssi_master.slcp** project file select **software component** tab and search for **SSI** in search bar. +- Using configuration wizard one can configure different parameters like: ![Figure: Introduction](resources/uc_screen/ssi_uc_screen.png) -- Enable the ULP_SSI_MASTER in UC before running/flashing the code. -- Open **sl_si91x_ulp_ssi_master.slcp** project file select **software component** tab and search for **SSI** in search bar. -- Using configuration wizard one can configure different parameters like: - **SSI Configuration** - Frame Format: SSI Frame Format can be configured, i.e., - Mode 0: Clock Polarity is zero and Clock Phase is zero. @@ -139,9 +138,9 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Configure the following macros in ulp_ssi_master_example.h file and update/modify following macros if required. ```C -#define SL_USE_TRANSFER ENABLE // To use the transfer API -#define SL_USE_SEND DISABLE // To use the send API -#define SL_USE_RECEIVE DISABLE // To use the receive API +#define ULP_SSI_MASTER_TRANSFER ENABLE // To use the transfer API +#define ULP_SSI_MASTER_SEND DISABLE // To use the send API +#define ULP_SSI_MASTER_RECEIVE DISABLE // To use the receive API ``` ## Pin Configuration of the WPK[BRD4002A] Base Board @@ -167,7 +166,7 @@ Follow the steps below for successful execution of the application: 1. Connect ULP SSI Master SCK, CS0, MOSI, MISO pins with the SSI Slave device. 2. When the application runs, it receives and send data. 3. After the transfer is completed, it validates the data and prints "Test Case Passed" on the console. -3. If USE_RECEIVE or USE_SEND is enabled, SSI slave will receive and send data respectively. +3. If ULP_SSI_MASTER_RECEIVE or ULP_SSI_MASTER_SEND is enabled, SSI slave will receive and send data respectively. 4. After successful program execution the prints in serial console looks as shown below. - Master output: @@ -181,5 +180,6 @@ Follow the steps below for successful execution of the application: > **Note:** > >- After Flashing ULP examples as M4 flash will be turned off,flash erase does not work. ->- To Erase the chip follow the below procedure ->- Press ISP and RESET button at same time and then release, now perform Chip erase through commander. +> +- To Erase the chip follow the below procedure + - **Press ISP and RESET button at same time and then release, now perform Chip erase through commander.** diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/sl_si91x_ulp_ssi_master.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/sl_si91x_ulp_ssi_master.slcp index 2b9ad9a5..79bf8eeb 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/sl_si91x_ulp_ssi_master.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/sl_si91x_ulp_ssi_master.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system @@ -35,10 +35,9 @@ other_file: - path: resources/readme/output_ssi_slave.png requires: - name: ulp_mode_execution -define: - - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: SPI_MULTI_SLAVE - - name: SSI_CONFIG +configuration: + - name: SL_SSI_DEVICE_MODE + value: SL_SSI_ULP_MASTER_ACTIVE readme: - path: readme.md ui_hints: diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.c b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.c index 884b027a..2299fd43 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.c @@ -24,39 +24,39 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 1024 // Length of data to be sent through SPI -#define SSI_BIT_WIDTH 8 // SSI bit width -#define SSI_BAUDRATE 10000000 // SSI baudrate -#define MAX_BIT_WIDTH 16 // Maximum Bit width -#define RECEIVE_SAMPLE_DELAY 0 // By default sample delay is 0 -#define ULP_BANK_OFFSET 0x800 // ULP Memory bank offset value. -#define TX_BUF_MEMORY (ULP_SRAM_START_ADDR + (1 * ULP_BANK_OFFSET)) -#define RX_BUF_MEMORY (ULP_SRAM_START_ADDR + (2 * ULP_BANK_OFFSET)) +#define ULP_SSI_MASTER_BUFFER_SIZE 1024 // Length of data to be sent through SPI +#define ULP_SSI_MASTER_BIT_WIDTH 8 // SSI bit width +#define ULP_SSI_MASTER_BAUDRATE 10000000 // SSI baudrate +#define ULP_SSI_MASTER_MAX_BIT_WIDTH 16 // Maximum Bit width +#define ULP_SSI_MASTER_RECEIVE_SAMPLE_DELAY 0 // By default sample delay is 0 +#define ULP_SSI_MASTER_BANK_OFFSET 0x800 // ULP Memory bank offset value. +#define ULP_SSI_MASTER_TX_BUF_MEMORY (ULP_SRAM_START_ADDR + (1 * ULP_SSI_MASTER_BANK_OFFSET)) +#define ULP_SSI_MASTER_RX_BUF_MEMORY (ULP_SRAM_START_ADDR + (2 * ULP_SSI_MASTER_BANK_OFFSET)) /******************************************************************************* ********************** Local Function prototypes *************************** ******************************************************************************/ -static void callback_event_handler(uint32_t event); -static void compare_loopback_data(void); +static void ulp_ssi_master_callback_event_handler(uint32_t event); +static void ulp_ssi_master_compare_loopback_data(void); /******************************************************************************* ********************** Local variables ************************************* ******************************************************************************/ -static uint8_t data_out[BUFFER_SIZE] = { '\0' }; -static uint8_t data_in[BUFFER_SIZE] = { '\0' }; -static sl_ssi_handle_t ssi_driver_handle = NULL; -boolean_t transfer_complete = false; -boolean_t begin_transmission = true; -static uint32_t slave_number = SSI_SLAVE_0; +static uint8_t ulp_ssi_master_tx_buffer[ULP_SSI_MASTER_BUFFER_SIZE] = { '\0' }; +static uint8_t ulp_ssi_master_rx_buffer[ULP_SSI_MASTER_BUFFER_SIZE] = { '\0' }; +static sl_ssi_handle_t ssi_driver_handle = NULL; +boolean_t ulp_ssi_master_transfer_complete = false; +boolean_t ulp_ssi_master_begin_transmission = true; +static uint32_t ulp_ssi_master_slave_number = SSI_SLAVE_0; /// @brief Enumeration for different transmission scenarios typedef enum { - SL_TRANSFER_DATA, - SL_RECEIVE_DATA, - SL_SEND_DATA, - SL_TRANSMISSION_COMPLETED, + ULP_SSI_MASTER_TRANSFER_DATA, + ULP_SSI_MASTER_RECEIVE_DATA, + ULP_SSI_MASTER_SEND_DATA, + ULP_SSI_MASTER_TRANSMISSION_COMPLETED, } ssi_mode_enum_t; -static ssi_mode_enum_t current_mode = SL_TRANSFER_DATA; +static ssi_mode_enum_t ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSFER_DATA; extern void hardware_setup(void); @@ -79,24 +79,29 @@ void ssi_master_example_init(void) uint16_t i = 0; sl_status_t sl_status = 0; - sl_ssi_version_t version; + sl_ssi_version_t ulp_ssi_master_version; // Configuring the user configuration structure - sl_ssi_control_config_t config; - config.bit_width = SSI_BIT_WIDTH; - config.device_mode = SL_SSI_ULP_MASTER_ACTIVE; - config.clock_mode = SL_SSI_PERIPHERAL_CPOL0_CPHA0; - config.baud_rate = SSI_BAUDRATE; - config.receive_sample_delay = RECEIVE_SAMPLE_DELAY; + sl_ssi_control_config_t ulp_ssi_master_config; + ulp_ssi_master_config.bit_width = ULP_SSI_MASTER_BIT_WIDTH; + ulp_ssi_master_config.device_mode = SL_SSI_ULP_MASTER_ACTIVE; + ulp_ssi_master_config.clock_mode = SL_SSI_PERIPHERAL_CPOL0_CPHA0; + ulp_ssi_master_config.baud_rate = ULP_SSI_MASTER_BAUDRATE; + ulp_ssi_master_config.receive_sample_delay = ULP_SSI_MASTER_RECEIVE_SAMPLE_DELAY; // Filled data into input buffer - for (i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)(i + 1); + for (i = 0; i < ULP_SSI_MASTER_BUFFER_SIZE; i++) { + ulp_ssi_master_tx_buffer[i] = (uint8_t)(i + 1); } - memcpy((uint8_t *)TX_BUF_MEMORY, &data_out, sizeof(data_out[0]) * BUFFER_SIZE); + memcpy((uint8_t *)ULP_SSI_MASTER_TX_BUF_MEMORY, + &ulp_ssi_master_tx_buffer, + sizeof(ulp_ssi_master_tx_buffer[0]) * ULP_SSI_MASTER_BUFFER_SIZE); do { // Version information of SSI driver - version = sl_si91x_ssi_get_version(); + ulp_ssi_master_version = sl_si91x_ssi_get_version(); DEBUGOUT("SSI version is fetched successfully \n"); - DEBUGOUT("API version is %d.%d.%d\n", version.release, version.major, version.minor); + DEBUGOUT("API version is %d.%d.%d\n", + ulp_ssi_master_version.release, + ulp_ssi_master_version.major, + ulp_ssi_master_version.minor); // Switching MCU from PS4 to PS2 state(low power state) // In this mode, whatever be the timer clock source value, it will run with 20MHZ only, // as it trims higher clock frequencies to 20MHZ. @@ -104,21 +109,21 @@ void ssi_master_example_init(void) hardware_setup(); DEBUGINIT(); // Initialize the SSI driver - sl_status = sl_si91x_ssi_init(config.device_mode, &ssi_driver_handle); + sl_status = sl_si91x_ssi_init(ulp_ssi_master_config.device_mode, &ssi_driver_handle); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI Initialization Failed, Error Code : %lu \n", sl_status); break; } DEBUGOUT("SSI Initialization Success \n"); // Configure the SSI to Master, 16-bit mode @10000 kBits/sec - sl_status = sl_si91x_ssi_set_configuration(ssi_driver_handle, &config, slave_number); + sl_status = sl_si91x_ssi_set_configuration(ssi_driver_handle, &ulp_ssi_master_config, ulp_ssi_master_slave_number); if (sl_status != SL_STATUS_OK) { DEBUGOUT("Failed to Set Configuration Parameters to SSI, Error Code : %lu \n", sl_status); break; } DEBUGOUT("Set Configuration Parameters to SSI \n"); // Register the user callback - sl_status = sl_si91x_ssi_register_event_callback(ssi_driver_handle, callback_event_handler); + sl_status = sl_si91x_ssi_register_event_callback(ssi_driver_handle, ulp_ssi_master_callback_event_handler); if (sl_status != SL_STATUS_OK) { DEBUGOUT("SSI register event callback Failed, Error Code : %lu \n", sl_status); break; @@ -129,15 +134,15 @@ void ssi_master_example_init(void) // Fetching and printing the current frame length DEBUGOUT("Current Frame Length is %lu \n", sl_si91x_ssi_get_frame_length(ssi_driver_handle)); // As per the macros enabled in the header file, it will configure the current mode. - if (SL_USE_TRANSFER) { - current_mode = SL_TRANSFER_DATA; + if (ULP_SSI_MASTER_TRANSFER) { + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSFER_DATA; break; } - if (SL_USE_SEND) { - current_mode = SL_SEND_DATA; + if (ULP_SSI_MASTER_SEND) { + ulp_ssi_master_current_mode = ULP_SSI_MASTER_SEND_DATA; break; } - current_mode = SL_RECEIVE_DATA; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_RECEIVE_DATA; } while (false); } /******************************************************************************* @@ -150,103 +155,111 @@ void ssi_master_example_process_action(void) // In this switch case, according to the macros enabled in header file, it starts to execute the APIs // Assuming all the macros are enabled, after transfer, receive will be executed and after receive // send will be executed. - switch (current_mode) { - case SL_TRANSFER_DATA: - if (begin_transmission == true) { + switch (ulp_ssi_master_current_mode) { + case ULP_SSI_MASTER_TRANSFER_DATA: + if (ulp_ssi_master_begin_transmission == true) { // Validation for executing the API only once - sl_si91x_ssi_set_slave_number(slave_number); + sl_si91x_ssi_set_slave_number(ulp_ssi_master_slave_number); status = sl_si91x_ssi_transfer_data(ssi_driver_handle, - (uint8_t *)TX_BUF_MEMORY, - (uint8_t *)RX_BUF_MEMORY, - BUFFER_SIZE); + (uint8_t *)ULP_SSI_MASTER_TX_BUF_MEMORY, + (uint8_t *)ULP_SSI_MASTER_RX_BUF_MEMORY, + ULP_SSI_MASTER_BUFFER_SIZE); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_transfer_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI transfer begin successfully \n"); - begin_transmission = false; + ulp_ssi_master_begin_transmission = false; } - if (transfer_complete) { - transfer_complete = false; - memcpy(&data_in, (uint8_t *)RX_BUF_MEMORY, sizeof(data_out[0]) * BUFFER_SIZE); + if (ulp_ssi_master_transfer_complete) { + ulp_ssi_master_transfer_complete = false; + memcpy(&ulp_ssi_master_rx_buffer, + (uint8_t *)ULP_SSI_MASTER_RX_BUF_MEMORY, + sizeof(ulp_ssi_master_tx_buffer[0]) * ULP_SSI_MASTER_BUFFER_SIZE); DEBUGOUT("SSI transfer completed successfully \n"); // After comparing the loopback transfer, it compares the data_out and // data_in. - compare_loopback_data(); - if (SL_USE_SEND) { + ulp_ssi_master_compare_loopback_data(); + if (ULP_SSI_MASTER_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; - begin_transmission = true; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_SEND_DATA; + ulp_ssi_master_begin_transmission = true; break; } - if (SL_USE_RECEIVE) { + if (ULP_SSI_MASTER_RECEIVE) { // If receive macro is enabled, current mode is set to receive - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_RECEIVE_DATA; + ulp_ssi_master_begin_transmission = true; break; } // If above macros are not enabled, current mode is set to complete - current_mode = SL_TRANSMISSION_COMPLETED; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSMISSION_COMPLETED; } break; - case SL_SEND_DATA: - if (begin_transmission) { + case ULP_SSI_MASTER_SEND_DATA: + if (ulp_ssi_master_begin_transmission) { // Validation for executing the API only once - sl_si91x_ssi_set_slave_number(slave_number); - status = sl_si91x_ssi_send_data(ssi_driver_handle, (uint8_t *)TX_BUF_MEMORY, BUFFER_SIZE); + sl_si91x_ssi_set_slave_number(ulp_ssi_master_slave_number); + status = sl_si91x_ssi_send_data(ssi_driver_handle, + (uint8_t *)ULP_SSI_MASTER_TX_BUF_MEMORY, + ULP_SSI_MASTER_BUFFER_SIZE); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_send_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI send begin successfully \n"); - begin_transmission = false; + ulp_ssi_master_begin_transmission = false; } //Waiting till the send is completed - if (transfer_complete) { + if (ulp_ssi_master_transfer_complete) { // If DMA is enabled, it will wait untill transfer_complete flag is set. - transfer_complete = false; - if (SL_USE_RECEIVE) { + ulp_ssi_master_transfer_complete = false; + if (ULP_SSI_MASTER_RECEIVE) { // If send macro is enabled, current mode is set to send - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_RECEIVE_DATA; + ulp_ssi_master_begin_transmission = true; DEBUGOUT("SSI send completed \n"); break; } DEBUGOUT("SSI send completed \n"); // If send macro is not enabled, current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSMISSION_COMPLETED; } break; - case SL_RECEIVE_DATA: - if (begin_transmission == true) { + case ULP_SSI_MASTER_RECEIVE_DATA: + if (ulp_ssi_master_begin_transmission == true) { // Validation for executing the API only once - sl_si91x_ssi_set_slave_number(slave_number); - status = sl_si91x_ssi_receive_data(ssi_driver_handle, (uint8_t *)RX_BUF_MEMORY, BUFFER_SIZE); + sl_si91x_ssi_set_slave_number(ulp_ssi_master_slave_number); + status = sl_si91x_ssi_receive_data(ssi_driver_handle, + (uint8_t *)ULP_SSI_MASTER_RX_BUF_MEMORY, + ULP_SSI_MASTER_BUFFER_SIZE); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_ssi_receive_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSMISSION_COMPLETED; break; } DEBUGOUT("SSI receive begin successfully \n"); - begin_transmission = false; + ulp_ssi_master_begin_transmission = false; //Waiting till the receive is completed } - if (transfer_complete) { + if (ulp_ssi_master_transfer_complete) { // If DMA is enabled, it will wait until transfer_complete flag is set. - memcpy(&data_in, (uint8_t *)RX_BUF_MEMORY, sizeof(data_out[0]) * BUFFER_SIZE); - transfer_complete = false; + memcpy(&ulp_ssi_master_rx_buffer, + (uint8_t *)ULP_SSI_MASTER_RX_BUF_MEMORY, + sizeof(ulp_ssi_master_tx_buffer[0]) * ULP_SSI_MASTER_BUFFER_SIZE); + ulp_ssi_master_transfer_complete = false; DEBUGOUT("SSI receive completed \n"); - compare_loopback_data(); + ulp_ssi_master_compare_loopback_data(); // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + ulp_ssi_master_current_mode = ULP_SSI_MASTER_TRANSMISSION_COMPLETED; } break; - case SL_TRANSMISSION_COMPLETED: + case ULP_SSI_MASTER_TRANSMISSION_COMPLETED: break; } } @@ -257,25 +270,25 @@ void ssi_master_example_process_action(void) * and decides whether the test case passed/failed. * @return None *******************************************************************************/ -static void compare_loopback_data(void) +static void ulp_ssi_master_compare_loopback_data(void) { // If the data width is not standard (8-bit) then the data should be masked. // The extra bits of the integer should be always zero. // For example, if bit width is 7, then from 8-15 all bits should be zero in a 16 bit integer. // So mask has value according to the data width and it is applied to the data. - uint16_t data_index; - uint8_t frame_length = 0; - uint16_t mask = (uint16_t)~0; - frame_length = sl_si91x_ssi_get_frame_length(ssi_driver_handle); - mask = mask >> (MAX_BIT_WIDTH - frame_length); - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - data_in[data_index] &= mask; - data_out[data_index] &= mask; - if (data_out[data_index] != data_in[data_index]) { + uint16_t ssi_data_index; + uint8_t ssi_frame_length = 0; + uint16_t ssi_mask = (uint16_t)~0; + ssi_frame_length = sl_si91x_ssi_get_frame_length(ssi_driver_handle); + ssi_mask = ssi_mask >> (ULP_SSI_MASTER_MAX_BIT_WIDTH - ssi_frame_length); + for (ssi_data_index = 0; ssi_data_index < ULP_SSI_MASTER_BUFFER_SIZE; ssi_data_index++) { + ulp_ssi_master_rx_buffer[ssi_data_index] &= ssi_mask; + ulp_ssi_master_tx_buffer[ssi_data_index] &= ssi_mask; + if (ulp_ssi_master_tx_buffer[ssi_data_index] != ulp_ssi_master_rx_buffer[ssi_data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (ssi_data_index == ULP_SSI_MASTER_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); @@ -287,11 +300,11 @@ static void compare_loopback_data(void) * @param[in]event SSI transmit and receive events * @return None *******************************************************************************/ -static void callback_event_handler(uint32_t event) +static void ulp_ssi_master_callback_event_handler(uint32_t event) { switch (event) { case SSI_EVENT_TRANSFER_COMPLETE: - transfer_complete = true; + ulp_ssi_master_transfer_complete = true; break; case SSI_EVENT_DATA_LOST: diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.h b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.h index 2972d53e..d220c8bf 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.h +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_ssi_master/ulp_ssi_master_example.h @@ -18,9 +18,9 @@ #ifndef ULP_SSI_MASTER_EXAMPLE_H_ #define ULP_SSI_MASTER_EXAMPLE_H_ -#define SL_USE_TRANSFER ENABLE -#define SL_USE_SEND DISABLE -#define SL_USE_RECEIVE DISABLE +#define ULP_SSI_MASTER_TRANSFER ENABLE +#define ULP_SSI_MASTER_SEND DISABLE +#define ULP_SSI_MASTER_RECEIVE DISABLE // ----------------------------------------------------------------------------- // Prototypes @@ -46,4 +46,4 @@ void ssi_master_example_init(void); ******************************************************************************/ void ssi_master_example_process_action(void); -#endif /* SL_SI91X_SSI_MASTER_EXAMPLE_H_ */ \ No newline at end of file +#endif /* SL_SI91X_SSI_MASTER_EXAMPLE_H_ */ diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/readme.md b/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/readme.md index 17d6fbb5..5873362e 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/readme.md @@ -93,7 +93,9 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - \ref SL_ULP_TIMER_SYNC_TO_ULPSS_PCLK, true to Enable & false to disable sync to ULPSS pclock - \ref SL_ULP_TIMER_CLK_INPUT_SOURCE, for possible options \ref ulp_timer_clk_input_source_t - \ref SL_ULP_TIMER_DIRECTION, true to enable waiting for switching timer clk & false to skip waiting for switching timer clk. -- After configuring above macros, their values are passed to \ref ulp_timer_clk_src_config_t structure type variable \ref sl_timer_clk_handle which is used to configure clock using API-\ref sl_si91x_ulp_timer_init. +- After configuring above macros, their values are passed to \ref ulp_timer_clk_src_config_t structure type variable \ref sl_timer_clk_handle which is used to configure clock using API-\ref sl_si91x_ulp_timer_init. +- To use SOC clock source use API \ref sl_si91x_ulp_timer_configure_soc_clock() API in place of \ref sl_si91x_ulp_timer_init API. Also comment out hardware_setup() +call from ulp_timer_example.c file as this clock source should be used in high power mode only. ### Macros for Timer Configurations: @@ -121,6 +123,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - Evaluation kit board's LED0 will be toggled five times at 1sec periodic rate. - After toggling LED0 for five times, timer stops and configured with new parameters and toggles LED0 five more times. +- If timer-mode is 'one-shot' mode then LED0 will toggle only one time and then timer will stop. - At the end of this example "Unregistered timer timeout callback, on timer operation completion" serial console print can be noticed. - After successful program execution the prints in serial console looks as shown below. diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/sl_si91x_ulp_timer.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/sl_si91x_ulp_timer.slcp index a7e38c17..ceeea910 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/sl_si91x_ulp_timer.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/sl_si91x_ulp_timer.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/ulp_timer_example.c b/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/ulp_timer_example.c index a173eef4..ade963bb 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/ulp_timer_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_timer/ulp_timer_example.c @@ -46,10 +46,11 @@ #define SL_TIMER_MATCH_VALUE \ ((CLOCKS_PER_MICROSECONDS_20MHZ) * (TIME_IN_MICROSECONDS)) // Timer match value for down-counter type with 20mhz clock -#define LED0 0 // For On-board LED-0 -#define ONE_SEC_MATCH_VALUE_256US_TYPE 3906 // Timer match value for 1-sec, in 256us type -#define FIFTH_INTERRUPT_COUNT 5 // Count for fifth timeout interrupt -#define TENTH_INTERRUPT_COUNT 10 // Count for tenth timeout interrupt +#define LED0 0 // For On-board LED-0 +#define ONE_SEC_MATCH_VALUE_256US_TYPE 3906 // Timer match value for 1-sec, in 256us type +#define ONE_SEC_MATCH_VALUE_1US_TYPE 1000000 // Timer match value for 1-sec, in 1us type +#define FIFTH_INTERRUPT_COUNT 5 // Count for fifth timeout interrupt +#define TENTH_INTERRUPT_COUNT 10 // Count for tenth timeout interrupt // Macros used to construct ulp-timer instance #define ULP_TIMER_INSTANCE \ @@ -201,10 +202,11 @@ void ulp_timer_example_process_action(void) /******************************************************************************* * Callback function of ulp-timer instance -* +* * @param none * @return none ******************************************************************************/ +// Note : Remove all debugouts for exact delays static void SL_ULP_TIMER_CALLBACK(void) { static uint8_t interrupt_count = 0; diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/sl_si91x_ulp_uart.slcp b/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/sl_si91x_ulp_uart.slcp index 8bf7f5bb..82f99f54 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/sl_si91x_ulp_uart.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/sl_si91x_ulp_uart.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -40,9 +40,7 @@ requires: - name: ulp_mode_execution define: - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: USART_CONFIG - name: SLI_SI91X_MCU_CONFIG_RADIO_BOARD_BASE_VER - - name: SYSCALLS_WRITE readme: - path: readme.md ui_hints: diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.c b/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.c index 3d483d5c..be324c47 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.c @@ -24,36 +24,40 @@ *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 1024 // Data send and receive length -#define USART_BAUDRATE 115200 // Baud rate <9600-7372800> -#define ULP_GPIO_PIN 2 // ULP GPIO to receive -#define OUTPUT_VALUE 1 // GPIO output value -#define ULP_GPIO_PORT 4 // GPIO Port no -#define ULP_GPIO_TOGGLE 10 // ULP GPIO to toggle -#define SET 1 // Macro to set -#define CLR 0 // Macro to clear +#define ULP_UART_BUFFER_SIZE 1024 // Data send and receive length +#define USART_BAUDRATE 115200 // Baud rate <9600-7372800> +#define ULP_GPIO_PIN 2 // ULP GPIO to receive +#define OUTPUT_VALUE 1 // GPIO output value +#define ULP_GPIO_PORT 4 // GPIO Port no +#define ULP_GPIO_TOGGLE 10 // ULP GPIO to toggle +#define SET 1 // Macro to set +#define CLR 0 // Macro to clear #define NON_UC_DEFAULT_CONFIG \ 0 // Enable this macro to set the default configurations in non_uc case, this is useful when someone don't want to use UC configuration +#define ULP_BANK_OFFSET 0x800 // ULP Memory bank offset value. +#define TX_BUF_MEMORY (ULP_SRAM_START_ADDR + (1 * ULP_BANK_OFFSET)) // Transfer buffer start address at 2K +#define RX_BUF_MEMORY (ULP_SRAM_START_ADDR + (2 * ULP_BANK_OFFSET)) // Rx buffer start address at 4k /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -static uint8_t data_in[BUFFER_SIZE]; -static uint8_t data_out[BUFFER_SIZE]; +static uint8_t ulp_uart_data_in[ULP_UART_BUFFER_SIZE]; +static uint8_t ulp_uart_data_out[ULP_UART_BUFFER_SIZE]; -volatile boolean_t send_complete = false, transfer_complete = false, receive_complete = false; -static boolean_t begin_transmission = true; +volatile boolean_t ulp_uart_send_complete = false, ulp_uart_transfer_complete = false, + ulp_uart_receive_complete = false; +static boolean_t ulp_uart_begin_transmission = true; /******************************************************************************* ********************** Local Function prototypes *************************** ******************************************************************************/ -void callback_event(uint32_t event); +void ulp_uart_callback_event(uint32_t event); static void compare_loop_back_data(void); /******************************************************************************* ************************** GLOBAL VARIABLES ******************************* ******************************************************************************/ sl_usart_handle_t usart_handle; -usart_mode_enum_t current_mode = SL_SEND_DATA; +usart_mode_enum_t current_mode = SL_ULP_UART_SEND_DATA; sl_gpio_t ulp_gpio_rx = { ULP_GPIO_PORT, ULP_GPIO_PIN }; sl_gpio_t ulp_gpio_toggle = { ULP_GPIO_PORT, ULP_GPIO_TOGGLE }; @@ -90,10 +94,11 @@ void usart_example_init(void) usart_config.synch_mode = DISABLE; #endif - //Set pin 0 in GPIO mode + //Set ulp pin 10 in GPIO mode sl_gpio_driver_set_pin_mode(&ulp_gpio_toggle, EGPIO_PIN_MUX_MODE0, OUTPUT_VALUE); //Set output direction sl_si91x_gpio_driver_set_pin_direction(ULP_GPIO_PORT, ULP_GPIO_TOGGLE, (sl_si91x_gpio_direction_t)GPIO_OUTPUT); + do { // Initialize the UART status = sl_si91x_usart_init(ULPUART, &usart_handle); @@ -121,14 +126,14 @@ void usart_example_init(void) sl_gpio_driver_set_pin_mode(&ulp_gpio_rx, EGPIO_PIN_MUX_MODE3, OUTPUT_VALUE); #endif // Register user callback function - status = sl_si91x_usart_register_event_callback(callback_event); + status = sl_si91x_usart_register_event_callback(ulp_uart_callback_event); if (status != SL_STATUS_OK) { DEBUGOUT("sl_si91x_usart_register_event_callback: Error Code : %lu \n", status); break; } DEBUGOUT("USART user event callback registered successfully \n"); sl_si91x_usart_get_configurations(ULPUART, &get_config); - DEBUGOUT("Baud Rate = %d \n", get_config.baudrate); + DEBUGOUT("Baud Rate = %ld \n", get_config.baudrate); } while (false); } @@ -139,61 +144,65 @@ void usart_example_process_action(void) { sl_status_t status; // In this switch case, according to the macros enabled in header file, it starts to execute the APIs - // Assuming all the macros are enabled, after transfer, receive will be executed and after receive - // send will be executed. switch (current_mode) { -#if (SL_USART_SYNCH_MODE != ENABLE) - case SL_SEND_DATA: + case SL_ULP_UART_SEND_DATA: // Validation for executing the API only once - if (begin_transmission == true) { + if (ulp_uart_begin_transmission == true) { // Fill the data buffer to be send - for (uint16_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)(i + 1); + for (uint16_t i = 0; i < ULP_UART_BUFFER_SIZE; i++) { + ulp_uart_data_out[i] = (uint8_t)(i + 1); } - status = sl_si91x_usart_send_data(usart_handle, data_out, sizeof(data_out)); + + memcpy((uint8_t *)TX_BUF_MEMORY, &ulp_uart_data_out, sizeof(ulp_uart_data_out[0]) * ULP_UART_BUFFER_SIZE); + + status = sl_si91x_usart_send_data(usart_handle, (uint8_t *)TX_BUF_MEMORY, sizeof(ulp_uart_data_out)); + if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_usart_send_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_ULP_UART_TRANSMISSION_COMPLETED; break; } - begin_transmission = false; + ulp_uart_begin_transmission = false; } - send_complete = false; + ulp_uart_send_complete = false; if (USE_RECEIVE) { // If receive macro is enabled, current mode is set to receive - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + current_mode = SL_ULP_UART_RECEIVE_DATA; + ulp_uart_begin_transmission = true; break; } DEBUGOUT("USART send completed successfully \n"); // Current mode is set to complete - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_ULP_UART_TRANSMISSION_COMPLETED; break; - case SL_RECEIVE_DATA: - if (begin_transmission == true) { + case SL_ULP_UART_RECEIVE_DATA: + if (ulp_uart_begin_transmission == true) { // Validation for executing the API only once - status = sl_si91x_usart_receive_data(usart_handle, data_in, sizeof(data_in)); + status = sl_si91x_usart_receive_data(usart_handle, (uint8_t *)RX_BUF_MEMORY, sizeof(ulp_uart_data_in)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_usart_receive_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_ULP_UART_TRANSMISSION_COMPLETED; break; } DEBUGOUT("USART receive begin successfully \n"); - begin_transmission = false; + ulp_uart_begin_transmission = false; } - //Waiting till the receive is completed - if (receive_complete) { + + if (ulp_uart_receive_complete) { + + //Waiting till the receive is completed + memcpy(&ulp_uart_data_in, (uint8_t *)RX_BUF_MEMORY, sizeof(ulp_uart_data_in[0]) * ULP_UART_BUFFER_SIZE); // Update the receive compelete flag with 0. - receive_complete = false; + ulp_uart_receive_complete = false; if (USE_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; - begin_transmission = true; + current_mode = SL_ULP_UART_SEND_DATA; + ulp_uart_begin_transmission = true; compare_loop_back_data(); DEBUGOUT("USART receive completed \n"); break; @@ -203,42 +212,13 @@ void usart_example_process_action(void) DEBUGOUT("USART receive completed \n"); compare_loop_back_data(); // If send macro is not enabled, current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_ULP_UART_TRANSMISSION_COMPLETED; } break; - case SL_TRANSFER_DATA: -#else - // Validation for executing the API only once - if (begin_transmission) { - // Fill the data buffer to be send - for (int i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)i + 1; - } - - status = sl_si91x_usart_transfer_data(usart_handle, data_out, data_in, sizeof(data_out)); - if (status != SL_STATUS_OK) { - // If it fails to execute the API, it will not execute rest of the things - DEBUGOUT("sl_si91x_usart_transfer_data: Error Code : %lu \n", status); - current_mode = completed; - break; - } - DEBUGOUT("USART transfer begin successfully \n"); - begin_transmission = false; - } - - //Waiting till the transfer is completed - if (transfer_complete) { - // Update transfer_complete flag with 0. - transfer_complete = false; - // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; - } - DEBUGOUT("USART transfer completed \n"); -#endif + case SL_ULP_UART_TRANSMISSION_COMPLETED: break; - - case SL_TRANSMISSION_COMPLETED: + case SL_ULP_UART_TRANSFER_DATA: // This case is not required in ULP_UART mode break; } } @@ -252,12 +232,12 @@ static void compare_loop_back_data(void) uint16_t data_index = 0; // Check for data in and data out are same, if same then comparision // will continue till end of the buffer - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - if (data_in[data_index] != data_out[data_index]) { + for (data_index = 0; data_index < ULP_UART_BUFFER_SIZE; data_index++) { + if (ulp_uart_data_in[data_index] != ulp_uart_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == ULP_UART_BUFFER_SIZE) { // Set the pin sl_gpio_driver_set_pin(&ulp_gpio_toggle); // Clear the pin @@ -271,17 +251,14 @@ static void compare_loop_back_data(void) /******************************************************************************* * Callback function triggered on data Transfer and reception ******************************************************************************/ -void callback_event(uint32_t event) +void ulp_uart_callback_event(uint32_t event) { switch (event) { case SL_USART_EVENT_SEND_COMPLETE: - send_complete = true; + ulp_uart_send_complete = true; break; case SL_USART_EVENT_RECEIVE_COMPLETE: - receive_complete = true; - break; - case SL_USART_EVENT_TRANSFER_COMPLETE: - transfer_complete = true; + ulp_uart_receive_complete = true; break; } } diff --git a/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.h b/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.h index 3c5bc6e7..05ee18c9 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.h +++ b/examples/si91x_soc/peripheral/sl_si91x_ulp_uart/ulp_uart_example.h @@ -30,10 +30,10 @@ ******************************************************************************/ //Enum for different transmission scenarios typedef enum { - SL_SEND_DATA, - SL_RECEIVE_DATA, - SL_TRANSFER_DATA, - SL_TRANSMISSION_COMPLETED, + SL_ULP_UART_SEND_DATA, + SL_ULP_UART_RECEIVE_DATA, + SL_ULP_UART_TRANSFER_DATA, + SL_ULP_UART_TRANSMISSION_COMPLETED, } usart_mode_enum_t; // ----------------------------------------------------------------------------- diff --git a/examples/si91x_soc/peripheral/sl_si91x_usart/sl_si91x_usart.slcp b/examples/si91x_soc/peripheral/sl_si91x_usart/sl_si91x_usart.slcp index 7310039e..50760e51 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_usart/sl_si91x_usart.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_usart/sl_si91x_usart.slcp @@ -11,7 +11,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c @@ -28,14 +28,9 @@ component: from: wiseconnect3_sdk - id: sl_usart from: wiseconnect3_sdk - - id: sl_dma - from: wiseconnect3_sdk define: - name: SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH - - name: USART_CONFIG - name: SLI_SI91X_MCU_CONFIG_RADIO_BOARD_BASE_VER - - name: SL_SI91X_USART_DMA - - name: SL_SI91X_DMA other_file: - path: resources/readme/setupdiagram.png - path: resources/readme/image513d.png diff --git a/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.c b/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.c index 0c54f663..10d7b7fa 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.c @@ -22,30 +22,30 @@ /******************************************************************************* *************************** Defines / Macros ******************************** ******************************************************************************/ -#define BUFFER_SIZE 1024 // Data send and receive length -#define USART_BAUDRATE 115200 // Baud rate <9600-7372800> +#define USART_BUFFER_SIZE 1024 // Data send and receive length +#define USART_BAUDRATE 115200 // Baud rate <9600-7372800> #define NON_UC_DEFAULT_CONFIG \ 0 // Enable this macro to set the default configurations in non_uc case, this is useful when someone don't want to use UC configuration /******************************************************************************* *************************** LOCAL VARIABLES ******************************* ******************************************************************************/ -static uint8_t data_in[BUFFER_SIZE]; -static uint8_t data_out[BUFFER_SIZE]; +static uint8_t usart_data_in[USART_BUFFER_SIZE]; +static uint8_t usart_data_out[USART_BUFFER_SIZE]; -volatile boolean_t send_complete = false, transfer_complete = false, receive_complete = false; -static boolean_t begin_transmission = true; +volatile boolean_t usart_send_complete = false, usart_transfer_complete = false, usart_receive_complete = false; +static boolean_t usart_begin_transmission = true; /******************************************************************************* ********************** Local Function prototypes *************************** ******************************************************************************/ -void callback_event(uint32_t event); +void usart_callback_event(uint32_t event); static void compare_loop_back_data(void); /******************************************************************************* ************************** GLOBAL VARIABLES ******************************* ******************************************************************************/ sl_usart_handle_t usart_handle; -usart_mode_enum_t current_mode = SL_SEND_DATA; +usart_mode_enum_t current_mode = SL_USART_SEND_DATA; /******************************************************************************* * USART Example Initialization function ******************************************************************************/ @@ -83,7 +83,7 @@ void usart_example_init(void) } DEBUGOUT("USART configuration is successful \n"); // Register user callback function - status = sl_si91x_usart_register_event_callback(callback_event); + status = sl_si91x_usart_register_event_callback(usart_callback_event); if (status != SL_STATUS_OK) { DEBUGOUT("sl_si91x_usart_register_event_callback: Error Code : %lu \n", status); break; @@ -108,60 +108,60 @@ void usart_example_process_action(void) // Assuming all the macros are enabled, after transfer, receive will be executed and after receive // send will be executed. switch (current_mode) { - case SL_SEND_DATA: + case SL_USART_SEND_DATA: #if (SL_USART_SYNCH_MODE != ENABLE) // Validation for executing the API only once - if (begin_transmission == true) { + if (usart_begin_transmission == true) { // Fill the data buffer to be send - for (uint16_t i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)(i + 1); + for (uint16_t i = 0; i < USART_BUFFER_SIZE; i++) { + usart_data_out[i] = (uint8_t)(i + 1); } - status = sl_si91x_usart_send_data(usart_handle, data_out, sizeof(data_out)); + status = sl_si91x_usart_send_data(usart_handle, usart_data_out, sizeof(usart_data_out)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_usart_send_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_USART_TRANSMISSION_COMPLETED; break; } - begin_transmission = false; + usart_begin_transmission = false; } - send_complete = false; + usart_send_complete = false; if (USE_RECEIVE) { // If receive macro is enabled, current mode is set to receive - current_mode = SL_RECEIVE_DATA; - begin_transmission = true; + current_mode = SL_USART_RECEIVE_DATA; + usart_begin_transmission = true; break; } DEBUGOUT("USART send completed successfully \n"); // Current mode is set to complete - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_USART_TRANSMISSION_COMPLETED; #endif break; - case SL_RECEIVE_DATA: + case SL_USART_RECEIVE_DATA: #if (SL_USART_SYNCH_MODE != ENABLE) - if (begin_transmission == true) { + if (usart_begin_transmission == true) { // Validation for executing the API only once - status = sl_si91x_usart_receive_data(usart_handle, data_in, sizeof(data_in)); + status = sl_si91x_usart_receive_data(usart_handle, usart_data_in, sizeof(usart_data_in)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_usart_receive_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_USART_TRANSMISSION_COMPLETED; break; } DEBUGOUT("USART receive begin successfully \n"); - begin_transmission = false; + usart_begin_transmission = false; } //Waiting till the receive is completed - if (receive_complete) { + if (usart_receive_complete) { // Update the receive compelete flag with 0. - receive_complete = false; + usart_receive_complete = false; if (USE_SEND) { // If send macro is enabled, current mode is set to send - current_mode = SL_SEND_DATA; - begin_transmission = true; + current_mode = SL_USART_SEND_DATA; + usart_begin_transmission = true; DEBUGOUT("USART receive completed \n"); break; } @@ -170,44 +170,44 @@ void usart_example_process_action(void) DEBUGOUT("USART receive completed \n"); compare_loop_back_data(); // If send macro is not enabled, current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_USART_TRANSMISSION_COMPLETED; } #endif break; - case SL_TRANSFER_DATA: + case SL_USART_TRANSFER_DATA: #if (SL_USART_SYNCH_MODE == ENABLE) // Validation for executing the API only once - if (begin_transmission) { + if (usart_begin_transmission) { // Fill the data buffer to be send - for (int i = 0; i < BUFFER_SIZE; i++) { - data_out[i] = (uint8_t)i + 1; + for (int i = 0; i < USART_BUFFER_SIZE; i++) { + usart_data_out[i] = (uint8_t)i + 1; } - status = sl_si91x_usart_transfer_data(usart_handle, data_out, data_in, sizeof(data_out)); + status = sl_si91x_usart_transfer_data(usart_handle, usart_data_out, usart_data_in, sizeof(usart_data_out)); if (status != SL_STATUS_OK) { // If it fails to execute the API, it will not execute rest of the things DEBUGOUT("sl_si91x_usart_transfer_data: Error Code : %lu \n", status); - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_USART_TRANSMISSION_COMPLETED; break; } DEBUGOUT("USART transfer begin successfully \n"); - begin_transmission = false; + usart_begin_transmission = false; } //Waiting till the transfer is completed - if (transfer_complete) { - // Update transfer_complete flag with 0. - transfer_complete = false; + if (usart_transfer_complete) { + // Update usart_transfer_complete flag with 0. + usart_transfer_complete = false; compare_loop_back_data(); // At last current mode is set to completed. - current_mode = SL_TRANSMISSION_COMPLETED; + current_mode = SL_USART_TRANSMISSION_COMPLETED; DEBUGOUT("USART transfer completed \n"); } #endif break; - case SL_TRANSMISSION_COMPLETED: + case SL_USART_TRANSMISSION_COMPLETED: break; } } @@ -221,12 +221,12 @@ static void compare_loop_back_data(void) uint16_t data_index = 0; // Check for data in and data out are same, if same then comparision // will continue till end of the buffer - for (data_index = 0; data_index < BUFFER_SIZE; data_index++) { - if (data_in[data_index] != data_out[data_index]) { + for (data_index = 0; data_index < USART_BUFFER_SIZE; data_index++) { + if (usart_data_in[data_index] != usart_data_out[data_index]) { break; } } - if (data_index == BUFFER_SIZE) { + if (data_index == USART_BUFFER_SIZE) { DEBUGOUT("Data comparison successful, Loop Back Test Passed \n"); } else { DEBUGOUT("Data comparison failed, Loop Back Test failed \n"); @@ -236,17 +236,17 @@ static void compare_loop_back_data(void) /******************************************************************************* * Callback function triggered on data Transfer and reception ******************************************************************************/ -void callback_event(uint32_t event) +void usart_callback_event(uint32_t event) { switch (event) { case SL_USART_EVENT_SEND_COMPLETE: - send_complete = true; + usart_send_complete = true; break; case SL_USART_EVENT_RECEIVE_COMPLETE: - receive_complete = true; + usart_receive_complete = true; break; case SL_USART_EVENT_TRANSFER_COMPLETE: - transfer_complete = true; + usart_transfer_complete = true; break; } } diff --git a/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.h b/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.h index 2e2a4d55..1f60ea8d 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.h +++ b/examples/si91x_soc/peripheral/sl_si91x_usart/usart_example.h @@ -31,10 +31,10 @@ ******************************************************************************/ //Enum for different transmission scenarios typedef enum { - SL_SEND_DATA, - SL_RECEIVE_DATA, - SL_TRANSFER_DATA, - SL_TRANSMISSION_COMPLETED, + SL_USART_SEND_DATA, + SL_USART_RECEIVE_DATA, + SL_USART_TRANSFER_DATA, + SL_USART_TRANSMISSION_COMPLETED, } usart_mode_enum_t; // ----------------------------------------------------------------------------- diff --git a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/readme.md b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/readme.md index c1deb173..9151c011 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/readme.md +++ b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/readme.md @@ -37,9 +37,8 @@ ## About Example Code - \ref watchdog_timer_example.c this example file demonstrates how to use Watchdog-timer(WDT) to trigger WDT warnings and reset system after few warnings . - With every WDT timeout interrupt at every 1 seconds, WDT restarted (kicked) by application & onboard LED0 toggles. After 6 time toggles application does not restart WDT then timer - loads system-reset time (kept 4 seconds), once that time is over WDT resets system. After that again WDT started with new parameters and toggles LED0 6 times and then WDT is stopped, - callback unregistered and de-initialized. + With every WDT timeout interrupt at every 1 seconds, WDT restarted (kicked) by application & onboard LED0 toggles. After 6 time toggles application does not restart WDT then timer loads system-reset time (kept 4 seconds), once that time is over WDT resets system. After that again WDT started with new parameters + and toggles LED0 6 times and then WDT is stopped, callback unregistered and de-initialized. - In this example, first application toggles LED0 once and checks whether its a power-on reset or WDT system reset through \ref sl_si91x_watchdog_get_timer_system_reset_status API. - If its a power-on reset then initializes WDT by enabling peripheral power, enabling WDT to run during CPU sleep mode & unmasking its interrupt through \ref sl_si91x_watchdog_init_timer API. - Then clock and timer are configured with default configuration values from UC through \ref sl_si91x_watchdog_configure_clock and \ref sl_si91x_watchdog_set_configuration APIs respectively. @@ -58,7 +57,7 @@ \ref sl_si91x_watchdog_get_window_time to read window time. - Then application again toggles onboard LED0 6 times & restarts (kicks) WDT, on every interrupt(every 2 seconds) through \ref sl_si91x_watchdog_restart_timer - At sixth WDT interrupt application not restarts WDT and immediately application stops WDT through \ref sl_si91x_watchdog_stop_timer API -- Then un-registers callback and de-initializes timer through \ref sl_si91x_watchdog_unregister_timeout_callback & \ref sl_si91x_watchdog_deinit_timer APIs respectively. +- Then un-registers callback and de-initializes timer through \ref sl_si91x_watchdog_deinit_timer API. ## Prerequisites/Setup Requirements @@ -100,7 +99,6 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ### Macros for Clock Configurations - \ref SL_LOW_FREQ_FSM_CLK_SRC, for configuring low frequency FSM clock refer \ref low_freq_fsm_clock_t -- \ref SL_HIGH_FREQ_FSM_CLK_SRC, for configuring high frequency FSM clock refer \ref high_freq_fsm_clock_t - \ref SL_ULP_TIMER_CLK_ISL_BG_PMU_CLOCK_SRC, for configuring BG-PMU clock refer \ref bg_pmu_clock_t - \ref SL_ULP_TIMER_DIRECTION, true to enable waiting for switching timer clk & false to skip waiting for switching timer clk. - After configuring above macros, their values are passed to \ref watchdog_timer_clock_config_t structure type variable \ref sl_watchdog_timer_clk_config_handle which is used to configure clock through API-\ref sl_si91x_watchdog_configure_clock. diff --git a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/resources/uc_screen/watchdog_uc_screen.png b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/resources/uc_screen/watchdog_uc_screen.png index 141304c8..34014cc3 100644 Binary files a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/resources/uc_screen/watchdog_uc_screen.png and b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/resources/uc_screen/watchdog_uc_screen.png differ diff --git a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/sl_si91x_watchdog_timer.slcp b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/sl_si91x_watchdog_timer.slcp index b6fe6808..eb0011b6 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/sl_si91x_watchdog_timer.slcp +++ b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/sl_si91x_watchdog_timer.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: main.c - path: app.c diff --git a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/watchdog_timer_example.c b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/watchdog_timer_example.c index 4c9ad472..8513e55c 100644 --- a/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/watchdog_timer_example.c +++ b/examples/si91x_soc/peripheral/sl_si91x_watchdog_timer/watchdog_timer_example.c @@ -66,9 +66,8 @@ void watchdog_timer_example_init(void) sl_status_t status; sl_watchdog_timer_version_t version; watchdog_timer_clock_config_t wdt_clock_config; - wdt_clock_config.low_freq_fsm_clock_src = KHZ_RC_CLK_SEL; - wdt_clock_config.high_freq_fsm_clock_src = FSM_32MHZ_RC; - wdt_clock_config.bg_pmu_clock_source = RO_32KHZ_CLOCK; + wdt_clock_config.low_freq_fsm_clock_src = KHZ_RC_CLK_SEL; + wdt_clock_config.bg_pmu_clock_source = RO_32KHZ_CLOCK; watchdog_timer_config_t wdt_config; wdt_config.interrupt_time = SL_WDT_INTERRUPT_TIME; wdt_config.system_reset_time = SL_WDT_SYSTEM_RESET_TIME; @@ -99,14 +98,14 @@ void watchdog_timer_example_init(void) // Configuring watchdog-timer status = sl_si91x_watchdog_configure_clock(&wdt_clock_config); if (status != SL_STATUS_OK) { - DEBUGOUT("sl_si91x_watchdog_timer_config : Invalid Parameters, Error Code : %lu \n", status); + DEBUGOUT("sl_si91x_watchdog_configure_clock : Invalid Parameters, Error Code : %lu \n", status); break; } DEBUGOUT("Successfully Configured watchdog-timer with default clock sources\n"); // Configuring watchdog-timer status = sl_si91x_watchdog_set_configuration(&wdt_config); if (status != SL_STATUS_OK) { - DEBUGOUT("sl_si91x_watchdog_timer_config : Invalid Parameters, Error Code : %lu \n", status); + DEBUGOUT("sl_si91x_watchdog_set_configuration : Invalid Parameters, Error Code : %lu \n", status); break; } DEBUGOUT("Successfully Configured watchdog-timer with default parameters\n"); @@ -192,9 +191,7 @@ void on_timeout_callback(void) if ((wdt_interrupt_count > WDT_RESTART_CNT) && (wdt_stop_flag)) { // Stopping the watchdog-timer after watchdog-timer system reset sl_si91x_watchdog_stop_timer(); - // Unregistering the timeout_callback - sl_si91x_watchdog_unregister_timeout_callback(); - // De-initializing watchdog-timer + // De-initializing and unregistering callback for watchdog-timer sl_si91x_watchdog_deinit_timer(); DEBUGOUT("Successfully stopped, unregistered & De-initialized watchdog-timer\n"); } diff --git a/examples/si91x_soc/service/iostream_usart_baremetal/iostream_usart_baremetal.slcp b/examples/si91x_soc/service/iostream_usart_baremetal/iostream_usart_baremetal.slcp index c2a66882..a5ea195d 100644 --- a/examples/si91x_soc/service/iostream_usart_baremetal/iostream_usart_baremetal.slcp +++ b/examples/si91x_soc/service/iostream_usart_baremetal/iostream_usart_baremetal.slcp @@ -14,7 +14,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 readme: - path: readme.md source: diff --git a/examples/si91x_soc/service/iostream_usart_baremetal/readme.md b/examples/si91x_soc/service/iostream_usart_baremetal/readme.md index e796b561..9dcdbb57 100644 --- a/examples/si91x_soc/service/iostream_usart_baremetal/readme.md +++ b/examples/si91x_soc/service/iostream_usart_baremetal/readme.md @@ -112,7 +112,5 @@ Refer instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect > ![Figure: output screen](resources/readme/outputConsoleI_IOSTREAM.png) > **Note** - >- To add iostream for debug prints in any examples, install below components **Wiseconnect_3_SDK/IOSTREAM**, **SERVICES/IO Stream: Si91x UART - Give instance name vcom** , **Services/IO Stream: Retarget STDIO**, + >- To add iostream for debug prints in any examples, install below components **Wiseconnect_3_SDK/IOSTREAM Si91x**, **SERVICES/IO Stream: Si91x UART - Give instance name vcom** >- When iostream components installed for debug prints then make sure DEBUG_UART macro is not present in preprocessor window. - - diff --git a/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/app.c b/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/app.c index 9ef4d1a3..fd4cad21 100644 --- a/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/app.c +++ b/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/app.c @@ -92,7 +92,7 @@ static const sl_wifi_device_configuration_t station_init_configuration = { ), .bt_feature_bit_map = 0, .ext_tcp_ip_feature_bit_map = - (SL_SI91X_EXT_TCP_IP_FEAT_SSL_HIGH_PERFORMANCE | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD + (SL_SI91X_EXT_FEAT_HTTP_OTAF_SUPPORT | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), .ble_feature_bit_map = 0, .ble_ext_feature_bit_map = 0, diff --git a/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/sl_si91x_nvm3_common_flash.slcp b/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/sl_si91x_nvm3_common_flash.slcp index c769af95..25b495de 100644 --- a/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/sl_si91x_nvm3_common_flash.slcp +++ b/examples/si91x_soc/service/sl_si91x_nvm3_common_flash/sl_si91x_nvm3_common_flash.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/service/sl_si91x_nvm3_dual_flash/sl_si91x_nvm3_dual_flash.slcp b/examples/si91x_soc/service/sl_si91x_nvm3_dual_flash/sl_si91x_nvm3_dual_flash.slcp index c29c3b38..9c554dbf 100644 --- a/examples/si91x_soc/service/sl_si91x_nvm3_dual_flash/sl_si91x_nvm3_dual_flash.slcp +++ b/examples/si91x_soc/service/sl_si91x_nvm3_dual_flash/sl_si91x_nvm3_dual_flash.slcp @@ -21,7 +21,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 toolchain_settings: [] component: - id: sl_system diff --git a/examples/si91x_soc/service/sl_si91x_power_manager_m4_wireless/sl_si91x_power_manager_m4_wireless.slcp b/examples/si91x_soc/service/sl_si91x_power_manager_m4_wireless/sl_si91x_power_manager_m4_wireless.slcp index e90aa5c9..e3ab2d32 100644 --- a/examples/si91x_soc/service/sl_si91x_power_manager_m4_wireless/sl_si91x_power_manager_m4_wireless.slcp +++ b/examples/si91x_soc/service/sl_si91x_power_manager_m4_wireless/sl_si91x_power_manager_m4_wireless.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 readme: - path: readme.md source: diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/readme.md b/examples/si91x_soc/service/sl_si91x_sensorhub/readme.md index ec54df25..8db0f96c 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/readme.md +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/readme.md @@ -25,6 +25,7 @@ * 3- I2C-based sensors namely a BH1750(Light Sensor), LM75(Temperature Sensor) and APDS9960(RGB Proximity Gesture sensor) * 2- ADC-based Sensors(Joystick and GUVA_12D_UV) * 1- GPIO-based Push Button-0 as sensor + * 1- SPI-based sensor ADXL345(Accelorometer Sensor) - The application starts in PS4 mode, initializes peripherals, and configures sensors on the corresponding peripheral interfaces. Sensor data will be sampled and shown on the serial console based on the sensor configurations. @@ -150,6 +151,17 @@ Refer instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect .data_deliver.data_mode = SL_SH_NUM_OF_SAMPLES, .data_deliver.numofsamples = 5, ``` + ```c + //For ADC Sensors, channel should be BIT(channel number) + .sensor_name = "ADC_JOYSTICK", + .sensor_id = SL_SENSOR_ADC_JOYSTICK_ID, + .channel = BIT(SL_SH_ADC_CH0_CHANNEL), + .sensor_bus = SL_SH_ADC, + .sensor_mode = SL_SH_POLLING_MODE, + .sampling_interval = 200, + .data_deliver.data_mode = SL_SH_NUM_OF_SAMPLES, + .data_deliver.numofsamples = SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES, + ``` - **INTERRUPT Sensor Mode** configures the below parameters: @@ -175,16 +187,16 @@ Refer instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect .data_deliver.data_mode = SL_SH_NO_DATA_MODE, ``` + ```c - //For ADC Sensor + //For ADC Sensors, channel should be BIT(channel number) .sensor_name = "ADC_JOYSTICK", .sensor_id = SL_SENSOR_ADC_JOYSTICK_ID, - .channel = SL_SH_ADC_CH0_CHANNEL, + .channel = BIT(SL_SH_ADC_CH0_CHANNEL), .sensor_bus = SL_SH_ADC, .sensor_mode = SL_SH_INTERRUPT_MODE, .data_deliver.data_mode = SL_SH_NO_DATA_MODE, ``` - 3. **PowerSave Configurations:** * The SensorHub utilizes the **Tickles Idle low-power mode** provided by the RTOS. * To configure the PS2, please update the below macro in the preprocessor settings: @@ -248,17 +260,34 @@ Refer instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect configure as shown below in the ***adc_sensor_hal.h*** file: ```C - // Set SL_SH_ADC_CH0_NUM_SAMPLES to a value between 100 and 1023 if you are using sleep mode. - //Setting it to a value less than 100 may result in undefined behavior due to an immediate ADC interrupt. - #define SL_SH_ADC_CH0_NUM_SAMPLES 100 - - #define SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES 1 - ``` - - - ADC can read between 1 and 1023 samples at a time and generates interrupts when operating in FIFO mode. - - To configure the PS1 power state from the PS2 State, please update the below macro in the preprocessor settings. - * Disable the tickles mode in the FreeRTOS.h file. - * The PS1 state transition only applies to ADC FIFO Mode. Before entering this mode, kindly turn off any other sensors. + // Set SL_SH_ADC_CH0_NUM_SAMPLES to a value between 100 and 1023 if you are using sample rate >= 100 + // If you want to set SL_SH_ADC_CH0_NUM_SAMPLES to 1 and use <= 2 channels, you should use a lower sampling rate (less than 100) + // Using any other combination may result in undefined behavior due to an immediate ADC interrupt. + #define SL_SH_ADC_CH0_NUM_SAMPLES 100 + #define SL_SH_ADC_SAMPLING_RATE 100 + #define SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES 1 + ``` + * **Example configurations for ADXL335 GY61 sensor**. + ```C + #define SL_SH_ADC_CH0_NUM_SAMPLES 1 + #define SL_SH_ADC_CH1_NUM_SAMPLES 1 + #define SL_SH_ADC_CH2_NUM_SAMPLES 1 + #define SL_SH_ADC_SAMPLING_RATE 10 + #define SL_SH_ADC_NUM_CHANNELS_ENABLE 4 + #define GY61_ADC_SENSOR + + .sensor_name = "GY61", + .sensor_id = SL_SENSOR_ADC_GY_61_ID, + .channel = BIT(SL_SH_ADC_CH1_CHANNEL) | BIT(SL_SH_ADC_CH2_CHANNEL) | BIT(SL_SH_ADC_CH3_CHANNEL), + .sensor_bus = SL_SH_ADC, + .sensor_mode = SL_SH_INTERRUPT_MODE, + .data_deliver.data_mode = SL_SH_NO_DATA_MODE, + ``` + + * ADC can read between 1 and 1023 samples at a time and generates interrupts when operating in FIFO mode. + * To configure the PS1 power state from the PS2 State, please update the below macro in the preprocessor settings. + 1. Disable the tickles mode in the FreeRTOS.h file. + 2. The PS1 state transition only applies to ADC FIFO Mode. Before entering this mode, kindly turn off any other sensors. ```C SL_SH_ADC_PS1=1 @@ -283,18 +312,29 @@ Refer instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect | ADDR (for BH1750 Light Sensor) |(WPK) (GND) | Connect to GND pin | | +### SPI Sensor Pin Configurations +| Sensor PIN | ULP GPIO PIN | Description | +| --- | --- | --- | +| MOSI | ULP_GPIO_1 [ F16/ P16 ] | Connect to SDA pin | +| MISO | ULP_GPIO_2 [ F10 ] | Connect to SDO pin | +| CLK | ULP_GPIO_8 | P15 | +| CS | ULP_GPIO_10 | P17 | +| ### ADC Sensor Pin Configurations | Sensor PIN | ULP GPIO PIN | Description | | --- | --- | --- | -| ADC Input | ULP_GPIO_10 [ P17 ] | Connect to Joystick output (P36) -| +| ADC Input | ULP_GPIO_2 [ F10 ] | Connect to Joystick output (P36) / GUVA sensor output +| ADC Input | ULP_GPIO_8 [ P15 ] | Connect to ADXL335 GY61 X axis analog output +| ADC Input | ULP_GPIO_10 [ P17 ] | Connect to ADXL335 GY61 Y axis analog output +| ADC Input | ULP_GPIO_1 [ P16 ] | Connect to ADXL335 GY61 Z axis analog output +| ## Test the Application - Compile and run the application. -- Connect the I2C and ADC sensors, based on the above pin configuration. +- Connect the I2C, SPI and ADC sensors, based on the above pin configuration. ## Expected Results @@ -303,8 +343,8 @@ Refer instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect >### Note: >#### General > - >- ADC sensor will not work in Sleep state. >- The GPIO bsed Interrupt Sensor Mode won't function in Sleep mode. + >- SPI sensor will only work in PS4 state > >#### ADC > diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_app.c b/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_app.c index 0d350490..eaa090e4 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_app.c +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_app.c @@ -57,12 +57,38 @@ const osThreadAttr_t app_thread_attributes = { .tz_module = 0, .reserved = 0, }; + +#if SH_AWS_ENABLE +const osThreadAttr_t aws_thread_attributes = { + .name = "AWS_App", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityLow, + .tz_module = 0, + .reserved = 0, +}; +#endif + rsi_task_handle_t app_task_handle = NULL; +#if SH_AWS_ENABLE +osSemaphoreId_t sl_semaphore_app_task_id_2; + +extern osSemaphoreId_t sl_semaphore_aws_task_id; + +char mqtt_publish_payload[500]; + +void sl_si91x_aws_task(void); +#endif + /******************************************************************************* ******************** Extern variables/structures *************************** ******************************************************************************/ extern sl_sensor_info_t sensor_hub_info_t[SL_MAX_NUM_SENSORS]; // Sensor info structure +extern sl_bus_intf_config_t bus_intf_info; //< Bus interface configuration structure /******************************************************************************* ********************** Local/global variables ******************************* @@ -77,6 +103,23 @@ void sl_si91x_sensorhub_app_task(void); // applica void sensorhub_app_init(void); // application initialization void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event); // application event handler +/**************************************************************************/ /** + * @fn void gy61_adc_raw_data_map() + * @brief Map the raw input data of adc gy61 to output range + * + * @param[in] x :Sensor raw dara + * @param[in] in_min :Sensor raw min + * @param[in] in_max :Sensor raw max + * @param[in] out_min :Sensor output min + * @param[in] out_max :Sensor output max + * @param[out] sensor g output + * +******************************************************************************/ +static long gy61_adc_raw_data_map(long x, long in_min, long in_max, long out_min, long out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + /**************************************************************************/ /** * @fn void sl_si91x_sensor_event_handler() * @brief This Sensor event handle to the Sensor HUB. @@ -88,6 +131,12 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event); // applica ******************************************************************************/ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) { +#if SH_AWS_ENABLE + osStatus_t sl_semapptaskacq_status; + + strcpy(mqtt_publish_payload, ""); +#endif + uint8_t sens_ind; for (sens_ind = 0; sens_ind < SL_MAX_NUM_SENSORS; sens_ind++) { if (sensor_hub_info_t[sens_ind].sensor_id == sensor_id) { @@ -123,6 +172,20 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.y); DEBUGOUT("Axis Z = %f \t\n ", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.z); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_x: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.x); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_y: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.y); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_z: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.z); +#endif } else if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_POLLING_MODE) { if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_THRESHOLD) { DEBUGOUT("Axis X = %f, \t", @@ -131,6 +194,20 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.y); DEBUGOUT("Axis Z = %f \t\r\n ", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.z); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_x: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.x); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_y: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.y); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_z: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].accelerometer.z); +#endif } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_TIMEOUT) { for (uint32_t i = 0; @@ -142,6 +219,23 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.y); DEBUGOUT("Axis Z = %f \r\n ", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.z); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_%lu_x: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.x); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_%lu_y: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.y); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_%lu_z: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.z); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_NUM_OF_SAMPLES) { @@ -152,6 +246,23 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.y); DEBUGOUT("Z = %f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.z); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_%lu_x: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.x); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_%lu_y: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.y); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADXL345_ID_%lu_z: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].accelerometer.z); +#endif } } } @@ -164,6 +275,24 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) DEBUGOUT("Proximity = %f ;\t\n", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.proximity); // DEBUGOUT("Gesture = %c \t\n", (char)sensor_hub_info_t[sens_ind].sens_data_ptr->sensor_data[0].gesture); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_r: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.r); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_g: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.g); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_b: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.b); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_prox: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.proximity); +#endif } else if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_POLLING_MODE) { if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_THRESHOLD) { @@ -173,6 +302,24 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) DEBUGOUT("Proximity = %f ;\t\n", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.proximity); // DEBUGOUT("Gesture = %c \t\n", (char)sensor_hub_info_t[sens_ind].sens_data_ptr->sensor_data[0].gesture); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_r: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.r); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_g: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.g); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_b: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.b); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_prox: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].rgbw.proximity); +#endif } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_TIMEOUT) { for (uint32_t i = 0; @@ -184,6 +331,28 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) DEBUGOUT(" G = %f, \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.g); DEBUGOUT(" B = %f \t\n ", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.b); // DEBUGOUT("Gesture = %c \t\n", (char)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].gesture); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_r: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.r); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_g: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.g); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_b: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.b); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_prox: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.proximity); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_NUM_OF_SAMPLES) { @@ -194,6 +363,28 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) DEBUGOUT(" Proximity = %f ", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.proximity); // DEBUGOUT("Gesture = %c \t\n", (char)sensor_hub_info_t[sens_ind].sens_data_ptr->sensor_data[i].gesture); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_r: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.r); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_g: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.g); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_b: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.b); + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_APDS9960_ID_%lu_prox: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].rgbw.proximity); +#endif } } } @@ -202,22 +393,48 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) if (SL_SENSOR_LM75_ID == sensor_id) { if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_INTERRUPT_MODE) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].temperature); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_LM75_ID: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].temperature); +#endif } else if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_POLLING_MODE) { if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_TIMEOUT) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.timeout / sensor_hub_info_t[sens_ind].sampling_interval; i++) { DEBUGOUT(" %f \t ", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].temperature); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_LM75_ID_%lu: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].temperature); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_NUM_OF_SAMPLES) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.numofsamples; i++) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].temperature); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_LM75_ID_%lu: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].temperature); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_THRESHOLD) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].temperature); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_LM75_ID: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].temperature); +#endif } } } @@ -225,22 +442,48 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) if (SL_SENSOR_BH1750_ID == sensor_id) { if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_INTERRUPT_MODE) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].light); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_BH1750_ID: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].light); +#endif } else if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_POLLING_MODE) { if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_TIMEOUT) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.timeout / sensor_hub_info_t[sens_ind].sampling_interval; i++) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].light); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_BH1750_ID_%lu: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].light); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_NUM_OF_SAMPLES) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.numofsamples; i++) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].light); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_BH1750_ID_%lu: %f ", + (i + 1), + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[i].light); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_THRESHOLD) { DEBUGOUT("%f \t", (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].light); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_BH1750_ID: %f ", + (double)sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].light); +#endif } } } @@ -248,8 +491,15 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) if (SL_SENSOR_ADC_JOYSTICK_ID == sensor_id) { float vout = 0; if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_INTERRUPT_MODE) { - for (uint32_t i = 0; i < SL_SH_ADC_CH0_NUM_SAMPLES; i++) { + for (uint32_t i = 0; i < bus_intf_info.adc_config.adc_ch_cfg.num_of_samples[JS_ADC_CHANNEL]; i++) { DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_JOYSTICK_ID_%lu: %dmV ", + (i + 1), + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#endif } } else if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_POLLING_MODE) { if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_TIMEOUT) { @@ -257,52 +507,162 @@ void sl_si91x_sensor_event_handler(uint8_t sensor_id, uint8_t event) i < sensor_hub_info_t[sens_ind].data_deliver.timeout / sensor_hub_info_t[sens_ind].sampling_interval; i++) { DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_JOYSTICK_ID_%lu: %dmV ", + (i + 1), + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_NUM_OF_SAMPLES) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.numofsamples; i++) { DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_JOYSTICK_ID_%lu: %dmV ", + (i + 1), + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_THRESHOLD) { DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[0]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_JOYSTICK_ID: %dmV ", + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[0]); +#endif } } vout = - (((float)*(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc) / (float)SL_SH_ADC_MAX_OP_VALUE) + (((float)(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[0]) / (float)SL_SH_ADC_MAX_OP_VALUE) * SL_SH_ADC_VREF_VALUE); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "Single-ended output: %lfV ", + (double)vout); +#endif DEBUGOUT("Single ended input: %lfV \t", (double)vout); } if (SL_SENSOR_ADC_GUVA_S12D_ID == sensor_id) { float vout = 0; if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_INTERRUPT_MODE) { - for (uint32_t i = 0; i < SL_SH_ADC_CH0_NUM_SAMPLES; i++) { + for (uint32_t i = 0; i < bus_intf_info.adc_config.adc_ch_cfg.num_of_samples[GUVA_ADC_CHANNEL]; i++) { DEBUGOUT("%d \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_GUVA_S12D_ID_%lu: %d ", + (i + 1), + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#endif } } else if (sensor_hub_info_t[sens_ind].sensor_mode == SL_SH_POLLING_MODE) { if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_TIMEOUT) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.timeout / sensor_hub_info_t[sens_ind].sampling_interval; i++) { - DEBUGOUT("%d \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); + DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_GUVA_S12D_ID_%lu: %d ", + (i + 1), + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_NUM_OF_SAMPLES) { for (uint32_t i = 0; i < sensor_hub_info_t[sens_ind].data_deliver.numofsamples; i++) { - DEBUGOUT("%d \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); + DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_GUVA_S12D_ID_%lu: %d ", + (i + 1), + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[i]); +#endif } } if (sensor_hub_info_t[sens_ind].data_deliver.data_mode == SL_SH_THRESHOLD) { DEBUGOUT("%dmV \t", sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[0]); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "SL_SENSOR_ADC_GUVA_S12D_ID: %dmV ", + sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[0]); +#endif } } vout = - (((float)*(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc) / (float)SL_SH_ADC_MAX_OP_VALUE) + (((float)(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].adc[0]) / (float)SL_SH_ADC_MAX_OP_VALUE) * SL_SH_ADC_VREF_VALUE); +#if SH_AWS_ENABLE + snprintf(mqtt_publish_payload + strlen(mqtt_publish_payload), + sizeof(mqtt_publish_payload) - strlen(mqtt_publish_payload), + "Single-ended output: %lfV ", + (double)vout); +#endif DEBUGOUT("Single ended input: %lfV \t", (double)vout); } + + if (SL_SENSOR_ADC_GY_61_ID == sensor_id) { +#ifdef GY61_X_AXIS_ADC_CHANNEL + for (uint32_t i = 0; i < bus_intf_info.adc_config.adc_ch_cfg.num_of_samples[GY61_X_AXIS_ADC_CHANNEL]; i++) { + double x_g = + ((float)gy61_adc_raw_data_map(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].gy61.x[i], + GY61_X_RAW_MIN, + GY61_X_RAW_MAX, + GY61_G_SCALE_MIN, + GY61_G_SCALE_MAX)) + / -100.0; + DEBUGOUT("X = %gg, \t", x_g); + } +#endif +#ifdef GY61_Y_AXIS_ADC_CHANNEL + for (uint32_t i = 0; i < bus_intf_info.adc_config.adc_ch_cfg.num_of_samples[GY61_Y_AXIS_ADC_CHANNEL]; i++) { + double y_g = + ((float)gy61_adc_raw_data_map(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].gy61.y[0], + GY61_Y_RAW_MIN, + GY61_Y_RAW_MAX, + GY61_G_SCALE_MIN, + GY61_G_SCALE_MAX)) + / -100.0; + DEBUGOUT("Y = %gg, \t", y_g); + } +#endif +#ifdef GY61_Z_AXIS_ADC_CHANNEL + for (uint32_t i = 0; i < bus_intf_info.adc_config.adc_ch_cfg.num_of_samples[GY61_Z_AXIS_ADC_CHANNEL]; i++) { + double z_g = + ((float)gy61_adc_raw_data_map(sensor_hub_info_t[sens_ind].sensor_data_ptr->sensor_data[0].gy61.z[0], + GY61_Z_RAW_MIN, + GY61_Z_RAW_MAX, + GY61_G_SCALE_MIN, + GY61_G_SCALE_MAX)) + / -100.0; + DEBUGOUT("Z = %gg \t", z_g); + } +#endif + } + DEBUGOUT(" data_deliver.mode:%d \r\n", sensor_hub_info_t[sens_ind].data_deliver.data_mode); +#if SH_AWS_ENABLE + sl_semapptaskacq_status = osSemaphoreRelease(sl_semaphore_aws_task_id); + if (sl_semapptaskacq_status != osOK) { + DEBUGOUT("\r\n event post osSemaphoreRelease failed :%d \r\n", sl_semapptaskacq_status); + } + + sl_semapptaskacq_status = osSemaphoreAcquire(sl_semaphore_app_task_id_2, osWaitForever); + if (sl_semapptaskacq_status != osOK) { + DEBUGOUT("\r\n osSemaphoreAcquire failed :%d \r\n", sl_semapptaskacq_status); + } +#endif // Acknowledge data reception event_ack = sensor_id; @@ -357,6 +717,13 @@ void sl_si91x_sensorhub_app_task(void) DEBUGOUT("\r\n Start Sensor HUB APP Task \r\n"); sl_semaphore_app_task_id = osSemaphoreNew(1U, 0U, &sl_app_semaphore_attr_st); +#if SH_AWS_ENABLE + sl_semapptaskacq_status = osSemaphoreAcquire(sl_semaphore_app_task_id_2, osWaitForever); + if (sl_semapptaskacq_status != osOK) { + DEBUGOUT("\r\n osSemaphoreAcquire failed :%d \r\n", sl_semapptaskacq_status); + } +#endif + // Register callback handler for getting different events from the sensor hub status = sl_si91x_sensorhub_notify_cb_register(sl_si91x_sensor_event_handler, (sl_sensor_id_t *)&event_ack); if (status != SL_STATUS_OK) { @@ -445,6 +812,19 @@ void sensorhub_app_init(void) // Initializes board UART for Prints DEBUGINIT(); +#if SH_AWS_ENABLE + osSemaphoreAttr_t sl_app_semaphore_attr_st; + sl_app_semaphore_attr_st.attr_bits = 0U; + sl_app_semaphore_attr_st.cb_mem = NULL; + sl_app_semaphore_attr_st.cb_size = 0U; + sl_app_semaphore_attr_st.name = NULL; + + sl_semaphore_app_task_id_2 = osSemaphoreNew(1U, 0U, &sl_app_semaphore_attr_st); +#endif + // Create the APP task osThreadNew((osThreadFunc_t)sl_si91x_sensorhub_app_task, NULL, &app_thread_attributes); +#if SH_AWS_ENABLE + osThreadNew((osThreadFunc_t)sl_si91x_aws_task, NULL, &aws_thread_attributes); +#endif } diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_aws_app.c b/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_aws_app.c new file mode 100644 index 00000000..2b32dd9b --- /dev/null +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_aws_app.c @@ -0,0 +1,610 @@ +/***************************************************************************/ /** + * @file sensorhub_aws_app.c + * @brief Wi-Fi and AWS MQTT application code + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +/*************************************************************************** + * @brief : This file connects the SiWx917 to AWS MQTT cloud and publishes the + * sensor data collected from the sensorhub task to the cloud. (TA powersave is also supported) + ******************************************************************************/ + +#include +#include "cmsis_os2.h" +#include "sl_status.h" +#include "sl_net.h" +#include "sl_wifi.h" +#include "sl_wifi_device.h" +#include "sl_net_wifi_types.h" +#include "sl_utility.h" +#include "sl_si91x_driver.h" + +#include "sl_board_configuration.h" +#include "errno.h" +#include "socket.h" +#include "sl_net_si91x.h" +#include "sl_wifi_callback_framework.h" +#include "sl_si91x_socket.h" + +#ifdef SLI_SI91X_MCU_INTERFACE +#include "sl_si91x_m4_ps.h" +#endif + +//! Certificates to be loaded +#include "aws_client_certificate.pem.crt.h" +#include "aws_client_private_key.pem.key.h" +#include "aws_starfield_ca.pem.h" + +//! AWS files +#include "aws_iot_error.h" +#include "aws_iot_config.h" +#include "aws_iot_shadow_interface.h" + +/****************************************************** +* Constants +******************************************************/ + +#define CERTIFICATE_INDEX 0 + +#define SUBSCRIBE_TO_TOPIC "aws_status_555" //! Subscribe Topic to receive the message from cloud +#define PUBLISH_ON_TOPIC "siwx91x_status_555" //! Publish Topic to send the status from application to cloud +#define SUBSCRIBE_QOS QOS1 //! Quality of Service for subscribed topic "SUBSCRIBE_TO_TOPIC" +#define PUBLISH_QOS QOS1 //! Quality of Service for publish topic "PUBLISH_ON_TOPIC" +#define PUBLISH_PERIODICITY 1000 //! Publish periodicity in milliseconds +#define MQTT_USERNAME "username" +#define MQTT_PASSWORD "password" + +#define ENABLE_POWER_SAVE 0 + +#if SH_AWS_ENABLE +extern char mqtt_publish_payload[500]; +#else +#define MQTT_PUBLISH_PAYLOAD "Hi from SiWx91x" //! Publish message +#endif + +#if ENABLE_POWER_SAVE +volatile uint8_t powersave_given = 0; +#endif + +/****************************************************** +* Function Declarations +******************************************************/ +//static void application_start(void *argument); +sl_status_t load_certificates_in_flash(void); +sl_status_t start_aws_mqtt(void); +void subscribe_handler(struct _Client *pClient, + char *pTopicName, + short unsigned int topicNameLen, + IoT_Publish_Message_Params *pParams, + void *pClientData); +void disconnect_notify_handler(AWS_IoT_Client *pClient, void *data); + +//! Enumeration for states in application +typedef enum app_state { + WLAN_INITIAL_STATE = 0, + WLAN_SCAN_STATE, + WLAN_UNCONNECTED_STATE, + WLAN_CONNECTED_STATE, + WLAN_DISCONNECT, + AWS_MQTT_INIT_STATE, + AWS_MQTT_CONNECT_STATE, + AWS_MQTT_SUBSCRIBE_STATE, + AWS_MQTT_PUBLISH_STATE, + AWS_MQTT_RECEIVE_STATE, + AWS_MQTT_DISCONNECT, + AWS_SELECT_CONNECT_STATE, + IDLE_STATE +} app_state_t; + +volatile app_state_t application_state; + +#if SH_AWS_ENABLE +extern osSemaphoreId_t sl_semaphore_app_task_id_2; +osSemaphoreId_t sl_semaphore_aws_task_id; +osSemaphoreAttr_t sl_aws_semaphore_attr_st; +#endif + +/****************************************************** +* Variable Definitions +******************************************************/ + +IoT_Publish_Message_Params publish_iot_msg = { 0 }; + +fd_set read_fds; +AWS_IoT_Client mqtt_client = { 0 }; +#define RSI_FD_ISSET(x, y) rsi_fd_isset(x, y) +volatile uint8_t check_for_recv_data; +extern osSemaphoreId_t select_sem; +extern volatile uint8_t pub_state, qos1_publish_handle, select_given; +int32_t status = SL_STATUS_OK; + +const osThreadAttr_t thread_attributes = { + .name = "app", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityNormal, + .tz_module = 0, + .reserved = 0, +}; + +//! No of ltcp socktes +#define RSI_NUMBER_OF_LTCP_SOCKETS 0 + +//! Default number of sockets supported,max 10 sockets are supported +#define RSI_NUMBER_OF_SOCKETS (6 + RSI_NUMBER_OF_LTCP_SOCKETS) + +//! Default number of sockets supported,max 10 selects are supported +#define RSI_NUMBER_OF_SELECTS (RSI_NUMBER_OF_SOCKETS) + +static const sl_wifi_device_configuration_t client_init_configuration = { + .boot_option = LOAD_NWP_FW, + .mac_address = NULL, + .band = SL_SI91X_WIFI_BAND_2_4GHZ, + .region_code = US, + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_ONLY_MODE, + .feature_bit_map = +#ifdef SLI_SI91X_MCU_INTERFACE + (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE), +#else + (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION +#if ENABLE_POWER_SAVE + | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE +#endif + ), +#endif + + .tcp_ip_feature_bit_map = + (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | SL_SI91X_TCP_IP_FEAT_SSL +#ifdef SLI_SI91X_ENABLE_IPV6 + | SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 +#endif + | SL_SI91X_TCP_IP_FEAT_ICMP | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), + .custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID, + .ext_custom_feature_bit_map = + (SL_SI91X_EXT_FEAT_XTAL_CLK | SL_SI91X_EXT_FEAT_UART_SEL_FOR_DEBUG_PRINTS + | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 | SL_SI91X_EXT_FEAT_LOW_POWER_MODE + | MEMORY_CONFIG +#ifdef SLI_SI917 + | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 +#endif + ), + .bt_feature_bit_map = 0, + .ext_tcp_ip_feature_bit_map = + (SL_SI91X_EXT_TCP_IP_WINDOW_SCALING | SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(1) + | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), + .ble_feature_bit_map = 0, + .ble_ext_feature_bit_map = 0, +#ifdef SLI_SI91X_MCU_INTERFACE + .config_feature_bit_map = 0 +#else +#if ENABLE_POWER_SAVE + .config_feature_bit_map = SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP +#else + .config_feature_bit_map = 0 +#endif +#endif + } +}; +/****************************************************** +* Function Definitions +******************************************************/ + +void async_socket_select(fd_set *fd_read, fd_set *fd_write, fd_set *fd_except, int32_t status) +{ + UNUSED_PARAMETER(fd_except); + UNUSED_PARAMETER(fd_write); + UNUSED_PARAMETER(status); + + //!Check the data pending on this particular socket descriptor + if (FD_ISSET(mqtt_client.networkStack.socket_id, fd_read)) { + if (pub_state != 1) { //This check is for handling PUBACK in QOS1 + check_for_recv_data = 1; + application_state = AWS_SELECT_CONNECT_STATE; + } else if (pub_state == 1) { //This check is for handling PUBACK in QOS1 + osSemaphoreRelease(select_sem); + } + } + application_state = AWS_SELECT_CONNECT_STATE; +} + +void disconnect_notify_handler(AWS_IoT_Client *pClient, void *data) +{ + UNUSED_PARAMETER(pClient); + UNUSED_PARAMETER(data); + printf("\r\nMQTT disconnected abruptly and pClient state is: %d\r\n", pClient->clientStatus.clientState); +} + +void subscribe_handler(struct _Client *pClient, + char *pTopicName, + short unsigned int topicNameLen, + IoT_Publish_Message_Params *pParams, + void *data) +{ + UNUSED_PARAMETER(pClient); + UNUSED_PARAMETER(pTopicName); + UNUSED_PARAMETER(topicNameLen); + UNUSED_PARAMETER(data); + printf("\rData received on the Subscribed Topic: %.*s \r\n", pParams->payloadLen, (char *)pParams->payload); +} +// +//void app_init(void) +//{ +// osThreadNew((osThreadFunc_t)application_start, NULL, &thread_attributes); +//} + +void sl_si91x_aws_task(void) +{ + sl_net_wifi_client_profile_t profile = { 0 }; + sl_ip_address_t ip_address = { 0 }; +#if SH_AWS_ENABLE + sl_aws_semaphore_attr_st.attr_bits = 0U; + sl_aws_semaphore_attr_st.cb_mem = NULL; + sl_aws_semaphore_attr_st.cb_size = 0U; + sl_aws_semaphore_attr_st.name = NULL; +#endif + + select_sem = osSemaphoreNew(1, 0, NULL); +#if SH_AWS_ENABLE + sl_semaphore_aws_task_id = osSemaphoreNew(1U, 0U, &sl_aws_semaphore_attr_st); +#endif + printf("\r\nWi-Fi Begin\r\n"); + sl_status_t status = sl_net_init(SL_NET_WIFI_CLIENT_INTERFACE, &client_init_configuration, NULL, NULL); + if (status != SL_STATUS_OK) { + printf("\r\nUnexpected error while initializing Wi-Fi: 0x%lx\r\n", status); + return; + } + printf("\r\nWi-Fi is Initialized\r\n"); + +#ifdef SLI_SI91X_MCU_INTERFACE + uint8_t xtal_enable = 1; + status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, NULL); + if (status != SL_STATUS_OK) { + printf("\r\nFailed to bring m4_ta_secure_handshake: 0x%lx\r\n", status); + return; + } + printf("\r\nM4-NWP secure handshake is successful\r\n"); +#endif + + status = sl_net_up(SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID); + if (status != SL_STATUS_OK) { + printf("\r\nError while connecting to Access point: 0x%lx\r\n", status); + return; + } + printf("\r\nConnected to Access point\r\n"); + + status = sl_net_get_profile(SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID, &profile); + if (status != SL_STATUS_OK) { + printf("\r\nFailed to get client profile: 0x%lx\r\n", status); + return; + } + printf("\r\nGetting client profile is successful\r\n"); + + ip_address.type = SL_IPV4; + memcpy(&ip_address.ip.v4.bytes, &profile.ip.ip.v4.ip_address.bytes, sizeof(sl_ipv4_address_t)); + printf("\r\nIP address is "); + print_sl_ip_address(&ip_address); + printf("\r\n"); + + status = load_certificates_in_flash(); + if (status != SL_STATUS_OK) { + printf("\r\Error while loading certificates: 0x%lx\r\n", status); + return; + } + printf("\r\nLoaded certificates\r\n"); + + status = start_aws_mqtt(); + if (status != SL_STATUS_OK) { + printf("\r\nUnexpected error occurred in AWS connection: 0x%lx\r\n", status); + return; + } +} + +sl_status_t load_certificates_in_flash(void) +{ + sl_status_t status; + + // Load SSL CA certificate + status = sl_net_set_credential(SL_NET_TLS_SERVER_CREDENTIAL_ID(CERTIFICATE_INDEX), + SL_NET_SIGNING_CERTIFICATE, + aws_starfield_ca, + sizeof(aws_starfield_ca) - 1); + if (status != SL_STATUS_OK) { + printf("\r\nLoading TLS CA certificate in to FLASH Failed, Error Code : 0x%lX\r\n", status); + return status; + } + printf("\r\nLoading TLS CA certificate at index %d Successful\r\n", CERTIFICATE_INDEX); + + // Load SSL Client certificate + status = sl_net_set_credential(SL_NET_TLS_CLIENT_CREDENTIAL_ID(CERTIFICATE_INDEX), + SL_NET_CERTIFICATE, + aws_client_certificate, + sizeof(aws_client_certificate) - 1); + if (status != SL_STATUS_OK) { + printf("\r\nLoading TLS certificate in to FLASH failed, Error Code : 0x%lX\r\n", status); + return status; + } + printf("\r\nLoading TLS Client certificate at index %d Successful\r\n", CERTIFICATE_INDEX); + + // Load SSL Client private key + status = sl_net_set_credential(SL_NET_TLS_CLIENT_CREDENTIAL_ID(CERTIFICATE_INDEX), + SL_NET_PRIVATE_KEY, + aws_client_private_key, + sizeof(aws_client_private_key) - 1); + if (status != SL_STATUS_OK) { + printf("\r\nLoading TLS Client private key in to FLASH Failed, Error Code : 0x%lX\r\n", status); + return status; + } + printf("\r\nLoading TLS Client private key at index %d Successful\r\n", CERTIFICATE_INDEX); + + return SL_STATUS_OK; +} + +sl_status_t start_aws_mqtt(void) +{ + IoT_Error_t rc = FAILURE; + + IoT_Client_Init_Params mqtt_init_params = iotClientInitParamsDefault; + IoT_Client_Connect_Params mqtt_connect_params = iotClientConnectParamsDefault; +#if SH_AWS_ENABLE + osStatus_t sl_semawstaskacq_status; +#endif + + sl_mac_address_t mac_addr = { 0 }; + char mac_id[18]; + sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &mac_addr); + sprintf(mac_id, + "%x:%x:%x:%x:%x:%x", + mac_addr.octet[0], + mac_addr.octet[1], + mac_addr.octet[2], + mac_addr.octet[3], + mac_addr.octet[4], + mac_addr.octet[5]); + printf("\r\n client_id:%s \r\n", mac_id); + + sl_wifi_firmware_version_t fw_version = { 0 }; + status = sl_wifi_get_firmware_version(&fw_version); + if (status != SL_STATUS_OK) { + printf("\r\nFirmware version Failed, Error Code : 0x%lX\r\n", status); + } else { + print_firmware_version(&fw_version); + } + + mqtt_init_params.enableAutoReconnect = true; + mqtt_init_params.pHostURL = AWS_IOT_MQTT_HOST; + mqtt_init_params.port = AWS_IOT_MQTT_PORT; + mqtt_init_params.pRootCALocation = (char *)aws_starfield_ca; + mqtt_init_params.pDeviceCertLocation = (char *)aws_client_certificate; + mqtt_init_params.pDevicePrivateKeyLocation = (char *)aws_client_private_key; + mqtt_init_params.mqttCommandTimeout_ms = 20000; + mqtt_init_params.tlsHandshakeTimeout_ms = 5000; + mqtt_init_params.isSSLHostnameVerify = true; + mqtt_init_params.disconnectHandler = disconnect_notify_handler; + mqtt_init_params.disconnectHandlerData = NULL; + + mqtt_connect_params.keepAliveIntervalInSec = 1200; + mqtt_connect_params.isCleanSession = true; + mqtt_connect_params.MQTTVersion = MQTT_3_1_1; + mqtt_connect_params.pClientID = AWS_IOT_MQTT_CLIENT_ID; + mqtt_connect_params.clientIDLen = (uint16_t)strlen(AWS_IOT_MQTT_CLIENT_ID); + mqtt_connect_params.isWillMsgPresent = false; + mqtt_connect_params.pUsername = MQTT_USERNAME; + mqtt_connect_params.usernameLen = strlen(MQTT_USERNAME); + mqtt_connect_params.pPassword = MQTT_PASSWORD; + mqtt_connect_params.passwordLen = strlen(MQTT_PASSWORD); + + application_state = AWS_MQTT_INIT_STATE; + + while (1) { + + switch (application_state) { + + case AWS_MQTT_INIT_STATE: { + rc = aws_iot_mqtt_init(&mqtt_client, &mqtt_init_params); + if (SUCCESS != rc) { + application_state = AWS_MQTT_INIT_STATE; + printf("\r\nMQTT Initialization failed with error: 0x%x\r\n", rc); + } else { + application_state = AWS_MQTT_CONNECT_STATE; + printf("\r\nMQTT Initialization success\r\n"); + } + + } break; + case AWS_MQTT_CONNECT_STATE: { + rc = aws_iot_mqtt_connect(&mqtt_client, &mqtt_connect_params); + if (SUCCESS != rc) { + if (rc == NETWORK_ALREADY_CONNECTED_ERROR) { + printf("\r\nNetwork is already connected\r\n"); + + } else { + printf("\r\nMQTT connect failed with error: 0x%x\r\n", rc); + application_state = AWS_MQTT_DISCONNECT; + } + } else { + printf("\r\nConnected to AWS IoT Cloud\n"); + application_state = AWS_MQTT_SUBSCRIBE_STATE; + } + + } break; + case AWS_MQTT_SUBSCRIBE_STATE: { + rc = aws_iot_mqtt_subscribe(&mqtt_client, + SUBSCRIBE_TO_TOPIC, + strlen(SUBSCRIBE_TO_TOPIC), + SUBSCRIBE_QOS, + subscribe_handler, + NULL); + + if (SUCCESS != rc) { + if (NETWORK_DISCONNECTED_ERROR == rc) { + printf("\r\nSubscription failed with error: 0x%x\r\n", rc); + application_state = AWS_MQTT_CONNECT_STATE; + } else if (NETWORK_ATTEMPTING_RECONNECT == rc) { + // If the client is attempting to reconnect skip the rest of the loop + continue; + } + application_state = AWS_MQTT_SUBSCRIBE_STATE; + } else { + printf("\rSubscribed to the specified topic with QoS%d\n", SUBSCRIBE_QOS); + application_state = AWS_SELECT_CONNECT_STATE; + } + + } break; + + case AWS_SELECT_CONNECT_STATE: { + { + if (!select_given) { + select_given = 1; + memset(&read_fds, 0, sizeof(fd_set)); + + FD_SET(mqtt_client.networkStack.socket_id, &read_fds); + printf("\rSocket ID: %d\n", mqtt_client.networkStack.socket_id); + + status = + sl_si91x_select(mqtt_client.networkStack.socket_id + 1, &read_fds, NULL, NULL, NULL, async_socket_select); + + printf("\rSelect status: 0x%lX\r\n", status); + } +#if SH_AWS_ENABLE + sl_semawstaskacq_status = osSemaphoreRelease(sl_semaphore_app_task_id_2); + if (sl_semawstaskacq_status != osOK) { + DEBUGOUT("\r\n osSemaphoreRelease failed :%d \r\n", sl_semawstaskacq_status); + } + + // waiting for the semaphore release + sl_semawstaskacq_status = osSemaphoreAcquire(sl_semaphore_aws_task_id, osWaitForever); + if (sl_semawstaskacq_status != osOK) { + DEBUGOUT("\r\n osSemaphoreAcquire failed :%d \r\n", sl_semawstaskacq_status); + } +#endif + + if (check_for_recv_data) { + check_for_recv_data = 0; + select_given = 0; + application_state = AWS_MQTT_RECEIVE_STATE; + } else { + application_state = AWS_MQTT_PUBLISH_STATE; + } + } + + } break; + + case AWS_MQTT_RECEIVE_STATE: { + rc = aws_iot_shadow_yield(&mqtt_client, 1); + if (SUCCESS == rc) { + printf("\rYield is successful\n"); + } + application_state = AWS_SELECT_CONNECT_STATE; + + } break; + + case AWS_MQTT_PUBLISH_STATE: { +#if SH_AWS_ENABLE + printf("\rData to be published: %s\n", mqtt_publish_payload); + + publish_iot_msg.qos = PUBLISH_QOS; + publish_iot_msg.payload = mqtt_publish_payload; + publish_iot_msg.isRetained = 0; + publish_iot_msg.payloadLen = strlen(mqtt_publish_payload); +#else + printf("\rData to be published: %s\n", MQTT_PUBLISH_PAYLOAD); + + publish_iot_msg.qos = PUBLISH_QOS; + publish_iot_msg.payload = MQTT_PUBLISH_PAYLOAD; + publish_iot_msg.isRetained = 0; + publish_iot_msg.payloadLen = sizeof(MQTT_PUBLISH_PAYLOAD); +#endif + if (SUBSCRIBE_QOS == QOS1 || PUBLISH_QOS == QOS1) { + pub_state = 1; + } + rc = aws_iot_mqtt_publish(&mqtt_client, PUBLISH_ON_TOPIC, strlen(PUBLISH_ON_TOPIC), &publish_iot_msg); + + if (rc != SUCCESS) { + printf("\r\nMQTT Publish with QoS%d failed with error: 0x%x\n", PUBLISH_QOS, rc); + application_state = AWS_MQTT_DISCONNECT; + break; + } + + else if (rc == MQTT_REQUEST_TIMEOUT_ERROR) { + printf("\r\nACK not received for QoS%d publish\r\n", PUBLISH_QOS); + } else { + printf("\rQoS%d publish is successful\r\n", PUBLISH_QOS); + } + +#if ENABLE_POWER_SAVE + sl_wifi_performance_profile_t performance_profile = { .profile = ASSOCIATED_POWER_SAVE, + .listen_interval = 1000 }; + if (!powersave_given) { + rc = sl_wifi_set_performance_profile(&performance_profile); + if (rc != SL_STATUS_OK) { + printf("\r\nPower save configuration Failed, Error Code : 0x%X\r\n", rc); + } + printf("\r\nAssociated Power Save is enabled\r\n"); + powersave_given = 1; + } + application_state = AWS_SELECT_CONNECT_STATE; +#else + application_state = IDLE_STATE; +#endif + } break; + + case AWS_MQTT_DISCONNECT: { + rc = aws_iot_mqtt_disconnect(&mqtt_client); + if (SUCCESS != rc) { + printf("\r\nMQTT disconnection error\r\n"); + application_state = AWS_MQTT_INIT_STATE; + } + application_state = AWS_MQTT_INIT_STATE; + + } break; + case IDLE_STATE: { + + application_state = AWS_SELECT_CONNECT_STATE; + + } break; + +#if 0 + case RSI_WLAN_DISCONNECT: { + rc = sl_net_down(); + if (SUCCESS != rc) { + printf("\r\nWLAN disconnection error\r\n"); + application_state = WLAN_DISCONNECT; + } + sl_si91x_host_delay_ms(100); + application_state = WLAN_INITIAL_STATE; + } + break; +#endif + default: + break; + } + } + + return rc; +} diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_config.c b/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_config.c index bb45901a..68603d13 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_config.c +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensorhub_config.c @@ -53,13 +53,13 @@ sl_sensor_info_t sensor_hub_info_t[SL_MAX_NUM_SENSORS] = { /* { .sensor_name = "ADC_JOYSTICK", .sensor_id = SL_SENSOR_ADC_JOYSTICK_ID, - .channel = SL_SH_ADC_CH0_CHANNEL, + .channel = BIT(SL_SH_ADC_CH1_CHANNEL), .sensor_bus = SL_SH_ADC, .sensor_mode = SL_SH_POLLING_MODE, .sampling_interval = 100, .data_deliver.data_mode = SL_SH_NUM_OF_SAMPLES, - .data_deliver.numofsamples = SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES, - }, */ + .data_deliver.numofsamples = SL_SH_ADC_SENSOR1_NUM_OF_SAMPLES, + },*/ /* { .sensor_name = "ACCELEROMETER_SENSOR", .sensor_bus = SL_SH_SPI, @@ -74,7 +74,7 @@ sl_sensor_info_t sensor_hub_info_t[SL_MAX_NUM_SENSORS] = { { .sensor_name = "GUVA_12D_UV", .sensor_id = SL_SENSOR_ADC_GUVA_S12D_ID, - .channel = SL_SH_ADC_CH0_CHANNEL, + .channel = BIT(SL_SH_ADC_CH0_CHANNEL), .sensor_bus = SL_SH_ADC, .sensor_mode = SL_SH_POLLING_MODE, .sampling_interval = 100, @@ -82,6 +82,15 @@ sl_sensor_info_t sensor_hub_info_t[SL_MAX_NUM_SENSORS] = { .data_deliver.numofsamples = SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES, }, + /*{ + .sensor_name = "GY61", + .sensor_id = SL_SENSOR_ADC_GY_61_ID, + .channel = BIT(SL_SH_ADC_CH1_CHANNEL) | BIT(SL_SH_ADC_CH2_CHANNEL) | BIT(SL_SH_ADC_CH3_CHANNEL), + .sensor_bus = SL_SH_ADC, + .sensor_mode = SL_SH_INTERRUPT_MODE, + .data_deliver.data_mode = SL_SH_NO_DATA_MODE, + },*/ + { .sensor_name = "LIGHT_SENSOR", .sensor_bus = SL_SH_I2C, @@ -116,7 +125,7 @@ sl_sensor_info_t sensor_hub_info_t[SL_MAX_NUM_SENSORS] = { } }; -const sl_bus_intf_config_t bus_intf_info = { +sl_bus_intf_config_t bus_intf_info = { .i2c_config.i2c_bus_speed = ARM_I2C_BUS_SPEED_FAST, .i2c_config.i2c_power_state = ARM_POWER_FULL, .i2c_config.i2c_control_mode = ARM_I2C_BUS_SPEED, @@ -130,7 +139,7 @@ const sl_bus_intf_config_t bus_intf_info = { .spi_config.spi_cs_number = SPI_CHIP_SELECT, .spi_config.spi_cs_misc_mode = ARM_SPI_CONTROL_SS, .spi_config.spi_sec_sel_sig = ARM_SPI_SS_ACTIVE, - +#ifdef SL_SH_ADC_CHANNEL0 .adc_config.adc_cfg.operation_mode = SL_ADC_STATIC_MODE, .adc_config.adc_cfg.num_of_channel_enable = SL_SH_ADC_NUM_CHANNELS_ENABLE, @@ -139,6 +148,34 @@ const sl_bus_intf_config_t bus_intf_info = { .adc_config.adc_ch_cfg.pos_inp_sel[0] = SL_SH_ADC_CH0_P_INPUT, .adc_config.adc_ch_cfg.opamp_gain[0] = SL_SH_ADC_CH0_OPAMP_GAIN, .adc_config.adc_ch_cfg.num_of_samples[0] = SL_SH_ADC_CH0_NUM_SAMPLES, - .adc_config.adc_ch_cfg.chnl_ping_address[0] = ADC_PING_BUFFER, - .adc_config.adc_ch_cfg.chnl_pong_address[0] = ADC_PING_BUFFER + (SL_SH_ADC_CH0_NUM_SAMPLES), + .adc_config.adc_ch_cfg.chnl_ping_address[0] = ADC_PING_BUFFER0, + .adc_config.adc_ch_cfg.chnl_pong_address[0] = ADC_PING_BUFFER0 + SL_SH_ADC_CH0_NUM_SAMPLES, +#endif +#ifdef SL_SH_ADC_CHANNEL1 + .adc_config.adc_ch_cfg.input_type[1] = SL_ADC_SINGLE_ENDED, + .adc_config.adc_ch_cfg.sampling_rate[1] = SL_SH_ADC_SAMPLING_RATE, + .adc_config.adc_ch_cfg.pos_inp_sel[1] = SL_SH_ADC_CH1_P_INPUT, + .adc_config.adc_ch_cfg.opamp_gain[1] = SL_SH_ADC_CH1_OPAMP_GAIN, + .adc_config.adc_ch_cfg.num_of_samples[1] = SL_SH_ADC_CH1_NUM_SAMPLES, + .adc_config.adc_ch_cfg.chnl_ping_address[1] = ADC_PING_BUFFER1, + .adc_config.adc_ch_cfg.chnl_pong_address[1] = ADC_PING_BUFFER1 + SL_SH_ADC_CH1_NUM_SAMPLES, +#endif +#ifdef SL_SH_ADC_CHANNEL2 + .adc_config.adc_ch_cfg.input_type[2] = SL_ADC_SINGLE_ENDED, + .adc_config.adc_ch_cfg.sampling_rate[2] = SL_SH_ADC_SAMPLING_RATE, + .adc_config.adc_ch_cfg.pos_inp_sel[2] = SL_SH_ADC_CH2_P_INPUT, + .adc_config.adc_ch_cfg.opamp_gain[2] = SL_SH_ADC_CH2_OPAMP_GAIN, + .adc_config.adc_ch_cfg.num_of_samples[2] = SL_SH_ADC_CH2_NUM_SAMPLES, + .adc_config.adc_ch_cfg.chnl_ping_address[2] = ADC_PING_BUFFER2, + .adc_config.adc_ch_cfg.chnl_pong_address[2] = ADC_PING_BUFFER2 + SL_SH_ADC_CH2_NUM_SAMPLES, +#endif +#ifdef SL_SH_ADC_CHANNEL3 + .adc_config.adc_ch_cfg.input_type[3] = SL_ADC_SINGLE_ENDED, + .adc_config.adc_ch_cfg.sampling_rate[3] = SL_SH_ADC_SAMPLING_RATE, + .adc_config.adc_ch_cfg.pos_inp_sel[3] = SL_SH_ADC_CH3_P_INPUT, + .adc_config.adc_ch_cfg.opamp_gain[3] = SL_SH_ADC_CH3_OPAMP_GAIN, + .adc_config.adc_ch_cfg.num_of_samples[3] = SL_SH_ADC_CH3_NUM_SAMPLES, + .adc_config.adc_ch_cfg.chnl_ping_address[3] = ADC_PING_BUFFER3, + .adc_config.adc_ch_cfg.chnl_pong_address[3] = ADC_PING_BUFFER3 + SL_SH_ADC_CH3_NUM_SAMPLES, +#endif }; diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/accelerometer_sensor/adxl345.h b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/accelerometer_sensor/adxl345.h index cad0f3e3..235d8b1b 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/accelerometer_sensor/adxl345.h +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/accelerometer_sensor/adxl345.h @@ -258,7 +258,7 @@ void sl_si91x_adxl345_read_acceleration_value(int *xyz); * @param[in] a, b, c: Axis at all g ranges with 10 Bit Resolution (2 Bytes) * @return Returns RSI_OK if Success, else SL_FAIL for Failure *******************************************************************************/ -void sl_si91x_adxl345_read_acceleration(int *read_a, int *read_b, int *read_c); +void sl_si91x_adxl345_read_acceleration(int16_t *read_a, int16_t *read_b, int16_t *read_c); /******************************************************************************* * @fn void sl_si91x_adxl345_get_Gxyz(double *xyz) diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/adc_sensor/adc_sensor_hal.h b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/adc_sensor/adc_sensor_hal.h index d4e51bf2..b007afac 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/adc_sensor/adc_sensor_hal.h +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/adc_sensor/adc_sensor_hal.h @@ -43,29 +43,85 @@ typedef int32_t sl_adc_error_t; /* Macros for sensor hub */ #define SL_SH_ADC_CHANNEL0 +#define SL_SH_ADC_CHANNEL1 +#define SL_SH_ADC_CHANNEL2 +#define SL_SH_ADC_CHANNEL3 #ifdef SL_SH_ADC_CHANNEL0 #include "adc_sensor_hal.h" #endif -#define SL_SH_FIFO_MODE /* ADC peripheral configurations */ -#define SL_SH_ADC_SAMPLING_RATE 10000 ///< ADC sampling rate, 10sps, 20 milliseconds per sample */ -#define SL_SH_ADC_NUM_CHANNELS_ENABLE 1 ///< ADC number of channels enabled */ +#define SL_SH_ADC_SAMPLING_RATE 1000 ///< ADC sampling rate, 10sps, 20 milliseconds per sample */ +#define SL_SH_ADC_NUM_CHANNELS_ENABLE 1 ///< ADC number of channels enabled */ -/* ADC sensor 0 configurations */ +/* ADC channel 0 configurations */ #ifdef SL_SH_ADC_CHANNEL0 -#define SL_SH_ADC_CH0_P_INPUT 5 ///< ADC sensor 0 positive input selection */ -#define SL_SH_ADC_CH0_CHANNEL 0 ///< ADC sensor 0 channel number */ -#define SL_SH_ADC_CH0_OPAMP_GAIN 2 ///< ADC sensor 0 opamp gain */ -#define SL_SH_ADC_CH0_NUM_SAMPLES 1 ///< ADC sensor 0 number of samples */ +#define SL_SH_ADC_CH0_P_INPUT 1 ///< ADC channel 0 positive input selection ULP_GPIO_2 */ +#define SL_SH_ADC_CH0_CHANNEL 0 ///< ADC channel 0 channel number */ +#define SL_SH_ADC_CH0_OPAMP_GAIN 2 ///< ADC channel 0 opamp gain */ +#define SL_SH_ADC_CH0_NUM_SAMPLES 1 ///< ADC channel 0 number of samples */ +#define ADC_PING_BUFFER0 0x24060000 ///< ADC ping buffer starting address for channel 0. #endif -#define SL_SH_ADC_MAX_OP_VALUE 4096 ///< Maximum voltage output value from adc */ -#define SL_SH_ADC_VREF_VALUE 3.3f ///< Reference voltage */ -#define ADC_PING_BUFFER 0x24060800 ///< ADC ping buffer starting address. +/* ADC channel 1 configurations */ +#ifdef SL_SH_ADC_CHANNEL1 +#define SL_SH_ADC_CH1_P_INPUT 4 ///< ADC channel 0 positive input selection ULP_GPIO_8 */ +#define SL_SH_ADC_CH1_CHANNEL 1 ///< ADC channel 0 channel number */ +#define SL_SH_ADC_CH1_OPAMP_GAIN 2 ///< ADC channel 0 opamp gain */ +#define SL_SH_ADC_CH1_NUM_SAMPLES 1 ///< ADC channel 0 number of samples */ +#define ADC_PING_BUFFER1 0x24060800 ///< ADC ping buffer starting address for channel 1. +#endif + +/* ADC channel 2 configurations */ +#ifdef SL_SH_ADC_CHANNEL2 +#define SL_SH_ADC_CH2_P_INPUT 5 ///< ADC channel 0 positive input selection ULP_GPIO_10 */ +#define SL_SH_ADC_CH2_CHANNEL 2 ///< ADC channel 0 channel number */ +#define SL_SH_ADC_CH2_OPAMP_GAIN 2 ///< ADC channel 0 opamp gain */ +#define SL_SH_ADC_CH2_NUM_SAMPLES 1 ///< ADC channel 0 number of samples */ +#define ADC_PING_BUFFER2 0x24061000 ///< ADC ping buffer starting address for channel 2. +#endif + +/* ADC channel 3 configurations */ +#ifdef SL_SH_ADC_CHANNEL3 +#define SL_SH_ADC_CH3_P_INPUT 10 ///< ADC channel 0 positive input selection ULP_GPIO_1 */ +#define SL_SH_ADC_CH3_CHANNEL 3 ///< ADC channel 0 channel number */ +#define SL_SH_ADC_CH3_OPAMP_GAIN 2 ///< ADC channel 0 opamp gain */ +#define SL_SH_ADC_CH3_NUM_SAMPLES 1 ///< ADC channel 0 number of samples */ +#define ADC_PING_BUFFER3 0x24061800 ///< ADC ping buffer starting address for channel 2. +#endif + +#define SL_SH_ADC_MAX_OP_VALUE 4095 ///< Maximum voltage output value from adc */ +#define SL_SH_ADC_VREF_VALUE 3.3f ///< Reference voltage */ + +#define SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES 1 ///< Number of samples for ADC sensor0 +#define SL_SH_ADC_SENSOR1_NUM_OF_SAMPLES 1 ///< Number of samples for ADC sensor1 +#define SL_SH_ADC_SENSOR2_NUM_OF_SAMPLES 1 ///< Number of samples for ADC sensor2 + +#define GY61_ADC_SENSOR +/* ADC channel numbers used for sensors */ +#define JS_ADC_CHANNEL 0 +#define GUVA_ADC_CHANNEL 0 +#ifdef GY61_ADC_SENSOR +#define GY61_X_AXIS_ADC_CHANNEL 1 +#define GY61_Y_AXIS_ADC_CHANNEL 2 +#define GY61_Z_AXIS_ADC_CHANNEL 3 +#define GY61_ADC_SENSOR_CHANNELS \ + (BIT(GY61_X_AXIS_ADC_CHANNEL) | BIT(GY61_Y_AXIS_ADC_CHANNEL) | BIT(GY61_Z_AXIS_ADC_CHANNEL)) + +/* ADXL335 GY61 sensor g conversion values*/ +#define GY61_X_RAW_MIN 3005 +#define GY61_X_RAW_MAX 3390 +#define GY61_Y_RAW_MIN 3005 +#define GY61_Y_RAW_MAX 3380 +#define GY61_Z_RAW_MIN 1750 +#define GY61_Z_RAW_MAX 2550 +#define GY61_G_SCALE_MIN -100 +#define GY61_G_SCALE_MAX 100 +#endif -#define SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES 5 ///< Number of samples for ADC sensor0 +#define IS_MULTI_CHANNEL(X) ((X & (X - 1)) != 0) +#define IS_SINGLE_CHANNEL(X) ((X & (X - 1)) == 0) /* ADC sensor implementations for sensors */ typedef struct { diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensor_type.h b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensor_type.h index 55cc3357..ba9211c2 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensor_type.h +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensor_type.h @@ -81,6 +81,16 @@ typedef struct { #define SL_UV_T sl_uv_t #endif +//Sensor ADXL335 GY61 analog data +#ifndef SL_ADC_GY61_T +typedef struct { + uint16_t *x; + uint16_t *y; + uint16_t *z; +} sl_adc_gy61_t; +#define SL_ADC_GY61_T sl_adc_gy61_t +#endif + //Sensor operations typedef enum { SL_COMMAND_SET_MODE, @@ -111,6 +121,7 @@ typedef struct { float temperature; ///< Temperature unit: dCelsius float light; ///< Light unit: lux SL_UV_T uv; ///< ultraviole unit: lux + SL_ADC_GY61_T gy61; ///< ADC GY61 uint: gy61 uint16_t *adc; ///< ADC output unit: mV }; } sl_sensor_data_t; diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensors_config.h b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensors_config.h index a6d3efc8..413973f6 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensors_config.h +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/inc/sensors_config.h @@ -89,6 +89,7 @@ typedef enum { typedef enum { SL_ADC_JOYSTICK_ID = 0x00, /*!< adc joystick id*/ SL_ADC_GUVA_S12D_ID, /*!< adc uv sensor */ + SL_ADC_GY61_ID, /*!< adc gy61 sensor */ SL_ADC_MAX_ID, /*!< max adc sensor id*/ } adc_sensor_id_t; @@ -110,7 +111,8 @@ typedef enum { SL_GPIO_SENSE_BUTTON_ID = (SL_GPIO_SENSOR_ID << SL_SENSOR_ID_OFFSET) | SL_SH_GPIO_0, ///< GPIOs id #ifdef SL_CONFIG_SENSOR_ADC SL_SENSOR_ADC_JOYSTICK_ID = (SL_ADC_SENSOR_ID << SL_SENSOR_ID_OFFSET) | SL_ADC_JOYSTICK_ID, ///< ADC joystick id - SL_SENSOR_ADC_GUVA_S12D_ID = (SL_ADC_SENSOR_ID << SL_SENSOR_ID_OFFSET) | SL_ADC_GUVA_S12D_ID, ///< ADC joystick id + SL_SENSOR_ADC_GUVA_S12D_ID = (SL_ADC_SENSOR_ID << SL_SENSOR_ID_OFFSET) | SL_ADC_GUVA_S12D_ID, ///< ADC GUVA sensor id + SL_SENSOR_ADC_GY_61_ID = (SL_ADC_SENSOR_ID << SL_SENSOR_ID_OFFSET) | SL_ADC_GY61_ID, ///< ADC GY61 sensor id #endif } sl_sensor_id_t; diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/accelerometer_sensor/adxl345.c b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/accelerometer_sensor/adxl345.c index 4cba25e2..10eefa39 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/accelerometer_sensor/adxl345.c +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/accelerometer_sensor/adxl345.c @@ -400,7 +400,7 @@ void sl_si91x_adxl345_read_acceleration_value(int *xyz) * @param[in] a, b, c: Axis at all g ranges with 10 Bit Resolution (2 Bytes) * @return NULL *******************************************************************************/ -void sl_si91x_adxl345_read_acceleration(int *read_a, int *read_b, int *read_c) +void sl_si91x_adxl345_read_acceleration(int16_t *read_a, int16_t *read_b, int16_t *read_c) { read(SL_ADXL345_DATAX0, SL_ADXL345_TO_READ, buff); // Read Accel Data from ADXL345 diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/adc_sensor/adc_sensor_hal.c b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/adc_sensor/adc_sensor_hal.c index 76a27f6e..4458632e 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/adc_sensor/adc_sensor_hal.c +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sensors/src/adc_sensor/adc_sensor_hal.c @@ -30,6 +30,7 @@ #include #include +#include #include "rsi_debug.h" #include "sensor_hub.h" #include "sensor_type.h" @@ -44,7 +45,13 @@ uint16_t adc_data_ram_ch0[SL_SH_ADC_SENSOR0_NUM_OF_SAMPLES * SL_SH_ADC_CH0_NUM_SAMPLES] __attribute__((aligned(2))); #endif #ifdef SL_SH_ADC_CHANNEL1 -uint16_t adc_data_ram_ch1[SL_SH_ADC_CH1_NUM_SAMPLES] __attribute__((aligned(2))); +uint16_t adc_data_ram_ch1[SL_SH_ADC_SENSOR2_NUM_OF_SAMPLES * SL_SH_ADC_CH1_NUM_SAMPLES] __attribute__((aligned(2))); +#endif +#ifdef SL_SH_ADC_CHANNEL2 +uint16_t adc_data_ram_ch2[SL_SH_ADC_SENSOR2_NUM_OF_SAMPLES * SL_SH_ADC_CH2_NUM_SAMPLES] __attribute__((aligned(2))); +#endif +#ifdef SL_SH_ADC_CHANNEL3 +uint16_t adc_data_ram_ch3[SL_SH_ADC_SENSOR2_NUM_OF_SAMPLES * SL_SH_ADC_CH3_NUM_SAMPLES] __attribute__((aligned(2))); #endif #ifdef SL_SH_ADC_CHANNEL0 @@ -53,6 +60,12 @@ uint16_t *adc_data_ptrs[] = { #ifdef SL_SH_ADC_CHANNEL1 adc_data_ram_ch1, #endif +#ifdef SL_SH_ADC_CHANNEL2 + adc_data_ram_ch2, +#endif +#ifdef SL_SH_ADC_CHANNEL3 + adc_data_ram_ch3, +#endif }; #endif @@ -62,54 +75,6 @@ uint16_t *adc_data_ptrs[] = { static bool is_channel_init = false; static sl_adc_cfg_t *adc_config; -sl_adc_error_t sl_si91x_guva_s12d_sample(uint8_t channel, bool is_static, uint16_t *adc_value); -sl_adc_error_t sl_si91x_joystick_sample(uint8_t channel, bool is_static, uint16_t *adc_value); - -sl_adc_sensor_data_t adc_sensor_info[] = { - { .channel = SL_SH_ADC_CH0_CHANNEL, .sample = sl_si91x_guva_s12d_sample, .sleep = NULL, .wakeup = NULL }, - - { .channel = SL_SH_ADC_CH0_CHANNEL, .sample = sl_si91x_joystick_sample, .sleep = NULL, .wakeup = NULL } -}; - -sl_adc_error_t sl_si91x_guva_s12d_sample(uint8_t channel, bool is_static, uint16_t *adc_value) -{ - if (is_static) { - sl_si91x_adc_sensor_sample_static(adc_value); - } else { - sl_si91x_sensor_channel_sample(channel); - } - return SL_STATUS_OK; -} - -sl_adc_error_t sl_si91x_joystick_sample(uint8_t channel, bool is_static, uint16_t *adc_value) -{ - if (is_static) { - sl_si91x_adc_sensor_sample_static(adc_value); - } else { - sl_si91x_sensor_channel_sample(channel); - } - return SL_STATUS_OK; -} - -/******************************************************************************* - * @fn static const adc_sensor_impl_t *get_implementation(int channel) - * @brief ADC get sensor implementation - * - * @return pointer to adc sensor implementation -*******************************************************************************/ - -static sl_adc_sensor_data_t *get_implementation(uint8_t channel) -{ - uint8_t i; - uint8_t size = sizeof(adc_sensor_info) / sizeof(sl_adc_sensor_data_t); - for (i = 0; i < size; i++) { - if (adc_sensor_info[i].channel == channel) { - return &adc_sensor_info[i]; - } - } - return NULL; -} - /******************************************************************************* * @fn static sl_status_t adc_stop(sl_adc_config_t *adc_cfg) * @brief ADC stop @@ -142,8 +107,10 @@ static sl_status_t adc_stop(sl_adc_config_t *adc_cfg) sl_sensor_adc_handle_t sl_si91x_adc_sensor_create(UNUSED_PARAM sl_sensor_bus_t bus, int channel) { if (!is_channel_init) { + /* All other adc sensor handles will be called only after sensor_create, so we are storing the pointer to adc bus interface info here */ adc_config = sl_si91x_fetch_adc_bus_intf_info(); } + sl_adc_sensor_data_t *p_sensor = (sl_adc_sensor_data_t *)pvPortMalloc(sizeof(sl_adc_sensor_data_t)); if (p_sensor == NULL) { DEBUGOUT("\r\n ADC sensor create failed while memory allocation:%u \r\n", sizeof(sl_adc_sensor_data_t)); @@ -151,9 +118,6 @@ sl_sensor_adc_handle_t sl_si91x_adc_sensor_create(UNUSED_PARAM sl_sensor_bus_t b } p_sensor->channel = (uint8_t)channel; - p_sensor = get_implementation(p_sensor->channel); - /* All other adc sensor handles will be called only after sensor_create, so we are storing the pointer to adc bus interface info here */ - if (!is_channel_init) { sl_status_t ret = sl_si91x_adc_channel_init(&adc_config->adc_ch_cfg, &adc_config->adc_cfg); if (ret != SL_STATUS_OK) { @@ -162,7 +126,22 @@ sl_sensor_adc_handle_t sl_si91x_adc_sensor_create(UNUSED_PARAM sl_sensor_bus_t b } is_channel_init = true; } - DEBUGOUT("\r\n ADC - sensor created, channels %d\r\n", channel); + if (IS_MULTI_CHANNEL(channel)) { + DEBUGOUT("\r\n ADC - sensor created \r\n"); + for (uint8_t ch_no = 0; ch_no < MAX_CHNL_NO; ch_no++) { + if (BIT(ch_no) & channel) { + DEBUGOUT(" channel %d\r\n", ch_no); + } + channel &= ~(BIT(ch_no)); + if (channel == 0) { // Printed all the channels + break; + } + } + } else { + // Channel is set as BIT(channel_number) as per design, so to get the actual channel number use log2 + uint8_t actual_channel = log2(channel); + DEBUGOUT("\r\n ADC - sensor created, channel %d\r\n", actual_channel); + } p_sensor->is_init = true; return (sl_sensor_adc_handle_t)p_sensor; @@ -264,7 +243,7 @@ sl_adc_error_t sl_si91x_adc_sensor_delete(sl_sensor_adc_handle_t *sensor) } free(p_sensor); - *sensor = NULL; + sensor = NULL; return SL_STATUS_OK; } @@ -376,6 +355,23 @@ sl_adc_error_t sl_si91x_sensor_channel_sample(uint8_t channel) return SL_STATUS_OK; } +void update_adc_sensor_multi_channel_data(sl_sensor_data_group_t *data_group, uint8_t ch_no) +{ +#ifdef GY61_ADC_SENSOR + if (ch_no == GY61_ADC_SENSOR_CHANNELS) { +#ifdef GY61_X_AXIS_ADC_CHANNEL + data_group->sensor_data[0].gy61.x = adc_data_ptrs[GY61_X_AXIS_ADC_CHANNEL]; +#endif +#ifdef GY61_Y_AXIS_ADC_CHANNEL + data_group->sensor_data[0].gy61.y = adc_data_ptrs[GY61_Y_AXIS_ADC_CHANNEL]; +#endif +#ifdef GY61_Z_AXIS_ADC_CHANNEL + data_group->sensor_data[0].gy61.z = adc_data_ptrs[GY61_Z_AXIS_ADC_CHANNEL]; +#endif + } +#endif +} + /******************************************************************************* * @fn sl_status_t sl_si91x_adc_sensor_sample(sl_sensor_adc_handle_t *sensor, sl_sensor_data_group_t *data_group) * @brief ADC sensor sample @@ -392,45 +388,55 @@ sl_adc_error_t sl_si91x_adc_sensor_sample(sl_sensor_adc_handle_t sensor, sl_sens sl_adc_sensor_data_t *p_sensor = (sl_adc_sensor_data_t *)(sensor); sl_status_t ret = 0; uint8_t ch_no = p_sensor->channel; - bool is_static = false; if (p_sensor == NULL) { return SL_STATUS_NULL_POINTER; } else if (p_sensor->is_init == false) { return SL_STATUS_NOT_INITIALIZED; - } else if (adc_config->adc_cfg.operation_mode == SL_ADC_FIFO_MODE) { - if ((adc_config->adc_data_ready & BIT(ch_no)) != 1) { - return SL_STATUS_NOT_READY; - } } if (adc_config->adc_cfg.operation_mode == SL_ADC_STATIC_MODE) { - is_static = true; - ret = p_sensor->sample(p_sensor->channel, is_static, (uint16_t *)&adc_data_ptrs[0][data_group->number]); + ret = sl_si91x_adc_sensor_sample_static((uint16_t *)&adc_data_ptrs[0][data_group->number]); data_group->sensor_data[0].adc = (uint16_t *)adc_data_ptrs[0]; if (SL_STATUS_OK != ret) { return ret; } data_group->number++; - } else { - if (adc_config->adc_data_ready & BIT(ch_no)) { - adc_config->adc_data_ready &= ~(BIT(ch_no)); - if (p_sensor->sample != NULL) { - p_sensor->sample(ch_no, is_static, NULL); - for (uint16_t sample_length = 0; sample_length < adc_config->adc_ch_cfg.num_of_samples[ch_no]; + } else if (IS_MULTI_CHANNEL(ch_no)) { + update_adc_sensor_multi_channel_data(data_group, ch_no); + for (uint8_t channel = 0; channel < MAX_CHNL_NO; channel++) { + if (BIT(channel) & ch_no) { + sl_si91x_sensor_channel_sample(channel); + for (uint16_t sample_length = 0; sample_length < adc_config->adc_ch_cfg.num_of_samples[channel]; sample_length++) { - if (adc_config->adc_ch_cfg.rx_buf[ch_no][sample_length] & BIT(11)) { - adc_config->adc_ch_cfg.rx_buf[ch_no][sample_length] = - (adc_config->adc_ch_cfg.rx_buf[ch_no][sample_length] & (ADC_MASK_VALUE)); + if (adc_config->adc_ch_cfg.rx_buf[channel][sample_length] & BIT(11)) { + adc_config->adc_ch_cfg.rx_buf[channel][sample_length] = + (adc_config->adc_ch_cfg.rx_buf[channel][sample_length] & (ADC_MASK_VALUE)); } else { - adc_config->adc_ch_cfg.rx_buf[ch_no][sample_length] = adc_config->adc_ch_cfg.rx_buf[ch_no][sample_length] - | BIT(11); + adc_config->adc_ch_cfg.rx_buf[channel][sample_length] = + adc_config->adc_ch_cfg.rx_buf[channel][sample_length] | BIT(11); } } - data_group->sensor_data[0].adc = (uint16_t *)adc_config->adc_ch_cfg.rx_buf[ch_no]; - data_group->number = adc_config->adc_ch_cfg.num_of_samples[ch_no]; + ch_no &= ~(BIT(channel)); + } + if (ch_no == 0) { // sampled all the channels + break; + } + } + } else { + // Channel is set as BIT(channel_number) as per design, so to get the actual channel number check which bit is set + uint8_t channel = log2(ch_no); + sl_si91x_sensor_channel_sample(channel); + for (uint16_t sample_length = 0; sample_length < adc_config->adc_ch_cfg.num_of_samples[channel]; sample_length++) { + if (adc_config->adc_ch_cfg.rx_buf[channel][sample_length] & BIT(11)) { + adc_config->adc_ch_cfg.rx_buf[channel][sample_length] = + (adc_config->adc_ch_cfg.rx_buf[channel][sample_length] & (ADC_MASK_VALUE)); + } else { + adc_config->adc_ch_cfg.rx_buf[channel][sample_length] = adc_config->adc_ch_cfg.rx_buf[channel][sample_length] + | BIT(11); } } + data_group->sensor_data[0].adc = adc_data_ptrs[channel]; } return SL_STATUS_OK; diff --git a/examples/si91x_soc/service/sl_si91x_sensorhub/sl_si91x_sensorhub.slcp b/examples/si91x_soc/service/sl_si91x_sensorhub/sl_si91x_sensorhub.slcp index 9410c980..1b0b2db8 100644 --- a/examples/si91x_soc/service/sl_si91x_sensorhub/sl_si91x_sensorhub.slcp +++ b/examples/si91x_soc/service/sl_si91x_sensorhub/sl_si91x_sensorhub.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: sensorhub_config.c - path: sensors/src/hub_hal_intf.c @@ -75,6 +75,8 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk + - id: sl_si91x_asynchronous_socket + from: wiseconnect3_sdk requires: - name: ulp_mode_execution define: diff --git a/examples/si91x_soc/service/sl_si91x_sleeptimer/sl_si91x_sleeptimer.slcp b/examples/si91x_soc/service/sl_si91x_sleeptimer/sl_si91x_sleeptimer.slcp index 1db74d86..5ab41d07 100644 --- a/examples/si91x_soc/service/sl_si91x_sleeptimer/sl_si91x_sleeptimer.slcp +++ b/examples/si91x_soc/service/sl_si91x_sleeptimer/sl_si91x_sleeptimer.slcp @@ -10,7 +10,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/sl_si91x_empty_c/sl_si91x_empty_c.slcp b/examples/si91x_soc/sl_si91x_empty_c/sl_si91x_empty_c.slcp index df1e82cb..7cc61b85 100644 --- a/examples/si91x_soc/sl_si91x_empty_c/sl_si91x_empty_c.slcp +++ b/examples/si91x_soc/sl_si91x_empty_c/sl_si91x_empty_c.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/sl_si91x_empty_cpp/sl_si91x_empty_cpp.slcp b/examples/si91x_soc/sl_si91x_empty_cpp/sl_si91x_empty_cpp.slcp index a9761649..b9d8d48c 100644 --- a/examples/si91x_soc/sl_si91x_empty_cpp/sl_si91x_empty_cpp.slcp +++ b/examples/si91x_soc/sl_si91x_empty_cpp/sl_si91x_empty_cpp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.cpp - path: main.cpp diff --git a/examples/si91x_soc/wlan/m4_firmware_update/m4_firmware_update.slcp b/examples/si91x_soc/wlan/m4_firmware_update/m4_firmware_update.slcp index 87c802d4..8e94ab6c 100644 --- a/examples/si91x_soc/wlan/m4_firmware_update/m4_firmware_update.slcp +++ b/examples/si91x_soc/wlan/m4_firmware_update/m4_firmware_update.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_ncp.slcp b/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_ncp.slcp index e8b6464c..be98632b 100644 --- a/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_ncp.slcp +++ b/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_soc.slcp b/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_soc.slcp index e65daa66..0da0bbc4 100644 --- a/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_soc.slcp +++ b/examples/si91x_soc/wlan/tcp_tx_on_periodic_wakeup/tcp_tx_on_periodic_wakeup_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c diff --git a/examples/snippets/ble/ble_accept_list/app.c b/examples/snippets/ble/ble_accept_list/app.c index a6a6bf01..58caf464 100644 --- a/examples/snippets/ble/ble_accept_list/app.c +++ b/examples/snippets/ble/ble_accept_list/app.c @@ -96,7 +96,7 @@ static volatile uint32_t ble_app_event_map1; //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif static const sl_wifi_device_configuration_t config = { .boot_option = LOAD_NWP_FW, @@ -116,11 +116,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = diff --git a/examples/snippets/ble/ble_accept_list/ble_accept_list_ncp.slcp b/examples/snippets/ble/ble_accept_list/ble_accept_list_ncp.slcp index a53dcd2b..c138b0a9 100644 --- a/examples/snippets/ble/ble_accept_list/ble_accept_list_ncp.slcp +++ b/examples/snippets/ble/ble_accept_list/ble_accept_list_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,6 +53,9 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror + configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_accept_list/ble_accept_list_soc.slcp b/examples/snippets/ble/ble_accept_list/ble_accept_list_soc.slcp index 4c55c08f..948dafa5 100644 --- a/examples/snippets/ble/ble_accept_list/ble_accept_list_soc.slcp +++ b/examples/snippets/ble/ble_accept_list/ble_accept_list_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -57,7 +57,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_ae_central/app.c b/examples/snippets/ble/ble_ae_central/app.c index 92952f07..f42dab12 100644 --- a/examples/snippets/ble/ble_ae_central/app.c +++ b/examples/snippets/ble/ble_ae_central/app.c @@ -72,7 +72,7 @@ //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif #if defined(SL_SI91X_PRINT_DBG_LOG) @@ -129,11 +129,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = @@ -420,6 +416,7 @@ void rsi_ble_simple_central_on_conn_status_event(rsi_ble_event_conn_status_t *re */ void rsi_ble_simple_central_on_disconnect_event(rsi_ble_event_disconnect_t *resp_disconnect, uint16_t reason) { + UNUSED_PARAMETER(reason); memcpy(&rsi_app_disconnected_device, resp_disconnect, sizeof(rsi_ble_event_disconnect_t)); rsi_ble_app_set_event(RSI_APP_EVENT_DISCONNECTED); @@ -497,7 +494,6 @@ void ble_ae_central(void) int32_t status = 0; int32_t temp_event_map = 0; int32_t temp_event_map1 = 0; - int32_t size = 0; sl_wifi_firmware_version_t version = { 0 }; status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler); @@ -658,7 +654,7 @@ void ble_ae_central(void) #endif rsi_ble_ae_dev_to_periodic_list_t ae_clear_dev = { 0 }; // AE Clear Periodic Adv list - rsi_ascii_dev_address_to_6bytes_rev((uint8_t *)REM_ADDR1, (int8_t *)ae_clear_dev.adv_addr); + rsi_ascii_dev_address_to_6bytes_rev((uint8_t *)ae_clear_dev.adv_addr, (int8_t *)REM_ADDR1); ae_clear_dev.adv_addr_type = LE_RANDOM_ADDRESS; ae_clear_dev.adv_sid = 1; ae_clear_dev.type = BLE_AE_CLEAR_PER_LIST; diff --git a/examples/snippets/ble/ble_ae_central/ble_ae_central_ncp.slcp b/examples/snippets/ble/ble_ae_central/ble_ae_central_ncp.slcp index 7208c426..24841afe 100644 --- a/examples/snippets/ble/ble_ae_central/ble_ae_central_ncp.slcp +++ b/examples/snippets/ble/ble_ae_central/ble_ae_central_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_ae_central/ble_ae_central_soc.slcp b/examples/snippets/ble/ble_ae_central/ble_ae_central_soc.slcp index 7758e948..d03eb30c 100644 --- a/examples/snippets/ble/ble_ae_central/ble_ae_central_soc.slcp +++ b/examples/snippets/ble/ble_ae_central/ble_ae_central_soc.slcp @@ -12,7 +12,7 @@ filter: value: ["Advanced"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -44,7 +44,9 @@ component: from: wiseconnect3_sdk - id: ble from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} readme: diff --git a/examples/snippets/ble/ble_ae_peripheral/app.c b/examples/snippets/ble/ble_ae_peripheral/app.c index 90136c00..debcadc9 100644 --- a/examples/snippets/ble/ble_ae_peripheral/app.c +++ b/examples/snippets/ble/ble_ae_peripheral/app.c @@ -83,7 +83,7 @@ uint8_t ble_acceptlist_addr1[BLE_ACCEPT_LIST_ADDR_LEN] = { 0xDA, 0x81, 0xE0, 0xB #define PSP_MODE RSI_SLEEP_MODE_2 //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! Application global parameters. @@ -132,11 +132,7 @@ static const sl_wifi_device_configuration_t #else .ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENTION_VALID, #endif - .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL) -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL)), /*Enable BLE custom feature bitmap*/ .ble_feature_bit_map = (SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) diff --git a/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_ncp.slcp b/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_ncp.slcp index 6fbb0792..a9381c97 100644 --- a/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_ncp.slcp +++ b/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_soc.slcp b/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_soc.slcp index 07b41010..60b642ec 100644 --- a/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_soc.slcp +++ b/examples/snippets/ble/ble_ae_peripheral/ble_ae_peripheral_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: ble from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_central/app.c b/examples/snippets/ble/ble_central/app.c index e6d8e233..0fb562fd 100644 --- a/examples/snippets/ble/ble_central/app.c +++ b/examples/snippets/ble/ble_central/app.c @@ -75,7 +75,7 @@ uint8_t adv_payload_for_compare[31] = { 0x6E, 0xC5, 0xFD, 0x05, 0x54, 0x9E, 0x68 //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! Application supported events list @@ -105,11 +105,12 @@ static const sl_wifi_device_configuration_t config = { .mac_address = NULL, .band = SL_SI91X_WIFI_BAND_2_4GHZ, .region_code = US, - .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, - .coex_mode = SL_SI91X_WLAN_BLE_MODE, - .feature_bit_map = (SL_SI91X_FEAT_WPS_DISABLE | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_BLE_MODE, + .feature_bit_map = (SL_SI91X_FEAT_WPS_DISABLE | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE | SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1), - .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT), + .tcp_ip_feature_bit_map = + (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID), .ext_custom_feature_bit_map = (SL_SI91X_EXT_FEAT_LOW_POWER_MODE | SL_SI91X_EXT_FEAT_XTAL_CLK | MEMORY_CONFIG @@ -118,12 +119,8 @@ static const sl_wifi_device_configuration_t config = { #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE // Enable BT feature ), - .ext_tcp_ip_feature_bit_map = (0), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), /*Enable BLE custom feature bitmap*/ .ble_feature_bit_map = (SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) diff --git a/examples/snippets/ble/ble_central/ble_central_ncp.slcp b/examples/snippets/ble/ble_central/ble_central_ncp.slcp index c68c94d6..26802b90 100644 --- a/examples/snippets/ble/ble_central/ble_central_ncp.slcp +++ b/examples/snippets/ble/ble_central/ble_central_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_central/ble_central_soc.slcp b/examples/snippets/ble/ble_central/ble_central_soc.slcp index d1c5431f..649bd5c9 100644 --- a/examples/snippets/ble/ble_central/ble_central_soc.slcp +++ b/examples/snippets/ble/ble_central/ble_central_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -56,7 +56,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_datalength/app.c b/examples/snippets/ble/ble_datalength/app.c index ca5711ca..bac95eb6 100644 --- a/examples/snippets/ble/ble_datalength/app.c +++ b/examples/snippets/ble/ble_datalength/app.c @@ -70,7 +70,7 @@ //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! Application global parameters. @@ -107,11 +107,7 @@ static const sl_wifi_device_configuration_t config = { #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), - .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL) -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL)), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = ((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) diff --git a/examples/snippets/ble/ble_datalength/ble_datalength_ncp.slcp b/examples/snippets/ble/ble_datalength/ble_datalength_ncp.slcp index 6cd7292e..f06b83e1 100644 --- a/examples/snippets/ble/ble_datalength/ble_datalength_ncp.slcp +++ b/examples/snippets/ble/ble_datalength/ble_datalength_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,6 +53,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_datalength/ble_datalength_soc.slcp b/examples/snippets/ble/ble_datalength/ble_datalength_soc.slcp index 189deefa..5d890a24 100644 --- a/examples/snippets/ble/ble_datalength/ble_datalength_soc.slcp +++ b/examples/snippets/ble/ble_datalength/ble_datalength_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -57,7 +57,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_heart_rate_profile/app.c b/examples/snippets/ble/ble_heart_rate_profile/app.c index cc2f05e3..555aefeb 100644 --- a/examples/snippets/ble/ble_heart_rate_profile/app.c +++ b/examples/snippets/ble/ble_heart_rate_profile/app.c @@ -159,7 +159,7 @@ uint8_t heartratefun(heart_rate_t, uint8_t *); //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! global parameters list @@ -206,11 +206,7 @@ static const sl_wifi_device_configuration_t #endif | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE)), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), - .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL) -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL)), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = ((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) diff --git a/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_ncp.slcp b/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_ncp.slcp index 619928ab..049d7f65 100644 --- a/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_ncp.slcp +++ b/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_psram.slcp b/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_psram.slcp index 5b29207e..04b028d5 100644 --- a/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_psram.slcp +++ b/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_psram.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -74,7 +74,9 @@ component: from: wiseconnect3_sdk - id: text_segment_in_psram from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_soc.slcp b/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_soc.slcp index 1b8b8248..b8bc8acd 100644 --- a/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_soc.slcp +++ b/examples/snippets/ble/ble_heart_rate_profile/ble_heart_rate_profile_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -65,7 +65,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_hid_on_gatt/app.c b/examples/snippets/ble/ble_hid_on_gatt/app.c index 39a46f54..f2352c42 100644 --- a/examples/snippets/ble/ble_hid_on_gatt/app.c +++ b/examples/snippets/ble/ble_hid_on_gatt/app.c @@ -116,7 +116,7 @@ //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif #define MITM_REQ 0x01 @@ -166,6 +166,9 @@ sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 #define ADVERTISE 3 #define SCAN 4 +#define MIN_CONN_INTERVAL 36 +#define MAX_CONN_INTERVAL 36 +#define SLAVE_LATENCY 0 //! global parameters list static volatile uint32_t ble_app_event_map; static volatile uint32_t ble_app_event_map1; @@ -216,7 +219,7 @@ typedef struct rsi_ble_hid_info_s { } rsi_ble_hid_info_t; static rsi_ble_hid_info_t hid_info_g; - +void rsi_ble_hid_srv_gatt_wr_cb(void); #if (GATT_ROLE == SERVER) static const uint8_t hid_report_map[] = { 0x05, @@ -316,11 +319,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE)), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = @@ -552,6 +551,9 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t UNUSED_PARAMETER(event_id); //This statement is added only to resolve compilation warning, value is unchanged LOG_PRINT("gatt wr \n"); memcpy(&app_ble_write_event, rsi_ble_write, sizeof(rsi_ble_event_write_t)); +#if (GATT_ROLE == SERVER) + rsi_ble_hid_srv_gatt_wr_cb(); +#endif rsi_ble_app_set_event(RSI_BLE_EVENT_GATT_WR); } @@ -1262,7 +1264,7 @@ static uint32_t rsi_ble_add_hid_serv(rsi_ble_hid_info_t *p_hid_info) * @section description * handles server side write events and set respective flags. */ -static void rsi_ble_hid_srv_gatt_wr_cb(void) +void rsi_ble_hid_srv_gatt_wr_cb(void) { LOG_PRINT("wr handle\n"); LOG_PRINT("report handle is:%d\n", rsi_ble_hid_in_report_val_hndl); @@ -1279,8 +1281,6 @@ static void rsi_ble_hid_srv_gatt_wr_cb(void) rsi_ble_app_clear_event(RSI_BLE_GATT_SEND_DATA); } LOG_PRINT("Input report notify val: %lu\n", app_state & BIT(REPORT_IN_NOTIFY_ENABLE)); - - rsi_ble_conn_params_update(temp_le_ltk_req.dev_addr, 36, 36, 0, 300); } } #endif @@ -1494,7 +1494,7 @@ void ble_hids_gatt_application(rsi_ble_hid_info_t *p_hid_info) if (event_id == -1) { #if SLI_SI91X_MCU_INTERFACE && ENABLE_POWER_SAVE //! if events are not received loop will be continued. - if ((!(P2P_STATUS_REG & TA_wakeup_M4))) { + if ((!(P2P_STATUS_REG & TA_wakeup_M4)) && (ble_app_event_map == 0) && (ble_app_event_map1 == 0)) { P2P_STATUS_REG &= ~M4_wakeup_TA; sl_si91x_m4_sleep_wakeup(); } @@ -1613,10 +1613,6 @@ void ble_hids_gatt_application(rsi_ble_hid_info_t *p_hid_info) #endif //! clear the served event rsi_ble_app_clear_event(RSI_BLE_EVENT_GATT_WR); - -#if (GATT_ROLE == SERVER) - rsi_ble_hid_srv_gatt_wr_cb(); -#endif } break; case RSI_BLE_EVENT_GATT_RD: { @@ -1892,6 +1888,15 @@ void ble_hids_gatt_application(rsi_ble_hid_info_t *p_hid_info) case RSI_BLE_GATT_SEND_DATA: //! clear the served event + status = rsi_ble_conn_params_update(conn_event_to_app.dev_addr, + MIN_CONN_INTERVAL, + MAX_CONN_INTERVAL, + SLAVE_LATENCY, + SUPERVISION_TIMEOUT); + if (status != SL_STATUS_OK) { + LOG_PRINT("\r\nrsi_ble_conn_params_update Failed, Error Code : 0x%lX\r\n", status); + return; + } if (app_state & BIT(CONNECTED)) { if (app_state & BIT(REPORT_IN_NOTIFY_ENABLE)) { hid_data[2] = 0xb; // key 'h' pressed diff --git a/examples/snippets/ble/ble_hid_on_gatt/ble_config.h b/examples/snippets/ble/ble_hid_on_gatt/ble_config.h index 342f6455..9cf2f5cb 100644 --- a/examples/snippets/ble/ble_hid_on_gatt/ble_config.h +++ b/examples/snippets/ble/ble_hid_on_gatt/ble_config.h @@ -168,8 +168,10 @@ #define CONNECTION_INTERVAL_MIN 0x00A0 #define CONNECTION_INTERVAL_MAX 0x00A0 -#define CONNECTION_LATENCY 0x0000 -#define SUPERVISION_TIMEOUT 0x07D0 //2000 +#define CONNECTION_LATENCY 0x0000 +#ifndef SUPERVISION_TIMEOUT +#define SUPERVISION_TIMEOUT 300 //2000 +#endif /*=======================================================================*/ diff --git a/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_ncp.slcp b/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_ncp.slcp index 56b0a04e..93aa0cd6 100644 --- a/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_ncp.slcp +++ b/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -54,11 +54,15 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' - name: configTOTAL_HEAP_SIZE value: '51200' +- name: configUSE_POSIX_ERRNO + value: '1' readme: - path: readme.md other_file: diff --git a/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_soc.slcp b/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_soc.slcp index 994967d6..4acdfa32 100644 --- a/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_soc.slcp +++ b/examples/snippets/ble/ble_hid_on_gatt/ble_hid_on_gatt_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -57,7 +57,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_ibeacon/app.c b/examples/snippets/ble/ble_ibeacon/app.c index 87a12aa3..f13d3214 100644 --- a/examples/snippets/ble/ble_ibeacon/app.c +++ b/examples/snippets/ble/ble_ibeacon/app.c @@ -68,7 +68,7 @@ static volatile uint32_t ble_app_event_map1; //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif static const sl_wifi_device_configuration_t config = { @@ -89,11 +89,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = diff --git a/examples/snippets/ble/ble_ibeacon/ble_ibeacon_ncp.slcp b/examples/snippets/ble/ble_ibeacon/ble_ibeacon_ncp.slcp index f9e633b1..0357d6cb 100644 --- a/examples/snippets/ble/ble_ibeacon/ble_ibeacon_ncp.slcp +++ b/examples/snippets/ble/ble_ibeacon/ble_ibeacon_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_ibeacon/ble_ibeacon_soc.slcp b/examples/snippets/ble/ble_ibeacon/ble_ibeacon_soc.slcp index 49bba1cb..a6ba5985 100644 --- a/examples/snippets/ble/ble_ibeacon/ble_ibeacon_soc.slcp +++ b/examples/snippets/ble/ble_ibeacon/ble_ibeacon_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -56,7 +56,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_longrange_2mbps/app.c b/examples/snippets/ble/ble_longrange_2mbps/app.c index 4e3f0725..9d558004 100644 --- a/examples/snippets/ble/ble_longrange_2mbps/app.c +++ b/examples/snippets/ble/ble_longrange_2mbps/app.c @@ -68,7 +68,7 @@ #define PSP_MODE RSI_SLEEP_MODE_2 //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! Application global parameters. @@ -103,11 +103,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = @@ -430,7 +426,7 @@ void ble_central(void *argument) //! initiating power save in wlan mode status = sl_wifi_set_performance_profile(&wifi_profile); if (status != SL_STATUS_OK) { - LOG_PRINT("\r\n Failed to initiate power save in Wi-Fi mode :%d\r\n", status); + LOG_PRINT("\r\n Failed to initiate power save in Wi-Fi mode :%ld\r\n", status); return; } diff --git a/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_ncp.slcp b/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_ncp.slcp index c99b75da..cbd3b60c 100644 --- a/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_ncp.slcp +++ b/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,6 +53,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_soc.slcp b/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_soc.slcp index cc488c96..c52f3ed2 100644 --- a/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_soc.slcp +++ b/examples/snippets/ble/ble_longrange_2mbps/ble_longrange_2mbps_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -57,7 +57,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_multiconnection_gatt_test/app.c b/examples/snippets/ble/ble_multiconnection_gatt_test/app.c index d8f8d5ec..cb186ec2 100644 --- a/examples/snippets/ble/ble_multiconnection_gatt_test/app.c +++ b/examples/snippets/ble/ble_multiconnection_gatt_test/app.c @@ -54,7 +54,7 @@ extern volatile uint32_t ble_app_event_task_map[TOTAL_CONNECTIONS]; extern volatile uint32_t ble_app_event_task_map1[TOTAL_CONNECTIONS]; extern volatile uint32_t ble_temp_event_map[TOTAL_CONNECTIONS]; -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif /*=======================================================================*/ @@ -83,11 +83,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = diff --git a/examples/snippets/ble/ble_multiconnection_gatt_test/ble_device_info.h b/examples/snippets/ble/ble_multiconnection_gatt_test/ble_device_info.h index 5de5be08..ea09acda 100644 --- a/examples/snippets/ble/ble_multiconnection_gatt_test/ble_device_info.h +++ b/examples/snippets/ble/ble_multiconnection_gatt_test/ble_device_info.h @@ -140,10 +140,10 @@ typedef struct rsi_ble_dev_ltk_list_s { } rsi_ble_dev_ltk_list_t; #endif -uint8_t rsi_get_ble_conn_id(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN], uint8_t *remote_name, uint8_t size); -uint8_t rsi_add_ble_conn_id(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN], uint8_t *remote_name, uint8_t size); -uint8_t rsi_get_remote_device_role(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN]); -uint8_t rsi_remove_ble_conn_id(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN]); +uint8_t rsi_get_ble_conn_id(uint8_t *remote_dev_addr, uint8_t *remote_name, uint8_t size); +uint8_t rsi_add_ble_conn_id(uint8_t *remote_dev_addr, uint8_t *remote_name, uint8_t size); +uint8_t rsi_get_remote_device_role(uint8_t *remote_dev_addr); +uint8_t rsi_remove_ble_conn_id(uint8_t *remote_dev_addr); uint8_t rsi_check_ble_conn_status(uint8_t connection_id); #endif diff --git a/examples/snippets/ble/ble_multiconnection_gatt_test/ble_main_task.c b/examples/snippets/ble/ble_multiconnection_gatt_test/ble_main_task.c index 3599d442..d4d87aa3 100644 --- a/examples/snippets/ble/ble_multiconnection_gatt_test/ble_main_task.c +++ b/examples/snippets/ble/ble_multiconnection_gatt_test/ble_main_task.c @@ -2105,7 +2105,7 @@ void rsi_ble_main_app_task() status = rsi_initiate_power_awake(); if (status != RSI_SUCCESS) { LOG_PRINT("\r\n Failed to keep Module in ACTIVE mode \r\n"); - return status; + return; } } #endif diff --git a/examples/snippets/ble/ble_multiconnection_gatt_test/ble_multiconnection_gatt_test.slcp b/examples/snippets/ble/ble_multiconnection_gatt_test/ble_multiconnection_gatt_test.slcp index d70db81d..6611cdc6 100644 --- a/examples/snippets/ble/ble_multiconnection_gatt_test/ble_multiconnection_gatt_test.slcp +++ b/examples/snippets/ble/ble_multiconnection_gatt_test/ble_multiconnection_gatt_test.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: ble_device_info.c - path: ble_main_task.c @@ -61,7 +61,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_power_save/app.c b/examples/snippets/ble/ble_power_save/app.c index 34c9c0c0..553c69ce 100644 --- a/examples/snippets/ble/ble_power_save/app.c +++ b/examples/snippets/ble/ble_power_save/app.c @@ -53,7 +53,7 @@ //! Application powersave configurations /*=======================================================================*/ #if ENABLE_POWER_SAVE -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #ifdef SLI_SI91X_MCU_INTERFACE void fpuInit(void); @@ -68,6 +68,7 @@ int32_t rsi_initiate_power_save(void); uint8_t wlan_radio_initialized = 0, powersave_cmd_given = 0; uint8_t device_found = false; uint8_t remote_dev_addr[18] = { 0 }; +uint8_t local_dev_addr[18] = { 0 }; uint8_t remote_dev_bd_addr[6] = { 0 }; static uint8_t remote_name[31]; static uint8_t remote_addr_type = 0; @@ -99,11 +100,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE)), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = @@ -443,11 +440,8 @@ void ble_app_task(void *argument) LOG_PRINT("\r\n ble get local device address cmd failed with reason code : %lX \n", status); return; } - LOG_PRINT("\n Get local device address: %x:%x:%x:%x\n", - rsi_app_resp_get_dev_addr[3], - rsi_app_resp_get_dev_addr[2], - rsi_app_resp_get_dev_addr[1], - rsi_app_resp_get_dev_addr[0]); + rsi_6byte_dev_address_to_ascii(local_dev_addr, (uint8_t *)rsi_app_resp_get_dev_addr); + LOG_PRINT("\n Get local device address: %s \n", local_dev_addr); //! set the local device name status = rsi_bt_set_local_name((uint8_t *)RSI_BLE_LOCAL_NAME); @@ -455,6 +449,7 @@ void ble_app_task(void *argument) LOG_PRINT("\r\n ble set local name cmd failed with reason code : %lX \n", status); return; } + LOG_PRINT("\n Local name set to: %s\n", RSI_BLE_LOCAL_NAME); //! get the local device name status = rsi_bt_get_local_name(&rsi_app_resp_get_local_name); @@ -462,7 +457,7 @@ void ble_app_task(void *argument) LOG_PRINT("\r\n ble get local name cmd failed with reason code : %lX \n", status); return; } - LOG_PRINT("\n Local name set to: %s\n", rsi_app_resp_get_local_name.name); + LOG_PRINT("\n Get local name: %s\n", rsi_app_resp_get_local_name.name); ble_slave_conn_sem = osSemaphoreNew(1, 0, NULL); diff --git a/examples/snippets/ble/ble_power_save/ble_power_save_ncp.slcp b/examples/snippets/ble/ble_power_save/ble_power_save_ncp.slcp index 31ec3b50..010140a8 100644 --- a/examples/snippets/ble/ble_power_save/ble_power_save_ncp.slcp +++ b/examples/snippets/ble/ble_power_save/ble_power_save_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,6 +53,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_power_save/ble_power_save_psram.slcp b/examples/snippets/ble/ble_power_save/ble_power_save_psram.slcp index b38ee8d7..69c865e2 100644 --- a/examples/snippets/ble/ble_power_save/ble_power_save_psram.slcp +++ b/examples/snippets/ble/ble_power_save/ble_power_save_psram.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -75,7 +75,9 @@ component: from: wiseconnect3_sdk - id: text_segment_in_psram from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_power_save/ble_power_save_soc.slcp b/examples/snippets/ble/ble_power_save/ble_power_save_soc.slcp index 8820fa8d..332bcf10 100644 --- a/examples/snippets/ble/ble_power_save/ble_power_save_soc.slcp +++ b/examples/snippets/ble/ble_power_save/ble_power_save_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -66,7 +66,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_privacy/app.c b/examples/snippets/ble/ble_privacy/app.c index 60dde33c..7a11d859 100644 --- a/examples/snippets/ble/ble_privacy/app.c +++ b/examples/snippets/ble/ble_privacy/app.c @@ -119,7 +119,7 @@ //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! user defined structure //LE resolvlist group. @@ -219,11 +219,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = diff --git a/examples/snippets/ble/ble_privacy/ble_privacy_ncp.slcp b/examples/snippets/ble/ble_privacy/ble_privacy_ncp.slcp index 58019b9a..cd427423 100644 --- a/examples/snippets/ble/ble_privacy/ble_privacy_ncp.slcp +++ b/examples/snippets/ble/ble_privacy/ble_privacy_ncp.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -54,6 +54,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_privacy/ble_privacy_soc.slcp b/examples/snippets/ble/ble_privacy/ble_privacy_soc.slcp index 54b37db1..87eb1d62 100644 --- a/examples/snippets/ble/ble_privacy/ble_privacy_soc.slcp +++ b/examples/snippets/ble/ble_privacy/ble_privacy_soc.slcp @@ -19,7 +19,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -58,7 +58,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_secureconnection/app.c b/examples/snippets/ble/ble_secureconnection/app.c index d508d433..d35ef800 100644 --- a/examples/snippets/ble/ble_secureconnection/app.c +++ b/examples/snippets/ble/ble_secureconnection/app.c @@ -86,7 +86,7 @@ //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif //! global parameters list @@ -123,11 +123,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = @@ -566,7 +562,7 @@ void ble_smp_test_app(void *argument) //! initiating power save in wlan mode status = sl_wifi_set_performance_profile(&wifi_profile); if (status != SL_STATUS_OK) { - LOG_PRINT("\r\n Failed to initiate power save in Wi-Fi mode :%d\r\n", status); + LOG_PRINT("\r\n Failed to initiate power save in Wi-Fi mode :%ld\r\n", status); return; } diff --git a/examples/snippets/ble/ble_secureconnection/ble_secureconnection_ncp.slcp b/examples/snippets/ble/ble_secureconnection/ble_secureconnection_ncp.slcp index 67a568f6..28fac184 100644 --- a/examples/snippets/ble/ble_secureconnection/ble_secureconnection_ncp.slcp +++ b/examples/snippets/ble/ble_secureconnection/ble_secureconnection_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -50,7 +50,9 @@ component: from: wiseconnect3_sdk - id: ble from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_secureconnection/ble_secureconnection_soc.slcp b/examples/snippets/ble/ble_secureconnection/ble_secureconnection_soc.slcp index d3281ed0..abeafc8e 100644 --- a/examples/snippets/ble/ble_secureconnection/ble_secureconnection_soc.slcp +++ b/examples/snippets/ble/ble_secureconnection/ble_secureconnection_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -57,7 +57,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_testmodes/app.c b/examples/snippets/ble/ble_testmodes/app.c index 46f58d7b..a5b27d4e 100644 --- a/examples/snippets/ble/ble_testmodes/app.c +++ b/examples/snippets/ble/ble_testmodes/app.c @@ -86,11 +86,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE)), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = diff --git a/examples/snippets/ble/ble_testmodes/ble_testmodes_ncp.slcp b/examples/snippets/ble/ble_testmodes/ble_testmodes_ncp.slcp index 649e4f3f..606ab088 100644 --- a/examples/snippets/ble/ble_testmodes/ble_testmodes_ncp.slcp +++ b/examples/snippets/ble/ble_testmodes/ble_testmodes_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_testmodes/ble_testmodes_soc.slcp b/examples/snippets/ble/ble_testmodes/ble_testmodes_soc.slcp index 6cb698ea..a7aa5c30 100644 --- a/examples/snippets/ble/ble_testmodes/ble_testmodes_soc.slcp +++ b/examples/snippets/ble/ble_testmodes/ble_testmodes_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: ble from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_throughput_app/app.c b/examples/snippets/ble/ble_throughput_app/app.c index d553462c..a0792ac9 100644 --- a/examples/snippets/ble/ble_throughput_app/app.c +++ b/examples/snippets/ble/ble_throughput_app/app.c @@ -56,7 +56,8 @@ #define RSI_BLE_SMP_PASSKEY 0 #define MITM_REQ 0x01 -#define MAX_MTU_SIZE 240 +#define MAX_MTU_SIZE 240 +#define MAX_SEND_DATA_LEN 232 //! application event list #define RSI_BLE_ADV_REPORT_EVENT 0x01 @@ -138,11 +139,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = @@ -634,7 +631,7 @@ static uint32_t rsi_ble_add_simple_chat_serv(void) { uuid_t new_uuid = { 0 }; rsi_ble_resp_add_serv_t new_serv_resp = { 0 }; - uint8_t data[20] = { "silabs_sampletest" }; + uint8_t data[RSI_BLE_MAX_DATA_LEN] = { "silabs_sampletest" }; //! adding new service new_uuid.size = 16; @@ -684,7 +681,7 @@ static uint32_t rsi_ble_add_simple_chat_serv(void) new_uuid, RSI_BLE_ATT_PROPERTY_READ | RSI_BLE_ATT_PROPERTY_NOTIFY, data, - RSI_BLE_MAX_DATA_LEN, + sizeof(data), 0); return 0; } @@ -842,9 +839,9 @@ void ble_throughput_test_app(void *argument) UNUSED_PARAMETER(argument); int32_t status = 0; int32_t event_id; - uint8_t adv[31] = { 2, 1, 6 }; - sl_wifi_firmware_version_t version = { 0 }; - uint8_t send_buf[RSI_BLE_MAX_DATA_LEN] = { + uint8_t adv[31] = { 2, 1, 6 }; + sl_wifi_firmware_version_t version = { 0 }; + uint8_t send_buf[MAX_SEND_DATA_LEN] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 72, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, diff --git a/examples/snippets/ble/ble_throughput_app/ble_throughput_app_ncp.slcp b/examples/snippets/ble/ble_throughput_app/ble_throughput_app_ncp.slcp index 84583e32..81f6193f 100644 --- a/examples/snippets/ble/ble_throughput_app/ble_throughput_app_ncp.slcp +++ b/examples/snippets/ble/ble_throughput_app/ble_throughput_app_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -50,7 +50,9 @@ component: from: wiseconnect3_sdk - id: ble from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_throughput_app/ble_throughput_app_psram.slcp b/examples/snippets/ble/ble_throughput_app/ble_throughput_app_psram.slcp index bcb950b9..5eb19b25 100644 --- a/examples/snippets/ble/ble_throughput_app/ble_throughput_app_psram.slcp +++ b/examples/snippets/ble/ble_throughput_app/ble_throughput_app_psram.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -65,7 +65,9 @@ component: from: wiseconnect3_sdk - id: text_segment_in_psram from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_throughput_app/ble_throughput_app_soc.slcp b/examples/snippets/ble/ble_throughput_app/ble_throughput_app_soc.slcp index f0cd69d5..f91d8dcf 100644 --- a/examples/snippets/ble/ble_throughput_app/ble_throughput_app_soc.slcp +++ b/examples/snippets/ble/ble_throughput_app/ble_throughput_app_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -54,7 +54,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/app.c b/examples/snippets/ble/ble_unified_ae_coex_app/app.c index 8eac7c19..d1c5821b 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/app.c +++ b/examples/snippets/ble/ble_unified_ae_coex_app/app.c @@ -96,7 +96,7 @@ int32_t rsi_ble_dual_role(void); #define PSP_MODE RSI_SLEEP_MODE_2 //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 }, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif static const sl_wifi_device_configuration_t @@ -132,11 +132,7 @@ static const sl_wifi_device_configuration_t #else .ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENTION_VALID, #endif - .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL) -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = ((SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL)), /*Enable BLE custom feature bitmap*/ .ble_feature_bit_map = (SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmd_hdlr_auto_gen.c b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmd_hdlr_auto_gen.c index c5439048..5be74ef2 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmd_hdlr_auto_gen.c +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmd_hdlr_auto_gen.c @@ -1,96 +1,97 @@ #include "ble_cmd_hdlr_auto_gen.h" #include "event_loop.h" #include +#include "rsi_common_apis.h" generic_command_handler_lut_entry_t ble_commands_hdlr_lut[] = { - ble_module_req_adv_cmd_handler, - ble_module_req_scan_cmd_handler, - ble_module_req_conn_cmd_handler, - ble_module_req_adv_stop_cmd_handler, - ble_module_req_scan_stop_cmd_handler, - ble_module_req_disconnect_cmd_handler, - ble_module_get_dev_state_cmd_handler, - ble_module_cmd_conn_params_update_cmd_handler, - ble_module_req_start_encryption_cmd_handler, - ble_module_req_smp_pair_cmd_handler, - ble_module_smp_pair_response_cmd_handler, - ble_module_smp_passkey_cmd_handler, - ble_module_req_profiles_cmd_handler, - ble_module_req_profile_cmd_handler, - ble_module_req_char_services_cmd_handler, - ble_module_req_inc_services_cmd_handler, - ble_module_req_read_by_uuid_cmd_handler, - ble_module_req_desc_cmd_handler, - ble_module_req_read_val_cmd_handler, - ble_module_req_multiple_read_cmd_handler, - ble_module_req_long_read_cmd_handler, - ble_module_req_write_cmd_handler, - ble_module_req_write_no_ack_cmd_handler, - ble_module_req_long_write_cmd_handler, - ble_module_req_prepare_write_cmd_handler, - ble_module_req_execute_write_cmd_handler, - ble_module_add_service_cmd_handler, - ble_module_add_attribute_cmd_handler, - ble_module_set_local_att_value_cmd_handler, - ble_module_get_local_att_value_cmd_handler, - ble_module_cmd_notify_cmd_handler, - ble_module_cmd_indicate_cmd_handler, - ble_module_set_advertise_data_cmd_handler, - ble_module_get_le_ping_cmd_handler, - ble_module_set_le_ping_cmd_handler, - ble_module_set_random_address_cmd_handler, - ble_module_encrypt_cmd_handler, - ble_module_cmd_read_resp_cmd_handler, - ble_module_set_scan_response_data_cmd_handler, - ble_module_le_accept_list_cmd_handler, - ble_module_cmd_remove_service_cmd_handler, - ble_module_cmd_remove_attribute_cmd_handler, - ble_module_process_resolv_list_cmd_handler, - ble_module_get_resolving_list_size_cmd_handler, - ble_module_set_address_resolution_enable_cmd_handler, - ble_module_req_read_phy_cmd_handler, - ble_module_req_set_phy_cmd_handler, - ble_module_set_data_len_cmd_handler, - ble_module_read_max_data_len_cmd_handler, - ble_module_set_privacy_mode_cmd_handler, - ble_module_cbfc_conn_req_cmd_handler, - ble_module_cbfc_conn_resp_cmd_handler, - ble_module_cbfc_tx_data_cmd_handler, - ble_module_cbfc_disconn_cmd_handler, - ble_module_le_ltk_req_reply_cmd_handler, - ble_module_rx_test_mode_cmd_handler, - ble_module_tx_test_mode_cmd_handler, - ble_module_end_test_mode_cmd_handler, - ble_module_per_tx_mode_cmd_handler, - ble_module_per_rx_mode_cmd_handler, - ble_module_cmd_att_error_cmd_handler, - ble_module_req_profiles_async_cmd_handler, - ble_module_req_profile_async_cmd_handler, - ble_module_get_charservices_async_cmd_handler, - ble_module_get_includeservices_async_cmd_handler, - ble_module_readcharvaluebyuuid_async_cmd_handler, - ble_module_get_attribute_async_cmd_handler, - ble_module_get_descriptorvalue_async_cmd_handler, - ble_module_get_multiplevalues_async_cmd_handler, - ble_module_get_longdescvalues_async_cmd_handler, - ble_module_set_descvalue_async_cmd_handler, - ble_module_set_preparewrite_async_cmd_handler, - ble_module_execute_longdescwrite_async_cmd_handler, - ble_module_set_smp_pairing_capability_data_cmd_handler, - ble_module_conn_param_resp_cmd_cmd_handler, - ble_module_cmd_indicate_confirmation_cmd_handler, - ble_module_mtu_exchange_request_cmd_handler, - ble_module_cmd_set_wwo_resp_notify_buf_info_cmd_handler, - ble_module_cmd_write_resp_cmd_handler, - ble_module_cmd_prepare_write_resp_cmd_handler, - ble_module_cmd_set_local_irk_cmd_handler, - ble_module_cmd_set_prop_protocol_ble_bandedge_txpower_cmd_handler, - ble_module_cmd_mtu_exchange_resp_cmd_handler, - ble_module_cmd_set_ble_tx_power_cmd_handler, - ble_module_cmd_indicate_sync_cmd_handler, - ble_module_prop_protocol_cmd_cmd_handler, - ble_module_prop_protocol_cmd_per_cmd_handler, - NULL + { ble_module_req_adv_cmd_handler }, + { ble_module_req_scan_cmd_handler }, + { ble_module_req_conn_cmd_handler }, + { ble_module_req_adv_stop_cmd_handler }, + { ble_module_req_scan_stop_cmd_handler }, + { ble_module_req_disconnect_cmd_handler }, + { ble_module_get_dev_state_cmd_handler }, + { ble_module_cmd_conn_params_update_cmd_handler }, + { ble_module_req_start_encryption_cmd_handler }, + { ble_module_req_smp_pair_cmd_handler }, + { ble_module_smp_pair_response_cmd_handler }, + { ble_module_smp_passkey_cmd_handler }, + { ble_module_req_profiles_cmd_handler }, + { ble_module_req_profile_cmd_handler }, + { ble_module_req_char_services_cmd_handler }, + { ble_module_req_inc_services_cmd_handler }, + { ble_module_req_read_by_uuid_cmd_handler }, + { ble_module_req_desc_cmd_handler }, + { ble_module_req_read_val_cmd_handler }, + { ble_module_req_multiple_read_cmd_handler }, + { ble_module_req_long_read_cmd_handler }, + { ble_module_req_write_cmd_handler }, + { ble_module_req_write_no_ack_cmd_handler }, + { ble_module_req_long_write_cmd_handler }, + { ble_module_req_prepare_write_cmd_handler }, + { ble_module_req_execute_write_cmd_handler }, + { ble_module_add_service_cmd_handler }, + { ble_module_add_attribute_cmd_handler }, + { ble_module_set_local_att_value_cmd_handler }, + { ble_module_get_local_att_value_cmd_handler }, + { ble_module_cmd_notify_cmd_handler }, + { ble_module_cmd_indicate_cmd_handler }, + { ble_module_set_advertise_data_cmd_handler }, + { ble_module_get_le_ping_cmd_handler }, + { ble_module_set_le_ping_cmd_handler }, + { ble_module_set_random_address_cmd_handler }, + { ble_module_encrypt_cmd_handler }, + { ble_module_cmd_read_resp_cmd_handler }, + { ble_module_set_scan_response_data_cmd_handler }, + { ble_module_le_accept_list_cmd_handler }, + { ble_module_cmd_remove_service_cmd_handler }, + { ble_module_cmd_remove_attribute_cmd_handler }, + { ble_module_process_resolv_list_cmd_handler }, + { ble_module_get_resolving_list_size_cmd_handler }, + { ble_module_set_address_resolution_enable_cmd_handler }, + { ble_module_req_read_phy_cmd_handler }, + { ble_module_req_set_phy_cmd_handler }, + { ble_module_set_data_len_cmd_handler }, + { ble_module_read_max_data_len_cmd_handler }, + { ble_module_set_privacy_mode_cmd_handler }, + { ble_module_cbfc_conn_req_cmd_handler }, + { ble_module_cbfc_conn_resp_cmd_handler }, + { ble_module_cbfc_tx_data_cmd_handler }, + { ble_module_cbfc_disconn_cmd_handler }, + { ble_module_le_ltk_req_reply_cmd_handler }, + { ble_module_rx_test_mode_cmd_handler }, + { ble_module_tx_test_mode_cmd_handler }, + { ble_module_end_test_mode_cmd_handler }, + { ble_module_per_tx_mode_cmd_handler }, + { ble_module_per_rx_mode_cmd_handler }, + { ble_module_cmd_att_error_cmd_handler }, + { ble_module_req_profiles_async_cmd_handler }, + { ble_module_req_profile_async_cmd_handler }, + { ble_module_get_charservices_async_cmd_handler }, + { ble_module_get_includeservices_async_cmd_handler }, + { ble_module_readcharvaluebyuuid_async_cmd_handler }, + { ble_module_get_attribute_async_cmd_handler }, + { ble_module_get_descriptorvalue_async_cmd_handler }, + { ble_module_get_multiplevalues_async_cmd_handler }, + { ble_module_get_longdescvalues_async_cmd_handler }, + { ble_module_set_descvalue_async_cmd_handler }, + { ble_module_set_preparewrite_async_cmd_handler }, + { ble_module_execute_longdescwrite_async_cmd_handler }, + { ble_module_set_smp_pairing_capability_data_cmd_handler }, + { ble_module_conn_param_resp_cmd_cmd_handler }, + { ble_module_cmd_indicate_confirmation_cmd_handler }, + { ble_module_mtu_exchange_request_cmd_handler }, + { ble_module_cmd_set_wwo_resp_notify_buf_info_cmd_handler }, + { ble_module_cmd_write_resp_cmd_handler }, + { ble_module_cmd_prepare_write_resp_cmd_handler }, + { ble_module_cmd_set_local_irk_cmd_handler }, + { ble_module_cmd_set_prop_protocol_ble_bandedge_txpower_cmd_handler }, + { ble_module_cmd_mtu_exchange_resp_cmd_handler }, + { ble_module_cmd_set_ble_tx_power_cmd_handler }, + { ble_module_cmd_indicate_sync_cmd_handler }, + { ble_module_prop_protocol_cmd_cmd_handler }, + { ble_module_prop_protocol_cmd_per_cmd_handler }, + { NULL } }; /*==============================================*/ diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmds_autogen.c.j2 b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmds_autogen.c.j2 index 6a462d47..22fa8d25 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmds_autogen.c.j2 +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_cmds_autogen.c.j2 @@ -1,13 +1,14 @@ #include "ble_cmd_hdlr_auto_gen.h" #include "event_loop.h" #include +#include "rsi_common_apis.h" generic_command_handler_lut_entry_t ble_commands_hdlr_lut[] = { {% for command, details in user_interface["ble"]["commands"].items() %} - {{ details["module_handler"] }}, + { {{ details["module_handler"] }} }, {% endfor %} - NULL + { NULL } }; {% macro render_ui_cmd_handler_callback_function(command) %} diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_event_hdlr_auto_gen.c b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_event_hdlr_auto_gen.c index e39771c0..1aba0bc9 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_event_hdlr_auto_gen.c +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_event_hdlr_auto_gen.c @@ -3,61 +3,62 @@ #include "event_loop.h" #include #include "rsi_common_utils.h" +#include "rsi_common_apis.h" generic_task_cb_t ble_generic_cb; -generic_event_handler_lut_entry_t ble_events_lut[] = { rsi_ble_event_adv_report, - rsi_ble_event_disconnect, - rsi_ble_event_conn_status, - rsi_ble_event_enhance_conn_status, - rsi_ble_event_mtu_exchange_information, - rsi_ble_event_mtu, - rsi_ble_event_more_data_req, - rsi_ble_simple_peripheral_on_remote_features_event, - rsi_ble_event_data_length_update, - rsi_ble_event_phy_update, - rsi_ble_on_remote_conn_params_request_event, - rsi_ble_event_conn_update, - rsi_ble_read_req, - rsi_ble_gatt_error_event, - rsi_ble_event_gatt_desc, - rsi_ble_char_services_event, - rsi_ble_profile_event, - rsi_ble_event_profiles_list, - rsi_ble_on_gatt_write_event, - rsi_ble_on_gatt_prepare_write_event, - rsi_ble_on_execute_write_event, - rsi_ble_on_event_write_resp, - rsi_ble_prepare_write_resp, - rsi_ble_on_read_resp_event, - rsi_ble_event_indication_confirmation, - rsi_ble_event_ext_adv_report, - rsi_ble_event_extended_per_sync_establish, - rsi_ble_event_extended_per_adv_report, - rsi_ble_event_extended_per_sync_lost, - rsi_ble_event_extended_scan_timeout, - rsi_ble_on_terminate, - rsi_ble_event_extended_scan_req_received, - rsi_bt_event_smp_req, - rsi_bt_event_smp_resp, - rsi_bt_event_smp_passkey, - rsi_bt_event_smp_failed, - rsi_bt_event_encryption_enabled, - rsi_bt_event_smp_passkey_display, - rsi_bt_event_sc_passkey, - rsi_bt_event_le_ltk_request, - rsi_bt_event_le_security_keys, - rsi_ble_event_data_transmit, - rsi_ble_event_smp_pending, - rsi_ble_event_advertisement_restart, - rsi_ble_event_scan_restart, - rsi_ble_event_on_data_recieve, - rsi_ble_event_conn_update_req, - rsi_ble_event_set_buffer_config, - rsi_ble_event_select_data_transfer, - rsi_ble_event_profile_discovery, - rsi_ble_event_profile_dummy, - NULL }; +generic_event_handler_lut_entry_t ble_events_lut[] = { { rsi_ble_event_adv_report }, + { rsi_ble_event_disconnect }, + { rsi_ble_event_conn_status }, + { rsi_ble_event_enhance_conn_status }, + { rsi_ble_event_mtu_exchange_information }, + { rsi_ble_event_mtu }, + { rsi_ble_event_more_data_req }, + { rsi_ble_simple_peripheral_on_remote_features_event }, + { rsi_ble_event_data_length_update }, + { rsi_ble_event_phy_update }, + { rsi_ble_on_remote_conn_params_request_event }, + { rsi_ble_event_conn_update }, + { rsi_ble_read_req }, + { rsi_ble_gatt_error_event }, + { rsi_ble_event_gatt_desc }, + { rsi_ble_char_services_event }, + { rsi_ble_profile_event }, + { rsi_ble_event_profiles_list }, + { rsi_ble_on_gatt_write_event }, + { rsi_ble_on_gatt_prepare_write_event }, + { rsi_ble_on_execute_write_event }, + { rsi_ble_on_event_write_resp }, + { rsi_ble_prepare_write_resp }, + { rsi_ble_on_read_resp_event }, + { rsi_ble_event_indication_confirmation }, + { rsi_ble_event_ext_adv_report }, + { rsi_ble_event_extended_per_sync_establish }, + { rsi_ble_event_extended_per_adv_report }, + { rsi_ble_event_extended_per_sync_lost }, + { rsi_ble_event_extended_scan_timeout }, + { rsi_ble_on_terminate }, + { rsi_ble_event_extended_scan_req_received }, + { rsi_bt_event_smp_req }, + { rsi_bt_event_smp_resp }, + { rsi_bt_event_smp_passkey }, + { rsi_bt_event_smp_failed }, + { rsi_bt_event_encryption_enabled }, + { rsi_bt_event_smp_passkey_display }, + { rsi_bt_event_sc_passkey }, + { rsi_bt_event_le_ltk_request }, + { rsi_bt_event_le_security_keys }, + { rsi_ble_event_data_transmit }, + { rsi_ble_event_smp_pending }, + { rsi_ble_event_advertisement_restart }, + { rsi_ble_event_scan_restart }, + { rsi_ble_event_on_data_recieve }, + { rsi_ble_event_conn_update_req }, + { rsi_ble_event_set_buffer_config }, + { rsi_ble_event_select_data_transfer }, + { rsi_ble_event_profile_discovery }, + { rsi_ble_event_profile_dummy }, + { NULL } }; /*==============================================*/ /** @@ -1737,6 +1738,7 @@ APP_WEAK void rsi_ble_event_data_transmit_driver_callback(uint8_t conn_id) { LOG_PRINT_D("\n in rsi_ble_data_transmit_driver_callback \n"); generic_event_message_t *msg; + UNUSED_PARAMETER(conn_id); //! allocate message diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_events_autogen.c.j2 b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_events_autogen.c.j2 index 1dbfd7dc..6b1d5126 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_events_autogen.c.j2 +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_events_autogen.c.j2 @@ -3,6 +3,7 @@ #include "event_loop.h" #include #include "rsi_common_utils.h" +#include "rsi_common_apis.h" generic_task_cb_t ble_generic_cb; @@ -11,26 +12,26 @@ generic_event_handler_lut_entry_t ble_events_lut[] = { {% for ble_event, callback in ble_events.items() %} {% if "handler" in callback.keys() and callback["handler"] != Null %} - {{ callback["handler"] }}, + { {{ callback["handler"] }} }, {% else %} NULL, {% endif %} {% endfor %} {% for bt_event, callback in bt_events.items() %} {% if "handler" in callback.keys() and callback["handler"] != Null %} - {{ callback["handler"] }}, + { {{ callback["handler"] }} }, {% else %} NULL, {% endif %} {% endfor %} {% for dummy_event, callback in dummy_events.items() %} {% if "handler" in callback.keys() and callback["handler"] != Null %} - {{ callback["handler"] }}, + { {{ callback["handler"] }} }, {% else %} NULL, {% endif %} {% endfor %} - NULL + { NULL } }; {% macro render_driver_callback_function(ble_event, value) %} @@ -321,7 +322,10 @@ APP_WEAK void rsi_ble_event_{{ dummy_event }}_driver_callback(rsi_ble_{{ dummy_e { LOG_PRINT_D("\n in rsi_ble_{{ dummy_event }}_driver_callback \n"); generic_event_message_t *msg; - + {% if dummy_event == 'data_transmit' %} + UNUSED_PARAMETER(conn_id); + {% endif %} + //! allocate message {% if value == 'uint' %} diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_cmd.c b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_cmd.c index 46b42c7e..826cff83 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_cmd.c +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_cmd.c @@ -2599,7 +2599,7 @@ void ble_module_cmd_set_ble_tx_power_cmd_handler(generic_command_message_t *gene { //! Add handling here int32_t status; - status = rsi_ble_set_ble_tx_power(uint8_t role, uint8_t *remote_dev_address, int8_t tx_power); + status = rsi_ble_set_ble_tx_power(int8_t tx_power); if (status != RSI_SUCCESS) { LOG_PRINT("\r\n ble_module_cmd_set_ble_tx_power_cmd_handler : error status 0x%lx \n", status); } else { diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_event_hdlrs.c b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_event_hdlrs.c index 3305587c..8fbbf363 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_event_hdlrs.c +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble/ble_user_event_hdlrs.c @@ -4453,7 +4453,7 @@ void rsi_ble_on_terminate(uint16_t __attribute__((unused)) status, void __attrib */ void rsi_ble_event_extended_scan_req_received(uint16_t status, void *event_data) { - + UNUSED_PARAMETER(status); uint8_t remote_dev_str_addr[18] = { 0 }; rsi_ble_scan_req_recvd_t *scan_req_recvd = (rsi_ble_scan_req_recvd_t *)event_data; diff --git a/examples/snippets/ble/ble_unified_ae_coex_app/ble_unified_ae_coex_app.slcp b/examples/snippets/ble/ble_unified_ae_coex_app/ble_unified_ae_coex_app.slcp index c9e2a307..da1acbf8 100644 --- a/examples/snippets/ble/ble_unified_ae_coex_app/ble_unified_ae_coex_app.slcp +++ b/examples/snippets/ble/ble_unified_ae_coex_app/ble_unified_ae_coex_app.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -77,7 +77,9 @@ component: from: wiseconnect3_sdk - id: ble from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/ble_update_gain_table/app.c b/examples/snippets/ble/ble_update_gain_table/app.c new file mode 100644 index 00000000..e3b7442b --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/app.c @@ -0,0 +1,367 @@ +/******************************************************************************* +* @file app.c +* @brief +******************************************************************************* +* # License +* Copyright 2023 Silicon Laboratories Inc. www.silabs.com +******************************************************************************* +* +* The licensor of this software is Silicon Laboratories Inc. Your use of this +* software is governed by the terms of Silicon Labs Master Software License +* Agreement (MSLA) available at +* www.silabs.com/about-us/legal/master-software-license-agreement. This +* software is distributed to you in Source Code format and is governed by the +* sections of the MSLA applicable to Source Code. +* +******************************************************************************/ +/************************************************************************* + * + */ + +/*================================================================================ + * @brief : This file contains example application for BLE Gain table update + * @section Description : + * This application demonstrates how to update the Gain table. + =================================================================================*/ + +/** + * Include files + * */ +//! SL Wi-Fi SDK includes +#include "sl_board_configuration.h" +#include "sl_wifi.h" +#include "sl_wifi_callback_framework.h" +#include "cmsis_os2.h" +#include "sl_utility.h" + +//! BLE include file to refer BLE APIs +#include + +#include "ble_config.h" +#include "rsi_ble_apis.h" +#include "rsi_ble_common_config.h" +#include "rsi_bt_common.h" +#include "rsi_bt_common_apis.h" + +//! Common include file +#include "rsi_common_apis.h" +#ifdef SLI_SI91X_MCU_INTERFACE +#include "sl_si91x_m4_ps.h" +#endif + +/*=======================================================================*/ +// ! MACROS +/*=======================================================================*/ +#define RSI_BT_BLE_MODE 9 +#define GLOBAL_BUFF_LEN 15000 +#define UPDATE_GAIN_TABLE_MAX_POWER 0 +#define UPDATE_GAIN_TABLE_OFFSET 1 +#define BLE_NODE 0 + +#define GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE 1 //! To update gain table and max tx power and offsets + +#if GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE + +#define FCC 0 +#define ETSI 1 +#define TELEC 2 +#define WORLDWIDE 3 +#define KCC 4 + +#define BLE_GAIN_TABLE_MAXPOWER_UPDATE 0 +#define BLE_GAIN_TABLE_OFFSET_UPDATE 1 +#define BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE 2 +#define BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE 3 + +// clang-format off +//! structure for the MAXPOWER +uint8_t Si917_BLE_REGION_BASED_MAXPOWER[16] = {//{{{ + //BLE Max Power Index, + FCC, 16, + ETSI, 8, + TELEC, 10, + WORLDWIDE, 16, + KCC, 10, +};//}}} + + +//! structure for the MAXPOWER OFFSET +uint8_t Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET[128] = {//{{{ + 5,//NUM_OF_REGIONS + FCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 500kbps 125kbps + 255, 0, 0, 5, 0, + 0, 0, 0, 5, 0, + 38, 0, 2, 5, 0, + 39, 0, 16, 5, 0, + ETSI, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 500kbps 125kbps + 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0, + TELEC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 500kbps 125kbps + 255, 0, 0, 0, 0, + 0, 2, 2, 2, 2, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0, + WORLDWIDE, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 500kbps 125kbps + 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, + 39, 0, 0, 0, 0, + KCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 500kbps 125kbps + 255, 0, 0, 0, 0, + 0, 2, 2, 2, 2, + 20, 0, 0, 0, 0, + 39, 0, 0, 0, 0 +}; + +//! structure for the MAXPOWER OFFSET +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX[128] = {//{{{ + 5,//NUM_OF_REGIONS + FCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 125kbps 500kbps + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 8, 31, 31, + ETSI, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, + TELEC, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, + WORLDWIDE, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, + KCC, + 4,//NUM_OF_CHANNELS + 255, 31, 31, 31, 31, + 0, 31, 31, 31, 31, + 19, 31, 31, 31, 31, + 39, 31, 31, 31, 31, +};//}}} + +//! structure for the MAXPOWER OFFSET +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX[128] = {//{{{ + 5,//NUM_OF_REGIONS + FCC, + 4,//NUM_OF_CHANNELS + //chan_num 1M 2M 125kbps 500kbps + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 35, 63, 63, + ETSI, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, + TELEC, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, + WORLDWIDE, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, + KCC, + 4,//NUM_OF_CHANNELS + 255, 63, 63, 63, 63, + 0, 63, 63, 63, 63, + 19, 63, 63, 63, 63, + 39, 63, 63, 63, 63, +};//}}} +#endif +// clang-format on + +static const sl_wifi_device_configuration_t config = { + .boot_option = LOAD_NWP_FW, + .mac_address = NULL, + .band = SL_SI91X_WIFI_BAND_2_4GHZ, + .region_code = US, + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_BLE_MODE, + .feature_bit_map = (SL_SI91X_FEAT_WPS_DISABLE | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE + | SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1), + .tcp_ip_feature_bit_map = + (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), + .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID), + .ext_custom_feature_bit_map = + (SL_SI91X_EXT_FEAT_LOW_POWER_MODE | SL_SI91X_EXT_FEAT_XTAL_CLK | MEMORY_CONFIG +#ifdef SLI_SI917 + | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 +#endif + | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE // Enable BT feature + ), + .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), + /*Enable BLE custom feature bitmap*/ + .ble_feature_bit_map = + (SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) + | SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) + | SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) + | SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC) + | SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) + | SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) + | SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE +#if RSI_BLE_GATT_ASYNC_ENABLE + | SL_SI91X_BLE_GATT_ASYNC_ENABLE +#endif + ), + .ble_ext_feature_bit_map = + (SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) + | SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES) +#if RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST + | SL_SI91X_BLE_INDICATE_CONFIRMATION_FROM_HOST //indication response from app +#endif +#if RSI_BLE_MTU_EXCHANGE_FROM_HOST + | SL_SI91X_BLE_MTU_EXCHANGE_FROM_HOST //MTU Exchange request initiation from app +#endif +#if RSI_BLE_SET_SCAN_RESP_DATA_FROM_HOST + | (SL_SI91X_BLE_SET_SCAN_RESP_DATA_FROM_HOST) //Set SCAN Resp Data from app +#endif +#if RSI_BLE_DISABLE_CODED_PHY_FROM_HOST + | (SL_SI91X_BLE_DISABLE_CODED_PHY_FROM_HOST) //Disable Coded PHY from app +#endif +#if BLE_SIMPLE_GATT + | SL_SI91X_BLE_GATT_INIT +#endif + ), + .config_feature_bit_map = (SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP) } +}; + +const osThreadAttr_t thread_attributes = { + .name = "application_thread", + .attr_bits = 0, + .cb_mem = 0, + .cb_size = 0, + .stack_mem = 0, + .stack_size = 3072, + .priority = osPriorityNormal, + .tz_module = 0, + .reserved = 0, +}; + +/*=======================================================================*/ +//! Powersave configurations +/*=======================================================================*/ +#define ENABLE_POWER_SAVE 0 //! Set to 1 for powersave mode + +#if ENABLE_POWER_SAVE +//! Power Save Profile Mode +#define PSP_MODE RSI_SLEEP_MODE_2 +//! Power Save Profile type +#define PSP_TYPE RSI_MAX_PSP + +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; +#endif + +/*=======================================================================*/ +// ! GLOBAL VARIABLES +/*=======================================================================*/ +void update_gain_table(void *argument) +{ + UNUSED_PARAMETER(argument); + int32_t status = RSI_SUCCESS; + uint8_t _Si917_BLE_REGION_BASED_MAXPOWER_XX[16]; + uint8_t _Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX[128]; + + sl_wifi_firmware_version_t version = { 0 }; + +#if (defined SLI_SI91X_MCU_INTERFACE && ENABLE_POWER_SAVE) + sl_si91x_hardware_setup(); +#endif /* SLI_SI91X_MCU_INTERFACE */ + + status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler); + if (status != SL_STATUS_OK) { + LOG_PRINT("\r\nWi-Fi Initialization Failed, Error Code : 0x%lX\r\n", status); + return; + } else { + LOG_PRINT("\r\n Wi-Fi Initialization Success\n"); + } + + //! Firmware version Prints + status = sl_wifi_get_firmware_version(&version); + if (status != SL_STATUS_OK) { + LOG_PRINT("\r\nFirmware version Failed, Error Code : 0x%lX\r\n", status); + } else { + print_firmware_version(&version); + } + + memcpy(_Si917_BLE_REGION_BASED_MAXPOWER_XX, Si917_BLE_REGION_BASED_MAXPOWER, sizeof(Si917_BLE_REGION_BASED_MAXPOWER)); + memcpy(_Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX, + Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET, + sizeof(Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET)); + + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(BLE_NODE, + sizeof(_Si917_BLE_REGION_BASED_MAXPOWER_XX), + _Si917_BLE_REGION_BASED_MAXPOWER_XX, + UPDATE_GAIN_TABLE_MAX_POWER); + if (status != 0) { + LOG_PRINT("update gain table max_pwr Failed, Error Code : 0x%lX\r\n", status); + } else { + LOG_PRINT("update gain table max_pwr successful\n") + } + + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(BLE_NODE, + sizeof(_Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX), + _Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX, + UPDATE_GAIN_TABLE_OFFSET); + if (status != 0) { + LOG_PRINT("update gain table_offset Failed, Error Code : 0x%lX\r\n", status); + } else { + LOG_PRINT("update gain table offset successful\n") + } + + //! structure update for the LP_CHAIN 0dBm OFFSET + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(0, + sizeof(Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX), + Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX, + BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE); + if (status != RSI_SUCCESS) { + LOG_PRINT("\r\n update for the LP_CHAIN 0dBm OFFSET cmd failed with status = %lx\r\n", status); + } else { + LOG_PRINT("\r\n update for the LP_CHAIN 0dBm OFFSET successful \r\n"); + } + + //! structure update for the LP_CHAIN 10dBm OFFSET + status = rsi_bt_cmd_update_gain_table_offset_or_max_pwr(0, + sizeof(Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX), + Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX, + BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE); + if (status != RSI_SUCCESS) { + LOG_PRINT("\r\n update for the LP_CHAIN 10dBm OFFSET cmd failed with status = %lx\r\n", status); + } else { + LOG_PRINT("\r\n update for the LP_CHAIN 10dBm OFFSET successful \r\n"); + } +} + +void app_init(void) +{ + osThreadNew((osThreadFunc_t)update_gain_table, NULL, &thread_attributes); +} diff --git a/examples/snippets/ble/ble_update_gain_table/app.h b/examples/snippets/ble/ble_update_gain_table/app.h new file mode 100644 index 00000000..105a4712 --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/app.h @@ -0,0 +1,31 @@ +/***************************************************************************/ /** + * @file app.h + * @brief Top level application functions + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef APP_H +#define APP_H + +/***************************************************************************/ /** + * Initialize application. + ******************************************************************************/ +void app_init(void); + +/***************************************************************************/ /** + * App ticking function. + ******************************************************************************/ +void app_process_action(void); + +#endif // APP_H diff --git a/examples/snippets/ble/ble_update_gain_table/ble_config.h b/examples/snippets/ble/ble_update_gain_table/ble_config.h new file mode 100644 index 00000000..8cdbaab8 --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/ble_config.h @@ -0,0 +1,169 @@ +/******************************************************************************* +* @file ble_config.h +* @brief +******************************************************************************* +* # License +* Copyright 2023 Silicon Laboratories Inc. www.silabs.com +******************************************************************************* +* +* The licensor of this software is Silicon Laboratories Inc. Your use of this +* software is governed by the terms of Silicon Labs Master Software License +* Agreement (MSLA) available at +* www.silabs.com/about-us/legal/master-software-license-agreement. This +* software is distributed to you in Source Code format and is governed by the +* sections of the MSLA applicable to Source Code. +* +******************************************************************************/ + +#ifndef BLE_CONFIG_H +#define BLE_CONFIG_H + +/****************************************************** + * * Macros + * ******************************************************/ + +#define RSI_BLE_SET_RAND_ADDR "00:23:A7:12:34:56" + +#define CLEAR_ACCEPTLIST 0x00 +#define ADD_DEVICE_TO_ACCEPTLIST 0x01 +#define DELETE_DEVICE_FROM_ACCEPTLIST 0x02 + +#define ALL_PHYS 0x00 + +#define RSI_BLE_DEV_ADDR_RESOLUTION_ENABLE 0 + +#define RSI_OPERMODE_WLAN_BLE 9 + +#define RSI_BLE_MAX_NBR_ATT_REC 80 +#define RSI_BLE_MAX_NBR_ATT_SERV 10 + +#define RSI_BLE_MAX_NBR_PERIPHERALS 3 +#define RSI_BLE_MAX_NBR_CENTRALS 1 +#define RSI_BLE_GATT_ASYNC_ENABLE 0 +#define RSI_BLE_GATT_INIT 0 + +/* Number of BLE notifications */ +#define RSI_BLE_NUM_CONN_EVENTS 20 + +/* Number of BLE GATT RECORD SIZE IN (n*16 BYTES), eg:(0x40*16)=1024 bytes */ +#define RSI_BLE_NUM_REC_BYTES 0x40 + +#define RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST 0 + +/*=======================================================================*/ +//! Advertising command parameters +/*=======================================================================*/ + +#define RSI_BLE_ADV_TYPE UNDIR_CONN +#define RSI_BLE_ADV_FILTER_TYPE ALLOW_SCAN_REQ_ANY_CONN_REQ_ANY +#define RSI_BLE_ADV_DIR_ADDR_TYPE LE_PUBLIC_ADDRESS +#define RSI_BLE_ADV_DIR_ADDR "00:15:83:6A:64:17" + +#define RSI_BLE_ADV_INT_MIN 0x100 +#define RSI_BLE_ADV_INT_MAX 0x200 +#define RSI_BLE_ADV_CHANNEL_MAP 0x07 + +//!Advertise status +//! Start the advertising process +#define RSI_BLE_START_ADV 0x01 +//! Stop the advertising process +#define RSI_BLE_STOP_ADV 0x00 + +//! BLE Tx Power Index On Air +#define RSI_BLE_PWR_INX 30 + +//! BLE Active H/w Pwr Features +#define BLE_DISABLE_DUTY_CYCLING 0 +#define BLE_DUTY_CYCLING 1 +#define BLR_DUTY_CYCLING 2 +#define BLE_4X_PWR_SAVE_MODE 4 +#define RSI_BLE_PWR_SAVE_OPTIONS BLE_DISABLE_DUTY_CYCLING + +//!Advertise types + +/* Advertising will be visible(discoverable) to all the devices. + * Scanning/Connection is also accepted from all devices + * */ +#define UNDIR_CONN 0x80 + +/* Advertising will be visible(discoverable) to the particular device + * mentioned in RSI_BLE_ADV_DIR_ADDR only. + * Scanning and Connection will be accepted from that device only. + * */ +#define DIR_CONN 0x81 + +/* Advertising will be visible(discoverable) to all the devices. + * Scanning will be accepted from all the devices. + * Connection will be not be accepted from any device. + * */ +#define UNDIR_SCAN 0x82 + +/* Advertising will be visible(discoverable) to all the devices. + * Scanning and Connection will not be accepted from any device + * */ +#define UNDIR_NON_CONN 0x83 + +/* Advertising will be visible(discoverable) to the particular device + * mentioned in RSI_BLE_ADV_DIR_ADDR only. + * Scanning and Connection will be accepted from that device only. + * */ +#define DIR_CONN_LOW_DUTY_CYCLE 0x84 + +//!Advertising flags +#define LE_LIMITED_DISCOVERABLE 0x01 +#define LE_GENERAL_DISCOVERABLE 0x02 +#define LE_BR_EDR_NOT_SUPPORTED 0x04 + +//!Advertise filters +#define ALLOW_SCAN_REQ_ANY_CONN_REQ_ANY 0x00 +#define ALLOW_SCAN_REQ_ACCEPT_LIST_CONN_REQ_ANY 0x01 +#define ALLOW_SCAN_REQ_ANY_CONN_REQ_ACCEPT_LIST 0x02 +#define ALLOW_SCAN_REQ_ACCEPT_LIST_CONN_REQ_ACCEPT_LIST 0x03 + +//! Address types +#define LE_PUBLIC_ADDRESS 0x00 +#define LE_RANDOM_ADDRESS 0x01 +#define LE_RESOLVABLE_PUBLIC_ADDRESS 0x02 +#define LE_RESOLVABLE_RANDOM_ADDRESS 0x03 + +/*=======================================================================*/ + +/*=======================================================================*/ +//! Connection parameters +/*=======================================================================*/ +#define LE_SCAN_INTERVAL 0x0100 +#define LE_SCAN_WINDOW 0x0050 + +#define CONNECTION_INTERVAL_MIN 0x00A0 +#define CONNECTION_INTERVAL_MAX 0x00A0 + +#define CONNECTION_LATENCY 0x0000 +#define SUPERVISION_TIMEOUT 0x07D0 //2000 + +/*=======================================================================*/ + +/*=======================================================================*/ +//! Scan command parameters +/*=======================================================================*/ + +#define RSI_BLE_SCAN_TYPE SCAN_TYPE_ACTIVE +#define RSI_BLE_SCAN_FILTER_TYPE SCAN_FILTER_TYPE_ALL + +//!Scan status +#define RSI_BLE_START_SCAN 0x01 +#define RSI_BLE_STOP_SCAN 0x00 + +//!Scan types +#define SCAN_TYPE_ACTIVE 0x01 +#define SCAN_TYPE_PASSIVE 0x00 + +//!Scan filters +#define SCAN_FILTER_TYPE_ALL 0x00 +#define SCAN_FILTER_TYPE_ONLY_ACCEPT_LIST 0x01 + +#define RSI_SEL_INTERNAL_ANTENNA 0x00 +#define RSI_SEL_EXTERNAL_ANTENNA 0x01 + +#include "rsi_ble_common_config.h" + +#endif diff --git a/examples/snippets/ble/ble_update_gain_table/ble_update_gain_table_ncp.slcp b/examples/snippets/ble/ble_update_gain_table/ble_update_gain_table_ncp.slcp new file mode 100644 index 00000000..fe0bea73 --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/ble_update_gain_table_ncp.slcp @@ -0,0 +1,70 @@ +project_name: ble_update_gain_table_ncp +package: ble +quality: production +label: ble_update_gain_table_ncp +category: Example|BLE +description: | + Update BLE Gain table. +filter: +- name: Wireless Technology + value: + - BLE +- name: Project Difficulty + value: + - Beginner +sdk: + id: gecko_sdk + version: 4.4.0 +sdk_extension: +- id: wiseconnect3_sdk + version: 3.1.2 +source: +- path: app.c +- path: main.c +include: +- path: . + file_list: + - path: app.h + - path: ble_config.h +define: +- name: SL_SI91X_PRINT_DBG_LOG +component: +- id: sl_system +- id: freertos +- id: device_init +- id: iostream_retarget_stdio +- id: iostream_recommended_stream +- id: iostream_stdlib_config +- id: wiseconnect3_common + from: wiseconnect3_sdk +- id: wifi + from: wiseconnect3_sdk +- id: sl_si91x_internal_stack + from: wiseconnect3_sdk +- id: wifi_resources + from: wiseconnect3_sdk +- id: network_manager + from: wiseconnect3_sdk +- id: basic_network_config_manager + from: wiseconnect3_sdk +- id: ble + from: wiseconnect3_sdk +toolchain_settings: +- option: gcc_linker_option + value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror +configuration: +- name: SL_BOARD_ENABLE_VCOM + value: '1' +- name: configUSE_POSIX_ERRNO + value: '1' +- name: configTOTAL_HEAP_SIZE + value: '51200' +readme: +- path: readme.md + +ui_hints: + highlight: + - path: readme.md + focus: true \ No newline at end of file diff --git a/examples/snippets/ble/ble_update_gain_table/ble_update_gain_table_soc.slcp b/examples/snippets/ble/ble_update_gain_table/ble_update_gain_table_soc.slcp new file mode 100644 index 00000000..ed9329d2 --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/ble_update_gain_table_soc.slcp @@ -0,0 +1,73 @@ +project_name: ble_update_gain_table +package: ble +quality: production +label: ble_update_gain_table +category: Example|BLE +description: | + Update BLE gain table. +filter: +- name: Wireless Technology + value: + - BLE +- name: Project Difficulty + value: + - Advanced +sdk: + id: gecko_sdk + version: 4.4.0 +sdk_extension: +- id: wiseconnect3_sdk + version: 3.1.2 +source: +- path: app.c +- path: main.c +include: +- path: . + file_list: + - path: app.h + - path: ble_config.h +define: +- name: SL_SI91X_PRINT_DBG_LOG +- name: SL_SI91X_MCU_WIRELESS_BASED_WAKEUP +component: +- id: sl_system +- id: freertos +- id: syscalls + from: wiseconnect3_sdk +- id: si917_memory_default_config + from: wiseconnect3_sdk +- id: wiseconnect3_common + from: wiseconnect3_sdk +- id: wifi + from: wiseconnect3_sdk +- id: sl_si91x_internal_stack + from: wiseconnect3_sdk +- id: wifi_resources + from: wiseconnect3_sdk +- id: network_manager + from: wiseconnect3_sdk +- id: basic_network_config_manager + from: wiseconnect3_sdk +- id: ble + from: wiseconnect3_sdk +- id: sllib_m4_power_save + from: wiseconnect3_sdk +requires: + - name: device_needs_ram_execution + condition: + - si91x_common_flash +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror +configuration: +- name: SL_BOARD_ENABLE_VCOM + value: '1' +readme: +- path: readme.md + +ui_hints: + highlight: + - path: readme.md + focus: true +post_build: + path: ../../../../utilities/postbuild_profile/wiseconnect_soc.slpb \ No newline at end of file diff --git a/examples/snippets/ble/ble_update_gain_table/main.c b/examples/snippets/ble/ble_update_gain_table/main.c new file mode 100644 index 00000000..fd69ac2f --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/main.c @@ -0,0 +1,58 @@ +/***************************************************************************/ /** + * @file main.c + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "app.h" +#include "sl_component_catalog.h" +#include "sl_system_init.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif +#if defined(SL_CATALOG_KERNEL_PRESENT) +#include "sl_system_kernel.h" +#else // SL_CATALOG_KERNEL_PRESENT +#include "sl_system_process_action.h" +#endif // SL_CATALOG_KERNEL_PRESENT + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that if the kernel is present, processing task(s) will be created by + // this call. + sl_system_init(); + + // Initialize the application. For example, create periodic timer(s) or + // task(s) if the kernel is present. + app_init(); + +#if defined(SL_CATALOG_KERNEL_PRESENT) + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +#else // SL_CATALOG_KERNEL_PRESENT + while (1) { + // Do not remove this call: Silicon Labs components process action routine + // must be called from the super loop. + sl_system_process_action(); + + // Application process. + app_process_action(); + +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + // Let the CPU go to sleep if the system allows it. + sl_power_manager_sleep(); +#endif + } +#endif // SL_CATALOG_KERNEL_PRESENT +} diff --git a/examples/snippets/ble/ble_update_gain_table/readme.md b/examples/snippets/ble/ble_update_gain_table/readme.md new file mode 100644 index 00000000..fd8e1528 --- /dev/null +++ b/examples/snippets/ble/ble_update_gain_table/readme.md @@ -0,0 +1,227 @@ +# BLE - Update Gain Table + +## Table of Contents + +- [Purpose/Scope](#purposescope) +- [Prerequisites/Setup Requirements](#prerequisitessetup-requirements) + - [Hardware Requirements](#hardware-requirements) + - [Software Requirements](#software-requirements) +- [Getting Started](#getting-started) +- [Application Build Environment](#application-build-environment) +- [Test the Application](#test-the-application) + +## Purpose/Scope + +This application demonstrates how to modify gain table offset/max power details. The app can be used to overwrite the default region based gain table with a user-defined region-based gain table. + +There are two types of gain tables for BLE protocol + - Gain table holding maximum transmit power values + - Gain table with maximum power vs. offset values + +Both gain tables must be configured in the correct order to successfully apply changes in the firmware. + +## Prerequisites/Setup Requirements + +### Hardware Requirements + +- Windows PC +- SoC Mode: + - Silicon Labs [BRD4325A, BRD4325B, BRD4325C, BRD4325G, BRD4338A](https://www.silabs.com/) +- NCP Mode: + - Silicon Labs [BRD4180B](https://www.silabs.com/); + - Host MCU Eval Kit. This example has been tested with: + - Silicon Labs [WSTK + EFR32MG21](https://www.silabs.com/development-tools/wireless/efr32xg21-bluetooth-starter-kit) +- Smartphone + +### Software Requirements + +- Simplicity Studio IDE + +- Download and install the Silicon Labs [EFR Connect App or other BLE Central/Peripheral app.](https://www.silabs.com/developers/efr-connect-mobile-app) in the android smart phones for testing BLE applications. Users can also use their choice of BLE apps available in Android/iOS smart phones. + +## Getting Started + +Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: + +- Install Studio and WiSeConnect 3 extension +- Connect your device to the computer +- Upgrade your connectivity firmware +- Create a Studio project + +## Application Build Environment + +The application can be configured to suit your requirements and development environment. Read through the following sections and make any changes needed. + + + The API used to update the gain table is: +```c +int32_t rsi_bt_cmd_update_gain_table_offset_or_max_pwr(uint8_t node_id, + uint8_t payload_len, + uint8_t *payload, + uint8_t req_type) +``` +--- +**Note!** +* This command must be used immediately after opermode request +* Internally, the firmware maintains two tables + * Gain table holding Max Tx power values for all regions + * Gain table with Max power vs offset values for each channel of all regions +* There are 5 regions supported and are FCC, ETSI, TELEC, KCC, WORLDWIDE. These FCC/ETSI/TELEC/KCC gain table max power level and offset values should be loaded in end-to-end mode via BLE User Gain table. This has to be called upon every boot-up since this information is not saved inside flash. SoC uses these tables in FCC/ETSI/TELEC/KCC to limit power and not to violate allowed limits. +* For Worldwide region firmware uses Worldwide values for Tx. For other regions(FCC/ETSI/TELEC/KCC), Firmware uses min value out of Worldwide & Region based values for Tx. Also there will be part to part variation across chips and offsets are estimated during manufacturing flow which will be applied as correction factor during normal mode of operation. +* This frame has to be used by customers who has done FCC/ETSI/TELEC/KCC certification with their own antenna. All other customers should not use this. Inappropriate use of this frame may result in violation of FCC/ETSI/TELEC/KCC or any certifications and Silicon labs is not liable for that. + +--- + +* BLE power offset like , <1M_OFFSET>, <2M_OFFSET>, <500kbps_oFFSET>, <125kbps_oFFSET> + +--- + +Set below macro to update Max TX power and offset +```c +#define GAIN_TABLE_AND_MAX_POWER_UPDATE_ENABLE 1 //! To update gain table and max tx power and offsets +``` + +**req_type** can be set to one of the following macros : +```c +#define UPDATE_GAIN_TABLE_MAX_POWER 0 // For updating Gain table Max power +#define UPDATE_GAIN_TABLE_OFFSET 1 // For updating Gain table offset +#define BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE 2 +#define BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE 3 +``` +**node_id** refers to BLE Node id : +```c +#define BLE_NODE 0 // For selecting BLE node +``` + +The following arrays will be used to update_gain_table based on `node_id` and `req_type`. + +| `node_id` | `req_type` | Payload Array | +| ---------- | ----------------------------- | ------------------------------------------------ | +| `BLE_NODE` | `UPDATE_GAIN_TABLE_MAX_POWER` | `Si917_BLE_REGION_BASED_MAXPOWER_XX` | +| `BLE_NODE` | `UPDATE_GAIN_TABLE_OFFSET` | `Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET_XX` | +| `BLE_NODE` | `BLE_GAIN_TABLE_LP_CHAIN_0DBM_OFFSET_UPDATE` | `Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX` | +| `BLE_NODE` | `BLE_GAIN_TABLE_LP_CHAIN_10DBM_OFFSET_UPDATE` | `Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX` | + +**Gain Table Max Power Array Format** + +```c +uint8_t _Si917_BLE_REGION_BASED_MAXPOWER_XX[] = {}; //! Fill the user gain table max power values in the below mentioned way. + +
[] = { + , , + , , + . + . + , + }; +``` + +**Gain Table Offset Array Format** +```c +uint8_t _Si917_BLE_REGION_BASED_MAXPOWER_VS_OFFSET[] = {}; // Fill the user gain table offset values as shown. + +
[] = { + , + , , + , , , , + , , , , + . + . + , , + , , + , , , , + , , , , + . + . + , , , , + . + . + , , + , , , , + , , , , + . + . + , , , , + }; + +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_0DBM_OFFSET_XX[] = {}; // Fill the user gain table offset values as shown. + +
[] = { + , + , , + , , , , + , , , , + . + . + , , + , , + , , , , + , , , , + . + . + , , , , + . + . + , , + , , , , + , , , , + . + . + , , , , + }; + +uint8_t Si917_BLE_REGION_BASED_LP_CHAIN_10DBM_OFFSET_XX[] = {}; // Fill the user gain table offset values as shown. + +
[] = { + , + , , + , , , , + , , , , + . + . + , , + , , + , , , , + , , , , + . + . + , , , , + . + . + , , + , , , , + , , , , + . + . + , , , , + }; + +``` +**Region Name and Values** + +| Region Name | Value | +|--------------|---------| +| `FCC` | `0` | +| `ETSI` | `1` | +| `TELEC` | `2` | +| `WORLDWIDE` | `3` | +| `KCC` | `4` | + +## Test the Application + +Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: + +- Build the application in Studio. +- Flash, run and debug the application + +Follow the steps as mentioned for the successful execution of the application: + +1. As soon as the debug process is completed, the application control branches to the main(). + +2. Go to the J-link Silicon Labs console pane to observe the debug prints in the Serial 1 tab. + +3. Click on the **Resume** icon in the Simplicity Studio IDE toolbar to run the application. + +4. Review gain table updates on the serial terminal. Refer the following image for console prints: + +![](resources/readme/update_gain_table_logs.png) diff --git a/examples/snippets/ble/ble_update_gain_table/resources/readme/update_gain_table_logs.png b/examples/snippets/ble/ble_update_gain_table/resources/readme/update_gain_table_logs.png new file mode 100644 index 00000000..d1bad84f Binary files /dev/null and b/examples/snippets/ble/ble_update_gain_table/resources/readme/update_gain_table_logs.png differ diff --git a/examples/snippets/ble/gatt_long_read/app.c b/examples/snippets/ble/gatt_long_read/app.c index eeb1daaf..c6fff3ea 100644 --- a/examples/snippets/ble/gatt_long_read/app.c +++ b/examples/snippets/ble/gatt_long_read/app.c @@ -127,7 +127,7 @@ //! Power Save Profile type #define PSP_TYPE RSI_MAX_PSP -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000 }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; #endif /****************************************************** @@ -153,11 +153,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), #ifdef RSI_PROCESS_MAX_RX_DATA .ext_tcp_ip_feature_bit_map = (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_MAX_RECV_LENGTH), diff --git a/examples/snippets/ble/gatt_long_read/gatt_long_read_ncp.slcp b/examples/snippets/ble/gatt_long_read/gatt_long_read_ncp.slcp index 0e11683f..f72a94de 100644 --- a/examples/snippets/ble/gatt_long_read/gatt_long_read_ncp.slcp +++ b/examples/snippets/ble/gatt_long_read/gatt_long_read_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,6 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/ble/gatt_long_read/gatt_long_read_soc.slcp b/examples/snippets/ble/gatt_long_read/gatt_long_read_soc.slcp index d226ee68..1b9ae414 100644 --- a/examples/snippets/ble/gatt_long_read/gatt_long_read_soc.slcp +++ b/examples/snippets/ble/gatt_long_read/gatt_long_read_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -56,7 +56,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/cli_demo/cli_demo_ncp.slcp b/examples/snippets/cli_demo/cli_demo_ncp.slcp index e59aa147..1222c9a1 100644 --- a/examples/snippets/cli_demo/cli_demo_ncp.slcp +++ b/examples/snippets/cli_demo/cli_demo_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: demo.c - path: main.c @@ -68,7 +68,9 @@ component: from: wiseconnect3_sdk - id: iot_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/cli_demo/cli_demo_soc.slcp b/examples/snippets/cli_demo/cli_demo_soc.slcp index 7e755e8d..611b399f 100644 --- a/examples/snippets/cli_demo/cli_demo_soc.slcp +++ b/examples/snippets/cli_demo/cli_demo_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: demo.c - path: main.c @@ -70,7 +70,9 @@ component: from: wiseconnect3_sdk - id: iot_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/cli_demo/demo.c b/examples/snippets/cli_demo/demo.c index 4f2b3c98..ab668c18 100644 --- a/examples/snippets/cli_demo/demo.c +++ b/examples/snippets/cli_demo/demo.c @@ -21,7 +21,7 @@ #include "cmsis_os2.h" #include "sl_utility.h" #include - +#include /****************************************************** * Constants ******************************************************/ diff --git a/examples/snippets/cli_demo/wifi_commands.c b/examples/snippets/cli_demo/wifi_commands.c index 187941b7..50d11f2e 100644 --- a/examples/snippets/cli_demo/wifi_commands.c +++ b/examples/snippets/cli_demo/wifi_commands.c @@ -785,7 +785,7 @@ sl_status_t wifi_connect_command_handler(console_args_t *arguments) sl_wifi_credential_id_t id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID; sl_wifi_client_configuration_t ap = { 0 }; char *ssid = (char *)arguments->arg[0]; - char *password = GET_OPTIONAL_COMMAND_ARG(arguments, 1, NULL, const char *); + const char *password = GET_OPTIONAL_COMMAND_ARG(arguments, 1, NULL, const char *); sl_wifi_security_t security_type = GET_OPTIONAL_COMMAND_ARG(arguments, 2, SL_WIFI_WPA2, sl_wifi_security_t); const char *user_name = GET_OPTIONAL_COMMAND_ARG(arguments, 3, NULL, const char *); sl_wifi_encryption_t encryption_type = @@ -939,7 +939,7 @@ sl_status_t wifi_start_statistic_report_command_handler(console_args_t *argument { stop_wifi_statistic_report = false; // Run the start_statistic_report on a different thread as we should be able to call stop_statistic_report while the start_statistic_report is still running. - wifi_statistic_thread_id = osThreadNew(wifi_statistic_thread, arguments, NULL); + wifi_statistic_thread_id = osThreadNew((osThreadFunc_t)wifi_statistic_thread, arguments, NULL); if (wifi_statistic_thread_id == NULL) { return SL_STATUS_FAIL; } diff --git a/examples/snippets/crypto/aes/aes.slcp b/examples/snippets/crypto/aes/aes.slcp index 699d364c..58b0769e 100644 --- a/examples/snippets/crypto/aes/aes.slcp +++ b/examples/snippets/crypto/aes/aes.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -53,7 +53,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} readme: diff --git a/examples/snippets/crypto/attestation/app.c b/examples/snippets/crypto/attestation/app.c index afbb1df1..fff7394f 100644 --- a/examples/snippets/crypto/attestation/app.c +++ b/examples/snippets/crypto/attestation/app.c @@ -65,7 +65,7 @@ static const sl_wifi_device_configuration_t station_init_configuration = { (SL_SI91X_EXT_FEAT_XTAL_CLK | SL_SI91X_EXT_FEAT_UART_SEL_FOR_DEBUG_PRINTS | MEMORY_CONFIG), .bt_feature_bit_map = 0, .ext_tcp_ip_feature_bit_map = - (SL_SI91X_EXT_TCP_IP_FEAT_SSL_HIGH_PERFORMANCE | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD + (SL_SI91X_EXT_FEAT_HTTP_OTAF_SUPPORT | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), .ble_feature_bit_map = 0, .ble_ext_feature_bit_map = 0, diff --git a/examples/snippets/crypto/attestation/attestation.slcp b/examples/snippets/crypto/attestation/attestation.slcp index 96fcb548..fda9b00d 100644 --- a/examples/snippets/crypto/attestation/attestation.slcp +++ b/examples/snippets/crypto/attestation/attestation.slcp @@ -9,7 +9,7 @@ quality: production sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -17,7 +17,9 @@ include: - path: . file_list: - path: app.h -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror component: - id: rsilib_userconfig from: wiseconnect3_sdk diff --git a/examples/snippets/crypto/ecdh/ecdh.slcp b/examples/snippets/crypto/ecdh/ecdh.slcp index 23810f15..70ce183e 100644 --- a/examples/snippets/crypto/ecdh/ecdh.slcp +++ b/examples/snippets/crypto/ecdh/ecdh.slcp @@ -11,7 +11,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} readme: diff --git a/examples/snippets/crypto/hmac/hmac.slcp b/examples/snippets/crypto/hmac/hmac.slcp index 55a522d7..4932c63a 100644 --- a/examples/snippets/crypto/hmac/hmac.slcp +++ b/examples/snippets/crypto/hmac/hmac.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -50,7 +50,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} readme: diff --git a/examples/snippets/crypto/sha/app.c b/examples/snippets/crypto/sha/app.c index 927bb314..fc600575 100644 --- a/examples/snippets/crypto/sha/app.c +++ b/examples/snippets/crypto/sha/app.c @@ -41,9 +41,8 @@ /****************************************************** * Constants ******************************************************/ -#define SHA \ - "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" - +const char *message = + "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; /****************************************************** * Variable Definitions ******************************************************/ @@ -133,7 +132,7 @@ sl_status_t sha_process(void) sl_status_t status; // Compute digest using SHA - status = sl_si91x_sha(SL_SI91x_SHA_512, SHA, strlen(SHA), digest); + status = sl_si91x_sha(SL_SI91x_SHA_512, (uint8_t *)message, strlen(message), digest); if (status != SL_STATUS_OK) { printf("\r\n SHA Failed, Error Code : 0x%lX\r\n", status); return status; diff --git a/examples/snippets/crypto/sha/sha.slcp b/examples/snippets/crypto/sha/sha.slcp index 7b30f01f..7f27a6d5 100644 --- a/examples/snippets/crypto/sha/sha.slcp +++ b/examples/snippets/crypto/sha/sha.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -58,7 +58,9 @@ ui_hints: highlight: - path: readme.md focus: true -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} post_build: diff --git a/examples/snippets/wlan/access_point/access_point_ncp.slcp b/examples/snippets/wlan/access_point/access_point_ncp.slcp index 1312264f..04f61c01 100644 --- a/examples/snippets/wlan/access_point/access_point_ncp.slcp +++ b/examples/snippets/wlan/access_point/access_point_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/snippets/wlan/access_point/access_point_soc.slcp b/examples/snippets/wlan/access_point/access_point_soc.slcp index 99bb561c..179dbd17 100644 --- a/examples/snippets/wlan/access_point/access_point_soc.slcp +++ b/examples/snippets/wlan/access_point/access_point_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/snippets/wlan/access_point/app.c b/examples/snippets/wlan/access_point/app.c index bf74d57a..5a3c9435 100644 --- a/examples/snippets/wlan/access_point/app.c +++ b/examples/snippets/wlan/access_point/app.c @@ -31,7 +31,7 @@ #include "sl_net.h" #include "sl_utility.h" #include "cmsis_os2.h" - +#include "sl_wifi_callback_framework.h" /****************************************************** * Variable Definitions ******************************************************/ diff --git a/examples/snippets/wlan/calibration_app/app.c b/examples/snippets/wlan/calibration_app/app.c index 14e84d08..dc5bd7fe 100644 --- a/examples/snippets/wlan/calibration_app/app.c +++ b/examples/snippets/wlan/calibration_app/app.c @@ -38,10 +38,8 @@ #include "sl_wifi.h" #include "sl_net.h" #include "sl_utility.h" -#include #include "sl_si91x_driver.h" -#include - +#include /****************************************************** * Macros ******************************************************/ @@ -152,7 +150,7 @@ uint8_t cmd_index = -1; /******************************************************************************* ************************** GLOBAL FUNCTIONS ******************************* ******************************************************************************/ - +sl_status_t sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx); /***************************************************************************/ /** * Initialize example. ******************************************************************************/ @@ -543,17 +541,17 @@ sl_status_t calibration_app() } #define MAX_DPD_TRAINING_CHANNELS 6 uint8_t channel_sel[MAX_DPD_TRAINING_CHANNELS] = { 1, 3, 6, 8, 11, 13 }; -void sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) +sl_status_t sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) { uint8_t i; - sl_status_t status; + sl_status_t status = SL_STATUS_OK; sl_si91x_calibration_write_t calib_pkt = { 0 }; calib_pkt.target = 1; calib_pkt.flags = 256; status = sl_si91x_transmit_test_stop(); if (status != SL_STATUS_OK) { printf("Transmit failed to stop %lx\r\n", status); - return; + return status; } else { printf("Transmit command stopped\n"); } @@ -566,7 +564,7 @@ void sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) status = sl_si91x_transmit_test_start(&tx_test_info); if (status != SL_STATUS_OK) { printf("Transmit failed with channel num %lx\r\n", status); - return; + return status; } else { printf("Transmit command started with channel num %x\r\n", channel_sel[i]); } @@ -575,7 +573,7 @@ void sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) status = sl_si91x_transmit_test_stop(); if (status != SL_STATUS_OK) { printf("Transmit failed to stop %lx\r\n", status); - return; + return status; } else { printf("Transmit command stopped\n"); } @@ -585,7 +583,7 @@ void sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) status = sl_si91x_dpd_calibration(dpd_power_inx); if (status != SL_STATUS_OK) { printf("rsi_calibration_dpd_failed %lx\r\n", status); - return; + return status; } else { printf("calib-val coellecting\n"); } @@ -593,7 +591,7 @@ void sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) status = sl_si91x_calibration_write(calib_pkt); if (status != SL_STATUS_OK) { printf("rsi_calib_write failed with error %lx\r\n", status); - return; + return status; } else { printf("calib-write pass\n"); } @@ -601,11 +599,12 @@ void sl_process_dpd_calibration(sl_si91x_get_dpd_calib_data_t *dpd_power_inx) status = sl_si91x_dpd_calibration(dpd_power_inx); if (status != SL_STATUS_OK) { printf("rsi_calibration_dpd_failed %lx\r\n", status); - return; + return status; } else { printf("calib val collect\n"); } } osDelay(1000); } + return status; } diff --git a/examples/snippets/wlan/calibration_app/calibration_app_ncp.slcp b/examples/snippets/wlan/calibration_app/calibration_app_ncp.slcp index 667bc819..52507d31 100644 --- a/examples/snippets/wlan/calibration_app/calibration_app_ncp.slcp +++ b/examples/snippets/wlan/calibration_app/calibration_app_ncp.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} - {name: configTOTAL_HEAP_SIZE, value: '51200'} diff --git a/examples/snippets/wlan/calibration_app/calibration_app_soc.slcp b/examples/snippets/wlan/calibration_app/calibration_app_soc.slcp index 46758bbb..110cdf69 100644 --- a/examples/snippets/wlan/calibration_app/calibration_app_soc.slcp +++ b/examples/snippets/wlan/calibration_app/calibration_app_soc.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -67,7 +67,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} readme: diff --git a/examples/snippets/wlan/cloud_apps/aws/mqtt/app.c b/examples/snippets/wlan/cloud_apps/aws/mqtt/app.c index ace8d987..c01802bb 100644 --- a/examples/snippets/wlan/cloud_apps/aws/mqtt/app.c +++ b/examples/snippets/wlan/cloud_apps/aws/mqtt/app.c @@ -578,12 +578,11 @@ sl_status_t start_aws_mqtt(void) #if ENABLE_POWER_SAVE case SLEEP_STATE: { sl_si91x_host_delay_ms(200); - printf("\rM4 going to power save state..\r\n"); - printf("\rselect_given before sleep: %d\r\n", select_given); - if (select_given == 1 && (check_for_recv_data != 1)) { #ifdef SLI_SI91X_MCU_INTERFACE + printf("\rM4 going to power save state..\r\n"); + printf("\rselect_given before sleep: %d\r\n", select_given); sl_si91x_m4_sleep_wakeup(); #endif } diff --git a/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_ncp.slcp b/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_ncp.slcp index 30715523..da656e39 100644 --- a/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_ncp.slcp +++ b/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -51,7 +51,9 @@ component: from: wiseconnect3_sdk - id: aws_sdk from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_soc.slcp b/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_soc.slcp index 305fabd2..e0825fec 100644 --- a/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_soc.slcp +++ b/examples/snippets/wlan/cloud_apps/aws/mqtt/aws_mqtt_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -60,7 +60,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/concurrent_mode/concurrent_mode_ncp.slcp b/examples/snippets/wlan/concurrent_mode/concurrent_mode_ncp.slcp index 473736a7..ea254e89 100644 --- a/examples/snippets/wlan/concurrent_mode/concurrent_mode_ncp.slcp +++ b/examples/snippets/wlan/concurrent_mode/concurrent_mode_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/concurrent_mode/concurrent_mode_soc.slcp b/examples/snippets/wlan/concurrent_mode/concurrent_mode_soc.slcp index f1132d73..3bcab907 100644 --- a/examples/snippets/wlan/concurrent_mode/concurrent_mode_soc.slcp +++ b/examples/snippets/wlan/concurrent_mode/concurrent_mode_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_ncp.slcp b/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_ncp.slcp index e99c6a63..cb62f725 100644 --- a/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_ncp.slcp +++ b/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -51,7 +51,9 @@ component: from: wiseconnect3_sdk - id: mqtt from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_soc.slcp b/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_soc.slcp index 6e025e02..ac66c567 100644 --- a/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_soc.slcp +++ b/examples/snippets/wlan/embedded_mqtt_client/embedded_mqtt_client_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -51,7 +51,9 @@ component: from: wiseconnect3_sdk - id: mqtt from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_ncp.slcp b/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_ncp.slcp index bb7c56c1..e5a3d6b6 100644 --- a/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_ncp.slcp +++ b/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -51,7 +51,9 @@ component: from: wiseconnect3_sdk - id: mqtt from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_soc.slcp b/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_soc.slcp index d180ca63..e35d0fc2 100644 --- a/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_soc.slcp +++ b/examples/snippets/wlan/embedded_mqtt_client_twt/embedded_mqtt_client_twt_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -57,7 +57,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/enterprise_client/enterprise_client_ncp.slcp b/examples/snippets/wlan/enterprise_client/enterprise_client_ncp.slcp index d26e3ec9..a1204a53 100644 --- a/examples/snippets/wlan/enterprise_client/enterprise_client_ncp.slcp +++ b/examples/snippets/wlan/enterprise_client/enterprise_client_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/enterprise_client/enterprise_client_soc.slcp b/examples/snippets/wlan/enterprise_client/enterprise_client_soc.slcp index 2addb9e9..d2e12f48 100644 --- a/examples/snippets/wlan/enterprise_client/enterprise_client_soc.slcp +++ b/examples/snippets/wlan/enterprise_client/enterprise_client_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/http_client/http_client_ncp.slcp b/examples/snippets/wlan/http_client/http_client_ncp.slcp index 4086b0d1..910c4bf4 100644 --- a/examples/snippets/wlan/http_client/http_client_ncp.slcp +++ b/examples/snippets/wlan/http_client/http_client_ncp.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -47,7 +47,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} - {name: configTOTAL_HEAP_SIZE, value: '51200'} diff --git a/examples/snippets/wlan/http_client/http_client_soc.slcp b/examples/snippets/wlan/http_client/http_client_soc.slcp index 90823d24..ffe5145c 100644 --- a/examples/snippets/wlan/http_client/http_client_soc.slcp +++ b/examples/snippets/wlan/http_client/http_client_soc.slcp @@ -12,7 +12,7 @@ filter: value: ["Beginner"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c @@ -51,7 +51,9 @@ requires: condition: [device_has_devinfo] - name: emlib_ldma condition: [device_has_devinfo] -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - {name: SL_BOARD_ENABLE_VCOM, value: '1'} readme: diff --git a/examples/snippets/wlan/http_client/readme.md b/examples/snippets/wlan/http_client/readme.md index b8c42624..a839e410 100644 --- a/examples/snippets/wlan/http_client/readme.md +++ b/examples/snippets/wlan/http_client/readme.md @@ -10,6 +10,7 @@ - [Getting Started](#getting-started) - [Application Build Environment](#application-build-environment) - [Test the Application](#test-the-application) +- [Steps to set up HTTP server](#steps-to-set-up-http-server) ## Purpose/Scope @@ -23,14 +24,15 @@ This application demonstrates how to configure SiWx91x device as an HTTP client - SoC Mode: - Silicon Labs [BRD4325A, BRD4325B, BRD4325C, BRD4325G, BRD4388A](https://www.silabs.com/) - NCP Mode: - - Silicon Labs [BRD4180B](https://www.silabs.com/) **AND** - - Host MCU Eval Kit. This example has been tested with: - - Silicon Labs [WSTK + EFR32MG21](https://www.silabs.com/development-tools/wireless/efr32xg21-bluetooth-starter-kit) + - Standalone + - BRD4002A Wireless pro kit mainboard [SI-MB4002A] + - EFR32xG24 Wireless 2.4 GHz +10 dBm Radio Board [xG24-RB4186C](https://www.silabs.com/development-tools/wireless/xg24-rb4186c-efr32xg24-wireless-gecko-radio-board?tab=overview) + - NCP EFR Expansion Kit with NCP Radio board (BRD4346A + BRD8045A) [SiWx917-EB4346A] ### Software Requirements - Simplicity Studio -- Windows PC (Remote PC) with openssl application +- Windows PC (Remote PC) with HTTP server ### Setup Diagram @@ -124,3 +126,18 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise - User can see the log messages (success responses for HTTP PUT, HTTP GET and HTTP POST) at HTTP server as follows: ![http_client_Output](resources/readme/http_client_output.png) + +## Steps to set up HTTP server + +1. In a Windows PC, make sure python is installed. +2. Navigate to **`//resources/scripts/`**. Run **simple_http_server.py** script on port number 80 using the following command. + + `python simple_http_server.py 80` + + **NOTE:** If python command is not working replace the python with py. + +## Trouble shooting + +- If any permission errors are observed while setting up the Python HTTP server: + - Try running the python HTTP server script with admin privileges (Open command prompt or terminal in admin mode) + - Try using a different port like 8080 for the HTTP connection diff --git a/examples/snippets/wlan/http_client/resources/readme/http_client_soc_ncp.png b/examples/snippets/wlan/http_client/resources/readme/http_client_soc_ncp.png index 32d70091..462bf10b 100644 Binary files a/examples/snippets/wlan/http_client/resources/readme/http_client_soc_ncp.png and b/examples/snippets/wlan/http_client/resources/readme/http_client_soc_ncp.png differ diff --git a/examples/snippets/wlan/http_otaf/app.c b/examples/snippets/wlan/http_otaf/app.c index ae3c817d..9043cf24 100644 --- a/examples/snippets/wlan/http_otaf/app.c +++ b/examples/snippets/wlan/http_otaf/app.c @@ -184,7 +184,7 @@ static const sl_wifi_device_configuration_t station_init_configuration = { ), .bt_feature_bit_map = 0, .ext_tcp_ip_feature_bit_map = - (SL_SI91X_EXT_TCP_IP_FEAT_SSL_HIGH_PERFORMANCE | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD + (SL_SI91X_EXT_FEAT_HTTP_OTAF_SUPPORT | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), .ble_feature_bit_map = 0, .ble_ext_feature_bit_map = 0, diff --git a/examples/snippets/wlan/http_otaf/http_otaf_ncp.slcp b/examples/snippets/wlan/http_otaf/http_otaf_ncp.slcp index fb834987..a8585e63 100644 --- a/examples/snippets/wlan/http_otaf/http_otaf_ncp.slcp +++ b/examples/snippets/wlan/http_otaf/http_otaf_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -47,7 +47,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/http_otaf/http_otaf_soc.slcp b/examples/snippets/wlan/http_otaf/http_otaf_soc.slcp index 4f9df3bb..9ebe1d2a 100644 --- a/examples/snippets/wlan/http_otaf/http_otaf_soc.slcp +++ b/examples/snippets/wlan/http_otaf/http_otaf_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -54,7 +54,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_ncp.slcp b/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_ncp.slcp index 53e47b1d..db8c41a9 100644 --- a/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_ncp.slcp +++ b/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_soc.slcp b/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_soc.slcp index 0075fa64..4f831b82 100644 --- a/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_soc.slcp +++ b/examples/snippets/wlan/lwip_tcp_client/lwip_tcp_client_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,7 +53,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/lwip_tcp_client/readme.md b/examples/snippets/wlan/lwip_tcp_client/readme.md index 00fe0676..a64d0fc1 100644 --- a/examples/snippets/wlan/lwip_tcp_client/readme.md +++ b/examples/snippets/wlan/lwip_tcp_client/readme.md @@ -116,6 +116,9 @@ The M4 processor is set in sleep mode. The M4 processor can be woken in several - Wireless-based - When an RX packet is to be received by the TA, the M4 processor is woken up. - We can enable the Wireless-wakeup by adding the preprocessor macro "SL_SI91X_MCU_WIRELESS_BASED_WAKEUP" for the example. +### Note + - Enable `SL_SI91X_TCP_IP_FEAT_BYPASS` bitmap in tcp_ip_feature_bitmap to use the lwip stack. + - Refer [sl_net_init()](https://docs.silabs.com/wiseconnect/latest/wiseconnect-api-reference-guide-nwk-mgmt/net-interface-functions#sl-net-init) API for using the lwip stack. ## Test the application diff --git a/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_ncp.slcp b/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_ncp.slcp index 14ac1237..4da02b1c 100644 --- a/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_ncp.slcp +++ b/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_soc.slcp b/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_soc.slcp index 121d60ad..6cdd6166 100644 --- a/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_soc.slcp +++ b/examples/snippets/wlan/power_save_deep_sleep/power_save_deep_sleep_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,7 +53,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/select_app/select_app_ncp.slcp b/examples/snippets/wlan/select_app/select_app_ncp.slcp index b5386dae..48e07e36 100644 --- a/examples/snippets/wlan/select_app/select_app_ncp.slcp +++ b/examples/snippets/wlan/select_app/select_app_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/select_app/select_app_soc.slcp b/examples/snippets/wlan/select_app/select_app_soc.slcp index 24e9c8d3..3b5c9b1c 100644 --- a/examples/snippets/wlan/select_app/select_app_soc.slcp +++ b/examples/snippets/wlan/select_app/select_app_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/sntp_client/sntp_client_ncp.slcp b/examples/snippets/wlan/sntp_client/sntp_client_ncp.slcp index f260052e..7aeea0e6 100644 --- a/examples/snippets/wlan/sntp_client/sntp_client_ncp.slcp +++ b/examples/snippets/wlan/sntp_client/sntp_client_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: sntp from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/sntp_client/sntp_client_soc.slcp b/examples/snippets/wlan/sntp_client/sntp_client_soc.slcp index f3ef3cbf..e40f854a 100644 --- a/examples/snippets/wlan/sntp_client/sntp_client_soc.slcp +++ b/examples/snippets/wlan/sntp_client/sntp_client_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: sntp from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/station_ping/app.c b/examples/snippets/wlan/station_ping/app.c index 7d97f808..ec5ea8fc 100644 --- a/examples/snippets/wlan/station_ping/app.c +++ b/examples/snippets/wlan/station_ping/app.c @@ -134,6 +134,17 @@ static void application_start(void *argument) } printf("\r\nWi-Fi client connected\r\n"); +#define GET_STA_TSF 0 +#if GET_STA_TSF + sl_wifi_tsf64_t tsf = { 0 }; + status = sl_wifi_get_sta_tsf(SL_WIFI_2_4GHZ_INTERFACE, &tsf); + if (status != SL_STATUS_OK) { + printf("\r\nGet station TSF failed, Error Code : 0x%lX", status); + } else { + printf("\r\nGet station TSF success: tsf_m=0x%lx, tsf_l=0x%lx\r\n", tsf.tsf_m, tsf.tsf_l); + } +#endif + sl_ip_address_t remote_ip_address = { 0 }; sl_net_inet_addr(REMOTE_IP_ADDRESS, (uint32_t *)&remote_ip_address.ip.v4); remote_ip_address.type = SL_IPV4; diff --git a/examples/snippets/wlan/station_ping/station_ping_ncp.slcp b/examples/snippets/wlan/station_ping/station_ping_ncp.slcp index f3e66ce1..2a083c9c 100644 --- a/examples/snippets/wlan/station_ping/station_ping_ncp.slcp +++ b/examples/snippets/wlan/station_ping/station_ping_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/station_ping/station_ping_soc.slcp b/examples/snippets/wlan/station_ping/station_ping_soc.slcp index c7bea483..6d715153 100644 --- a/examples/snippets/wlan/station_ping/station_ping_soc.slcp +++ b/examples/snippets/wlan/station_ping/station_ping_soc.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -45,7 +45,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/station_ping_v6/station_ping_v6.slcp b/examples/snippets/wlan/station_ping_v6/station_ping_v6.slcp index 71b4adbc..f087e189 100644 --- a/examples/snippets/wlan/station_ping_v6/station_ping_v6.slcp +++ b/examples/snippets/wlan/station_ping_v6/station_ping_v6.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -47,8 +47,8 @@ component: - id: basic_network_config_manager from: wiseconnect3_sdk toolchain_settings: -- option: optimize - value: speed + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_ncp.slcp b/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_ncp.slcp index e70286f2..a23157e1 100644 --- a/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_ncp.slcp +++ b/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_soc.slcp b/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_soc.slcp index d2b4be05..0cc99a50 100644 --- a/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_soc.slcp +++ b/examples/snippets/wlan/three_ssl_concurrent_client_sockets/three_ssl_client_sockets_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/tls_client/tls_client_ncp.slcp b/examples/snippets/wlan/tls_client/tls_client_ncp.slcp index b995f8da..73c55a73 100644 --- a/examples/snippets/wlan/tls_client/tls_client_ncp.slcp +++ b/examples/snippets/wlan/tls_client/tls_client_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/tls_client/tls_client_soc.slcp b/examples/snippets/wlan/tls_client/tls_client_soc.slcp index 4fedf035..659c85c1 100644 --- a/examples/snippets/wlan/tls_client/tls_client_soc.slcp +++ b/examples/snippets/wlan/tls_client/tls_client_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_ncp.slcp b/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_ncp.slcp index 430dd198..711816cb 100644 --- a/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_ncp.slcp +++ b/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_ncp.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_soc.slcp b/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_soc.slcp index 27297f23..88de5e08 100644 --- a/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_soc.slcp +++ b/examples/snippets/wlan/twt_tcp_client/twt_tcp_client_soc.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -55,7 +55,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_ncp.slcp b/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_ncp.slcp index 24adeb37..2cd6da7a 100644 --- a/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_ncp.slcp +++ b/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_ncp.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: sl_si91x_asynchronous_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_soc.slcp b/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_soc.slcp index ec1ccb72..30364b10 100644 --- a/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_soc.slcp +++ b/examples/snippets/wlan/twt_use_case_remote_app/twt_use_case_remote_app_soc.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -49,7 +49,9 @@ component: from: wiseconnect3_sdk - id: sl_si91x_asynchronous_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/user_gain_table/user_gain_table_ncp.slcp b/examples/snippets/wlan/user_gain_table/user_gain_table_ncp.slcp index fbb5d487..2ce7230a 100644 --- a/examples/snippets/wlan/user_gain_table/user_gain_table_ncp.slcp +++ b/examples/snippets/wlan/user_gain_table/user_gain_table_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/user_gain_table/user_gain_table_soc.slcp b/examples/snippets/wlan/user_gain_table/user_gain_table_soc.slcp index 41de72df..e969d668 100644 --- a/examples/snippets/wlan/user_gain_table/user_gain_table_soc.slcp +++ b/examples/snippets/wlan/user_gain_table/user_gain_table_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -46,7 +46,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/wifi6_twt_use_case_demo/app.c b/examples/snippets/wlan/wifi6_twt_use_case_demo/app.c index 6f05166e..68673d06 100644 --- a/examples/snippets/wlan/wifi6_twt_use_case_demo/app.c +++ b/examples/snippets/wlan/wifi6_twt_use_case_demo/app.c @@ -115,7 +115,7 @@ static const sl_wifi_device_configuration_t sl_wifi_twt_client_configuration = { .bt_feature_bit_map = SL_SI91X_BT_RF_TYPE, .ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENTION_VALID - | (SL_SI91X_EXT_TCP_IP_FEAT_SSL_HIGH_PERFORMANCE | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD), + | (SL_SI91X_EXT_FEAT_HTTP_OTAF_SUPPORT | SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD), .ble_feature_bit_map = 0, .ble_ext_feature_bit_map = 0, .config_feature_bit_map = SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP } diff --git a/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_ncp.slcp b/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_ncp.slcp index 561333b2..5b2e296e 100644 --- a/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_ncp.slcp +++ b/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_ncp.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,7 +52,9 @@ component: from: wiseconnect3_sdk - id: sl_si91x_asynchronous_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_soc.slcp b/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_soc.slcp index 96bd2d4a..4bf23a61 100644 --- a/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_soc.slcp +++ b/examples/snippets/wlan/wifi6_twt_use_case_demo/wifi6_twt_use_case_demo_soc.slcp @@ -16,7 +16,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -59,7 +59,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/wlan_rf_test/app.c b/examples/snippets/wlan/wlan_rf_test/app.c index 944cb445..bf5ee350 100644 --- a/examples/snippets/wlan/wlan_rf_test/app.c +++ b/examples/snippets/wlan/wlan_rf_test/app.c @@ -221,7 +221,6 @@ sl_status_t wifi_stats_receive_handler(sl_wifi_event_t event, void *reponse, uin float p = result->crc_pass; float f = result->crc_fail; float t = p + f; - float r = result->cal_rssi; float per_pass = (p * 100 / t); float per_fail = (f * 100 / t); diff --git a/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_ncp.slcp b/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_ncp.slcp index 7609fb3f..c34ae625 100644 --- a/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_ncp.slcp +++ b/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_soc.slcp b/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_soc.slcp index 642af448..50a25a4c 100644 --- a/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_soc.slcp +++ b/examples/snippets/wlan/wlan_rf_test/wlan_rf_test_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -48,7 +48,9 @@ component: from: wiseconnect3_sdk - id: bsd_socket from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_ncp.slcp b/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_ncp.slcp index 1b824aac..cced510c 100644 --- a/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_ncp.slcp +++ b/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_ncp.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -52,8 +52,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float -- option: optimize - value: speed +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_soc.slcp b/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_soc.slcp index 26f116a3..61410251 100644 --- a/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_soc.slcp +++ b/examples/snippets/wlan/wlan_throughput_v6/wlan_throughput_v6_soc.slcp @@ -17,7 +17,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -56,8 +56,8 @@ requires: toolchain_settings: - option: gcc_linker_option value: -u _printf_float -- option: optimize - value: speed +- option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: '1' diff --git a/examples/snippets/wlan_ble/out_of_box_demo/app.c b/examples/snippets/wlan_ble/out_of_box_demo/app.c index 79f14d4a..b323916d 100644 --- a/examples/snippets/wlan_ble/out_of_box_demo/app.c +++ b/examples/snippets/wlan_ble/out_of_box_demo/app.c @@ -38,14 +38,13 @@ #include "sl_wifi.h" #include "sl_wifi_callback_framework.h" #include "cmsis_os2.h" - +#include "sl_si91x_driver.h" //BLE Specific inclusions #include #include "ble_config.h" #include "wifi_config.h" #include "rsi_ble_common_config.h" #include - #include "glib.h" // APP version @@ -59,6 +58,7 @@ extern void sl_wifi_app_task(void); extern void rsi_ble_configurator_task(void *argument); void rsi_ble_configurator_init(void); extern int32_t rsi_wlan_mqtt_certs_init(void); +extern void memlcd_app_init(void); int I2C_Transfer(void); uint8_t magic_word; @@ -94,11 +94,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(1) | SL_SI91X_EXT_EMB_MQTT_ENABLE #ifdef RSI_PROCESS_MAX_RX_DATA diff --git a/examples/snippets/wlan_ble/out_of_box_demo/ble_app.c b/examples/snippets/wlan_ble/out_of_box_demo/ble_app.c index 7884e4c7..986825fd 100644 --- a/examples/snippets/wlan_ble/out_of_box_demo/ble_app.c +++ b/examples/snippets/wlan_ble/out_of_box_demo/ble_app.c @@ -121,7 +121,6 @@ uint8_t data[20] = { 0 }; static volatile uint32_t ble_app_event_map; rsi_ble_event_conn_status_t conn_event_to_app; static rsi_ble_event_disconnect_t disconn_event_to_app; -static uint8_t rsi_ble_app_data[100]; static uint8_t rsi_ble_att1_val_hndl; static uint16_t rsi_ble_att2_val_hndl; static uint16_t rsi_ble_att3_val_hndl; @@ -466,9 +465,11 @@ static void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t *resp_disconn void rsi_ble_on_conn_update_complete_event(rsi_ble_event_conn_update_t *rsi_ble_event_conn_update_complete, uint16_t resp_status) { + UNUSED_PARAMETER(resp_status); rsi_6byte_dev_address_to_ascii(remote_dev_addr, (uint8_t *)rsi_ble_event_conn_update_complete->dev_addr); memcpy(&event_conn_update_complete, rsi_ble_event_conn_update_complete, sizeof(rsi_ble_event_conn_update_t)); rsi_ble_app_set_event(RSI_BLE_CONN_UPDATE_EVENT); + return; } /*============================================================================*/ @@ -780,7 +781,7 @@ void rsi_ble_configurator_task(void *argument) rsi_ble_set_local_att_value(rsi_ble_att2_val_hndl, RSI_BLE_MAX_DATA_LEN, data); sprintf(fw, - "%x%x.%d.%d.%d.%d.%d.%d\r\n", + "%x%x.%d.%d.%d.%d.%d.%d", firmware_version.chip_id, firmware_version.rom_id, firmware_version.major, @@ -792,7 +793,7 @@ void rsi_ble_configurator_task(void *argument) print_firmware_version(&firmware_version); GLIB_drawStringOnLine(&glibContext, "Firmware version:", currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); - GLIB_drawStringOnLine(&glibContext, &fw, currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); + GLIB_drawStringOnLine(&glibContext, fw, currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); DMD_updateDisplay(); osDelay(1000); diff --git a/examples/snippets/wlan_ble/out_of_box_demo/out_of_box_demo.slcp b/examples/snippets/wlan_ble/out_of_box_demo/out_of_box_demo.slcp index cc1f8cbc..3cc192b1 100644 --- a/examples/snippets/wlan_ble/out_of_box_demo/out_of_box_demo.slcp +++ b/examples/snippets/wlan_ble/out_of_box_demo/out_of_box_demo.slcp @@ -12,7 +12,7 @@ filter: value: ["Intermediate"] sdk: {id: gecko_sdk, version: 4.4.0} sdk_extension: -- {id: wiseconnect3_sdk, version: 3.1.1} +- {id: wiseconnect3_sdk, version: 3.1.2} source: - path: app.c - path: main.c diff --git a/examples/snippets/wlan_ble/out_of_box_demo/readme.md b/examples/snippets/wlan_ble/out_of_box_demo/readme.md index 0cf19ce6..d104e7ce 100644 --- a/examples/snippets/wlan_ble/out_of_box_demo/readme.md +++ b/examples/snippets/wlan_ble/out_of_box_demo/readme.md @@ -48,8 +48,8 @@ If a message is published onto the topic from a MQTT client application [https:/ ## Application build environment -It is highly recommended to modify the `CLIENT_ID` parameter from the default value (WIFI-SDK-MQTT-CLIENT) to any other unique string of user's choice in the wifi_app.c file before building and flashing the example. As the test MQTT server limits multiple devices with same CLIENT ID from connecting at the same time. -(wifi_app.c file can be found under the out_of_box_demo folder in the Project Explorer pane) +It is highly recommended to set the CLIENT_ID parameter in the wifi_app.c file to a unique string. As the test MQTT server limits multiple devices with same CLIENT ID from connecting at the same time. +In this version of the out of box demo example, the CLIENT_ID parameter is automatically set to a unique value. ## Test the Application diff --git a/examples/snippets/wlan_ble/out_of_box_demo/wifi_app.c b/examples/snippets/wlan_ble/out_of_box_demo/wifi_app.c index 70ad8f86..b23b84c7 100644 --- a/examples/snippets/wlan_ble/out_of_box_demo/wifi_app.c +++ b/examples/snippets/wlan_ble/out_of_box_demo/wifi_app.c @@ -102,6 +102,8 @@ #include "cacert.pem.h" #include "sl_wifi.h" #include "string.h" +#include "sl_net_dns.h" +#include "sl_net_ping.h" /****************************************************** * Constants @@ -192,6 +194,7 @@ void mqtt_client_error_event_handler(void *client, sl_mqtt_client_error_status_t void mqtt_client_cleanup(); void print_char_buffer(char *buffer, uint32_t buffer_length); sl_status_t mqtt_example(); +void memlcd_app_init(void); /* ********************************************************************************************************* * LOCAL GLOBAL VARIABLES @@ -203,7 +206,7 @@ static volatile bool scan_complete = false; static volatile sl_status_t callback_status = SL_STATUS_OK; uint16_t scanbuf_size = (sizeof(sl_wifi_scan_result_t) + (SL_WIFI_MAX_SCANNED_AP * sizeof(scan_result->scan_info[0]))); -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; //MQTT related variables uint8_t connected = 0, timeout = 0; @@ -293,6 +296,7 @@ extern void sl_wifi_app_send_to_ble(uint16_t msg_type, uint8_t *data, uint16_t d extern uint8_t coex_ssid[50], pwd[34], sec_type; void m4_sleep_wakeup(void); void wakeup_source_config(void); +void lcd_mac(void); uint8_t conn_status; extern uint8_t magic_word; @@ -462,6 +466,7 @@ sl_status_t network_event_handler(sl_net_event_t event, sl_status_t status, void switch (event) { case SL_NET_PING_RESPONSE_EVENT: { sl_si91x_ping_response_t *response = (sl_si91x_ping_response_t *)data; + UNUSED_VARIABLE(response); if (status != SL_STATUS_OK) { printf("\r\nPing request unsuccessful\r\n"); return status; @@ -469,6 +474,8 @@ sl_status_t network_event_handler(sl_net_event_t event, sl_status_t status, void printf("\r\nPing response from www.silabs.com \r\n"); break; } + default: + break; } return SL_STATUS_OK; @@ -483,6 +490,8 @@ void ping_silabs() remote_ip_address.type = SL_IPV4; + UNUSED_VARIABLE(remote_ip_address); + sl_ip_address_t dns_query_rsp = { 0 }; uint32_t server_address; int32_t dns_retry_count = MAX_DNS_RETRY_COUNT; @@ -495,7 +504,7 @@ void ping_silabs() } while ((dns_retry_count != 0) && (status != SL_STATUS_OK)); if (status != SL_STATUS_OK) { - printf("\r\nUnexpected error while resolving dns, Error 0x%X\r\n", status); + printf("\r\nUnexpected error while resolving dns, Error 0x%lX\r\n", status); return; } @@ -533,6 +542,7 @@ void mqtt_client_cleanup() void mqtt_client_message_handler(void *client, sl_mqtt_client_message_t *message, void *context) { UNUSED_PARAMETER(context); + UNUSED_PARAMETER(client); wireless_wkp_triggered = 1; printf("Message Received on Topic: "); print_char_buffer((char *)message->topic, message->topic_length); @@ -660,6 +670,8 @@ sl_status_t mqtt_example() remote_ip_address.type = SL_IPV4; + UNUSED_VARIABLE(remote_ip_address); + sl_ip_address_t dns_query_rsp = { 0 }; uint32_t server_address; int32_t dns_retry_count = MAX_DNS_RETRY_COUNT; @@ -672,7 +684,7 @@ sl_status_t mqtt_example() } while ((dns_retry_count != 0) && (status != SL_STATUS_OK)); if (status != SL_STATUS_OK) { - printf("\r\nUnexpected error while resolving dns, Error 0x%X\r\n", status); + printf("\r\nUnexpected error while resolving dns, Error 0x%lX\r\n", status); } server_address = dns_query_rsp.ip.v4.value; @@ -687,6 +699,22 @@ sl_status_t mqtt_example() mqtt_broker_configuration.ip.ip.v4.value = dns_query_rsp.ip.v4.value; + sl_mac_address_t mac_addr = { 0 }; + char mac_id[18]; + char client_id[25]; + sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &mac_addr); + sprintf(mac_id, + "%x:%x:%x:%x:%x:%x", + mac_addr.octet[0], + mac_addr.octet[1], + mac_addr.octet[2], + mac_addr.octet[3], + mac_addr.octet[4], + mac_addr.octet[5]); + int mac_id_len = strlen(mac_id); + mqtt_client_configuration.client_id = mac_id; + mqtt_client_configuration.client_id_length = strlen(mqtt_client_configuration.client_id); + status = sl_mqtt_client_connect(&client, &mqtt_broker_configuration, &last_will_message, &mqtt_client_configuration, 0); if (status != SL_STATUS_IN_PROGRESS) { @@ -918,7 +946,7 @@ void sl_wifi_app_task(void) fetch_ip->bytes[3]); printf("\r\nIP Address:%s \r\n", ip_add); GLIB_drawStringOnLine(&glibContext, "IP Address:", currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); - GLIB_drawStringOnLine(&glibContext, &ip_add, currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); + GLIB_drawStringOnLine(&glibContext, ip_add, currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); DMD_updateDisplay(); osDelay(1000); @@ -977,7 +1005,7 @@ void sl_wifi_app_task(void) rc = sl_wifi_set_performance_profile(&performance_profile); if (rc != SL_STATUS_OK) { - printf("\r\nPower save configuration Failed, Error Code : 0x%X\r\n", rc); + printf("\r\nPower save configuration Failed, Error Code : 0x%lX\r\n", rc); } printf("\r\nAssociated Power Save Enabled\n"); @@ -1102,7 +1130,7 @@ void m4_sleep_wakeup(void) printf("\r\nM4 Wake Up\r\n"); //Re-init of LCD - struct sl_memlcd_t *device1; + const struct sl_memlcd_t *device1; device1 = sl_memlcd_get(); sl_memlcd_clear(device1); @@ -1201,7 +1229,7 @@ void memlcd_app_init(void) void lcd_mac(void) { GLIB_drawStringOnLine(&glibContext, "MAC ID:", currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); - GLIB_drawStringOnLine(&glibContext, &mac_id, currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); + GLIB_drawStringOnLine(&glibContext, mac_id, currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); GLIB_drawStringOnLine(&glibContext, " ", currentLine++, GLIB_ALIGN_LEFT, 5, 5, true); DMD_updateDisplay(); } diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/app.c b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/app.c index add3442b..cdb60cb5 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/app.c +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/app.c @@ -79,11 +79,7 @@ static const sl_wifi_device_configuration_t | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif // SLI_SI917 | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), //!ENABLE_BLE_PROTOCOL in bt_feature_bit_map .ble_feature_bit_map = diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_app.c b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_app.c index 51adae22..209e0349 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_app.c +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_app.c @@ -71,34 +71,24 @@ #define RSI_BLE_ATT_PROPERTY_WRITE 0x08 #define RSI_BLE_ATT_PROPERTY_NOTIFY 0x10 -// local device IO capability -#define RSI_BLE_SMP_IO_CAPABILITY 0x00 -#define RSI_BLE_SMP_PASSKEY 0 - // application event list -#define RSI_BLE_ENH_CONN_EVENT 0x01 -#define RSI_BLE_DISCONN_EVENT 0x02 -#define RSI_BLE_SMP_REQ_EVENT 0x05 -#define RSI_BLE_WLAN_SCAN_RESP 0x03 -#define RSI_BLE_WLAN_JOIN_STATUS 0x15 - -#define RSI_BLE_SMP_RESP_EVENT 0x06 -#define RSI_BLE_SMP_PASSKEY_EVENT 0x07 -#define RSI_BLE_SMP_FAILED_EVENT 0x08 -#define RSI_BLE_ENCRYPT_STARTED_EVENT 0x09 - -#define RSI_BLE_WLAN_DISCONNECT_STATUS 0x14 -#define RSI_CUSTOMERID_EVENT 0x0B -#define RSI_CUSTOMERID_EVENT1 0x0C -#define RSI_SSID 0x0D -#define RSI_SECTYPE 0x0E -#define RSI_BLE_WLAN_DISCONN_NOTIFY 0x0F -#define RSI_WLAN_ALREADY 0x10 -#define RSI_WLAN_NOT_ALREADY 0x11 -#define RSI_BLE_WLAN_TIMEOUT_NOTIFY 0x12 -#define RSI_APP_FW_VERSION 0x13 - -#define RSI_FW_VERSION 0x01 +#define RSI_BLE_ENH_CONN_EVENT 0x01 +#define RSI_BLE_DISCONN_EVENT 0x02 +#define RSI_BLE_WLAN_SCAN_RESP 0x03 + +#define RSI_SSID 0x0D +#define RSI_SECTYPE 0x0E +#define RSI_BLE_WLAN_DISCONN_NOTIFY 0x0F +#define RSI_WLAN_ALREADY 0x10 +#define RSI_WLAN_NOT_ALREADY 0x11 +#define RSI_BLE_WLAN_TIMEOUT_NOTIFY 0x12 +#define RSI_APP_FW_VERSION 0x13 +#define RSI_BLE_WLAN_DISCONNECT_STATUS 0x14 +#define RSI_BLE_WLAN_JOIN_STATUS 0x15 +#define RSI_BLE_MTU_EVENT 0x16 +#define RSI_BLE_CONN_UPDATE_EVENT 0x17 +#define RSI_BLE_RECEIVE_REMOTE_FEATURES 0x18 +#define RSI_BLE_DATA_LENGTH_CHANGE 0x19 // Maximum length of SSID #define RSI_SSID_LEN 34 @@ -117,7 +107,6 @@ uint8_t data[20] = { 0 }; static volatile uint32_t ble_app_event_map; static rsi_ble_event_conn_status_t conn_event_to_app; static rsi_ble_event_disconnect_t disconn_event_to_app; -static uint8_t rsi_ble_app_data[100]; static uint8_t rsi_ble_att1_val_hndl; static uint16_t rsi_ble_att2_val_hndl; static uint16_t rsi_ble_att3_val_hndl; @@ -126,6 +115,12 @@ uint8_t pwd[RSI_BLE_MAX_DATA_LEN]; uint8_t sec_type; sl_wifi_scan_result_t *scanresult = NULL; +uint8_t remote_dev_addr[18] = { 0 }; +static rsi_ble_event_mtu_t app_ble_mtu_event; +static rsi_ble_event_conn_update_t event_conn_update_complete; +static rsi_ble_event_remote_features_t remote_dev_feature; +static rsi_ble_event_data_length_update_t updated_data_len_params; + extern uint8_t connected, disassosiated; extern uint8_t retry; extern sl_net_ip_configuration_t ip_address; @@ -385,7 +380,7 @@ static int32_t rsi_ble_app_get_event(void) /** * @fn rsi_ble_on_enhance_conn_status_event * @brief invoked when enhanced connection complete event is received - * @param[out] resp_conn, connected remote device information + * @param[out] resp_enh_conn, connected remote device information * @return none. * @section description * This callback function indicates the status of the connection @@ -419,8 +414,8 @@ static void rsi_ble_on_connect_event(rsi_ble_event_conn_status_t *resp_conn) /** * @fn rsi_ble_on_disconnect_event * @brief invoked when disconnection event is received - * @param[in] resp_disconnect, disconnected remote device information - * @param[in] reason, reason for disconnection. + * @param[out] resp_disconnect, disconnected remote device information + * @param[out] reason, reason for disconnection. * @return none. * @section description * This Callback function indicates disconnected device information and status @@ -434,91 +429,74 @@ static void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t *resp_disconn /*==============================================*/ /** - * @fn rsi_ble_on_smp_request - * @brief its invoked when smp request event is received. - * @param[in] remote_dev_address, it indicates remote bd address. - * @return none. - * @section description - * This callback function is invoked when SMP request events is received(we are in Central mode) - * Note: Peripheral requested to start SMP request, we have to send SMP request command - */ -void rsi_ble_on_smp_request(rsi_bt_event_smp_req_t *remote_dev_address) -{ - UNUSED_PARAMETER(remote_dev_address); - rsi_ble_app_set_event(RSI_BLE_SMP_REQ_EVENT); -} - -/*==============================================*/ -/** - * @fn rsi_ble_on_smp_response - * @brief its invoked when smp response event is received. - * @param[in] remote_dev_address, it indicates remote bd address. + * @fn rsi_ble_on_conn_update_complete_event + * @brief invoked when conn update complete event is received + * @param[out] rsi_ble_event_conn_update_complete contains the controller + * support conn information. + * @param[out] resp_status contains the response status (Success or Error code) * @return none. * @section description - * This callback function is invoked when SMP response events is received(we are in Peripheral mode) - * Note: Central initiated SMP protocol, we have to send SMP response command + * This Callback function indicates the conn update complete event is received */ -void rsi_ble_on_smp_response(rsi_bt_event_smp_resp_t *remote_dev_address) +void rsi_ble_on_conn_update_complete_event(rsi_ble_event_conn_update_t *rsi_ble_event_conn_update_complete, + uint16_t resp_status) { - UNUSED_PARAMETER(remote_dev_address); - rsi_ble_app_set_event(RSI_BLE_SMP_RESP_EVENT); + UNUSED_PARAMETER(resp_status); + rsi_6byte_dev_address_to_ascii(remote_dev_addr, (uint8_t *)rsi_ble_event_conn_update_complete->dev_addr); + memcpy(&event_conn_update_complete, rsi_ble_event_conn_update_complete, sizeof(rsi_ble_event_conn_update_t)); + rsi_ble_app_set_event(RSI_BLE_CONN_UPDATE_EVENT); } -/*==============================================*/ +/*============================================================================*/ /** - * @fn rsi_ble_on_smp_passkey - * @brief its invoked when smp passkey event is received. - * @param[in] remote_dev_address, it indicates remote bd address. + * @fn rsi_ble_on_remote_features_event + * @brief invoked when LE remote features event is received. + * @param[out] rsi_ble_event_remote_features, connected remote device information * @return none. * @section description - * This callback function is invoked when SMP passkey events is received - * Note: We have to send SMP passkey command + * This callback function indicates the remote device features */ -void rsi_ble_on_smp_passkey(rsi_bt_event_smp_passkey_t *remote_dev_address) +void rsi_ble_on_remote_features_event(rsi_ble_event_remote_features_t *rsi_ble_event_remote_features) { - UNUSED_PARAMETER(remote_dev_address); - rsi_ble_app_set_event(RSI_BLE_SMP_PASSKEY_EVENT); + memcpy(&remote_dev_feature, rsi_ble_event_remote_features, sizeof(rsi_ble_event_remote_features_t)); + rsi_ble_app_set_event(RSI_BLE_RECEIVE_REMOTE_FEATURES); } -/*==============================================*/ +/*============================================================================*/ /** - * @fn rsi_ble_on_smp_failed - * @brief its invoked when smp failed event is received. - * @param[in] remote_dev_address, it indicates remote bd address. - * @return none. + * @fn rsi_ble_data_length_change_event + * @brief invoked when data length is set + * @param[out] rsi_ble_data_length_update, data length information * @section description - * This callback function is invoked when SMP failed events is received + * This Callback function indicates data length is set */ -void rsi_ble_on_smp_failed(uint16_t status, rsi_bt_event_smp_failed_t *remote_dev_address) +void rsi_ble_data_length_change_event(rsi_ble_event_data_length_update_t *rsi_ble_data_length_update) { - UNUSED_PARAMETER(remote_dev_address); - UNUSED_PARAMETER(status); - rsi_ble_app_set_event(RSI_BLE_SMP_FAILED_EVENT); + memcpy(&updated_data_len_params, rsi_ble_data_length_update, sizeof(rsi_ble_event_data_length_update_t)); + rsi_ble_app_set_event(RSI_BLE_DATA_LENGTH_CHANGE); } - /*==============================================*/ /** - * @fn rsi_ble_on_encrypt_started - * @brief its invoked when encryption started event is received. - * @param[in] remote_dev_address, it indicates remote bd address. + * @fn rsi_ble_on_mtu_event + * @brief invoked when an MTU size event is received + * @param[out] rsi_ble_mtu, it indicates MTU size. * @return none. * @section description - * This callback function is invoked when encryption started events is received + * This callback function is invoked when an MTU size event is received */ -void rsi_ble_on_encrypt_started(uint16_t status, rsi_bt_event_encryption_enabled_t *enc_enabled) +static void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t *rsi_ble_mtu) { - UNUSED_PARAMETER(enc_enabled); - UNUSED_PARAMETER(status); - - rsi_ble_app_set_event(RSI_BLE_ENCRYPT_STARTED_EVENT); + memcpy(&app_ble_mtu_event, rsi_ble_mtu, sizeof(rsi_ble_event_mtu_t)); + rsi_6byte_dev_address_to_ascii(remote_dev_addr, app_ble_mtu_event.dev_addr); + rsi_ble_app_set_event(RSI_BLE_MTU_EVENT); } /*==============================================*/ /** * @fn rsi_ble_on_gatt_write_event * @brief this is call back function, it invokes when write/notify events received. - * @param[in] event_id, it indicates write/notification event id. - * @param[in] rsi_ble_write, write event parameters. + * @param[out] event_id, it indicates write/notification event id. + * @param[out] rsi_ble_write, write event parameters. * @return none. * @section description * This is a callback function @@ -554,7 +532,7 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t // Sending Security type case '5': //else if(rsi_ble_write->att_value[0] == '5') { - sec_type = 2; //rsi_ble_write->att_value[3]; // FixMe: Getting wrong sec_type from ble app + sec_type = ((rsi_ble_write->att_value[3]) - '0'); LOG_PRINT("In Security Request\n"); rsi_ble_app_set_event(RSI_SECTYPE); @@ -627,11 +605,13 @@ void rsi_ble_configurator_init(void) rsi_ble_on_disconnect_event, NULL, NULL, - NULL, + rsi_ble_data_length_change_event, rsi_ble_on_enhance_conn_status_event, NULL, - NULL, + rsi_ble_on_conn_update_complete_event, NULL); + //! registering the GAP extended call back functions + rsi_ble_gap_extended_register_callbacks(rsi_ble_on_remote_features_event, NULL); // registering the GATT callback functions rsi_ble_gatt_register_callbacks(NULL, @@ -645,7 +625,7 @@ void rsi_ble_configurator_init(void) NULL, NULL, NULL, - NULL, + rsi_ble_on_mtu_event, NULL, NULL, NULL, @@ -658,18 +638,6 @@ void rsi_ble_configurator_init(void) NULL, NULL); - rsi_ble_smp_register_callbacks(rsi_ble_on_smp_request, // registering the SMP call back functions - rsi_ble_on_smp_response, - rsi_ble_on_smp_passkey, - rsi_ble_on_smp_failed, - rsi_ble_on_encrypt_started, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - // Set local name rsi_bt_set_local_name((uint8_t *)RSI_BLE_APP_DEVICE_NAME); @@ -683,6 +651,7 @@ void rsi_ble_configurator_init(void) // set device in advertising mode. rsi_ble_start_advertising(); + LOG_PRINT("\r\nBLE Advertising Started...\r\n"); } /*==============================================*/ @@ -730,9 +699,15 @@ void rsi_ble_configurator_task(void *argument) //MTU exchange status = rsi_ble_mtu_exchange_event(conn_event_to_app.dev_addr, BLE_MTU_SIZE); if (status != RSI_SUCCESS) { - LOG_PRINT("\n rsi_ble_mtu_exchange_event command failed : %lx", status); - } else { - LOG_PRINT("\n rsi_ble_mtu_exchange_event command success \n"); + LOG_PRINT("\n MTU request failed with error code %lx", status); + } + status = rsi_ble_conn_params_update(conn_event_to_app.dev_addr, + CONN_INTERVAL_DEFAULT_MIN, + CONN_INTERVAL_DEFAULT_MAX, + CONNECTION_LATENCY, + SUPERVISION_TIMEOUT); + if (status != RSI_SUCCESS) { + LOG_PRINT("\n rsi_ble_conn_params_update command failed : %lx", status); } } break; @@ -741,33 +716,18 @@ void rsi_ble_configurator_task(void *argument) // clear the served event rsi_ble_app_clear_event(RSI_BLE_DISCONN_EVENT); + LOG_PRINT("\r\nDisconnected - remote_dev_addr : %s\r\n", + rsi_6byte_dev_address_to_ascii(remote_dev_addr, disconn_event_to_app.dev_addr)); // set device in advertising mode. adv: -// These lines are commented to avoid wlan disconnection if ble is disconnected. -#if 0 - if (connected) { - LOG_PRINT("disconnect command is passed\n"); - memset(data, 0, RSI_BLE_MAX_DATA_LEN); - sl_wifi_app_set_event(RSI_WLAN_DISCONN_NOTIFY_STATE); - } -#endif status = rsi_ble_start_advertising(); if (status != RSI_SUCCESS) { goto adv; + } else { + LOG_PRINT("\r\nStarted Advertising \n"); } } break; - - case SL_BLE_GATT_WRITE_EVENT: { - // event invokes when write/notification events received - - // clear the served event - rsi_ble_app_clear_event(SL_BLE_GATT_WRITE_EVENT); - - // set the local attribute value. - rsi_ble_set_local_att_value(rsi_ble_att2_val_hndl, RSI_BLE_MAX_DATA_LEN, rsi_ble_app_data); - } break; - case RSI_APP_FW_VERSION: { sl_wifi_firmware_version_t firmware_version = { 0 }; @@ -834,7 +794,7 @@ void rsi_ble_configurator_task(void *argument) case RSI_SECTYPE: { rsi_ble_app_clear_event(RSI_SECTYPE); - if (sec_type == '0') { + if (sec_type == 0) { sl_wifi_app_set_event(SL_WIFI_JOIN_STATE); } } break; @@ -902,6 +862,34 @@ void rsi_ble_configurator_task(void *argument) data); // set the local attribute value. LOG_PRINT("AP joined successfully\n\n"); } break; + case RSI_BLE_MTU_EVENT: { + //! clear the served event + rsi_ble_app_clear_event(RSI_BLE_MTU_EVENT); + //! event invokes when write/notification events received + } break; + case RSI_BLE_CONN_UPDATE_EVENT: { + rsi_ble_app_clear_event(RSI_BLE_CONN_UPDATE_EVENT); + + } break; + case RSI_BLE_RECEIVE_REMOTE_FEATURES: { + //! clear the served event + rsi_ble_app_clear_event(RSI_BLE_RECEIVE_REMOTE_FEATURES); + + if (remote_dev_feature.remote_features[0] & 0x20) { + status = rsi_ble_set_data_len(conn_event_to_app.dev_addr, TX_LEN, TX_TIME); + if (status != RSI_SUCCESS) { + LOG_PRINT("\n set data length cmd failed with error code = " + "%lx \n", + status); + rsi_ble_app_set_event(RSI_BLE_RECEIVE_REMOTE_FEATURES); + } + } + + } break; + case RSI_BLE_DATA_LENGTH_CHANGE: { + //! clear the served event + rsi_ble_app_clear_event(RSI_BLE_DATA_LENGTH_CHANGE); + } break; default: break; } diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_config.h b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_config.h index 7acb5fa7..f8c2c970 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_config.h +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/ble_config.h @@ -60,6 +60,10 @@ #define BLE_MTU_SIZE 232 +//! Tx Datalength parameters +#define TX_LEN 0xFB +#define TX_TIME 0x0148 + /*=======================================================================*/ // Advertising command parameters /*=======================================================================*/ @@ -144,11 +148,12 @@ #define LE_SCAN_INTERVAL 0x0100 #define LE_SCAN_WINDOW 0x0050 -#define CONNECTION_INTERVAL_MIN 0x00A0 -#define CONNECTION_INTERVAL_MAX 0x00A0 - -#define CONNECTION_LATENCY 0x0000 -#define SUPERVISION_TIMEOUT 0x07D0 //2000 +#define CONNECTION_INTERVAL_MIN 0x320 //0x08 +#define CONNECTION_INTERVAL_MAX 0x320 //0x08 +#define CONN_INTERVAL_DEFAULT_MIN 0x18 +#define CONN_INTERVAL_DEFAULT_MAX 0x18 +#define SUPERVISION_TIMEOUT 400 +#define CONNECTION_LATENCY 0 /*=======================================================================*/ diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/readme.md b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/readme.md index 0f91bd04..63e2684a 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/readme.md +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/readme.md @@ -60,7 +60,7 @@ SiWx91x is configured as a WiFi station and connects to an Access Point. - WLAN Station BLE Provisioning with windows based Silicon Labs Connect App - ![](resources/readme/bleprovisioningsetup_soc_ncp.png) + ![](resources/readme/image279wsbpa.png) ## Getting Started @@ -109,12 +109,13 @@ Open `ble_app.c` file and update/modify following macros #define RSI_BLE_MAX_DATA_LEN 66 + +**The following are the **non-configurable** macros in the application.** + `RSI_BLE_APP_DEVICE_NAME` refers to the name of the SiWx91x EVK to appear during scanning by remote devices. #define RSI_BLE_APP_DEVICE_NAME "BLE_CONFIGURATOR" -The following are the **non-configurable** macros in the application. - `RSI_BLE_ATT_PROPERTY_READ` is used to set the READ property to an attribute value. #define RSI_BLE_ATT_PROPERTY_READ 0x02 @@ -139,7 +140,7 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Steps to be followed to verify WLAN Station BLE Provisioning with Android **EFR Connect** App -1. Configure the Access point in OPEN/WPA-PSK/WPA2-PSK mode to connect the SiWx91x in STA mode. +1. Configure the Access point in OPEN/WPA-PSK/WPA2-PSK/WPA3 mode to connect the SiWx91x in STA mode. 2. Connect any serial console for prints. @@ -177,4 +178,3 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise ![](resources/readme/output2.png) -![](resources/readme/output3.png) diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output1.png b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output1.png index 62f58a14..b485407d 100644 Binary files a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output1.png and b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output1.png differ diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output2.png b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output2.png index e902fe20..41eae4c4 100644 Binary files a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output2.png and b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output2.png differ diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output3.png b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output3.png deleted file mode 100644 index 3e0d8b4d..00000000 Binary files a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/resources/readme/output3.png and /dev/null differ diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_ncp.slcp b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_ncp.slcp index a9c78e02..72ea7986 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_ncp.slcp +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_ncp.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,7 +53,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" @@ -69,7 +71,6 @@ other_file: - path: resources/readme/image279wsbpancp.png - path: resources/readme/output1.png - path: resources/readme/output2.png - - path: resources/readme/output3.png - path: resources/readme/remote_screen1.png - path: resources/readme/remote_screen2.png - path: resources/readme/remote_screen3.png diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_soc.slcp b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_soc.slcp index d0cee2c0..def7244a 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_soc.slcp +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning/wifi_station_ble_provisioning_soc.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -53,7 +53,9 @@ component: from: wiseconnect3_sdk - id: basic_network_config_manager from: wiseconnect3_sdk -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" @@ -65,7 +67,6 @@ other_file: - path: resources/readme/image279wsbpancp.png - path: resources/readme/output1.png - path: resources/readme/output2.png - - path: resources/readme/output3.png - path: resources/readme/remote_screen1.png - path: resources/readme/remote_screen2.png - path: resources/readme/remote_screen3.png diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/app.c b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/app.c index 865bcfd7..a71d42ff 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/app.c +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/app.c @@ -37,14 +37,14 @@ #include "sl_wifi.h" #include "sl_wifi_callback_framework.h" #include "cmsis_os2.h" - +#include "sl_si91x_driver.h" //BLE Specific inclusions #include #include "ble_config.h" #include "rsi_ble_common_config.h" #include -#ifdef v +#if (defined(SLI_SI91X_MCU_INTERFACE) && I2C_SENSOR_PERI_ENABLE) #include "i2c_leader_example.h" #endif @@ -92,11 +92,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = (SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(1) #ifdef RSI_PROCESS_MAX_RX_DATA @@ -173,17 +169,17 @@ void rsi_wlan_ble_app_init(void *argument) LOG_PRINT("\r\nWi-Fi Initialization Failed, Error Code : 0x%lX\r\n", status); return; } - LOG_PRINT("\r\n Wi-Fi Initialization Success\n"); + LOG_PRINT("\r\n Wi-Fi Initialization Success\r\n"); wlan_thread_sem = osSemaphoreNew(1, 0, NULL); if (wlan_thread_sem == NULL) { - LOG_PRINT("Failed to create wlan_thread_sem\n"); + LOG_PRINT("Failed to create wlan_thread_sem\r\n"); return; } ble_thread_sem = osSemaphoreNew(1, 0, NULL); if (ble_thread_sem == NULL) { - LOG_PRINT("Failed to create ble_thread_sem\n"); + LOG_PRINT("Failed to create ble_thread_sem\r\n"); return; } @@ -198,7 +194,7 @@ void rsi_wlan_ble_app_init(void *argument) #endif if (osThreadNew((osThreadFunc_t)rsi_ble_configurator_task, NULL, &ble_thread_attributes) == NULL) { - LOG_PRINT("Failed to create BLE thread\n"); + LOG_PRINT("Failed to create BLE thread\r\n"); } status = rsi_wlan_mqtt_certs_init(); diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_app.c b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_app.c index dccf8b96..7293833c 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_app.c +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_app.c @@ -40,7 +40,6 @@ #include "sl_net_ip_types.h" #include "cmsis_os2.h" #include "sl_utility.h" - // BLE include file to refer BLE APIs #include #include @@ -71,32 +70,24 @@ #define RSI_BLE_ATT_PROPERTY_WRITE 0x08 #define RSI_BLE_ATT_PROPERTY_NOTIFY 0x10 -// local device IO capability -#define RSI_BLE_SMP_IO_CAPABILITY 0x00 -#define RSI_BLE_SMP_PASSKEY 0 - // application event list -#define RSI_BLE_ENH_CONN_EVENT 0x01 -#define RSI_BLE_DISCONN_EVENT 0x02 -#define RSI_BLE_SMP_REQ_EVENT 0x05 -#define RSI_BLE_WLAN_SCAN_RESP 0x03 -#define RSI_BLE_WLAN_JOIN_STATUS 0x15 - -#define RSI_BLE_SMP_RESP_EVENT 0x06 -#define RSI_BLE_SMP_PASSKEY_EVENT 0x07 -#define RSI_BLE_SMP_FAILED_EVENT 0x08 -#define RSI_BLE_ENCRYPT_STARTED_EVENT 0x09 - -#define RSI_BLE_WLAN_DISCONNECT_STATUS 0x14 -#define RSI_CUSTOMERID_EVENT 0x0B -#define RSI_CUSTOMERID_EVENT1 0x0C -#define RSI_SSID 0x0D -#define RSI_SECTYPE 0x0E -#define RSI_BLE_WLAN_DISCONN_NOTIFY 0x0F -#define RSI_WLAN_ALREADY 0x10 -#define RSI_WLAN_NOT_ALREADY 0x11 -#define RSI_BLE_WLAN_TIMEOUT_NOTIFY 0x12 -#define RSI_APP_FW_VERSION 0x13 +#define RSI_BLE_ENH_CONN_EVENT 0x01 +#define RSI_BLE_DISCONN_EVENT 0x02 +#define RSI_BLE_WLAN_SCAN_RESP 0x03 + +#define RSI_SSID 0x0D +#define RSI_SECTYPE 0x0E +#define RSI_BLE_WLAN_DISCONN_NOTIFY 0x0F +#define RSI_WLAN_ALREADY 0x10 +#define RSI_WLAN_NOT_ALREADY 0x11 +#define RSI_BLE_WLAN_TIMEOUT_NOTIFY 0x12 +#define RSI_APP_FW_VERSION 0x13 +#define RSI_BLE_WLAN_DISCONNECT_STATUS 0x14 +#define RSI_BLE_WLAN_JOIN_STATUS 0x15 +#define RSI_BLE_MTU_EVENT 0x16 +#define RSI_BLE_CONN_UPDATE_EVENT 0x17 +#define RSI_BLE_RECEIVE_REMOTE_FEATURES 0x18 +#define RSI_BLE_DATA_LENGTH_CHANGE 0x19 #define RSI_FW_VERSION 0x01 @@ -108,11 +99,12 @@ #define RSI_AP_SCANNED_MAX 11 //! connection update param -#define CONN_INTERVAL_MIN 0x320 //0x08 -#define CONN_INTERVAL_MAX 0x320 //0x08 -#define CONN_INTERVAL_DEFAULT_MIN 0xC8 -#define CONN_INTERVAL_DEFAULT_MAX 0xC8 -#define CONN_LATENCY 0 +#define CONN_INTERVAL_MIN 0x320 //0x08 +#define CONN_INTERVAL_MAX 0x320 //0x08 +#define CONN_INTERVAL_DEFAULT_MIN 0x18 +#define CONN_INTERVAL_DEFAULT_MAX 0x18 +#define SUPERVISION_TIMEOUT_DEFAULT 400 +#define CONN_LATENCY 0 /******************************************************************************************************** * DATA TYPES @@ -124,13 +116,17 @@ uint8_t data[20] = { 0 }; static volatile uint32_t ble_app_event_map; rsi_ble_event_conn_status_t conn_event_to_app; static rsi_ble_event_disconnect_t disconn_event_to_app; -static uint8_t rsi_ble_app_data[100]; static uint8_t rsi_ble_att1_val_hndl; static uint16_t rsi_ble_att2_val_hndl; static uint16_t rsi_ble_att3_val_hndl; uint8_t coex_ssid[50]; uint8_t pwd[RSI_BLE_MAX_DATA_LEN]; uint8_t sec_type; +uint8_t remote_dev_addr[18] = { 0 }; +static rsi_ble_event_mtu_t app_ble_mtu_event; +static rsi_ble_event_conn_update_t event_conn_update_complete; +static rsi_ble_event_remote_features_t remote_dev_feature; +static rsi_ble_event_data_length_update_t updated_data_len_params; sl_wifi_scan_result_t *scanresult = NULL; @@ -394,7 +390,7 @@ static int32_t rsi_ble_app_get_event(void) /** * @fn rsi_ble_on_enhance_conn_status_event * @brief invoked when enhanced connection complete event is received - * @param[out] resp_conn, connected remote device information + * @param[out] resp_enh_conn, connected remote device information * @return none. * @section description * This callback function indicates the status of the connection @@ -403,7 +399,6 @@ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t *r { conn_event_to_app.dev_addr_type = resp_enh_conn->dev_addr_type; memcpy(conn_event_to_app.dev_addr, resp_enh_conn->dev_addr, RSI_DEV_ADDR_LEN); - conn_event_to_app.status = resp_enh_conn->status; rsi_ble_app_set_event(RSI_BLE_ENH_CONN_EVENT); } @@ -420,7 +415,6 @@ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t *r static void rsi_ble_on_connect_event(rsi_ble_event_conn_status_t *resp_conn) { memcpy(&conn_event_to_app, resp_conn, sizeof(rsi_ble_event_conn_status_t)); - rsi_ble_app_set_event(RSI_BLE_ENH_CONN_EVENT); } @@ -428,8 +422,8 @@ static void rsi_ble_on_connect_event(rsi_ble_event_conn_status_t *resp_conn) /** * @fn rsi_ble_on_disconnect_event * @brief invoked when disconnection event is received - * @param[in] resp_disconnect, disconnected remote device information - * @param[in] reason, reason for disconnection. + * @param[out] resp_disconnect, disconnected remote device information + * @param[out] reason, reason for disconnection. * @return none. * @section description * This Callback function indicates disconnected device information and status @@ -443,91 +437,73 @@ static void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t *resp_disconn /*==============================================*/ /** - * @fn rsi_ble_on_smp_request - * @brief its invoked when smp request event is received. - * @param[in] remote_dev_address, it indicates remote bd address. - * @return none. - * @section description - * This callback function is invoked when SMP request events is received(we are in Master mode) - * Note: slave requested to start SMP request, we have to send SMP request command - */ -void rsi_ble_on_smp_request(rsi_bt_event_smp_req_t *remote_dev_address) -{ - UNUSED_PARAMETER(remote_dev_address); - rsi_ble_app_set_event(RSI_BLE_SMP_REQ_EVENT); -} - -/*==============================================*/ -/** - * @fn rsi_ble_on_smp_response - * @brief its invoked when smp response event is received. - * @param[in] remote_dev_address, it indicates remote bd address. + * @fn rsi_ble_on_conn_update_complete_event + * @brief invoked when conn update complete event is received + * @param[out] rsi_ble_event_conn_update_complete contains the controller + * support conn information. + * @param[out] resp_status contains the response status (Success or Error code) * @return none. * @section description - * This callback function is invoked when SMP response events is received(we are in slave mode) - * Note: Master initiated SMP protocol, we have to send SMP response command + * This Callback function indicates the conn update complete event is received */ -void rsi_ble_on_smp_response(rsi_bt_event_smp_resp_t *remote_dev_address) +void rsi_ble_on_conn_update_complete_event(rsi_ble_event_conn_update_t *rsi_ble_event_conn_update_complete, + uint16_t resp_status) { - UNUSED_PARAMETER(remote_dev_address); - rsi_ble_app_set_event(RSI_BLE_SMP_RESP_EVENT); + UNUSED_PARAMETER(resp_status); + rsi_6byte_dev_address_to_ascii(remote_dev_addr, (uint8_t *)rsi_ble_event_conn_update_complete->dev_addr); + memcpy(&event_conn_update_complete, rsi_ble_event_conn_update_complete, sizeof(rsi_ble_event_conn_update_t)); + rsi_ble_app_set_event(RSI_BLE_CONN_UPDATE_EVENT); } -/*==============================================*/ +/*============================================================================*/ /** - * @fn rsi_ble_on_smp_passkey - * @brief its invoked when smp passkey event is received. - * @param[in] remote_dev_address, it indicates remote bd address. + * @fn rsi_ble_on_remote_features_event + * @brief invoked when LE remote features event is received. + * @param[out] rsi_ble_event_remote_features, connected remote device information * @return none. * @section description - * This callback function is invoked when SMP passkey events is received - * Note: We have to send SMP passkey command + * This callback function indicates the remote device features */ -void rsi_ble_on_smp_passkey(rsi_bt_event_smp_passkey_t *remote_dev_address) +void rsi_ble_on_remote_features_event(rsi_ble_event_remote_features_t *rsi_ble_event_remote_features) { - UNUSED_PARAMETER(remote_dev_address); - rsi_ble_app_set_event(RSI_BLE_SMP_PASSKEY_EVENT); + memcpy(&remote_dev_feature, rsi_ble_event_remote_features, sizeof(rsi_ble_event_remote_features_t)); + rsi_ble_app_set_event(RSI_BLE_RECEIVE_REMOTE_FEATURES); } - -/*==============================================*/ +/*============================================================================*/ /** - * @fn rsi_ble_on_smp_failed - * @brief its invoked when smp failed event is received. - * @param[in] remote_dev_address, it indicates remote bd address. - * @return none. + * @fn rsi_ble_data_length_change_event + * @brief invoked when data length is set + * @param[out] rsi_ble_data_length_update, data length information * @section description - * This callback function is invoked when SMP failed events is received + * This Callback function indicates data length is set */ -void rsi_ble_on_smp_failed(uint16_t status, rsi_bt_event_smp_failed_t *remote_dev_address) +void rsi_ble_data_length_change_event(rsi_ble_event_data_length_update_t *rsi_ble_data_length_update) { - UNUSED_PARAMETER(remote_dev_address); - UNUSED_PARAMETER(status); - rsi_ble_app_set_event(RSI_BLE_SMP_FAILED_EVENT); + memcpy(&updated_data_len_params, rsi_ble_data_length_update, sizeof(rsi_ble_event_data_length_update_t)); + rsi_ble_app_set_event(RSI_BLE_DATA_LENGTH_CHANGE); } - /*==============================================*/ /** - * @fn rsi_ble_on_encrypt_started - * @brief its invoked when encryption started event is received. - * @param[in] remote_dev_address, it indicates remote bd address. + * @fn rsi_ble_on_mtu_event + * @brief invoked when an MTU size event is received + * @param[out] rsi_ble_mtu, it indicates MTU size. * @return none. * @section description - * This callback function is invoked when encryption started events is received + * This callback function is invoked when an MTU size event is received */ -void rsi_ble_on_encrypt_started(uint16_t status, rsi_bt_event_encryption_enabled_t *enc_enabled) +static void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t *rsi_ble_mtu) { - UNUSED_PARAMETER(enc_enabled); - UNUSED_PARAMETER(status); - - rsi_ble_app_set_event(RSI_BLE_ENCRYPT_STARTED_EVENT); + memcpy(&app_ble_mtu_event, rsi_ble_mtu, sizeof(rsi_ble_event_mtu_t)); + rsi_6byte_dev_address_to_ascii(remote_dev_addr, app_ble_mtu_event.dev_addr); + rsi_ble_app_set_event(RSI_BLE_MTU_EVENT); } /*==============================================*/ /** * @fn rsi_ble_on_gatt_write_event * @brief this is call back function, it invokes when write/notify events received. - * @param[in] event_id, it indicates write/notification event id. - * @param[in] rsi_ble_write, write event parameters. + * @param[out] event_id, it indicates write/notification event id. + * @param[out] rsi_ble_write, write event parameters. * @return none. * @section description * This is a callback function @@ -545,7 +521,7 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t // Scan command request case '3': //else if(rsi_ble_write->att_value[0] == '3') { - LOG_PRINT("Received scan request\n"); + LOG_PRINT("Received scan request\r\n"); retry = 0; memset(data, 0, sizeof(data)); sl_wifi_app_set_event(SL_WIFI_SCAN_STATE); @@ -563,8 +539,8 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t // Sending Security type case '5': //else if(rsi_ble_write->att_value[0] == '5') { - sec_type = 2; //rsi_ble_write->att_value[3]; // FixMe: Getting wrong sec_type from ble app - LOG_PRINT("In Security Request\n"); + sec_type = ((rsi_ble_write->att_value[3]) - '0'); + LOG_PRINT("In Security Request\r\n"); rsi_ble_app_set_event(RSI_SECTYPE); } break; @@ -574,14 +550,14 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t { memset(data, 0, sizeof(data)); strcpy((char *)pwd, (const char *)&rsi_ble_write->att_value[3]); - LOG_PRINT("PWD from ble app\n"); + LOG_PRINT("PWD from ble app\r\n"); sl_wifi_app_set_event(SL_WIFI_JOIN_STATE); } break; // WLAN Status Request case '7': //else if(rsi_ble_write->att_value[0] == '7') { - LOG_PRINT("WLAN status request received\n"); + LOG_PRINT("WLAN status request received\r\n"); memset(data, 0, sizeof(data)); if (connected) { rsi_ble_app_set_event(RSI_WLAN_ALREADY); @@ -593,7 +569,7 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t // WLAN disconnect request case '4': //else if(rsi_ble_write->att_value[0] == '4') { - LOG_PRINT("WLAN disconnect request received\n"); + LOG_PRINT("WLAN disconnect request received\r\n"); memset(data, 0, sizeof(data)); sl_wifi_app_set_event(SL_WIFI_DISCONN_NOTIFY_STATE); } break; @@ -602,11 +578,11 @@ static void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t case '8': { memset(data, 0, sizeof(data)); rsi_ble_app_set_event(RSI_APP_FW_VERSION); - LOG_PRINT("FW version request\n"); + LOG_PRINT("FW version request\r\n"); } break; default: - LOG_PRINT("Default command case \n\n"); + LOG_PRINT("Default command case \r\n\n"); break; } } @@ -636,11 +612,13 @@ void rsi_ble_configurator_init(void) rsi_ble_on_disconnect_event, NULL, NULL, - NULL, + rsi_ble_data_length_change_event, rsi_ble_on_enhance_conn_status_event, NULL, - NULL, + rsi_ble_on_conn_update_complete_event, NULL); + //! registering the GAP extended call back functions + rsi_ble_gap_extended_register_callbacks(rsi_ble_on_remote_features_event, NULL); // registering the GATT callback functions rsi_ble_gatt_register_callbacks(NULL, @@ -654,7 +632,7 @@ void rsi_ble_configurator_init(void) NULL, NULL, NULL, - NULL, + rsi_ble_on_mtu_event, NULL, NULL, NULL, @@ -667,18 +645,6 @@ void rsi_ble_configurator_init(void) NULL, NULL); - rsi_ble_smp_register_callbacks(rsi_ble_on_smp_request, // registering the SMP call back functions - rsi_ble_on_smp_response, - rsi_ble_on_smp_passkey, - rsi_ble_on_smp_failed, - rsi_ble_on_encrypt_started, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - // Set local name rsi_bt_set_local_name((uint8_t *)RSI_BLE_APP_DEVICE_NAME); @@ -692,7 +658,7 @@ void rsi_ble_configurator_init(void) // set device in advertising mode. rsi_ble_start_advertising(); - LOG_PRINT("\r\nBLE Advertising Start...\r\n"); + LOG_PRINT("\r\nBLE Advertising Started...\r\n"); } /*==============================================*/ @@ -716,7 +682,7 @@ void rsi_ble_configurator_task(void *argument) scanresult = (sl_wifi_scan_result_t *)malloc(scanbuf_size); if (scanresult == NULL) { - LOG_PRINT("Failed to allocate memory for scan result\n"); + LOG_PRINT("Failed to allocate memory for scan result\r\n"); return; } memset(scanresult, 0, scanbuf_size); @@ -736,12 +702,21 @@ void rsi_ble_configurator_task(void *argument) // clear the served event rsi_ble_app_clear_event(RSI_BLE_ENH_CONN_EVENT); + LOG_PRINT("\r\nConnected - remote_dev_addr : %s\r\n", + rsi_6byte_dev_address_to_ascii(remote_dev_addr, conn_event_to_app.dev_addr)); + //MTU exchange status = rsi_ble_mtu_exchange_event(conn_event_to_app.dev_addr, BLE_MTU_SIZE); if (status != RSI_SUCCESS) { - LOG_PRINT("\n rsi_ble_mtu_exchange_event command failed : %lx", status); - } else { - LOG_PRINT("\n rsi_ble_mtu_exchange_event command success \n"); + LOG_PRINT("\n MTU request failed with error code %lx", status); + } + status = rsi_ble_conn_params_update(conn_event_to_app.dev_addr, + CONN_INTERVAL_DEFAULT_MIN, + CONN_INTERVAL_DEFAULT_MAX, + CONN_LATENCY, + SUPERVISION_TIMEOUT_DEFAULT); + if (status != RSI_SUCCESS) { + LOG_PRINT("\n rsi_ble_conn_params_update command failed : %lx", status); } } break; @@ -750,33 +725,19 @@ void rsi_ble_configurator_task(void *argument) // clear the served event rsi_ble_app_clear_event(RSI_BLE_DISCONN_EVENT); - + LOG_PRINT("\r\nDisconnected - remote_dev_addr : %s\r\n", + rsi_6byte_dev_address_to_ascii(remote_dev_addr, disconn_event_to_app.dev_addr)); // set device in advertising mode. adv: -// These lines are commented to avoid wlan disconnection if ble is disconnected. -#if 0 - if (connected) { - LOG_PRINT("disconnect command is passed\n"); - memset(data, 0, RSI_BLE_MAX_DATA_LEN); - sl_wifi_app_set_event(RSI_WLAN_DISCONN_NOTIFY_STATE); - } -#endif status = rsi_ble_start_advertising(); if (status != RSI_SUCCESS) { + LOG_PRINT("\r\nstart advertising cmd failed with error code = %lx \n", status); goto adv; + } else { + LOG_PRINT("\r\nStarted Advertising \n"); } } break; - case SL_BLE_GATT_WRITE_EVENT: { - // event invokes when write/notification events received - - // clear the served event - rsi_ble_app_clear_event(SL_BLE_GATT_WRITE_EVENT); - - // set the local attribute value. - rsi_ble_set_local_att_value(rsi_ble_att2_val_hndl, RSI_BLE_MAX_DATA_LEN, rsi_ble_app_data); - } break; - case RSI_APP_FW_VERSION: { sl_wifi_firmware_version_t firmware_version = { 0 }; @@ -843,7 +804,7 @@ void rsi_ble_configurator_task(void *argument) case RSI_SECTYPE: { rsi_ble_app_clear_event(RSI_SECTYPE); - if (sec_type == '0') { + if (sec_type == 0) { sl_wifi_app_set_event(SL_WIFI_JOIN_STATE); } } break; @@ -870,7 +831,7 @@ void rsi_ble_configurator_task(void *argument) osDelay(10); } - LOG_PRINT("Displayed scan list in Silabs app\n\n"); + LOG_PRINT("Displayed scan list in Silabs app\r\n\n"); } break; // WLAN connection response status (response to '2' command) @@ -909,12 +870,12 @@ void rsi_ble_configurator_task(void *argument) rsi_ble_set_local_att_value(rsi_ble_att2_val_hndl, RSI_BLE_MAX_DATA_LEN, data); // set the local attribute value. - LOG_PRINT("AP joined successfully\n\n"); - rsi_ble_conn_params_update(conn_event_to_app.dev_addr, - CONN_INTERVAL_MIN, - CONN_INTERVAL_MAX, - CONN_LATENCY, - SUPERVISION_TIMEOUT); + LOG_PRINT("AP joined successfully\r\n\n"); + status = rsi_ble_conn_params_update(conn_event_to_app.dev_addr, + CONN_INTERVAL_MIN, + CONN_INTERVAL_MAX, + CONN_LATENCY, + SUPERVISION_TIMEOUT); if (status != RSI_SUCCESS) { LOG_PRINT("\r\nconn params update cmd failed with status " "= %lx \r\n", @@ -923,6 +884,35 @@ void rsi_ble_configurator_task(void *argument) // conn_params_updated = 1; // rsi_ble_app_clear_event(RSI_APP_BLE_GATT_SERVICE_RESP_DESCRIPTOR); } break; + case RSI_BLE_MTU_EVENT: { + //! clear the served event + rsi_ble_app_clear_event(RSI_BLE_MTU_EVENT); + //! event invokes when write/notification events received + } break; + case RSI_BLE_CONN_UPDATE_EVENT: { + rsi_ble_app_clear_event(RSI_BLE_CONN_UPDATE_EVENT); + + } break; + case RSI_BLE_RECEIVE_REMOTE_FEATURES: { + //! clear the served event + rsi_ble_app_clear_event(RSI_BLE_RECEIVE_REMOTE_FEATURES); + + if (remote_dev_feature.remote_features[0] & 0x20) { + status = rsi_ble_set_data_len(conn_event_to_app.dev_addr, TX_LEN, TX_TIME); + if (status != RSI_SUCCESS) { + LOG_PRINT("\n set data length cmd failed with error code = " + "%lx \n", + status); + rsi_ble_app_set_event(RSI_BLE_RECEIVE_REMOTE_FEATURES); + } + } + + } break; + case RSI_BLE_DATA_LENGTH_CHANGE: { + //! clear the served event + rsi_ble_app_clear_event(RSI_BLE_DATA_LENGTH_CHANGE); + } break; + default: break; } diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_config.h b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_config.h index 70ccab36..1c2707c2 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_config.h +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/ble_config.h @@ -71,6 +71,10 @@ #define BLE_MTU_SIZE 232 +//! Tx Datalength parameters +#define TX_LEN 0xFB +#define TX_TIME 0x0148 + /*=======================================================================*/ //! Advertising command parameters /*=======================================================================*/ diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/i2c_leader_example.c b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/i2c_leader_example.c index de2db52b..a3350440 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/i2c_leader_example.c +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/i2c_leader_example.c @@ -168,7 +168,7 @@ void i2c_leader_example_process_action(void) DEBUGOUT("Data is transferred to Follower successfully \n"); // Validation for executing the API only once. - i2c_receive_data(read_buffer, 2, FOLLOWER_I2C_ADDR); + i2c_receive_data((uint8_t *)read_buffer, 2, FOLLOWER_I2C_ADDR); Delay(10); while (!i2c_receive_complete) ; @@ -201,8 +201,6 @@ void i2c_leader_example_process_action(void) info = 0; read_buffer[0] = 0; read_buffer[1] = 0; - read_buffer[2] = 0; - if (i2c_receive_complete) { // It waits till i2c_receive_complete is true in IRQ handler. DEBUGOUT("Data is received from Follower successfully \n"); diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/readme.md b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/readme.md index 4db92bfa..0f78758b 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/readme.md +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/readme.md @@ -5,19 +5,23 @@ - [Purpose / Scope](#purpose--scope) - [Prerequisites / Setup Requirements](#prerequisites--setup-requirements) - [Hardware Requirements](#hardware-requirements) + - [Base Board Pin Configuration for I2C- B0 Board(BRD4338A SOC Boards)](#base-board-pin-configuration-for-i2c-b0-boardbrd4338a-soc-boards) - [Software Requirements](#software-requirements) - [Setup Diagram](#setup-diagram) - [Getting Started](#getting-started) -- [Application Build Environment](#application-build-environment) - [Application Configuration Parameters](#application-configuration-parameters) - - [Base Board Pin Configuration for I2C- B0 Board(BRD4338A SOC Boards)](#base-board-pin-configuration-for-i2c-b0-boardbrd4338a-soc-boards) + - [To Load Certificates](#to-load-certificates) - [Test the Application](#test-the-application) + - [Observing the output prints on serial terminal](#observing-the-output-prints-on-serial-terminal) - [MQTT Connection](#mqtt-connection) +- [Additional Information](#additional-information) + - [Current Measurement](#current-measurement) - [Create an AWS Thing](#create-an-aws-thing) + - [Steps to create a policy from AWS console](#steps-to-create-a-policy-from-aws-console) ## Purpose / Scope -This example demonstrates how to configure/connects SiWx91x to get the Wi-Fi connection functionality using BLE provisioning. In this application, SiWx91x starts advertising in BLE mode and Access Point details are fetched using BLE Provisioning. After successful Wi-Fi connection, application connects to AWS Core and subscribes to a topic. Publishes a message on subscribed topic and application waits to receive the data published on subscribed topic from the cloud. +In this application, SiWx917 starts advertising in BLE mode and Access Point details are fetched using BLE Provisioning. After successful Wi-Fi connection, application connects to AWS Core and subscribes to a topic. Publishes a message on subscribed topic and application waits to receive the data published on subscribed topic from the cloud. **Soc Mode**: @@ -48,7 +52,7 @@ A timer is run with a periodicity of **PUBLISH_PERIODICITY** milliseconds. The a - When an incoming publish is received by the application. -*NOTE*: The bold texts are the macros defined in the application. You can find more details about them in the [Application Configuration Parameters](#application-configuration-parameters) +**NOTE:** The bold texts are the macros defined in the application. You can find more details about them in the [Application Configuration Parameters](#application-configuration-parameters) ## Prerequisites / Setup Requirements @@ -70,8 +74,7 @@ A timer is run with a periodicity of **PUBLISH_PERIODICITY** milliseconds. The a - BRD4002A Wireless pro kit mainboard [SI-MB4002A] - EFR32xG24 Wireless 2.4 GHz +10 dBm Radio Board [xG24-RB4186C](https://www.silabs.com/development-tools/wireless/xg24-rb4186c-efr32xg24-wireless-gecko-radio-board?tab=overview) - NCP EFR Expansion Kit with NCP Radio board (BRD4346A + BRD8045A) [SiWx917-EB4346A] - - Kits - - EFR32xG24 Pro Kit +10 dBm [xG24-PK6009A](https://www.silabs.com/development-tools/wireless/efr32xg24-pro-kit-10-dbm?tab=overview) +- USB-C cable - Wireless Access point (which has an active internet access) - Android Phone or iPhone with **EFR Connect** App, which is available in Play Store and App Store. @@ -91,13 +94,9 @@ A timer is run with a periodicity of **PUBLISH_PERIODICITY** milliseconds. The a - Simplicity Studio IDE - Download the [Simplicity Studio IDE](https://www.silabs.com/developers/simplicity-studio). - Follow the [Simplicity Studio user guide](https://docs.silabs.com/simplicity-studio-5-users-guide/1.1.0/ss-5-users-guide-getting-started/install-ss-5-and-software#install-ssv5) to install Simplicity Studio IDE. -- Serial console Setup - - The Serial Console setup instructions are provided below: -Refer [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/getting-started-with-soc-mode#perform-console-output-and-input-for-brd4338-a). +- Serial terminal for viewing the print [Tera term](https://tera-term.en.softonic.com/). - Download and install the Silicon Labs [EFR Connect App](https://www.silabs.com/developers/efr-connect-mobile-app), -which is also avilable in Play Store or app store. - (OR) -- Android phone or iPhone with the Silabs_connect.apk,which is available in the path $\wiseconnect\utilities\ble_provisioning_apps\android_based_provisioning_app +which is available in Play store/App store or `Silabs_connect.apk`, which is available in the path `\wiseconnect\utilities\ble_provisioning_apps\android_based_provisioning_app.` ### Setup Diagram @@ -109,7 +108,7 @@ which is also avilable in Play Store or app store. Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wiseconnect-getting-started/) to: -- Install Studio and WiSeConnect 3 extension +- Install Simplicity Studio and WiSeConnect 3 extension - Connect your device to the computer - Upgrade your connectivity firmware - Create a Studio project @@ -121,17 +120,16 @@ The application can be configured to suit your requirements and development envi ```c For SoC Mode only: - Open `` and set the following parameters + Open and set the following parameters #define RTE_I2C2_SCL_PORT_ID 2 #define RTE_I2C2_SDA_PORT_ID 2 - ``` Open `wlan_app.c` file and update/modify following macros - Modify the MQTT topics and give different names for both topics SiWx91x is subscribed to MQTT_TOPIC1 and publishing to MQTT_TOPIC2. + Modify the MQTT topics and give different names for both topics SiWx917 is subscribed to MQTT_TOPIC1 and publishing to MQTT_TOPIC2. MQTT web application is subscribed to `MQTT_TOPIC2` and publishing on `MQTT_TOPIC1`. ```c @@ -139,7 +137,7 @@ For SoC Mode only: #define MQTT_TOPIC2 "si91x_status" //! Publish Topic to send the status from application to cloud ``` - **NOTE:** If you would like to change the topic names, then you can modify only the last keyword of the topic, which are `aws_status` and `si91x_status`. + **NOTE:** You can change the topic names, which are `aws_status` and `si91x_status`. The below parameters are only applicable for SoC with power save enabled whereas **PUBLISH_PERIODICITY** and **ENABLE_POWER_SAVE** can be configured in NCP also. @@ -152,23 +150,6 @@ For SoC Mode only: #define PUBLISH_PERIODICITY (30000) // Configure this macro to publish data every 30 seconds (this works only in NCP with and without POWERSAVE and in SOC without POWERSAVE). ``` -Open `wlan_config.h` file and update/modify the following macros - -```c -#define CONCURRENT_MODE RSI_DISABLE -#define RSI_FEATURE_BIT_MAP (FEAT_SECURITY_OPEN | FEAT_AGGREGATION | FEAT_ULP_GPIO_BASED_HANDSHAKE) -#define RSI_TCP_IP_BYPASS RSI_DISABLE -#define RSI_TCP_IP_FEATURE_BIT_MAP (TCP_IP_FEAT_DHCPV4_CLIENT | TCP_IP_FEAT_SSL | TCP_IP_FEAT_DNS_CLIENT | TCP_IP_TOTAL_SOCKETS_1 | TCP_IP_FEAT_EXTENSION_VALID) -#define RSI_CUSTOM_FEATURE_BIT_MAP FEAT_CUSTOM_FEAT_EXTENTION_VALID -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_RSA_KEY_WITH_4096_SUPPORT | EXT_FEAT_SSL_CERT_WITH_4096_KEY_SUPPORT) -define RSI_EXT_TCPIP_FEATURE_BIT_MAP ( EXT_DYNAMIC_COEX_MEMORY | EXT_TCP_IP_FEAT_SSL_MEMORY_CLOUD | CONFIG_FEAT_EXTENTION_VALID) -define RSI_CONFIG_FEATURE_BITMAP RSI_FEAT_SLEEP_GPIO_SEL_BITMAP -define RSI_BT_FEATURE_BITMAP (BT_RF_TYPE | ENABLE_BLE_PROTOCOL) -define RSI_BAND RSI_BAND_2P4GHZ -``` - - > **Note:** `wlan_config.h` file is already set with the desired configuration in respective example folders, user need not change for each example. - Open `ble_app.c` file and update/modify following macros **Configuring the BLE Application** @@ -215,15 +196,17 @@ Open `ble_app.c` file and update/modify following macros #define RSI_BLE_MAX_DATA_LEN 20 ``` - `RSI_BLE_APP_DEVICE_NAME` refers to the name of the Silicon Labs device to appear during scanning by remote devices. + + **The following are the **non-configurable** macros in the application.** + + `RSI_BLE_APP_DEVICE_NAME` refers to the name of the Silicon Labs device to appear during scanning by remote devices. Use the same name as mentioned. ```c #define RSI_BLE_APP_DEVICE_NAME "BLE_CONFIGURATOR" ``` - The following are the **non-configurable** macros in the application. - RSI_BLE_ATT_PROPERTY_READ is used to set the READ property to an attribute value. + RSI_BLE_ATT_PROPERTY_READ is used to set the READ property to an attribute value. ```c #define RSI_BLE_ATT_PROPERTY_READ 0x02 @@ -241,34 +224,29 @@ Open `ble_app.c` file and update/modify following macros #define RSI_BLE_ATT_PROPERTY_NOTIFY 0x10 ``` - `BT_GLOBAL_BUFF_LEN` refers to the number of bytes required by the application and the driver. - -```c -#define BT_GLOBAL_BUFF_LEN 15000 -``` Open `aws_iot_config.h` file and change the AWS_IOT_MQTT_CLIENT_ID to your choice (Make sure this is unique, if more than one user use has same client id it might get conflict at server side). ```c //AWS Host name - #define AWS_IOT_MQTT_HOST "a25jwtlmds8eip-ats.iot.us-east-2.amazonaws.com" + #define AWS_IOT_MQTT_HOST "a2m21kovu9tcsh-ats.iot.us-east-2.amazonaws.com" //default port for MQTT #define AWS_IOT_MQTT_PORT "8883" - #define AWS_IOT_MQTT_CLIENT_ID "Redp" + #define AWS_IOT_MQTT_CLIENT_ID "silicon_labs_thing" // Thing Name of the Shadow this device is associated with - #define AWS_IOT_MY_THING_NAME "AWS-IoT-C-SDK" + #define AWS_IOT_MY_THING_NAME "silicon_labs_thing" ``` - **AWS_IOT_MQTT_HOST** parameter can be found as follows: - ![AWS_IOT_MQTT_HOST_PAGE_1](resources/readme/aws_iot_mqtt_host_url_1.png) + ![AWS_IOT_MQTT_HOST_PAGE_1](resources/readme/aws_iot_mqtt_host_url_1.png) - ![AWS_IOT_MQTT_HOST_PAGE_2](resources/readme/aws_iot_mqtt_host_url_2.png) + ![AWS_IOT_MQTT_HOST_PAGE_2](resources/readme/aws_iot_mqtt_host_url_2.png) -To Load Certificate +### To Load Certificates Place the certificate files in `/resources/certificates/` path and include the certificate files in wifi_app.c @@ -287,9 +265,9 @@ Place the certificate files in `/resources/certificates/` path and include status = sl_net_set_credential(SL_NET_TLS_SERVER_CREDENTIAL_ID(0), SL_NET_PRIVATE_KEY, aws_client_private_key, (sizeof(aws_client_private_key) - 1)); ``` - **Note:** +**NOTE:** - If user want to load certificates follow this steps: + If user wants to load certificates follow this steps: To authenticate and securely connect with AWS, your Wi-Fi device requires a unique x.509 security certificate and private key, as well as a CA certificate which is used to verify the AWS server. Security credentials need to be converted into a C-array rather than [PEM format](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) provided by AWS; they also need to be added to your project. @@ -298,16 +276,15 @@ The WiSeConnect SDK provides a conversion script (written in Python 3) to make t To convert the device certificate and private key to C arrays, go to the `resources>scripts>certificate_to_array.py`. Open a system command prompt and use the script as indicated in the following examples. ```sh -$> python certificate_to_array.py +$> py certificate_to_array.py For example: -$> python certificate_to_array.py d8f3a44d3f.cert.pem aws_client_certificate -$> python certificate_to_array.py d8f3a44d3f.private.key aws_client_private_certificate +$> py certificate_to_array.py d8f3a44d3f.cert.pem aws_client_certificate +$> py certificate_to_array.py d8f3a44d3f.private.key aws_client_private_certificate ``` + **NOTE:** - **NOTE**: - -1. If python command is not working replace the python with py +1. If py command is not working replace the py with python. 2. Make sure the certificate to be converted has to be in the same path. @@ -324,20 +301,21 @@ Go ahead and overwrite any existing files with the same name in that directory, The Root CA certificate used by your Wi-Fi device to verify the AWS server is already included in the WiSeConnect SDK; no additional setup is required. For reference, Amazon uses [Starfield Technologies](https://www.starfieldtech.com/) to secure the AWS website, the WiSeConnect SDK includes the [Starfield CA Certificate](https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk/tree/master/resources/certificates/aws_starfield_ca.pem.h). -> NOTE : +> **NOTE:** +> > For AWS connectivity, StarField Root CA Class 2 certificate has the highest authority being at the top of the signing hierarchy. > > The StarField Root CA Class 2 certificate is an expected/required certificate which usually comes pre-installed in the operating systems and it plays a key part in certificate chain verification when a device is performing TLS authentication with the IoT endpoint. > -> On SiWx91x device, we do not maintain root CA trust repository due to memory constraints, so it is mandatory to load StarField Root CA Class 2 certificate for successful mutual authentication to AWS server. +> On SiWx917 device, we do not maintain root CA trust repository due to memory constraints, so it is mandatory to load StarField Root CA Class 2 certificate for successful mutual authentication to AWS server. > > The certificate chain sent by AWS server is as below: > id-at-commonName=Amazon,id-at-organizationalUnitName=Server CA 1B,id-at-organizationName=Amazon,id-at-countryName=US > id-at-commonName=Amazon Root CA 1,id-at-organizationName=Amazon,id-at-countryName=US > id-at-commonName=Starfield Services Root Certificate Authority ,id-at-organizationName=Starfield Technologies, Inc.,id-at-localityName=Scottsdale,id-at- stateOrProvinceName=Arizona,id-at-countryName=US) > -> On SiWx91x to authenticate the AWS server, firstly Root CA is validated (validate the Root CA received with the Root CA loaded on the device). Once the Root CA is validation is successful , other certificates sent from the AWS server are validated. -> SiWx91x don't authenticate to AWS server if intermediate CA certificates are loaded instead of StarField Root CA Class 2 certificate and would result in Handshake error. +> On SiWx917 to authenticate the AWS server, firstly Root CA is validated (validate the Root CA received with the Root CA loaded on the device). Once the Root CA is validation is successful , other certificates sent from the AWS server are validated. +> SiWx917 don't authenticate to AWS server if intermediate CA certificates are loaded instead of StarField Root CA Class 2 certificate and would result in Handshake error. > StarField Root CA Class 2 certificate is at https://certs.secureserver.net/repository/sf-class2-root.crt > > Reference links : @@ -352,21 +330,21 @@ Refer to the instructions [here](https://docs.silabs.com/wiseconnect/latest/wise Follow the steps below for successful execution of the application: -1. Configure the Access point in OPEN/WPA-PSK/WPA2-PSK mode to connect the SiWx91x in STA mode.(make sure access point has active internet) +1. Configure the Access point in OPEN/WPA-PSK/WPA2-PSK/WPA3 mode to connect the SiWx917 in STA mode. 2. Connect any serial console for prints. -3. When SiWx91x EVK enters BLE advertising mode, launch the **EFR Connect** App. +3. When SiWx917 EVK enters BLE advertising mode, launch the **EFR Connect** App. 4. Click on Demo and select Wi-Fi Commissioning over BLE. ![](resources/readme/remote_screen1.png) -5. It will scan for the module, and it appears in the list. For example, 'BLE_CONFIGURATOR' on the UI, select as shown below. +5. It will scan for the module, and it appears as `BLE_CONFIGURATOR` on the UI, select as shown below. - ![](resources/readme/dut_scan_result.png) + ![](resources/readme/dut_scan_result.png) -6. Now, SiWx91x module will start as a station and scan for the access points (AP) nearby. +6. Now, SiWx917 module will start as a station and scan for the access points (AP) nearby. 7. Once the list of AP scan results is displayed on the screen, you can select the SSID of the AP to which you want to connect. @@ -384,9 +362,19 @@ Follow the steps below for successful execution of the application: 11. To disconnect from Access Point, click on connected AP and click on YES -![](resources/readme/remote_screen5.png) + ![](resources/readme/remote_screen5.png) +### Observing the output prints on serial terminal + ![](resources/readme/output5.png) + +#### When I2C_SENSOR_PERI_ENABLE macro enabled : + + ![](resources/readme/output1.png) + + ![](resources/readme/output2.png) + + ![](resources/readme/output3.png) ### MQTT Connection @@ -397,37 +385,27 @@ To do that, 2. Click on the thing you have created. Go to activity at below. Click on MQTT test client as shown below. - ![](resources/readme/aws_screen.png) + ![](resources/readme/aws_screen.png) 3. Then subscribe to a topic you gave in the application as shown in the picture. You can see the published data from the module as shown below. - ![](resources/readme/aws_screen1.png) - - ![](resources/readme/aws_screen2.png) + ![](resources/readme/aws_screen1.png) + + ![](resources/readme/aws_screen2.png) 4. If we want to publish data from AWS. Give the name of the topic name configured in application to publish as shown in the below picture. Write down the data at Message payload to send data to the module.Then click on publish. - ![](resources/readme/aws_screen3.png) - -## Observing the output prints on serial terminal + ![](resources/readme/aws_screen3.png) -![](resources/readme/output5.png) +## Additional Information -### when **I2C_SENSOR_PERI_ENABLE** macro enabled : -![](resources/readme/output1.png) - -![](resources/readme/output2.png) - -![](resources/readme/output3.png) - -### Additional Information +### Current Measurement: Using Simplicity Studio Energy Profiler for current measurement: - After flashing the application code to the module. Energy profiler can be used for current consumption measurements. - - From tools, choose Energy Profiler and click "OK" ![Figure: Energy Profiler Step 6](resources/readme/energy_profiler_step_6.png) @@ -443,8 +421,7 @@ Using Simplicity Studio Energy Profiler for current measurement: ![output_prints](resources/readme/power_meter_avg_current_consumption.png) - -### Note + **NOTE:** For NCP mode, following defines have to enabled manually in preprocessor setting of example project @@ -454,7 +431,9 @@ For NCP mode, following defines have to enabled manually in preprocessor setting ### Create an AWS Thing - **Thing Note**: By default we are giving ThingName: silicon_labs_thing, these related configuration we set default If you want your own thing name you can follow the below procedure. +**Thing Note:** + +By default we are giving ThingName: silicon_labs_thing, these related configuration we set default If you want your own thing name you can follow the below procedure. Create a thing in the AWS IoT registry to represent your IoT device. diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_app.c b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_app.c index 71cea318..30300c3a 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_app.c +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_app.c @@ -113,7 +113,7 @@ static volatile bool scan_complete = false; static volatile sl_status_t callback_status = SL_STATUS_OK; uint16_t scanbuf_size = (sizeof(sl_wifi_scan_result_t) + (SL_WIFI_MAX_SCANNED_AP * sizeof(scan_result->scan_info[0]))); -sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE, 0, 0, 1000, { 0 } }; +sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; uint8_t connected = 0, timeout = 0; uint8_t disconnected = 0, disassosiated = 0; @@ -145,10 +145,6 @@ int32_t status1 = RSI_SUCCESS; AWS_IoT_Client mqtt_client = { 0 }; #define RSI_FD_ISSET(x, y) rsi_fd_isset(x, y) -#ifdef SLI_SI91X_MCU_INTERFACE -static RTC_TIME_CONFIG_T rtc_configuration, alarm_configuration, rtc_get_time; -#endif - typedef struct sl_wlan_app_cb_s { //! wlan application state volatile sl_wifi_app_state_t state; @@ -307,20 +303,20 @@ static void iot_subscribe_callback_handler(AWS_IoT_Client *pClient, static void disconnectCallbackHandler(AWS_IoT_Client *pClient, void *data) { IoT_Error_t rc = FAILURE; - LOG_PRINT("MQTT Disconnect"); + LOG_PRINT("MQTT Disconnect\r\n"); if (NULL == pClient) { return; } IOT_UNUSED(data); if (aws_iot_is_autoreconnect_enabled(pClient)) { - LOG_PRINT("Auto Reconnect is enabled, Reconnecting attempt will start now\n"); + LOG_PRINT("Auto Reconnect is enabled, Reconnecting attempt will start now\r\n"); } else { - LOG_PRINT("Auto Reconnect not enabled. Starting manual reconnect...\n"); + LOG_PRINT("Auto Reconnect not enabled. Starting manual reconnect...\r\n"); rc = aws_iot_mqtt_attempt_reconnect(pClient); if (NETWORK_RECONNECTED == rc) { - LOG_PRINT("Manual Reconnect Successful"); + LOG_PRINT("Manual Reconnect Successful\r\n"); } else { - LOG_PRINT("Manual Reconnect \n"); + LOG_PRINT("Manual Reconnect \r\n"); } } } @@ -384,11 +380,11 @@ static sl_status_t show_scan_results() { SL_WIFI_ARGS_CHECK_NULL_POINTER(scan_result); uint8_t *bssid = NULL; - LOG_PRINT("%lu Scan results:\n", scan_result->scan_count); + LOG_PRINT("%lu Scan results:\r\n", scan_result->scan_count); if (scan_result->scan_count) { - LOG_PRINT("\n %s %24s %s", "SSID", "SECURITY", "NETWORK"); - LOG_PRINT("%12s %12s %s\n", "BSSID", "CHANNEL", "RSSI"); + LOG_PRINT("\r\n %s %24s %s", "SSID", "SECURITY", "NETWORK"); + LOG_PRINT("%12s %12s %s\r\n", "BSSID", "CHANNEL", "RSSI"); for (int a = 0; a < (int)scan_result->scan_count; ++a) { bssid = (uint8_t *)&scan_result->scan_info[a].bssid; @@ -396,7 +392,7 @@ static sl_status_t show_scan_results() scan_result->scan_info[a].ssid, scan_result->scan_info[a].security_mode, scan_result->scan_info[a].network_type); - LOG_PRINT(" %02x:%02x:%02x:%02x:%02x:%02x, %4u, -%u\n", + LOG_PRINT(" %02x:%02x:%02x:%02x:%02x:%02x, %4u, -%u\r\n", bssid[0], bssid[1], bssid[2], @@ -443,7 +439,7 @@ void sl_wifi_app_task(void) // Allocate memory for scan buffer scan_result = (sl_wifi_scan_result_t *)malloc(scanbuf_size); if (scan_result == NULL) { - LOG_PRINT("Failed to allocate memory for scan result\n"); + LOG_PRINT("Failed to allocate memory for scan result\r\n"); return; } memset(scan_result, 0, scanbuf_size); @@ -515,7 +511,7 @@ void sl_wifi_app_task(void) status = sl_net_set_credential(id, SL_NET_WIFI_PSK, pwd, strlen((char *)pwd)); if (SL_STATUS_OK == status) { - LOG_PRINT("Credentials set, id : %lu\n", id); + LOG_PRINT("Credentials set, id : %lu\r\n", id); access_point.ssid.length = strlen((char *)coex_ssid); memcpy(access_point.ssid.value, coex_ssid, access_point.ssid.length); @@ -523,7 +519,7 @@ void sl_wifi_app_task(void) access_point.encryption = SL_WIFI_CCMP_ENCRYPTION; access_point.credential_id = id; - LOG_PRINT("SSID %s\n", access_point.ssid.value); + LOG_PRINT("SSID %s\r\n", access_point.ssid.value); status = sl_wifi_connect(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, &access_point, TIMEOUT_MS); } if (status != RSI_SUCCESS) { @@ -535,7 +531,7 @@ void sl_wifi_app_task(void) disconnected = 1; connected = 0; } else { - LOG_PRINT("\n WLAN Connection Success\n"); + LOG_PRINT("\n WLAN Connection Success\r\n"); // update wlan application state sl_wifi_app_set_event(SL_WIFI_CONNECTED_STATE); } @@ -606,7 +602,7 @@ void sl_wifi_app_task(void) sl_wifi_mqtt_task(); - LOG_PRINT("SL_WIFI_IPCONFIG_DONE_STATE\n"); + LOG_PRINT("SL_WIFI_IPCONFIG_DONE_STATE\r\n"); } break; case SL_WIFI_ERROR_STATE: { @@ -619,7 +615,7 @@ void sl_wifi_app_task(void) sl_wifi_app_send_to_ble(SL_WIFI_DISCONNECTION_STATUS, (uint8_t *)&disconnected, 1); sl_wifi_app_set_event(SL_WIFI_FLASH_STATE); - LOG_PRINT("SL_WIFI_DISCONNECTED_STATE\n"); + LOG_PRINT("SL_WIFI_DISCONNECTED_STATE\r\n"); } break; case SL_WIFI_DISCONN_NOTIFY_STATE: { @@ -655,7 +651,6 @@ void sl_wifi_app_task(void) void sl_wifi_mqtt_task(void) { IoT_Error_t rc = FAILURE; - uint32_t status; IoT_Client_Init_Params mqttInitParams = iotClientInitParamsDefault; IoT_Client_Connect_Params connectParams = iotClientConnectParamsDefault; @@ -712,7 +707,7 @@ void sl_wifi_mqtt_task(void) osSemaphoreAcquire(rsi_mqtt_sem, osWaitForever); if (sl_wifi_app_get_event() == SL_WIFI_DISCONN_NOTIFY_STATE) { - LOG_PRINT("WLAN disconnect initiated\n"); + LOG_PRINT("WLAN disconnect initiated\r\n"); return; } @@ -731,11 +726,11 @@ void sl_wifi_mqtt_task(void) } break; case SL_WIFI_MQTT_CONNECT_STATE: { - LOG_PRINT("AWS IOT MQTT Connecting...\n"); + LOG_PRINT("AWS IOT MQTT Connecting...\r\n"); rc = aws_iot_mqtt_connect(&mqtt_client, &connectParams); if (SUCCESS != rc) { if (rc == NETWORK_ALREADY_CONNECTED_ERROR) { - LOG_PRINT("Network is already connected\n"); + LOG_PRINT("Network is already connected\r\n"); //sl_wlan_app_cb.state = RSI_WLAN_MQTT_PUBLISH_STATE; } else { LOG_PRINT("\r\nMqtt Subscribe failed with error: 0x%x\r\n", rc); @@ -751,13 +746,13 @@ void sl_wifi_mqtt_task(void) rc = aws_iot_mqtt_autoreconnect_set_status(&mqtt_client, false); if (SUCCESS != rc) { if (NETWORK_DISCONNECTED_ERROR == rc) { - LOG_PRINT("MQTT auto reconnect error\n"); + LOG_PRINT("MQTT auto reconnect error\r\n"); sl_wlan_app_cb.state = SL_WIFI_MQTT_CONNECT_STATE; } else if (NETWORK_ATTEMPTING_RECONNECT == rc) { // If the client is attempting to reconnect we will skip the rest of the loop. continue; } - LOG_PRINT("Unable to set Auto Reconnect to true\n "); + LOG_PRINT("Unable to set Auto Reconnect to true\r\n "); sl_wlan_app_cb.state = SL_WIFI_MQTT_AUTO_RECONNECT_SET_STATE; } else { sl_wlan_app_cb.state = SL_WIFI_MQTT_SUBSCRIBE_STATE; @@ -766,7 +761,7 @@ void sl_wifi_mqtt_task(void) } break; case SL_WIFI_MQTT_SUBSCRIBE_STATE: { - LOG_PRINT("\r\nAWS IOT MQTT Subscribe...\n"); + LOG_PRINT("\r\nAWS IOT MQTT Subscribe...\r\n"); rc = aws_iot_mqtt_subscribe(&mqtt_client, MQTT_TOPIC1, strlen(MQTT_TOPIC1), @@ -776,7 +771,7 @@ void sl_wifi_mqtt_task(void) if (SUCCESS != rc) { if (NETWORK_DISCONNECTED_ERROR == rc) { - LOG_PRINT("\r\nSubscribe error\n"); + LOG_PRINT("\r\nSubscribe error\r\n"); sl_wlan_app_cb.state = SL_WIFI_MQTT_CONNECT_STATE; } else if (NETWORK_ATTEMPTING_RECONNECT == rc) { // If the client is attempting to reconnect we will skip the rest of the loop. @@ -787,8 +782,7 @@ void sl_wifi_mqtt_task(void) sl_wlan_app_cb.state = RSI_AWS_SELECT_CONNECT_STATE; #if ENABLE_POWER_SAVE //! initiating power save in BLE mode - status = rsi_bt_power_save_profile(PSP_MODE, PSP_TYPE); - if (status != RSI_SUCCESS) { + if (rsi_bt_power_save_profile(PSP_MODE, PSP_TYPE) != RSI_SUCCESS) { LOG_PRINT("\r\n Failed to initiate power save in BLE mode \r\n"); } @@ -799,7 +793,7 @@ void sl_wifi_mqtt_task(void) if (rc != SL_STATUS_OK) { LOG_PRINT("\r\nPower save configuration Failed, Error Code : 0x%X\r\n", rc); } - LOG_PRINT("\r\nAssociated Power Save Enabled\n"); + LOG_PRINT("\r\nAssociated Power Save Enabled\r\n"); #endif osSemaphoreRelease(rsi_mqtt_sem); @@ -813,7 +807,7 @@ void sl_wifi_mqtt_task(void) memset(&read_fds, 0, sizeof(fd_set)); FD_SET(mqtt_client.networkStack.socket_id, &read_fds); - LOG_PRINT("\r\n Socket ID: %d", mqtt_client.networkStack.socket_id); + LOG_PRINT("\r\n Socket ID: %d\r\n", mqtt_client.networkStack.socket_id); status1 = sl_si91x_select(mqtt_client.networkStack.socket_id + 1, &read_fds, NULL, NULL, NULL, async_socket_select); @@ -846,12 +840,11 @@ void sl_wifi_mqtt_task(void) publish_QOS0.isRetained = 0; publish_QOS0.payloadLen = strlen(MQTT_publish_QOS0_PAYLOAD); -#if I2C_SENSOR_PERI_ENABLE +#if (defined(SLI_SI91X_MCU_INTERFACE) && I2C_SENSOR_PERI_ENABLE) char temp_data[11]; // Initialize I2C I2C_Init(); i2c_leader_example_process_action(); - //float sensor_data=temp_data; gcvt(sensor_data, 9, temp_data); char temp_string[] = "Current Temperature in Celsius: "; strcat(temp_string, temp_data); @@ -870,7 +863,7 @@ void sl_wifi_mqtt_task(void) } if (rc == MQTT_REQUEST_TIMEOUT_ERROR) { - LOG_PRINT("QOS0 publish ack not received.\n"); + LOG_PRINT("QOS0 publish ack not received.\r\n"); } LOG_PRINT("\r\nMQTT Publish Successful\r\n"); #if !(defined(SLI_SI91X_MCU_INTERFACE) && ENABLE_POWER_SAVE) @@ -922,10 +915,10 @@ void sl_wifi_mqtt_task(void) case SL_WLAN_MQTT_DISCONNECT: { rc = aws_iot_mqtt_disconnect(&mqtt_client); if (SUCCESS != rc) { - LOG_PRINT("MQTT Disconnection error\n"); + LOG_PRINT("MQTT Disconnection error\r\n"); sl_wlan_app_cb.state = SL_WIFI_MQTT_INIT_STATE; } else { - LOG_PRINT("MQTT Disconnection Successful\n"); + LOG_PRINT("MQTT Disconnection Successful\r\n"); sl_wlan_app_cb.state = SL_WIFI_MQTT_INIT_STATE; } osSemaphoreRelease(rsi_mqtt_sem); diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_ncp.slcp b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_ncp.slcp index a4e9e36d..e9f7e8e7 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_ncp.slcp +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_ncp.slcp @@ -20,7 +20,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -63,6 +63,8 @@ component: toolchain_settings: - option: gcc_linker_option value: -u _printf_float + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_soc.slcp b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_soc.slcp index 08357567..83d2ee33 100644 --- a/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_soc.slcp +++ b/examples/snippets/wlan_ble/wifi_station_ble_provisioning_aws/wifi_station_ble_provisioning_aws_soc.slcp @@ -20,7 +20,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -73,7 +73,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/app.c b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/app.c index 84b93c95..d81cbb77 100644 --- a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/app.c +++ b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/app.c @@ -92,17 +92,16 @@ static const sl_wifi_device_configuration_t config = { .mac_address = NULL, .band = SL_SI91X_WIFI_BAND_2_4GHZ, .region_code = US, - .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, - .coex_mode = SL_SI91X_WLAN_BLE_MODE, - .feature_bit_map = (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_BLE_MODE, + .feature_bit_map = (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE | SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1), - .tcp_ip_feature_bit_map = - (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT + .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT #if (!RSI_TCP_IP_BYPASS) - | SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID - | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | SL_SI91X_TCP_IP_FEAT_SSL + | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT + | SL_SI91X_TCP_IP_FEAT_SSL #endif - ), + ), .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_CUSTOM_FEAT_SOC_CLK_CONFIG_120MHZ), .ext_custom_feature_bit_map = (MEMORY_CONFIG | SL_SI91X_EXT_FEAT_XTAL_CLK @@ -113,11 +112,7 @@ static const sl_wifi_device_configuration_t config = { | SL_SI91X_EXT_FEAT_LOW_POWER_MODE #endif | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE), - .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), + .bt_feature_bit_map = (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL), .ext_tcp_ip_feature_bit_map = ( #ifdef RSI_PROCESS_MAX_RX_DATA SL_SI91X_EXT_TCP_MAX_RECV_LENGTH @@ -444,7 +439,7 @@ void rsi_common_app_task(void) return; } #else - rsi_wlan_app_thread(); + rsi_wlan_app_thread(NULL); #endif #endif diff --git a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/ble_device_info.h b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/ble_device_info.h index 0cc17493..ad60095e 100644 --- a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/ble_device_info.h +++ b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/ble_device_info.h @@ -135,10 +135,10 @@ typedef struct rsi_ble_dev_ltk_list_s { } rsi_ble_dev_ltk_list_t; #endif -uint8_t rsi_get_ble_conn_id(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN], uint8_t *remote_name, uint8_t size); -uint8_t rsi_add_ble_conn_id(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN], uint8_t *remote_name, uint8_t size); -uint8_t rsi_get_remote_device_role(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN]); -uint8_t rsi_remove_ble_conn_id(uint8_t remote_dev_addr[RSI_REM_DEV_ADDR_LEN]); +uint8_t rsi_get_ble_conn_id(uint8_t *remote_dev_addr, uint8_t *remote_name, uint8_t size); +uint8_t rsi_add_ble_conn_id(uint8_t *remote_dev_addr, uint8_t *remote_name, uint8_t size); +uint8_t rsi_get_remote_device_role(uint8_t *remote_dev_addr); +uint8_t rsi_remove_ble_conn_id(uint8_t *remote_dev_addr); uint8_t rsi_check_ble_conn_status(uint8_t connection_id); #endif diff --git a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_app.c b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_app.c index 607243a3..f610907b 100644 --- a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_app.c +++ b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_app.c @@ -319,20 +319,6 @@ void rsi_wlan_app_thread(void *unused) rsi_wlan_app_cb.state = RSI_WLAN_CONNECTED_STATE; //! update WLAN application state to connected state LOG_PRINT("WLAN connected state \r\n"); } - -#if (RX_DATA && ENABLE_POWER_SAVE) - status = rsi_wlan_power_save_profile(RSI_ACTIVE, PSP_TYPE); - if (status != RSI_SUCCESS) { - LOG_PRINT("\r\n Failed in initiating power save\r\n"); - return; - } - status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, PSP_TYPE); - if (status != RSI_SUCCESS) { - LOG_PRINT("\r\n Failed in initiating power save\r\n"); - return; - } - LOG_PRINT("Kept power save \r\n"); -#endif } break; case RSI_WLAN_CONNECTED_STATE: { //! Configure IP diff --git a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_throughput_ble_dual_role.slcp b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_throughput_ble_dual_role.slcp index 791020ad..ebd7ca52 100644 --- a/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_throughput_ble_dual_role.slcp +++ b/examples/snippets/wlan_ble/wifi_throughput_ble_dual_role/wifi_throughput_ble_dual_role.slcp @@ -18,7 +18,7 @@ sdk: version: 4.4.0 sdk_extension: - id: wiseconnect3_sdk - version: 3.1.1 + version: 3.1.2 source: - path: app.c - path: main.c @@ -64,7 +64,9 @@ requires: - name: device_needs_ram_execution condition: - si91x_common_flash -toolchain_settings: [] +toolchain_settings: + - option: gcc_compiler_option + value: -Wall -Werror configuration: - name: SL_BOARD_ENABLE_VCOM value: "1" diff --git a/out_of_box_demo/out-of-box-demo-soc.rps b/out_of_box_demo/out-of-box-demo-soc.rps index ad48f9fd..d9e9b73d 100644 Binary files a/out_of_box_demo/out-of-box-demo-soc.rps and b/out_of_box_demo/out-of-box-demo-soc.rps differ diff --git a/third_party/aws_sdk/platform/silabs/src/network_sl_api_wrapper.c b/third_party/aws_sdk/platform/silabs/src/network_sl_api_wrapper.c index b1a198b2..9fe844d2 100644 --- a/third_party/aws_sdk/platform/silabs/src/network_sl_api_wrapper.c +++ b/third_party/aws_sdk/platform/silabs/src/network_sl_api_wrapper.c @@ -202,7 +202,7 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) IoT_Error_t iot_tls_write(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *written_len) { - ssize_t bytes_written = 0; + size_t bytes_written = 0; size_t temp_len = len; if (len <= 0) { diff --git a/wifi_templates.xml b/wifi_templates.xml index c8430575..d83eba4f 100644 --- a/wifi_templates.xml +++ b/wifi_templates.xml @@ -585,6 +585,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -870,6 +900,21 @@ + + + + + + + + + + + + + + + diff --git a/wiseconnect3.slce b/wiseconnect3.slce index 0d2a5320..804dbcb0 100644 --- a/wiseconnect3.slce +++ b/wiseconnect3.slce @@ -2,7 +2,7 @@ id: wiseconnect3_sdk label: WiSeConnect 3 SDK description: > WiSeConnect 3 extension for the Gecko SDK -version: "3.1.1" +version: "3.1.2" sdk: id: gecko_sdk version: "4.4.0" @@ -27,6 +27,7 @@ component_path: - path: components/device/silabs/si91x/wireless/crypto/ecdh - path: components/device/silabs/si91x/wireless/crypto/trng - path: components/device/silabs/si91x/wireless/crypto/attestation + - path: components/device/silabs/si91x/wireless/crypto/multithread - path: components/device/silabs/si91x/wireless/errno/component - path: components/service/bsd_socket - path: components/service/network_manager diff --git a/wiseconnect3.slsdk b/wiseconnect3.slsdk index 9c3ec69b..034e3a6e 100644 --- a/wiseconnect3.slsdk +++ b/wiseconnect3.slsdk @@ -1,12 +1,12 @@ # Properties file for Simplicity Studio metadata id=uc.extension.wiseconnect3_sdk -version=3.1.1 +version=3.1.2 label=WiSeConnect 3 description=WiSeConnect 3 SDK -prop.subLabel=Wi-Fi\\ SDK\\ 3.1.1 +prop.subLabel=Wi-Fi\\ SDK\\ 3.1.2 prop.file.templatesFile=wifi_templates.xml wifi_internal_templates.xml