|
13 | 13 | #include <pbsys/command.h> |
14 | 14 | #include <pbsys/host.h> |
15 | 15 |
|
| 16 | +#define BLE_ONLY (PBSYS_CONFIG_BLUETOOTH && (!PBDRV_CONFIG_USB || PBDRV_CONFIG_USB_CHARGE_ONLY)) |
| 17 | +#define USB_ONLY (!PBSYS_CONFIG_BLUETOOTH && PBDRV_CONFIG_USB && !PBDRV_CONFIG_USB_CHARGE_ONLY) |
| 18 | +#define BLE_AND_USB (PBSYS_CONFIG_BLUETOOTH && PBDRV_CONFIG_USB && !PBDRV_CONFIG_USB_CHARGE_ONLY) |
| 19 | + |
16 | 20 | static pbsys_host_stdin_event_callback_t pbsys_host_stdin_event_callback; |
17 | 21 | static lwrb_t pbsys_host_stdin_ring_buf; |
18 | 22 |
|
@@ -142,11 +146,11 @@ pbio_error_t pbsys_host_stdin_read(uint8_t *data, uint32_t *size) { |
142 | 146 | * ::PBIO_SUCCESS if at least some data was queued. |
143 | 147 | */ |
144 | 148 | pbio_error_t pbsys_host_stdout_write(const uint8_t *data, uint32_t *size) { |
145 | | - #if PBSYS_CONFIG_BLUETOOTH && (!PBDRV_CONFIG_USB || PBDRV_CONFIG_USB_CHARGE_ONLY) |
| 149 | + #if BLE_ONLY |
146 | 150 | return pbdrv_bluetooth_tx(data, size); |
147 | | - #elif !PBSYS_CONFIG_BLUETOOTH && PBDRV_CONFIG_USB && !PBDRV_CONFIG_USB_CHARGE_ONLY |
| 151 | + #elif USB_ONLY |
148 | 152 | return pbdrv_usb_stdout_tx(data, size); |
149 | | - #elif PBSYS_CONFIG_BLUETOOTH && PBDRV_CONFIG_USB && !PBDRV_CONFIG_USB_CHARGE_ONLY |
| 153 | + #elif BLE_AND_USB |
150 | 154 |
|
151 | 155 | uint32_t bt_avail = pbdrv_bluetooth_tx_available(); |
152 | 156 | uint32_t usb_avail = pbdrv_usb_stdout_tx_available(); |
@@ -192,12 +196,16 @@ pbio_error_t pbsys_host_stdout_write(const uint8_t *data, uint32_t *size) { |
192 | 196 | * listening, false if there is still data queued to be sent. |
193 | 197 | */ |
194 | 198 | bool pbsys_host_tx_is_idle(void) { |
195 | | - #if PBDRV_CONFIG_USB && !PBDRV_CONFIG_USB_CHARGE_ONLY |
196 | 199 | // The USB part is a bit of a hack since it depends on the USB driver not |
197 | 200 | // buffering more than one packet at a time to actually be accurate. |
| 201 | + #if BLE_ONLY |
| 202 | + return pbdrv_bluetooth_tx_is_idle(); |
| 203 | + #elif USB_ONLY |
| 204 | + return pbdrv_usb_stdout_tx_available(); |
| 205 | + #elif BLE_AND_USB |
198 | 206 | return pbdrv_bluetooth_tx_is_idle() && pbdrv_usb_stdout_tx_available(); |
199 | 207 | #else |
200 | | - return pbdrv_bluetooth_tx_is_idle(); |
| 208 | + return true; |
201 | 209 | #endif |
202 | 210 | } |
203 | 211 |
|
|
0 commit comments