Skip to content

Commit d8216af

Browse files
Kyle Kearneyromanjoe
authored andcommitted
Simplify BSP contents
Remove some (Cypress-proprietary) BSP interfaces and hardware initialization from the BSPs which is better implemented by a library or application firmware. Move some remaining functionality from common to the individual targets.
1 parent 07a43f7 commit d8216af

File tree

20 files changed

+1133
-1368
lines changed

20 files changed

+1133
-1368
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/***************************************************************************//**
2-
* \file CY8CKIT-062S2-43012/cybsp.c
2+
* \file cybsp.c
33
*
44
* 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.
77
*
88
********************************************************************************
99
* \copyright
@@ -32,6 +32,15 @@
3232
extern "C" {
3333
#endif
3434

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+
3544
#if defined(CYBSP_WIFI_CAPABLE)
3645
static cyhal_sdio_t sdio_obj;
3746

@@ -41,6 +50,29 @@ cyhal_sdio_t* cybsp_get_wifi_sdio_obj(void)
4150
}
4251
#endif
4352

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+
4476
cy_rslt_t cybsp_init(void)
4577
{
4678
/* 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)
5284
result = cybsp_register_sysclk_pm_callback();
5385
}
5486

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-
8787
#if defined(CYBSP_WIFI_CAPABLE)
8888
/* Initialize SDIO interface. This must be done before other HAL API calls as some SDIO implementations require
8989
* specific peripheral instances.
@@ -107,8 +107,9 @@ cy_rslt_t cybsp_init(void)
107107
#endif /* defined(CYBSP_WIFI_CAPABLE) */
108108

109109
/* 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+
*/
112113
return result;
113114
}
114115

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/***************************************************************************//**
2-
* \file CY8CKIT-062S2-43012/cybsp.h
2+
* \file cybsp.h
33
*
4-
* Description:
5-
* Provides APIs for interacting with the hardware contained on the Cypress
6-
* CY8CKIT-062S2-43012 pioneer kit.
4+
* \brief
5+
* Basic API for setting up boards containing a Cypress MCU.
76
*
87
********************************************************************************
98
* \copyright
@@ -25,21 +24,25 @@
2524

2625
#pragma once
2726

27+
#include "cy_result.h"
2828
#include "cybsp_types.h"
29-
#include "cybsp_core.h"
3029
#if defined(CYBSP_WIFI_CAPABLE)
3130
#include "cyhal_sdio.h"
3231
#endif
33-
#ifndef __MBED__
34-
#include "cybsp_retarget.h"
35-
#include "cybsp_serial_flash.h"
36-
#include "cybsp_rgb_led.h"
37-
#endif /* __MBED__ */
3832

3933
#if defined(__cplusplus)
4034
extern "C" {
4135
#endif
4236

37+
/**
38+
* \addtogroup group_bsp_macros Macros
39+
* \{
40+
*/
41+
42+
/** Failed to configure sysclk power management callback */
43+
#define CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 0))
44+
45+
/** \} group_bsp_macros */
4346

4447
/**
4548
* \addtogroup group_bsp_functions Functions

0 commit comments

Comments
 (0)