@@ -139,7 +139,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) {
139
139
140
140
static uint64_t last_avail_time;
141
141
int written = 0 ;
142
- if (tud_cdc_connected () || _ignoreFlowControl ) {
142
+ if (tud_cdc_connected () || _ss. ignoreFlowControl ) {
143
143
for (size_t i = 0 ; i < length;) {
144
144
int n = length - i;
145
145
int avail = tud_cdc_write_available ();
@@ -181,19 +181,15 @@ SerialUSB::operator bool() {
181
181
}
182
182
183
183
void SerialUSB::ignoreFlowControl (bool ignore) {
184
- _ignoreFlowControl = ignore;
184
+ _ss. ignoreFlowControl = ignore;
185
185
}
186
186
187
- static bool _dtr = false ;
188
- static bool _rts = false ;
189
- static int _bps = 115200 ;
190
- static bool _rebooting = false ;
191
- static void CheckSerialReset () {
192
- if (!_rebooting && (_bps == 1200 ) && (!_dtr)) {
187
+ void SerialUSB::checkSerialReset () {
188
+ if (!_ss.rebooting && (_ss.bps == 1200 ) && (!_ss.dtr )) {
193
189
#ifdef __FREERTOS
194
190
__freertos_idle_other_core ();
195
191
#endif
196
- _rebooting = true ;
192
+ _ss. rebooting = true ;
197
193
// Disable NVIC IRQ, so that we don't get bothered anymore
198
194
irq_set_enabled (USBCTRL_IRQ, false );
199
195
// Reset the whole USB hardware block
@@ -207,24 +203,32 @@ static void CheckSerialReset() {
207
203
}
208
204
209
205
bool SerialUSB::dtr () {
210
- return _dtr ;
206
+ return _ss. dtr ;
211
207
}
212
208
213
209
bool SerialUSB::rts () {
214
- return _rts ;
210
+ return _ss. rts ;
215
211
}
216
212
217
213
extern " C" void tud_cdc_line_state_cb (uint8_t itf, bool dtr, bool rts) {
214
+ Serial.tud_cdc_line_state_cb (itf, dtr, rts);
215
+ }
216
+
217
+ void SerialUSB::tud_cdc_line_state_cb (uint8_t itf, bool dtr, bool rts) {
218
218
(void ) itf;
219
- _dtr = dtr ? true : false ;
220
- _rts = rts ? true : false ;
221
- CheckSerialReset ();
219
+ _ss. dtr = dtr ? 1 : 0 ;
220
+ _ss. rts = rts ? 1 : 0 ;
221
+ checkSerialReset ();
222
222
}
223
223
224
224
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);
226
+ }
227
+
228
+ void SerialUSB::tud_cdc_line_coding_cb (uint8_t itf, cdc_line_coding_t const * p_line_coding) {
225
229
(void ) itf;
226
- _bps = p_line_coding->bit_rate ;
227
- CheckSerialReset ();
230
+ _ss. bps = p_line_coding->bit_rate ;
231
+ checkSerialReset ();
228
232
}
229
233
230
234
SerialUSB Serial;
0 commit comments