|
29 | 29 | #include "rtos/ThisThread.h"
|
30 | 30 | #include <chrono>
|
31 | 31 |
|
| 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 | + |
32 | 43 | namespace ble {
|
33 | 44 | namespace vendor {
|
34 | 45 | namespace cypress_ble {
|
@@ -153,8 +164,9 @@ void CyH4TransportDriver::initialize()
|
153 | 164 | bt_host_wake_active = true;
|
154 | 165 | sleep_manager_lock_deep_sleep();
|
155 | 166 |
|
| 167 | + // Keep the bt_power line in the low level to ensure that the device resets. |
156 | 168 | bt_power = 0;
|
157 |
| - rtos::ThisThread::sleep_for(1ms); |
| 169 | + rtos::ThisThread::sleep_for(CY_BT_POWER_ON_RESET_TIME); |
158 | 170 |
|
159 | 171 | #if defined(CYW43XXX_UNBUFFERED_UART)
|
160 | 172 | uart.baud(DEF_BT_BAUD_RATE);
|
@@ -186,7 +198,9 @@ void CyH4TransportDriver::initialize()
|
186 | 198 | cyhal_uart_enable_event(&uart, CYHAL_UART_IRQ_RX_NOT_EMPTY, CYHAL_ISR_PRIORITY_DEFAULT, true);
|
187 | 199 | #endif
|
188 | 200 |
|
| 201 | + // Power up BT |
189 | 202 | bt_power = 1;
|
| 203 | + rtos::ThisThread::sleep_for(CY_BT_POWER_ON_SETTLING_TIME); |
190 | 204 |
|
191 | 205 | #if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
|
192 | 206 | if (bt_host_wake_name != NC) {
|
@@ -229,6 +243,7 @@ void CyH4TransportDriver::terminate()
|
229 | 243 |
|
230 | 244 | deassert_bt_dev_wake();
|
231 | 245 |
|
| 246 | + // Power down BT |
232 | 247 | bt_power = 0; //BT_POWER is an output, should not be freed only set inactive
|
233 | 248 |
|
234 | 249 | #if defined(CYW43XXX_UNBUFFERED_UART)
|
|
0 commit comments