20
20
#include " CyH4TransportDriver.h"
21
21
#include " mbed_power_mgmt.h"
22
22
#include " drivers/InterruptIn.h"
23
- #if !defined(CYW43XXX_UNBUFFERED_UART)
23
+ #if !( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
24
24
#include " cybsp_types.h"
25
25
#endif
26
26
#include " Callback.h"
@@ -34,7 +34,7 @@ namespace cypress_ble {
34
34
using namespace std ::chrono_literals;
35
35
36
36
CyH4TransportDriver::CyH4TransportDriver (PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud, PinName bt_host_wake_name, PinName bt_device_wake_name, uint8_t host_wake_irq, uint8_t dev_wake_irq) :
37
- #if defined(CYW43XXX_UNBUFFERED_UART)
37
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
38
38
uart (tx, rx),
39
39
#else
40
40
tx (tx), rx(rx),
@@ -54,7 +54,7 @@ CyH4TransportDriver::CyH4TransportDriver(PinName tx, PinName rx, PinName cts, Pi
54
54
}
55
55
56
56
CyH4TransportDriver::CyH4TransportDriver (PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud) :
57
- #if defined(CYW43XXX_UNBUFFERED_UART)
57
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
58
58
uart (tx, rx),
59
59
#else
60
60
tx (tx), rx(rx),
@@ -116,20 +116,20 @@ void CyH4TransportDriver::bt_host_wake_fall_irq_handler(void)
116
116
}
117
117
}
118
118
119
- #if defined(CYW43XXX_UNBUFFERED_UART)
119
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
120
120
void CyH4TransportDriver::on_controller_irq ()
121
121
#else
122
122
static void on_controller_irq (void *callback_arg, cyhal_uart_event_t event)
123
123
#endif
124
124
{
125
- #if !defined(CYW43XXX_UNBUFFERED_UART)
125
+ #if !( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
126
126
(void )(event);
127
127
cyhal_uart_t *uart_obj = (cyhal_uart_t *)callback_arg;
128
128
#endif
129
129
130
130
sleep_manager_lock_deep_sleep ();
131
131
132
- #if defined(CYW43XXX_UNBUFFERED_UART)
132
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
133
133
while (uart.readable ()) {
134
134
uint8_t char_received;
135
135
if (uart.read (&char_received, 1 )) {
@@ -153,7 +153,7 @@ void CyH4TransportDriver::initialize()
153
153
bt_power = 0 ;
154
154
rtos::ThisThread::sleep_for (1ms);
155
155
156
- #if defined(CYW43XXX_UNBUFFERED_UART)
156
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
157
157
uart.baud (DEF_BT_BAUD_RATE);
158
158
159
159
uart.format (
@@ -205,7 +205,7 @@ void CyH4TransportDriver::initialize()
205
205
206
206
void CyH4TransportDriver::terminate ()
207
207
{
208
- #if !defined(CYW43XXX_UNBUFFERED_UART)
208
+ #if !( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
209
209
cyhal_uart_event_t enable_irq_event = (cyhal_uart_event_t )(CYHAL_UART_IRQ_RX_DONE
210
210
| CYHAL_UART_IRQ_TX_DONE
211
211
| CYHAL_UART_IRQ_RX_NOT_EMPTY
@@ -229,7 +229,7 @@ void CyH4TransportDriver::terminate()
229
229
230
230
bt_power = 0 ; // BT_POWER is an output, should not be freed only set inactive
231
231
232
- #if defined(CYW43XXX_UNBUFFERED_UART)
232
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
233
233
uart.close ();
234
234
#else
235
235
cyhal_uart_free (&uart);
@@ -245,7 +245,7 @@ uint16_t CyH4TransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
245
245
246
246
while (i < len + 1 ) {
247
247
uint8_t to_write = i == 0 ? type : pData[i - 1 ];
248
- #if defined(CYW43XXX_UNBUFFERED_UART)
248
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
249
249
while (uart.writeable () == 0 );
250
250
uart.write (&to_write, 1 );
251
251
#else
@@ -254,8 +254,8 @@ uint16_t CyH4TransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
254
254
#endif
255
255
++i;
256
256
}
257
- #if defined(CYW43XXX_UNBUFFERED_UART)
258
- while (uart.writeable () = = 0 );
257
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
258
+ while (uart.is_tx_active () ! = 0 );
259
259
#else
260
260
while (cyhal_uart_is_tx_active (&uart));
261
261
#endif
@@ -294,7 +294,7 @@ void CyH4TransportDriver::deassert_bt_dev_wake()
294
294
295
295
void CyH4TransportDriver::update_uart_baud_rate (int baud)
296
296
{
297
- #if defined(CYW43XXX_UNBUFFERED_UART)
297
+ #if ( defined(CYW43XXX_UNBUFFERED_UART) && DEVICE_SERIAL_ASYNCH )
298
298
uart.baud ((uint32_t )baud);
299
299
#else
300
300
uint32_t ignore;
0 commit comments