diff --git a/digistump-avr/libraries/DigisparkCDC/DigiCDC.cpp b/digistump-avr/libraries/DigisparkCDC/DigiCDC.cpp index 938283a..c72fc30 100644 --- a/digistump-avr/libraries/DigisparkCDC/DigiCDC.cpp +++ b/digistump-avr/libraries/DigisparkCDC/DigiCDC.cpp @@ -16,6 +16,7 @@ and Digistump LLC (digistump.com) uchar sendEmptyFrame; static uchar intr3Status; /* used to control interrupt endpoint transmissions */ +static uchar portB_dtr_bit; DigiCDCDevice::DigiCDCDevice(void){} @@ -143,8 +144,8 @@ void DigiCDCDevice::usbBegin() RingBuffer_InitBuffer(&rxBuf,rxBuf_Data,sizeof(rxBuf_Data)); intr3Status = 0; - sendEmptyFrame = 0; - + sendEmptyFrame = 0; + portB_dtr_bit = 255; sei(); } @@ -186,11 +187,11 @@ void DigiCDCDevice::usbPollWrapper() } - - - - - +void DigiCDCDevice::setDtrPin(uint8_t dtrPin){ + portB_dtr_bit = dtrPin; + PORTB &= ~(_BV(portB_dtr_bit)); + DDRB |= (1 << portB_dtr_bit); +} #ifdef __cplusplus extern "C"{ @@ -320,6 +321,8 @@ usbRequest_t *rq = (usbRequest_t*)((void *)data); /* SET_LINE_CODING -> usbFunctionWrite() */ } if(rq->bRequest == SET_CONTROL_LINE_STATE){ + if(portB_dtr_bit != 0xFF) + PORTB = (PORTB&~(1<wValue.word&1)< +void setup() { + SerialUSB.begin(); + // initialize the digital pin 1 as an DTR output. + SerialUSB.setDtrPin(1); +} + +// the loop routine runs over and over again forever: +void loop() { + SerialUSB.delay(10); +}