@@ -139,7 +139,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) {
139139
140140    static  uint64_t  last_avail_time;
141141    int  written = 0 ;
142-     if  (tud_cdc_connected () || _ignoreFlowControl ) {
142+     if  (tud_cdc_connected () || _ss. ignoreFlowControl ) {
143143        for  (size_t  i = 0 ; i < length;) {
144144            int  n = length - i;
145145            int  avail = tud_cdc_write_available ();
@@ -181,19 +181,15 @@ SerialUSB::operator bool() {
181181}
182182
183183void  SerialUSB::ignoreFlowControl (bool  ignore) {
184-     _ignoreFlowControl  = ignore;
184+     _ss. ignoreFlowControl  = ignore;
185185}
186186
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 )) {
193189#ifdef  __FREERTOS
194190        __freertos_idle_other_core ();
195191#endif 
196-         _rebooting  = true ;
192+         _ss. rebooting  = true ;
197193        //  Disable NVIC IRQ, so that we don't get bothered anymore
198194        irq_set_enabled (USBCTRL_IRQ, false );
199195        //  Reset the whole USB hardware block
@@ -207,24 +203,33 @@ static void CheckSerialReset() {
207203}
208204
209205bool  SerialUSB::dtr () {
210-     return  _dtr ;
206+     return  _ss. dtr ;
211207}
212208
213209bool  SerialUSB::rts () {
214-     return  _rts ;
210+     return  _ss. rts ;
215211}
216212
217213extern  " 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) {
218218    (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 ();
222222}
223223
224224extern  " 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, (void  const  *)p_line_coding);
226+ }
227+ 
228+ void  SerialUSB::tud_cdc_line_coding_cb (uint8_t  itf, void  const  *p) {
225229    (void ) itf;
226-     _bps = p_line_coding->bit_rate ;
227-     CheckSerialReset ();
230+     cdc_line_coding_t  const * p_line_coding = (cdc_line_coding_t  const *)p;
231+     _ss.bps  = p_line_coding->bit_rate ;
232+     checkSerialReset ();
228233}
229234
230235SerialUSB Serial;
0 commit comments