Skip to content

Commit 07a43f7

Browse files
Kyle Kearneyromanjoe
authored andcommitted
Consolidate/clean up wifi initialization
1 parent 12af4b0 commit 07a43f7

File tree

18 files changed

+382
-256
lines changed

18 files changed

+382
-256
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,19 @@
3232
extern "C" {
3333
#endif
3434

35-
cy_rslt_t cybsp_init(void)
35+
#if defined(CYBSP_WIFI_CAPABLE)
36+
static cyhal_sdio_t sdio_obj;
37+
38+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
3639
{
37-
cy_rslt_t result;
40+
return &sdio_obj;
41+
}
42+
#endif
3843

39-
result = cyhal_hwmgr_init();
44+
cy_rslt_t cybsp_init(void)
45+
{
46+
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
47+
cy_rslt_t result = cyhal_hwmgr_init();
4048
init_cycfg_system();
4149

4250
if (CY_RSLT_SUCCESS == result)
@@ -77,14 +85,24 @@ cy_rslt_t cybsp_init(void)
7785
#endif /* __MBED__ */
7886

7987
#if defined(CYBSP_WIFI_CAPABLE)
80-
/* Initialize SDIO interface.
81-
NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically done
82-
when starting up WiFi. */
88+
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
89+
* specific peripheral instances.
90+
* NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically
91+
* done when starting up WiFi.
92+
*/
8393
if (CY_RSLT_SUCCESS == result)
8494
{
85-
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
86-
* CYBSP_WIFI_SDIO_CMD, CYBSP_WIFI_SDIO_CLK and CYBSP_WIFI_WL_REG_ON */
87-
result = cybsp_wifi_sdio_init();
95+
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
96+
* CYBSP_WIFI_SDIO_CMD and CYBSP_WIFI_SDIO_CLK.
97+
*/
98+
result = cyhal_sdio_init(
99+
&sdio_obj,
100+
CYBSP_WIFI_SDIO_CMD,
101+
CYBSP_WIFI_SDIO_CLK,
102+
CYBSP_WIFI_SDIO_D0,
103+
CYBSP_WIFI_SDIO_D1,
104+
CYBSP_WIFI_SDIO_D2,
105+
CYBSP_WIFI_SDIO_D3);
88106
}
89107
#endif /* defined(CYBSP_WIFI_CAPABLE) */
90108

@@ -94,7 +112,6 @@ cy_rslt_t cybsp_init(void)
94112
return result;
95113
}
96114

97-
98115
#if defined(__cplusplus)
99116
}
100117
#endif

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "cybsp_types.h"
2929
#include "cybsp_core.h"
3030
#if defined(CYBSP_WIFI_CAPABLE)
31-
#include "cybsp_wifi_sdio.h"
31+
#include "cyhal_sdio.h"
3232
#endif
3333
#ifndef __MBED__
3434
#include "cybsp_retarget.h"
@@ -41,6 +41,30 @@ extern "C" {
4141
#endif
4242

4343

44-
#if defined(__cplusplus)
44+
/**
45+
* \addtogroup group_bsp_functions Functions
46+
* \{
47+
*/
48+
49+
/**
50+
* \brief Initialize all hardware on the board
51+
* \returns CY_RSLT_SUCCESS if the board is sucessfully initialized, if there is
52+
* a problem initializing any hardware it returns an error code specific
53+
* to the hardware module that had a problem.
54+
*/
55+
cy_rslt_t cybsp_init(void);
56+
57+
#if defined(CYBSP_WIFI_CAPABLE)
58+
/**
59+
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
60+
* \note This function should only be called after cybsp_init();
61+
* \returns The initialized sdio object.
62+
*/
63+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void);
64+
#endif /* defined(CYBSP_WIFI_CAPABLE) */
65+
66+
/** \} group_bsp_functions */
67+
68+
#ifdef __cplusplus
4569
}
46-
#endif
70+
#endif /* __cplusplus */

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,39 @@
2424

2525
#include <stdlib.h>
2626
#include "cybsp.h"
27-
#include "cycfg_system.h"
27+
#include "cyhal_utils.h"
28+
#include "cycfg.h"
2829

