1
1
/***************************************************************************/ /**
2
- * \file CY8CKIT-062S2-43012/ cybsp.c
2
+ * \file cybsp.c
3
3
*
4
4
* Description:
5
- * Provides APIs for interacting with the hardware contained on the Cypress
6
- * CY8CKIT-062S2-43012 pioneer kit .
5
+ * Provides initialization code for starting up the hardware contained on the
6
+ * Cypress board .
7
7
*
8
8
********************************************************************************
9
9
* \copyright
32
32
extern "C" {
33
33
#endif
34
34
35
+ /* The sysclk deep sleep callback is recommended to be the last callback that
36
+ * is executed before entry into deep sleep mode and the first one upon
37
+ * exit the deep sleep mode.
38
+ * Doing so minimizes the time spent on low power mode entry and exit.
39
+ */
40
+ #ifndef CYBSP_SYSCLK_PM_CALLBACK_ORDER
41
+ #define CYBSP_SYSCLK_PM_CALLBACK_ORDER (255u)
42
+ #endif
43
+
35
44
#if defined(CYBSP_WIFI_CAPABLE )
36
45
static cyhal_sdio_t sdio_obj ;
37
46
@@ -41,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
41
50
}
42
51
#endif
43
52
53
+ /**
54
+ * Registers a power management callback that prepares the clock system
55
+ * for entering deep sleep mode and restore the clocks upon wakeup from deep sleep.
56
+ * NOTE: This is called automatically as part of \ref cybsp_init
57
+ */
58
+ static cy_rslt_t cybsp_register_sysclk_pm_callback (void )
59
+ {
60
+ cy_rslt_t result = CY_RSLT_SUCCESS ;
61
+ static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL , NULL };
62
+ static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = {
63
+ .callback = & Cy_SysClk_DeepSleepCallback ,
64
+ .type = CY_SYSPM_DEEPSLEEP ,
65
+ .callbackParams = & cybsp_sysclk_pm_callback_param ,
66
+ .order = CYBSP_SYSCLK_PM_CALLBACK_ORDER
67
+ };
68
+
69
+ if (!Cy_SysPm_RegisterCallback (& cybsp_sysclk_pm_callback ))
70
+ {
71
+ result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK ;
72
+ }
73
+ return result ;
74
+ }
75
+
44
76
cy_rslt_t cybsp_init (void )
45
77
{
46
78
/* Setup hardware manager to track resource usage then initialize all system (clock/power) board configuration */
@@ -52,38 +84,6 @@ cy_rslt_t cybsp_init(void)
52
84
result = cybsp_register_sysclk_pm_callback ();
53
85
}
54
86
55
- #ifndef __MBED__
56
- if (CY_RSLT_SUCCESS == result )
57
- {
58
- /* Initialize User LEDs */
59
- /* Reserves: CYBSP_USER_LED1 */
60
- result |= cybsp_led_init (CYBSP_USER_LED1 );
61
- /* Reserves: CYBSP_USER_LED2 */
62
- result |= cybsp_led_init (CYBSP_USER_LED2 );
63
- /* Reserves: CYBSP_USER_LED3 */
64
- result |= cybsp_led_init (CYBSP_USER_LED3 );
65
- /* Reserves: CYBSP_USER_LED4 */
66
- result |= cybsp_led_init (CYBSP_USER_LED4 );
67
- /* Reserves: CYBSP_USER_LED5 */
68
- result |= cybsp_led_init (CYBSP_USER_LED5 );
69
- /* Initialize User Buttons */
70
- /* Reserves: CYBSP_USER_BTN1 */
71
- result |= cybsp_btn_init (CYBSP_USER_BTN1 );
72
- /* Reserves: CYBSP_USER_BTN2 */
73
- result |= cybsp_btn_init (CYBSP_USER_BTN2 );
74
-
75
- CY_ASSERT (CY_RSLT_SUCCESS == result );
76
-
77
- /* Initialize retargetting stdio to 'DEBUG_UART' peripheral */
78
- if (CY_RSLT_SUCCESS == result )
79
- {
80
- /* Reserves: CYBSP_DEBUG_UART_RX, CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RTS, CYBSP_DEBUG_UART_CTS
81
- * corresponding SCB instance and one of available clock dividers */
82
- result = cybsp_retarget_init ();
83
- }
84
- }
85
- #endif /* __MBED__ */
86
-
87
87
#if defined(CYBSP_WIFI_CAPABLE )
88
88
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
89
89
* specific peripheral instances.
@@ -107,8 +107,9 @@ cy_rslt_t cybsp_init(void)
107
107
#endif /* defined(CYBSP_WIFI_CAPABLE) */
108
108
109
109
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
110
- * user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
111
- * (cyreservedresources.list) to make sure no resources are reserved by both. */
110
+ * user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
111
+ * (cyreservedresources.list) to make sure no resources are reserved by both.
112
+ */
112
113
return result ;
113
114
}
114
115
0 commit comments