Skip to content

Commit b19cd32

Browse files
Do typecasting in CPP, not H
1 parent 50d3563 commit b19cd32

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

cores/rp2040/SerialUSB.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,12 @@ void SerialUSB::tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
222222
}
223223

224224
extern "C" void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding) {
225-
Serial.tud_cdc_line_coding_cb(itf, p_line_coding);
225+
Serial.tud_cdc_line_coding_cb(itf, (void const *)p_line_coding);
226226
}
227227

228-
void SerialUSB::tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding) {
228+
void SerialUSB::tud_cdc_line_coding_cb(uint8_t itf, void const *p) {
229229
(void) itf;
230+
cdc_line_coding_t const* p_line_coding = (cdc_line_coding_t const*)p;
230231
_ss.bps = p_line_coding->bit_rate;
231232
checkSerialReset();
232233
}

cores/rp2040/SerialUSB.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@
2424
#include "api/HardwareSerial.h"
2525
#include <stdarg.h>
2626

27-
// We need the TUSB defines, but BTStack redefines them. So for this header we
28-
// turn on off HID before doing the include and then restore it after the include
29-
// is processed.
30-
#define SAVE_CFG_TUD_HID CFG_TUD_HID
31-
#undef CFG_TUD_HID
32-
#define CFG_TUD_HID 0
33-
#include <tusb.h>
34-
#undef CFG_TUD_HID
35-
#define CFG_TUD_HID SAVE_CFG_TUD_HID
36-
#undef SAVE_CFG_TUD_HID
3727
class SerialUSB : public arduino::HardwareSerial {
3828
public:
3929
SerialUSB();
@@ -65,7 +55,7 @@ class SerialUSB : public arduino::HardwareSerial {
6555

6656
// TUSB callbacks
6757
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
68-
void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
58+
void tud_cdc_line_coding_cb(uint8_t itf, void const *p_line_coding); // Can't use cdc_line_coding_t const* p_line_coding, TinyUSB and BTStack conflict when we include tusb.h + BTStack.h
6959

7060
private:
7161
bool _running = false;
@@ -83,7 +73,6 @@ class SerialUSB : public arduino::HardwareSerial {
8373
SyntheticState _ss = { 0, 0, 0, 0, 115200};
8474

8575
void checkSerialReset();
86-
8776
};
8877

8978
extern SerialUSB Serial;

0 commit comments

Comments
 (0)