diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c index 4bd9370200..77225501fa 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c @@ -26,7 +26,6 @@ #include #include "cybsp.h" #include "cyhal_utils.h" -#include "cyhal_implementation.h" #include "cycfg.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h index 70e4fd7b9f..09e992a74b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h @@ -54,13 +54,15 @@ #pragma once -#include "cybsp_api_core.h" +#include "cybsp_types.h" +#include "cybsp_core.h" #if defined(CYBSP_WIFI_CAPABLE) #include "cybsp_wifi_sdio.h" #endif #ifndef __MBED__ #include "cybsp_retarget.h" #include "cybsp_serial_flash.h" +#include "cybsp_rgb_led.h" #endif /* __MBED__ */ #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.c index a95ebd5512..8e1753a8d9 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.c @@ -25,8 +25,7 @@ #include #include "cybsp.h" -#include "cyhal_implementation.h" -#include "cycfg.h" +#include "cycfg_system.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.h index a453c7792b..326ec3ffb4 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.h @@ -52,23 +52,18 @@ #pragma once -#include "cybsp_api_core.h" +#include "cybsp_types.h" +#include "cybsp_core.h" +#ifndef __MBED__ +#include "cybsp_retarget.h" +#include "cybsp_serial_flash.h" +#include "cybsp_rgb_led.h" +#endif /* __MBED__ */ #if defined(__cplusplus) extern "C" { #endif -/** \cond INTERNAL */ - -// HAL HW configuration data -extern cyhal_qspi_t cybsp_qspi; -extern cyhal_uart_t cybsp_bt_uart; -extern cyhal_uart_t cybsp_uart; -extern cyhal_i2c_t cybsp_i2c; -extern cyhal_rtc_t cybsp_rtc; - -/** \endcond */ - #if defined(__cplusplus) } #endif diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.c index 6a16ee7712..dab6fdaa0e 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.c @@ -26,7 +26,6 @@ #include #include "cybsp.h" #include "cyhal_utils.h" -#include "cyhal_implementation.h" #include "cycfg.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.h index 3074116e09..cc73fc97e7 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.h @@ -25,10 +25,16 @@ #pragma once -#include "cybsp_api_core.h" +#include "cybsp_types.h" +#include "cybsp_core.h" #if defined(CYBSP_WIFI_CAPABLE) #include "cybsp_wifi_sdio.h" #endif +#ifndef __MBED__ +#include "cybsp_retarget.h" +#include "cybsp_serial_flash.h" +#include "cybsp_rgb_led.h" +#endif /* __MBED__ */ #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/cybsp.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/cybsp.c index ee7669cdb3..7660fba891 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/cybsp.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/cybsp.c @@ -25,7 +25,6 @@ #include #include "cybsp.h" -#include "cyhal_implementation.h" #include "cycfg.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.c index 5272e58cc8..55df15de11 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.c @@ -25,7 +25,6 @@ #include #include "cybsp.h" -#include "cyhal_implementation.h" #include "cycfg.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.h index f175ff878e..3d135b0c71 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.h @@ -52,11 +52,15 @@ #pragma once -#ifdef MBED -#include "cybsp_api_wifi.h" -#else -#include "cybsp_api_core.h" -#endif /* MBED */ +#include "cybsp_types.h" +#include "cybsp_core.h" +#if defined(CYBSP_WIFI_CAPABLE) +#include "cybsp_wifi_sdio.h" +#endif +#ifndef __MBED__ +#include "cybsp_retarget.h" +#include "cybsp_rgb_led.h" +#endif /* __MBED__ */ #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_common.c b/targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.c similarity index 74% rename from targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_common.c rename to targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.c index 7f883481de..c935686aff 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_common.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.c @@ -1,5 +1,5 @@ /***************************************************************************//** -* \file cybsp_utils.c +* \file cybsp_core.c * * \brief * Provides utility functions that are used by board support packages. @@ -22,16 +22,13 @@ * limitations under the License. *******************************************************************************/ -#include "cybsp_api_core.h" +#include "cybsp_core.h" #include "cyhal.h" -#include "cyhal_implementation.h" #if defined(__cplusplus) extern "C" { #endif -static void (*btn_interrupt_call_back) (void); - cy_rslt_t cybsp_led_init(cybsp_led_t which) { return cyhal_gpio_init((cyhal_gpio_t)which, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF); @@ -57,22 +54,12 @@ bool cybsp_btn_get_state(cybsp_btn_t which) return cyhal_gpio_read((cyhal_gpio_t)which); } -static void gpio_call_back_wrapper(void *handler_arg, cyhal_gpio_irq_event_t event) +void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_event_t type, cyhal_gpio_event_callback_t callback, void *callback_arg) { - if (btn_interrupt_call_back != NULL) - { - btn_interrupt_call_back(); - } + cyhal_gpio_register_callback((cyhal_gpio_t)which, callback, callback_arg); + cyhal_gpio_enable_event((cyhal_gpio_t)which, type, 7, 1); } -void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_irq_event_t type, void (*callback)(void)) -{ - btn_interrupt_call_back = callback; - cyhal_gpio_register_irq((cyhal_gpio_t)which, 7, &gpio_call_back_wrapper, NULL); - cyhal_gpio_irq_enable((cyhal_gpio_t)which, type, 1); -} - - #if defined(__cplusplus) } #endif diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/include/cybsp_api_core.h b/targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.h similarity index 90% rename from targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/include/cybsp_api_core.h rename to targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.h index f89edc0981..a91f6a3295 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/include/cybsp_api_core.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.h @@ -1,5 +1,5 @@ /***************************************************************************//** -* \file cybsp_api_core.h +* \file cybsp_core.h * * \brief * Basic abstraction layer for dealing with boards containing a Cypress MCU. This @@ -25,21 +25,21 @@ *******************************************************************************/ /** -* \addtogroup group_abstraction_board Board abstraction -* \ingroup group_abstraction +* \addtogroup group_bsp_core Core * \{ * Basic abstraction layer for dealing with boards containing a Cypress MCU. This * API provides convenience methods for initializing and manipulating different * hardware found on the board. * -* \defgroup group_abstraction_board_macros Macros -* \defgroup group_abstraction_board_functions Functions +* \defgroup group_bsp_core_macros Macros +* \defgroup group_bsp_core_functions Functions */ #pragma once #include #include "cy_result.h" +#include "cyhal_gpio.h" #include "cybsp_types.h" #if defined(__cplusplus) @@ -125,9 +125,10 @@ bool cybsp_btn_get_state(cybsp_btn_t which); * \brief Sets the interrupt to trigger when the button state is changed. * \param which The specific button number to get state from, see BSP header file for available buttones * \param type The type sets level vs edge and active high vs active low - * \param callback The function pointer to call when the button state changes + * \param callback The function pointer to call when the button state changes. NULL to unregister. + * \param callback_arg The optional argument to provide when the callback is executed. This can be NULL. */ -void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_irq_event_t type, void (*callback)(void)); +void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_event_t type, cyhal_gpio_event_callback_t callback, void *callback_arg); /** \} group_abstraction_board_functions */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c index 69c69a94a0..de6e52b0de 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c @@ -19,7 +19,7 @@ #include "device.h" #include "cycfg.h" #include "cyhal_hwmgr.h" -#include "cybsp_api_core.h" +#include "cybsp_core.h" #include "mbed_power_mgmt.h" #include "rtos_idle.h"