2930
#if defined(__cplusplus)
3031
extern "C" {
3132
#endif
3233

33-
cy_rslt_t cybsp_init(void)
34+
#if defined(CYBSP_WIFI_CAPABLE)
35+
static cyhal_sdio_t sdio_obj;
36+
37+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
3438
{
35-
cy_rslt_t result;
39+
return &sdio_obj;
40+
}
41+
#endif
3642

37-
result = cyhal_hwmgr_init();
43+
cy_rslt_t cybsp_init(void)
44+
{
45+
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
46+
cy_rslt_t result = cyhal_hwmgr_init();
3847
init_cycfg_system();
3948

4049
if (CY_RSLT_SUCCESS == result)
4150
{
4251
result = cybsp_register_sysclk_pm_callback();
4352
}
4453

45-
#ifndef __MBED__
54+
#if defined(CYBSP_WIFI_CAPABLE)
55+
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
56+
* specific peripheral instances.
57+
* NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically
58+
* done when starting up WiFi.
59+
*/
4660
if (CY_RSLT_SUCCESS == result)
4761
{
4862
/* Initialize User LEDs */
@@ -68,8 +82,19 @@ cy_rslt_t cybsp_init(void)
6882
* clock dividers */
6983
result = cybsp_retarget_init();
7084
}
85+
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
86+
* CYBSP_WIFI_SDIO_CMD and CYBSP_WIFI_SDIO_CLK.
87+
*/
88+
result = cyhal_sdio_init(
89+
&sdio_obj,
90+
CYBSP_WIFI_SDIO_CMD,
91+
CYBSP_WIFI_SDIO_CLK,
92+
CYBSP_WIFI_SDIO_D0,
93+
CYBSP_WIFI_SDIO_D1,
94+
CYBSP_WIFI_SDIO_D2,
95+
CYBSP_WIFI_SDIO_D3);
7196
}
72-
#endif /* __MBED__ */
97+
#endif /* defined(CYBSP_WIFI_CAPABLE) */
7398

7499
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
75100
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@
3737
extern "C" {
3838
#endif
3939

40-
#if defined(__cplusplus)
40+
/**
41+
* \addtogroup group_bsp_functions Functions
42+
* \{
43+
*/
44+
#if defined(CYBSP_WIFI_CAPABLE)
45+
/**
46+
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
47+
* \note This function should only be called after cybsp_init();
48+
* \returns The initialized sdio object.
49+
*/
50+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void);
51+
#endif /* defined(CYBSP_WIFI_CAPABLE) */
52+
53+
/** \} group_bsp_functions */
54+
55+
#ifdef __cplusplus
4156
}
42-
#endif
57+
#endif /* __cplusplus */

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,19 @@
3232
extern "C" {
3333
#endif
3434

35-
cy_rslt_t cybsp_init(void)
35+
#if defined(CYBSP_WIFI_CAPABLE)
36+
static cyhal_sdio_t sdio_obj;
37+
38+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
3639
{
37-
cy_rslt_t result;
40+
return &sdio_obj;
41+
}
42+
#endif
3843

39-
result = cyhal_hwmgr_init();
44+
cy_rslt_t cybsp_init(void)
45+
{
46+
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
47+
cy_rslt_t result = cyhal_hwmgr_init();
4048
init_cycfg_system();
4149

4250
if (CY_RSLT_SUCCESS == result)
@@ -74,15 +82,24 @@ cy_rslt_t cybsp_init(void)
7482
#endif /* __MBED__ */
7583

7684
#if defined(CYBSP_WIFI_CAPABLE)
77-
/* Initialize UDB SDIO interface. This must be done before any other HAL API attempts to allocate clocks or DMA
78-
instances. The UDB SDIO interface uses specific instances which are reserved as part of this call.
79-
NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically done
80-
when starting up WiFi. */
85+
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
86+
* specific peripheral instances.
87+
* NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically
88+
* done when starting up WiFi.
89+
*/
8190
if (CY_RSLT_SUCCESS == result)
8291
{
83-
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
84-
* CYBSP_WIFI_SDIO_CMD, CYBSP_WIFI_SDIO_CLK and CYBSP_WIFI_WL_REG_ON */
85-
result = cybsp_wifi_sdio_init();
92+
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
93+
* CYBSP_WIFI_SDIO_CMD and CYBSP_WIFI_SDIO_CLK.
94+
*/
95+
result = cyhal_sdio_init(
96+
&sdio_obj,
97+
CYBSP_WIFI_SDIO_CMD,
98+
CYBSP_WIFI_SDIO_CLK,
99+
CYBSP_WIFI_SDIO_D0,
100+
CYBSP_WIFI_SDIO_D1,
101+
CYBSP_WIFI_SDIO_D2,
102+
CYBSP_WIFI_SDIO_D3);
86103
}
87104
#endif /* defined(CYBSP_WIFI_CAPABLE) */
88105

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "cybsp_types.h"
2929
#include "cybsp_core.h"
3030
#if defined(CYBSP_WIFI_CAPABLE)
31-
#include "cybsp_wifi_sdio.h"
31+
#include "cyhal_sdio.h"
3232
#endif
3333
#ifndef __MBED__
3434
#include "cybsp_retarget.h"
@@ -47,6 +47,17 @@ extern cyhal_uart_t cybsp_debug_uart;
4747
extern cyhal_i2c_t cybsp_i2c;
4848
extern cyhal_rtc_t cybsp_rtc;
4949

50-
#if defined(__cplusplus)
50+
#if defined(CYBSP_WIFI_CAPABLE)
51+
/**
52+
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
53+
* \note This function should only be called after cybsp_init();
54+
* \returns The initialized sdio object.
55+
*/
56+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void);
57+
#endif /* defined(CYBSP_WIFI_CAPABLE) */
58+
59+
/** \} group_bsp_functions */
60+
61+
#ifdef __cplusplus
5162
}
52-
#endif
63+
#endif /* __cplusplus */

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CPROTO_062_4343W/cybsp.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,26 @@
2525

