Skip to content

Commit 3f4c888

Browse files
author
Kyle Kearney
committed
Clean up common BSP implementation
1 parent 247618b commit 3f4c888

File tree

11 files changed

+40
-50
lines changed

11 files changed

+40
-50
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <stdlib.h>
2727
#include "cybsp.h"
2828
#include "cyhal_utils.h"
29-
#include "cyhal_implementation.h"
3029
#include "cycfg.h"
3130

3231
#if defined(__cplusplus)

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062S2_43012/cybsp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@
5454

5555
#pragma once
5656

57-
#include "cybsp_api_core.h"
57+
#include "cybsp_types.h"
58+
#include "cybsp_core.h"
5859
#if defined(CYBSP_WIFI_CAPABLE)
5960
#include "cybsp_wifi_sdio.h"
6061
#endif
6162
#ifndef __MBED__
6263
#include "cybsp_retarget.h"
6364
#include "cybsp_serial_flash.h"
65+
#include "cybsp_rgb_led.h"
6466
#endif /* __MBED__ */
6567

6668
#if defined(__cplusplus)

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
#include <stdlib.h>
2727
#include "cybsp.h"
28-
#include "cyhal_implementation.h"
29-
#include "cycfg.h"
28+
#include "cycfg_system.h"
3029

3130
#if defined(__cplusplus)
3231
extern "C" {

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/cybsp.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,18 @@
5252

5353
#pragma once
5454

55-
#include "cybsp_api_core.h"
55+
#include "cybsp_types.h"
56+
#include "cybsp_core.h"
57+
#ifndef __MBED__
58+
#include "cybsp_retarget.h"
59+
#include "cybsp_serial_flash.h"
60+
#include "cybsp_rgb_led.h"
61+
#endif /* __MBED__ */
5662

5763
#if defined(__cplusplus)
5864
extern "C" {
5965
#endif
6066

61-
/** \cond INTERNAL */
62-
63-
// HAL HW configuration data
64-
extern cyhal_qspi_t cybsp_qspi;
65-
extern cyhal_uart_t cybsp_bt_uart;
66-
extern cyhal_uart_t cybsp_uart;
67-
extern cyhal_i2c_t cybsp_i2c;
68-
extern cyhal_rtc_t cybsp_rtc;
69-
70-
/** \endcond */
71-
7267
#if defined(__cplusplus)
7368
}
7469
#endif

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <stdlib.h>
2727
#include "cybsp.h"
2828
#include "cyhal_utils.h"
29-
#include "cyhal_implementation.h"
3029
#include "cycfg.h"
3130

3231
#if defined(__cplusplus)

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/cybsp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525

2626
#pragma once
2727

28-
#include "cybsp_api_core.h"
28+
#include "cybsp_types.h"
29+
#include "cybsp_core.h"
2930
#if defined(CYBSP_WIFI_CAPABLE)
3031
#include "cybsp_wifi_sdio.h"
3132
#endif
33+
#ifndef __MBED__
34+
#include "cybsp_retarget.h"
35+
#include "cybsp_serial_flash.h"
36+
#include "cybsp_rgb_led.h"
37+
#endif /* __MBED__ */
3238

3339
#if defined(__cplusplus)
3440
extern "C" {

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/cybsp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include <stdlib.h>
2727
#include "cybsp.h"
28-
#include "cyhal_implementation.h"
2928
#include "cycfg.h"
3029

3130
#if defined(__cplusplus)

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include <stdlib.h>
2727
#include "cybsp.h"
28-
#include "cyhal_implementation.h"
2928
#include "cycfg.h"
3029

3130
#if defined(__cplusplus)

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/cybsp.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@
5252

5353
#pragma once
5454

55-
#ifdef MBED
56-
#include "cybsp_api_wifi.h"
57-
#else
58-
#include "cybsp_api_core.h"
59-
#endif /* MBED */
55+
#include "cybsp_types.h"
56+
#include "cybsp_core.h"
57+
#if defined(CYBSP_WIFI_CAPABLE)
58+
#include "cybsp_wifi_sdio.h"
59+
#endif
60+
#ifndef __MBED__
61+
#include "cybsp_retarget.h"
62+
#include "cybsp_rgb_led.h"
63+
#endif /* __MBED__ */
6064

6165
#if defined(__cplusplus)
6266
extern "C" {

targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_common.c renamed to targets/TARGET_Cypress/TARGET_PSOC6/common/cybsp_core.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************//**
2-
* \file cybsp_utils.c
2+
* \file cybsp_core.c
33
*
44
* \brief
55
* Provides utility functions that are used by board support packages.
@@ -22,16 +22,13 @@
2222
* limitations under the License.
2323
*******************************************************************************/
2424

25-
#include "cybsp_api_core.h"
25+
#include "cybsp_core.h"
2626
#include "cyhal.h"
27-
#include "cyhal_implementation.h"
2827

2928
#if defined(__cplusplus)
3029
extern "C" {
3130
#endif
3231

33-
static void (*btn_interrupt_call_back) (void);
34-
3532
cy_rslt_t cybsp_led_init(cybsp_led_t which)
3633
{
3734
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)
5754
return cyhal_gpio_read((cyhal_gpio_t)which);
5855
}
5956

60-
static void gpio_call_back_wrapper(void *handler_arg, cyhal_gpio_irq_event_t event)
57+
void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_event_t type, cyhal_gpio_event_callback_t callback, void *callback_arg)
6158
{
62-
if (btn_interrupt_call_back != NULL)
63-
{
64-
btn_interrupt_call_back();
65-
}
59+
cyhal_gpio_register_callback((cyhal_gpio_t)which, callback, callback_arg);
60+
cyhal_gpio_enable_event((cyhal_gpio_t)which, type, 7, 1);
6661
}
6762

68-
void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_irq_event_t type, void (*callback)(void))
69-
{
70-
btn_interrupt_call_back = callback;
71-
cyhal_gpio_register_irq((cyhal_gpio_t)which, 7, &gpio_call_back_wrapper, NULL);
72-
cyhal_gpio_irq_enable((cyhal_gpio_t)which, type, 1);
73-
}
74-
75-
7663
#if defined(__cplusplus)
7764
}
7865
#endif
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************//**
2-
* \file cybsp_api_core.h
2+
* \file cybsp_core.h
33
*
44
* \brief
55
* Basic abstraction layer for dealing with boards containing a Cypress MCU. This
@@ -25,21 +25,21 @@
2525
*******************************************************************************/
2626

