Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HWCDC removed clearing USB Serial/JTAG interrupts during begin (#9316) #9344

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

kiran-desilva
Copy link

Description of Change

Fixes (#9316) where ESP may not respond over the USB Serial/JTAG interface if bytes are sent before HWCDC::begin(...) is called. Clearing of the interrupt status has been removed from HWCDC::begin(...) so that if the USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT is already set, the isr handler can process the interrupt status correctly.

Tests scenarios

Tested with ESP32-S3:

#include <Arduino.h>
#include <HWCDC.h>
#include <hal/usb_serial_jtag_ll.h>
#include <string>


uint32_t prevTime = 0;


void setup() {
  
  delay(5000);

  Serial.begin(115200);
  Serial.println("begin");
}

void loop() {

  if (millis() - prevTime > 500)
  {
    prevTime = millis();
    std::string output;
    output += "rxFifo: " + std::to_string(usb_serial_jtag_ll_rxfifo_data_available());
    output += " Serial avaliable: " + std::to_string(Serial.available());
    Serial.println(output.c_str());

  }

  while (Serial.available())
  {
    uint8_t b = Serial.read();
    Serial.print(Serial.available());
    Serial.print(" - ");
    Serial.write(b);
    Serial.println();
  }
  vTaskDelay(1); // watchdog
}

Related links

Closes (#9316)

@lucasssvaz lucasssvaz requested a review from SuGlider March 5, 2024 17:44
@lucasssvaz lucasssvaz added the Area: Peripherals API Relates to peripheral's APIs. label Mar 5, 2024
@lucasssvaz lucasssvaz added this to the 2.0.15 milestone Mar 5, 2024
@@ -186,7 +186,6 @@ void HWCDC::begin(unsigned long baud)
}
}
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
Copy link
Collaborator

@lucasssvaz lucasssvaz Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be moved to the end method rather than being deleted, like it was done in #9331.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean end of the begin method or to the HWCDC::end()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To HWCDC::end(). Check the PR I've linked

Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix of removing CLR INTR is the most important one.
LGTM.

@me-no-dev me-no-dev merged commit 995d3e9 into espressif:release/v2.x Mar 7, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants