26
26
#include "cybsp_api_wifi.h"
27
27
#include "cy_network_buffer.h"
28
28
#include "cmsis_os2.h"
29
- #include "whd_bus_types .h"
29
+ #include "whd_types .h"
30
30
#include "cyhal.h"
31
31
#include "cyhal_implementation.h"
32
32
@@ -45,6 +45,10 @@ extern "C" {
45
45
#define SDIO_RETRY_DELAY_MS 1
46
46
#define SDIO_BUS_LEVEL_MAX_RETRIES 5
47
47
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
+
48
52
/* Determine whether to use the SDIO oob interrupt.
49
53
* When CY_SDIO_BUS_NEEDS_OOB_INTR is defined,
50
54
* use its value to determine enable status; otherwise,
@@ -103,9 +107,6 @@ whd_driver_t whd_drv;
103
107
bool sdio_initialized = false;
104
108
cyhal_sdio_t sdio_obj ;
105
109
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
-
109
110
static whd_buffer_funcs_t buffer_ops =
110
111
{
111
112
.whd_host_buffer_get = cy_host_buffer_get ,
@@ -121,21 +122,9 @@ static whd_netif_funcs_t netif_ops =
121
122
.whd_network_process_ethernet_data = cy_network_process_ethernet_data ,
122
123
};
123
124
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
-
130
125
//TODO: Need to use resource implemenatation from abstraction layer.
131
126
extern whd_resource_source_t resource_ops ;
132
127
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
-
139
128
static cy_rslt_t sdio_try_send_cmd (const cyhal_sdio_t * sdio_object , cyhal_transfer_t direction , \
140
129
cyhal_sdio_command_t command , uint32_t argument , uint32_t * response )
141
130
{
@@ -223,22 +212,24 @@ static void deinit_sdio_whd(void)
223
212
224
213
static cy_rslt_t init_sdio_bus (void )
225
214
{
226
- whd_sdio_config_t whd_sdio_config ;
227
- cyhal_sdio_cfg_t config ;
228
-
229
215
cy_rslt_t result = cybsp_sdio_enumerate (& sdio_obj );
230
-
231
216
if (result == CY_RSLT_SUCCESS )
232
217
{
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
+
234
229
whd_sdio_config .sdio_1bit_mode = WHD_FALSE ;
235
230
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 );
242
233
243
234
/* Increase frequency to 25 MHz for better performance */
244
235
config .frequencyhal_hz = 25000000 ;
@@ -248,40 +239,6 @@ static cy_rslt_t init_sdio_bus(void)
248
239
return result ;
249
240
}
250
241
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
-
285
242
cy_rslt_t cybsp_sdio_init (void )
286
243
{
287
244
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)
307
264
if (ret == WHD_SUCCESS )
308
265
{
309
266
result = init_sdio_bus ();
310
- if (result == CY_RSLT_SUCCESS && CY_SDIO_BUS_USE_OOB_INTR != 0 )
311
- {
312
- result = init_wlan_wakeup ();
313
- }
314
267
}
315
268
else
316
269
{
0 commit comments