2626#include "cybsp_api_wifi.h"
2727#include "cy_network_buffer.h"
2828#include "cmsis_os2.h"
29- #include "whd_bus_types .h"
29+ #include "whd_types .h"
3030#include "cyhal.h"
3131#include "cyhal_implementation.h"
3232
@@ -45,6 +45,10 @@ extern "C" {
4545#define SDIO_RETRY_DELAY_MS 1
4646#define SDIO_BUS_LEVEL_MAX_RETRIES 5
4747
48+ #if !defined(CY_WIFI_OOB_INTR_PRIORITY )
49+ #define CY_WIFI_OOB_INTR_PRIORITY 2
50+ #endif /* !defined(CY_WIFI_OOB_INTR_PRIORITY) */
51+
4852/* Determine whether to use the SDIO oob interrupt.
4953 * When CY_SDIO_BUS_NEEDS_OOB_INTR is defined,
5054 * use its value to determine enable status; otherwise,
@@ -103,9 +107,6 @@ whd_driver_t whd_drv;
103107bool sdio_initialized = false;
104108cyhal_sdio_t sdio_obj ;
105109
106- static void cy_enable_oob_intr (whd_driver_t whd_driver , const whd_variant_t intr , whd_bool_t whd_enable );
107- static void cy_get_intr_config (whd_driver_t whd_driver , const whd_variant_t intr , whd_intr_config_t * config );
108-
109110static whd_buffer_funcs_t buffer_ops =
110111{
111112 .whd_host_buffer_get = cy_host_buffer_get ,
@@ -121,21 +122,9 @@ static whd_netif_funcs_t netif_ops =
121122 .whd_network_process_ethernet_data = cy_network_process_ethernet_data ,
122123};
123124
124- static whd_sdio_funcs_t sdio_ops =
125- {
126- .whd_enable_intr = cy_enable_oob_intr ,
127- .whd_get_intr_config = cy_get_intr_config ,
128- };
129-
130125//TODO: Need to use resource implemenatation from abstraction layer.
131126extern whd_resource_source_t resource_ops ;
132127
133- static void whd_wake_host_irq_handler (void * arg , cyhal_gpio_irq_event_t event )
134- {
135- //TODO: Swtich out from deep sleep or LP mode.
136- whd_bus_sdio_oob_intr_asserted (arg );
137- }
138-
139128static cy_rslt_t sdio_try_send_cmd (const cyhal_sdio_t * sdio_object , cyhal_transfer_t direction , \
140129 cyhal_sdio_command_t command , uint32_t argument , uint32_t * response )
141130{
@@ -223,22 +212,24 @@ static void deinit_sdio_whd(void)
223212
224213static cy_rslt_t init_sdio_bus (void )
225214{
226- whd_sdio_config_t whd_sdio_config ;
227- cyhal_sdio_cfg_t config ;
228-
229215 cy_rslt_t result = cybsp_sdio_enumerate (& sdio_obj );
230-
231216 if (result == CY_RSLT_SUCCESS )
232217 {
233- whd_sdio_config .flags = 0 ;
218+ whd_sdio_config_t whd_sdio_config ;
219+ whd_oob_config_t oob_config ;
220+ cyhal_sdio_cfg_t config ;
221+
222+ oob_config .host_oob_pin = CY_WIFI_HOST_WAKE_GPIO ;
223+ oob_config .dev_gpio_sel = DEFAULT_OOB_PIN ;
224+ oob_config .is_falling_edge = (CY_WIFI_HOST_WAKE_IRQ_EVENT == CYHAL_GPIO_IRQ_FALL )
225+ ? WHD_TRUE
226+ : WHD_FALSE ;
227+ oob_config .intr_priority = CY_WIFI_OOB_INTR_PRIORITY ;
228+
234229 whd_sdio_config .sdio_1bit_mode = WHD_FALSE ;
235230 whd_sdio_config .high_speed_sdio_clock = WHD_FALSE ;
236- if (CY_SDIO_BUS_USE_OOB_INTR != 0 )
237- {
238- whd_sdio_config .flags |= WHD_BUS_SDIO_OOB_INTR ;
239- whd_sdio_config .oob_intr .u32val = 0 ; /* reserved for multi whd instances */
240- }
241- whd_bus_sdio_attach (whd_drv , & whd_sdio_config , & sdio_obj , & sdio_ops );
231+ whd_sdio_config .oob_config = oob_config ;
232+ whd_bus_sdio_attach (whd_drv , & whd_sdio_config , & sdio_obj );
242233
243234 /* Increase frequency to 25 MHz for better performance */
244235 config .frequencyhal_hz = 25000000 ;
@@ -248,40 +239,6 @@ static cy_rslt_t init_sdio_bus(void)
248239 return result ;
249240}
250241
251- static cy_rslt_t init_wlan_wakeup (void )
252- {
253- /* assert(CY_SDIO_BUS_USE_OOB_INTR != 0) */
254- cy_rslt_t result = cyhal_gpio_init (CY_WIFI_HOST_WAKE_GPIO , CYHAL_GPIO_DIR_INPUT , CY_WIFI_HOST_WAKE_GPIO_DM , 0 );
255- if (result == CY_RSLT_SUCCESS )
256- {
257- cyhal_gpio_register_irq (CY_WIFI_HOST_WAKE_GPIO , WLAN_INTR_PRIORITY , whd_wake_host_irq_handler , whd_drv );
258- }
259- return result ;
260- }
261-
262- static void cy_enable_oob_intr (whd_driver_t whd_driver , const whd_variant_t intr , whd_bool_t whd_enable )
263- {
264- /* assert(CY_SDIO_BUS_USE_OOB_INTR != 0) */
265- (void )whd_driver ;
266- (void )intr ;
267- //TODO: This needs to be enabled in the WHD after the rtos is initialized. The current location where this is called
268- //causes a crash in the interrupt handler since it tries to set data on the thread before it is initialized.
269- //Need to review where this should be called in the WHD.
270- // cyhal_gpio_irq_enable(CY_WIFI_HOST_WAKE_GPIO, CY_WIFI_HOST_WAKE_IRQ_EVENT,
271- // (whd_enable == WHD_TRUE) ? true : false);
272- }
273-
274- static void cy_get_intr_config (whd_driver_t whd_driver , const whd_variant_t intr , whd_intr_config_t * config )
275- {
276- /* assert(CY_SDIO_BUS_USE_OOB_INTR != 0) */
277- (void )whd_driver ;
278- (void )intr ;
279- config -> dev_gpio_sel = DEFAULT_OOB_PIN ;
280- config -> is_falling_edge = (CY_WIFI_HOST_WAKE_IRQ_EVENT == CYHAL_GPIO_IRQ_FALL )
281- ? WHD_TRUE
282- : WHD_FALSE ;
283- }
284-
285242cy_rslt_t cybsp_sdio_init (void )
286243{
287244 cy_rslt_t result = cyhal_sdio_init (& sdio_obj , CYBSP_WIFI_SDIO_CMD , CYBSP_WIFI_SDIO_CLK , CYBSP_WIFI_SDIO_D0 , CYBSP_WIFI_SDIO_D1 , CYBSP_WIFI_SDIO_D2 , CYBSP_WIFI_SDIO_D3 );
@@ -307,10 +264,6 @@ cy_rslt_t cybsp_wifi_init(void)
307264 if (ret == WHD_SUCCESS )
308265 {
309266 result = init_sdio_bus ();
310- if (result == CY_RSLT_SUCCESS && CY_SDIO_BUS_USE_OOB_INTR != 0 )
311- {
312- result = init_wlan_wakeup ();
313- }
314267 }
315268 else
316269 {
0 commit comments