diff --git a/cores/arduino/USB/CDC.cpp b/cores/arduino/USB/CDC.cpp index b7332a82..ffae21b8 100644 --- a/cores/arduino/USB/CDC.cpp +++ b/cores/arduino/USB/CDC.cpp @@ -176,13 +176,10 @@ int Serial_::peek(void) int Serial_::read(void) { - ring_buffer *buffer = &cdc_rx_buffer; - - // if the head isn't ahead of the tail, we don't have any characters - if (buffer->head == buffer->tail && !buffer->full) - { - if (usb.available(CDC_ENDPOINT_OUT)) - accept(); + if (_serialPeek != -1) { + int res = _serialPeek; + _serialPeek = -1; + return res; } return usb.recv(CDC_ENDPOINT_OUT); } diff --git a/cores/arduino/USB/USBCore.cpp b/cores/arduino/USB/USBCore.cpp index efa614f9..f86f8568 100644 --- a/cores/arduino/USB/USBCore.cpp +++ b/cores/arduino/USB/USBCore.cpp @@ -292,15 +292,6 @@ void USBDeviceClass::standby() { void USBDeviceClass::handleEndpoint(uint8_t ep) { #if defined(CDC_ENABLED) - if (ep == CDC_ENDPOINT_OUT) - { - // The RAM Buffer is empty: we can receive data - //usbd.epBank0ResetReady(CDC_ENDPOINT_OUT); - - // Handle received bytes - if (available(CDC_ENDPOINT_OUT)) - Serial.accept(); - } if (ep == CDC_ENDPOINT_IN) { // NAK on endpoint IN, the bank is not yet filled in. diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 3a9aa36d..539c83ff 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -102,6 +102,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode) // Store interrupts to service in order of when they were attached // to allow for first come first serve handler uint32_t current = 0; + uint32_t inMask = (1UL << in); // Check if we already have this interrupt for (current=0; currentNMICTRL.bit.NMISENSE = EIC_NMICTRL_NMISENSE_HIGH; break; - case CHANGE: - EIC->CONFIG[config].reg |= EIC_CONFIG_SENSE0_BOTH_Val << pos; - break; - case CHANGE: EIC->NMICTRL.bit.NMISENSE = EIC_NMICTRL_NMISENSE_BOTH; break; @@ -146,7 +143,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode) } // Assign callback to interrupt - callbacksInt[EXTERNAL_INT_NMI] = callback; + ISRcallback[EXTERNAL_INT_NMI] = callback; } else { // Not NMI, is external interrupt @@ -161,7 +158,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode) pinPeripheral(pin, PIO_EXTINT); // Assign callback to interrupt - callbacksInt[in] = callback; + ISRcallback[in] = callback; // Look for right CONFIG register to be addressed if (in > EXTERNAL_INT_7) { @@ -208,7 +205,6 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode) EIC->CTRLA.bit.ENABLE = 1; while (EIC->SYNCBUSY.bit.ENABLE == 1) { } #endif - } } /* @@ -240,7 +236,7 @@ void detachInterrupt(uint32_t pin) // Remove callback from the ISR list uint32_t current; for (current=0; currentINTFLAG.reg & (1 << i)) != 0) { // Call the callback function if assigned - if (callbacksInt[i]) { - callbacksInt[i](); + if (ISRcallback[i]) { + ISRcallback[i](); } // Clear the interrupt @@ -376,6 +372,7 @@ void EIC_Handler(void) */ void NMI_Handler(void) { - if (callbacksInt[EXTERNAL_INT_NMI]) callbacksInt[EXTERNAL_INT_NMI](); + if (ISRcallback[EXTERNAL_INT_NMI]) ISRcallback[EXTERNAL_INT_NMI](); EIC->NMIFLAG.bit.NMI = 1; // Clear interrupt } +#endif \ No newline at end of file diff --git a/platform.txt b/platform.txt index 27438209..2cee5ab9 100644 --- a/platform.txt +++ b/platform.txt @@ -185,4 +185,4 @@ tools.openocd-withbootsize.erase.pattern= tools.openocd-withbootsize.bootloader.params.verbose=-d2 tools.openocd-withbootsize.bootloader.params.quiet=-d0 -tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{{runtime.platform.path}/bootloaders/{bootloader.file}}} verify reset; shutdown" +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{{runtime.platform.path}/bootloaders/{bootloader.file}}} verify reset; shutdown" \ No newline at end of file