Skip to content

[RFC] New way of handling frame IRQ #51

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcio-ao
Copy link
Contributor

Currently, the frame IRQ fires continuously every 1ms. This causes problems with timing critical code, especially code which also has a 1kHz interrupt (I'm talking about Marlin).

This PR modifies the handling of the frame IRQ so it is enabled only when needed:

  • The sof_countdown variable has been refactored into a SOF_Timer class
  • The SOF_Timer now has a "woken" and a "sleeping" state.
  • A device insertion or removal causes the CONDETIRQ to fire
    • The IRQ calls "wake()" on the SOF_Timer
    • This starts the 1ms timer, by setting the FRAMEIE bit in HEIN
  • State transitions continue at 1ms intervals until a USB_RUNNING, USB_ERROR or USB_IDLE state is reached
    • The state machines calls "sleep" on the SOF_Timer
    • The SOF_Timer clears the FRAMEIE bit in HEIN, silencing further frame interrupts and freeing up the CPU to do other things
  • While the timer is "asleep", no polling happens, but the CONDETIRQ will fire in the case of a device removal or insertion.
    • This will "awake" the SOF_Timer for processing of the event.

Don't merge this code in quite yet. I believe it can be cleaned up a bit more. I just wanted you to look over it and maybe test it on your devices.

@xxxajk
Copy link
Collaborator

xxxajk commented Jun 12, 2019

Please refactor, then I can review it. See also private email on concerns and validation testing.

@xxxajk
Copy link
Collaborator

xxxajk commented Jun 12, 2019

One other note: there are other host controllers that would have to be modified, not just the MAX chip.
EHCI and Kinetis, plus anything in the future.
Might be best to have a variable or a define to enable this feature as well.

@marcio-ao marcio-ao force-pushed the pr-lightweight-sof-timer branch from a24b778 to e8bbb9b Compare June 12, 2019 21:50
@marcio-ao marcio-ao closed this Jul 8, 2019
@marcio-ao marcio-ao deleted the pr-lightweight-sof-timer branch July 8, 2019 19:01
@marcio-ao marcio-ao restored the pr-lightweight-sof-timer branch July 8, 2019 22:05
@marcio-ao marcio-ao reopened this Jul 8, 2019
@marcio-ao marcio-ao force-pushed the pr-lightweight-sof-timer branch from ba590dc to 7b1fc90 Compare July 8, 2019 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants