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

[gen4] hal: get rid of unnecessary constant delay(1) in HAL_USB_USART_Send_Data() #2867

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

avtolstoy
Copy link
Member

Problem

We are always unnecessarily delaying 1ms on each byte sent over USB serial.

Moreover this happens even if there is no host connected, as _blocking = true by default and Serial::write() is implemented as following and always goes down to HAL_USB_USART_Send_Data():

size_t USBSerial::write(uint8_t byte)
{
  if (HAL_USB_USART_Available_Data_For_Write(_serial) > 0 || _blocking) {
    return std::max(0, (int)HAL_USB_USART_Send_Data(_serial, byte));
  }
  return 0;
}

Solution

Get rid of it. In addition to that fixes the FIXME about thread priorities. Don't need to delay(1) if we are below USB ISR processing task.

Steps to Test

N/A

Example App

N/A

References

  • [SC133780]

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@avtolstoy avtolstoy added the bug label Feb 20, 2025
@avtolstoy avtolstoy added this to the 6.3.1 milestone Feb 20, 2025
Copy link
Member

@scott-brust scott-brust left a comment

Choose a reason for hiding this comment

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

Just some questions

@avtolstoy avtolstoy merged commit 7f9864b into develop Feb 20, 2025
14 checks passed
@avtolstoy avtolstoy deleted the fix/gen4-usb-unnecessary-delay branch February 20, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants