Skip to content

Commit

Permalink
Portenta H7: add api to manage bluetooth low power mode status in CYW…
Browse files Browse the repository at this point in the history
…43xxx chip
  • Loading branch information
leonardocavagnis committed Oct 11, 2023
1 parent 3636262 commit 3ae2609
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 40 deletions.
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

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;
}

0 comments on commit 3ae2609

Please sign in to comment.