Skip to content

Commit 41d0622

Browse files
author
nazar.palamar
committed
Update of BT power up sequences to remove redundant delay (500ms) in BT_POWER operation during HCIDrive initialization.
Current BT_POWER sequence: 1. BT_POWER=0 ( from CyH4TransportDriver::initialize) 2. delay 1ms ( from CyH4TransportDriver::initialize) 3. BT_POWER=1 ( from CyH4TransportDriver::initialize) 4. delay 500ms (from HCIDriver::do_initialize) 5. BT_POWER=1 (from HCIDriver::do_initialize) 6. delay 500ms (from HCIDriver::do_initialize) updates: 1. remove 4) and 5) 2. keep all BT_POWER operations in one place. The best logic place is CyH4TransportDriver::initialize. So finally the BT_POWER sequences should looks like: 1. BT_POWER=0 ( from CyH4TransportDriver::initialize) 2. delay 1ms ( from CyH4TransportDriver::initialize) 3. BT_POWER=1 ( from CyH4TransportDriver::initialize) 4. delay 500ms ( from CyH4TransportDriver::initialize)
1 parent d4b1534 commit 41d0622

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
#include "rtos/ThisThread.h"
3030
#include <chrono>
3131

32+
// BT settling time after power on
33+
#if !defined (CY_BT_POWER_ON_SETTLING_TIME)
34+
#define CY_BT_POWER_ON_SETTLING_TIME (500ms)
35+
#endif /* !defined (CY_BT_POWER_ON_SETTLING_TIME) */
36+
37+
// Power on reset time
38+
#if !defined (CY_BT_POWER_ON_RESET_TIME)
39+
#define CY_BT_POWER_ON_RESET_TIME (1ms)
40+
#endif /* !defined (CY_BT_POWER_ON_RESET_TIME) */
41+
42+
3243
namespace ble {
3344
namespace vendor {
3445
namespace cypress_ble {
@@ -152,8 +163,9 @@ void CyH4TransportDriver::initialize()
152163
{
153164
sleep_manager_lock_deep_sleep();
154165

166+
// Keep the bt_power line in the low level to ensure that the device resets.
155167
bt_power = 0;
156-
rtos::ThisThread::sleep_for(1ms);
168+
rtos::ThisThread::sleep_for(CY_BT_POWER_ON_RESET_TIME);
157169

158170
#if defined(CYW43XXX_UNBUFFERED_UART)
159171
uart.baud(DEF_BT_BAUD_RATE);
@@ -185,7 +197,9 @@ void CyH4TransportDriver::initialize()
185197
cyhal_uart_enable_event(&uart, CYHAL_UART_IRQ_RX_NOT_EMPTY, CYHAL_ISR_PRIORITY_DEFAULT, true);
186198
#endif
187199

200+
// Power up BT
188201
bt_power = 1;
202+
rtos::ThisThread::sleep_for(CY_BT_POWER_ON_SETTLING_TIME);
189203

190204
#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
191205
if (bt_host_wake_name != NC) {
@@ -229,6 +243,7 @@ void CyH4TransportDriver::terminate()
229243

230244
deassert_bt_dev_wake();
231245

246+
// Power down BT
232247
bt_power = 0; //BT_POWER is an output, should not be freed only set inactive
233248

234249
#if defined(CYW43XXX_UNBUFFERED_UART)

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ class HCIDriver : public CordioHCIDriver {
103103
{
104104
//Prevent PSoC6 to enter deep-sleep till BT initialization is complete
105105
sleep_manager_lock_deep_sleep();
106-
rtos::ThisThread::sleep_for(500ms);
107-
bt_power = 1;
108-
rtos::ThisThread::sleep_for(500ms);
109106
}
110107

111108
virtual void do_terminate() { }

0 commit comments

Comments
 (0)