1 /***************************************************************************/ /** 2 * @file 3 * @brief 4 ******************************************************************************* 5 * # License 6 * <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b> 7 ******************************************************************************* 8 * 9 * SPDX-License-Identifier: Zlib 10 * 11 * The licensor of this software is Silicon Laboratories Inc. 12 * 13 * This software is provided 'as-is', without any express or implied 14 * warranty. In no event will the authors be held liable for any damages 15 * arising from the use of this software. 16 * 17 * Permission is granted to anyone to use this software for any purpose, 18 * including commercial applications, and to alter it and redistribute it 19 * freely, subject to the following restrictions: 20 * 21 * 1. The origin of this software must not be misrepresented; you must not 22 * claim that you wrote the original software. If you use this software 23 * in a product, an acknowledgment in the product documentation would be 24 * appreciated but is not required. 25 * 2. Altered source versions must be plainly marked as such, and must not be 26 * misrepresented as being the original software. 27 * 3. This notice may not be removed or altered from any source distribution. 28 * 29 ******************************************************************************/ 30 #pragma once 31 32 #include "sl_status.h" 33 #include "sl_wifi_types.h" 34 #include "sl_wifi_host_interface.h" 35 #include "sl_si91x_types.h" 36 #include "sl_wifi_device.h" 37 #include <stdbool.h> 38 #include <stdint.h> 39 40 typedef sl_status_t (*sl_si91x_host_rx_irq_handler)(void); 41 typedef void (*sl_si91x_host_rx_done_handler)(void); 42 43 typedef struct { 44 sl_si91x_host_rx_irq_handler rx_irq; 45 sl_si91x_host_rx_done_handler rx_done; 46 uint8_t boot_option; 47 } sl_si91x_host_init_configuration; 48 49 /** 50 * @brief 51 * This API will make RST GPIO to low. 52 */ 53 void sl_si91x_host_hold_in_reset(void); 54 55 /** 56 * @brief 57 * This API used to release the device from reset state. 58 */ 59 void sl_si91x_host_release_from_reset(void); 60 61 /** 62 * @brief 63 * This API used to allocate all threads, mutexes and event handlers 64 * @return sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 65 */ 66 sl_status_t sl_si91x_host_init(const sl_si91x_host_init_configuration *config); 67 68 /** 69 * @brief 70 * This API used to deallocate all threads, mutexes and event handlers. 71 * @return sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 72 */ 73 sl_status_t sl_si91x_host_deinit(void); 74 75 // --------------- 76 /** 77 * @brief 78 * This API is responsible for configuring a high speed communication bus. 79 */ 80 void sl_si91x_host_enable_high_speed_bus(); 81 82 /** 83 * @brief 84 * This API is used for processing the data frames. 85 * @param interface 86 * [sl_wifi_interface_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-constants#sl-wifi-interface-t) Wi-Fi interface on which the data frame needs to be processed. 87 * @param buffer 88 * pointer to a structure of type [sl_wifi_buffer_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-buffer-t) containing the data frame to be processed. 89 * @return sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 90 */ 91 sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface, sl_wifi_buffer_t *buffer); 92 93 /** 94 * @brief 95 * Enable interrupts 96 * 97 */ 98 void sl_si91x_host_enable_bus_interrupt(void); 99 100 /** 101 * @brief 102 * Disable interrupts 103 */ 104 void sl_si91x_host_disable_bus_interrupt(void); 105 106 /** 107 * @brief 108 * Sets sleep Indication GPIO to HIGH. 109 * 110 */ 111 void sl_si91x_host_set_sleep_indicator(void); 112 113 /** 114 * @addtogroup EXTERNAL_HOST_INTERFACE_FUNCTIONS 115 * @{ 116 */ 117 118 /** 119 * @brief 120 * Sets sleep Indication GPIO to LOW 121 */ 122 void sl_si91x_host_clear_sleep_indicator(void); 123 124 /** @} */ 125 126 /** 127 * @brief 128 * Reads Wakeup Indication GPIO value 129 * 130 * @return uint32_t 131 */ 132 uint32_t sl_si91x_host_get_wake_indicator(void); 133 134 sl_status_t sl_si91x_host_spi_transfer( 135 const void *tx_buffer, 136 void *rx_buffer, 137 uint16_t buffer_length); /*Function used for data transfer between NWP and MCU over SPI*/ 138 139 sl_status_t sl_si91x_host_uart_transfer( 140 const void *tx_buffer, 141 void *rx_buffer, 142 uint16_t buffer_length); /*Function used for data transfer between NWP and MCU over UART/USART*/ 143 144 void sl_si91x_host_flush_uart_rx(void); /*Function used to flush all the old data in the uart/usart rx stream*/ 145 146 void sl_si91x_host_uart_enable_hardware_flow_control(void); /*Function to enable Hardware Flow Control on host*/ 147 148 /** 149 * @brief Check whether the current CPU operation mode is handler mode 150 * 151 * @return true 152 * @return false 153 */ 154 bool sl_si91x_host_is_in_irq_context(void); 155