Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portenta H7: Add API to manage low power mode of CYW43xxx bluetooth chip #32

Open
wants to merge 3 commits into
base: extrapatches-6.17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,9 @@ ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_drive
return (ble_cordio_get_default_h4_transport_driver());
}

MBED_WEAK
void ble_cordio_set_cycfg_bt_lp_mode(bool status) {
(void)status;
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,6 @@ class CyH4TransportDriver : public CordioHCITransportDriver {

ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_default_h4_transport_driver();
ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver();
void ble_cordio_set_cycfg_bt_lp_mode(bool status);
#endif
#endif /* CY_H4TRANSPORT_DRIVER_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,7 @@ ble::CordioHCIDriver& ble_cordio_get_hci_driver()
);
return hci_driver;
}

void ble_cordio_set_lp_mode(bool status) {
ble_cordio_set_cycfg_bt_lp_mode(status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
#include "CyH4TransportDriver.h"

#define cyhal_gpio_to_rtos(x) (x)
#define CYCFG_BT_LP_ENABLED (1)
#define CYCFG_BT_HOST_WAKE_IRQ_EVENT WAKE_EVENT_ACTIVE_LOW
#define CYCFG_BT_DEV_WAKE_POLARITY WAKE_EVENT_ACTIVE_LOW

static bool cycfg_bt_lp_enabled = true;

/*******************************************************************************
* Function Name: ble_cordio_get_h4_transport_driver
********************************************************************************
Expand All @@ -53,45 +54,30 @@
ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver()
{
#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)

#if (defined(CYCFG_BT_LP_ENABLED))
if (CYCFG_BT_LP_ENABLED) {
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
/* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
/* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
/* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
/* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
DEF_BT_BAUD_RATE,
cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE),
cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE),
CYCFG_BT_HOST_WAKE_IRQ_EVENT,
CYCFG_BT_DEV_WAKE_POLARITY
);
return s_transport_driver;
} else { /* CYCFG_BT_LP_ENABLED */
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
/* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
/* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
/* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
/* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
DEF_BT_BAUD_RATE);
return s_transport_driver;
}
#else /* (defined(CYCFG_BT_LP_ENABLED)) */
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
/* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
/* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
/* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
/* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
DEF_BT_BAUD_RATE),
cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE), cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE)
);
return s_transport_driver;
#endif /* (defined(CYCFG_BT_LP_ENABLED)) */

if (cycfg_bt_lp_enabled) {
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
/* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
/* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
/* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
/* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
DEF_BT_BAUD_RATE,
cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE),
cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE),
CYCFG_BT_HOST_WAKE_IRQ_EVENT,
CYCFG_BT_DEV_WAKE_POLARITY
);
return s_transport_driver;
} else { /* cycfg_bt_lp_enabled */
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
/* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
/* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
/* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
/* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
DEF_BT_BAUD_RATE);
return s_transport_driver;
}
#else /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
Expand All @@ -103,3 +89,19 @@ ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_drive
return s_transport_driver;
#endif /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
}

/*******************************************************************************
* Function Name: ble_cordio_set_cycfg_bt_lp_mode
********************************************************************************
*
* Sets the low-power mode configuration for the Bluetooth stack.
* By default, low-power mode is enabled.
*
* \param status
* - `true` to enable low-power mode.
* - `false` to disable low-power mode.
*******************************************************************************/
void ble_cordio_set_cycfg_bt_lp_mode(bool status)
{
cycfg_bt_lp_enabled = status;
}
6 changes: 6 additions & 0 deletions connectivity/drivers/ble/FEATURE_BLE/CommonHCIDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "mbed_toolchain.h"

MBED_WEAK
void ble_cordio_set_lp_mode(bool status) {
(void)status;
}
Loading