2727
/**
28-
* \addtogroup group_abstraction_board Board abstraction
29-
* \ingroup group_abstraction
28+
* \addtogroup group_bsp_core Core
3029
* \{
3130
* Basic abstraction layer for dealing with boards containing a Cypress MCU. This
3231
* API provides convenience methods for initializing and manipulating different
3332
* hardware found on the board.
3433
*
35-
* \defgroup group_abstraction_board_macros Macros
36-
* \defgroup group_abstraction_board_functions Functions
34+
* \defgroup group_bsp_core_macros Macros
35+
* \defgroup group_bsp_core_functions Functions
3736
*/
3837

3938
#pragma once
4039

4140
#include <stdbool.h>
4241
#include "cy_result.h"
42+
#include "cyhal_gpio.h"
4343
#include "cybsp_types.h"
4444

4545
#if defined(__cplusplus)
@@ -125,9 +125,10 @@ bool cybsp_btn_get_state(cybsp_btn_t which);
125125
* \brief Sets the interrupt to trigger when the button state is changed.
126126
* \param which The specific button number to get state from, see BSP header file for available buttones
127127
* \param type The type sets level vs edge and active high vs active low
128-
* \param callback The function pointer to call when the button state changes
128+
* \param callback The function pointer to call when the button state changes. NULL to unregister.
129+
* \param callback_arg The optional argument to provide when the callback is executed. This can be NULL.
129130
*/
130-
void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_irq_event_t type, void (*callback)(void));
131+
void cybsp_btn_set_interrupt(cybsp_btn_t which, cyhal_gpio_event_t type, cyhal_gpio_event_callback_t callback, void *callback_arg);
131132

132133

133134
/** \} group_abstraction_board_functions */

0 commit comments

Comments
 (0)