2626
#include <stdlib.h>
2727
#include "cybsp.h"
28+
#include "cyhal_utils.h"
2829
#include "cycfg.h"
2930

3031
#if defined(__cplusplus)
3132
extern "C" {
3233
#endif
3334

34-
cy_rslt_t cybsp_init(void)
35+
#if defined(CYBSP_WIFI_CAPABLE)
36+
static cyhal_sdio_t sdio_obj;
37+
38+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
3539
{
36-
cy_rslt_t result;
40+
return &sdio_obj;
41+
}
42+
#endif
3743

38-
result = cyhal_hwmgr_init();
44+
cy_rslt_t cybsp_init(void)
45+
{
46+
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
47+
cy_rslt_t result = cyhal_hwmgr_init();
3948
init_cycfg_system();
4049

4150
if (CY_RSLT_SUCCESS == result)
@@ -65,14 +74,24 @@ cy_rslt_t cybsp_init(void)
6574
#endif /* __MBED__ */
6675

6776
#if defined(CYBSP_WIFI_CAPABLE)
68-
/* Initialize SDIO interface.
69-
NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically done
70-
when starting up WiFi. */
77+
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
78+
* specific peripheral instances.
79+
* NOTE: The full WiFi interface still needs to be initialized via cybsp_wifi_init_primary(). This is typically
80+
* done when starting up WiFi.
81+
*/
7182
if (CY_RSLT_SUCCESS == result)
7283
{
73-
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
74-
* CYBSP_WIFI_SDIO_CMD, CYBSP_WIFI_SDIO_CLK and CYBSP_WIFI_WL_REG_ON */
75-
result = cybsp_wifi_sdio_init();
84+
/* Reserves: CYBSP_WIFI_SDIO, CYBSP_WIFI_SDIO_D0, CYBSP_WIFI_SDIO_D1, CYBSP_WIFI_SDIO_D2, CYBSP_WIFI_SDIO_D3
85+
* CYBSP_WIFI_SDIO_CMD and CYBSP_WIFI_SDIO_CLK.
86+
*/
87+
result = cyhal_sdio_init(
88+
&sdio_obj,
89+
CYBSP_WIFI_SDIO_CMD,
90+
CYBSP_WIFI_SDIO_CLK,
91+
CYBSP_WIFI_SDIO_D0,
92+
CYBSP_WIFI_SDIO_D1,
93+
CYBSP_WIFI_SDIO_D2,
94+
CYBSP_WIFI_SDIO_D3);
7695
}
7796
#endif /* defined(CYBSP_WIFI_CAPABLE) */
7897

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CPROTO_062_4343W/cybsp.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "cybsp_types.h"
2929
#include "cybsp_core.h"
3030
#if defined(CYBSP_WIFI_CAPABLE)
31-
#include "cybsp_wifi_sdio.h"
31+
#include "cyhal_sdio.h"
3232
#endif
3333
#ifndef __MBED__
3434
#include "cybsp_retarget.h"
@@ -39,6 +39,22 @@
3939
extern "C" {
4040
#endif
4141

42-
#if defined(__cplusplus)
42+
/**
43+
* \addtogroup group_bsp_functions Functions
44+
* \{
45+
*/
46+
47+
#if defined(CYBSP_WIFI_CAPABLE)
48+
/**
49+
* \brief Get the initialized sdio object used for communicating with the WiFi Chip.
50+
* \note This function should only be called after cybsp_init();
51+
* \returns The initialized sdio object.
52+
*/
53+
cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void);
54+
#endif /* defined(CYBSP_WIFI_CAPABLE) */
55+
56+
/** \} group_bsp_functions */
57+
58+
#ifdef __cplusplus
4359
}
44-
#endif
60+
#endif /* __cplusplus */

0 commit comments

Comments
 (0)