|
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 {
|
@@ -152,8 +163,9 @@ void CyH4TransportDriver::initialize()
|
152 | 163 | {
|
153 | 164 | sleep_manager_lock_deep_sleep();
|
154 | 165 |
|
| 166 | + // Keep the bt_power line in the low level to ensure that the device resets. |
155 | 167 | bt_power = 0;
|
156 |
| - rtos::ThisThread::sleep_for(1ms); |
| 168 | + rtos::ThisThread::sleep_for(CY_BT_POWER_ON_RESET_TIME); |
157 | 169 |
|
158 | 170 | #if defined(CYW43XXX_UNBUFFERED_UART)
|
159 | 171 | uart.baud(DEF_BT_BAUD_RATE);
|
@@ -185,7 +197,9 @@ void CyH4TransportDriver::initialize()
|
185 | 197 | cyhal_uart_enable_event(&uart, CYHAL_UART_IRQ_RX_NOT_EMPTY, CYHAL_ISR_PRIORITY_DEFAULT, true);
|
186 | 198 | #endif
|
187 | 199 |
|
| 200 | + // Power up BT |
188 | 201 | bt_power = 1;
|
| 202 | + rtos::ThisThread::sleep_for(CY_BT_POWER_ON_SETTLING_TIME); |
189 | 203 |
|
190 | 204 | #if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
|
191 | 205 | 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