Skip to content

Commit c2f7a95

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 df00ed4 commit c2f7a95

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 {
@@ -153,8 +164,9 @@ void CyH4TransportDriver::initialize()
153164
bt_host_wake_active = true;
154165
sleep_manager_lock_deep_sleep();
155166

167+
// Keep the bt_power line in the low level to ensure that the device resets.
156168
bt_power = 0;
157-
rtos::ThisThread::sleep_for(1ms);
169+
rtos::ThisThread::sleep_for(CY_BT_POWER_ON_RESET_TIME);
158170

159171
#if defined(CYW43XXX_UNBUFFERED_UART)
160172
uart.baud(DEF_BT_BAUD_RATE);
@@ -186,7 +198,9 @@ void CyH4TransportDriver::initialize()
186198
cyhal_uart_enable_event(&uart, CYHAL_UART_IRQ_RX_NOT_EMPTY, CYHAL_ISR_PRIORITY_DEFAULT, true);
187199
#endif
188200

201+
// Power up BT
189202
bt_power = 1;
203+
rtos::ThisThread::sleep_for(CY_BT_POWER_ON_SETTLING_TIME);
190204

191205
#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
192206
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
@@ -101,9 +101,6 @@ class HCIDriver : public CordioHCIDriver {
101101

102102
virtual void do_initialize()
103103
{
104-
rtos::ThisThread::sleep_for(500ms);
105-
bt_power = 1;
106-
rtos::ThisThread::sleep_for(500ms);
107104
}
108105

109106
virtual void do_terminate() { }

0 commit comments

Comments
 (0)