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

Low latency (direct) interrupt handlers #1394

Merged
merged 12 commits into from Dec 13, 2017

Conversation

@avtolstoy
Copy link
Member

commented Sep 25, 2017

submission notes
**Important:** Please sanitize/remove any confidential info like usernames, passwords, org names, product names/ids, access tokens, client ids/secrets, or anything else you don't wish to share.

Please Read and Sign the Contributor License Agreement ([Info here](https://github.com/spark/firmware/blob/develop/CONTRIBUTING.md)).

You may also delete this submission notes header if you'd like. Thank you for contributing!

Problem

See #1168 #1333

Solution

This PR adds two wiring functions attachInterruptDirect() and detachInterruptDirect() that allow the user code to directly insert interrupt handlers into the interrupt vector table.

Steps to Test

  • wiring/no_fixture: INTERRUPTS_04_attachInterruptDirect

Example App

void pvd_irqn_handler() {
    // Do something
}

void setup() {
    attachInterruptDirect(PVD_IRQn, pvd_irqn_handler);
}

void loop() {

}

References


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
  • TODO: Add documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)
@pkourany

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2017

Reminder to review!

@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2017

Are you psychic...I was literally reviewing this when you commented!

@pkourany

This comment has been minimized.

Copy link
Contributor

commented Nov 9, 2017

I'll try and test with SparkIntervalTimer and a scope. This is an important one to release as soon as its ready IMO.

@pkourany

This comment has been minimized.

Copy link
Contributor

commented Nov 13, 2017

I tried this feature branch with my SparkIntervalTimer library coupled with my RGBPongClock and I get a hard fault. I will test with a more basic app (blink LED) along with the SparkIntervalTimer library next.

@pkourany

This comment has been minimized.

Copy link
Contributor

commented Nov 15, 2017

I tried a simple app with SparkIntervalTimer (using attachInterruptDirect()) and I get hard fault immediately after flashing over the code. If I compile with regular attachInterrupt() the code works fine.

To test, I simply change the original code using attachInterrupt() such as this line:
attachSystemInterrupt(SysInterrupt_TIM3_Update, Wiring_TIM3_Interrupt_Handler_override)
to:
attachInterruptDirect(TIM3_IRQn, Wiring_TIM3_Interrupt_Handler_override)

@avtolstoy

This comment has been minimized.

Copy link
Member Author

commented Nov 15, 2017

@pkourany I've just built SparkIntervalTimer with minimal changes:

        if (!attachInterruptDirect(TIM3_IRQn, Wiring_TIM3_Interrupt_Handler_override)) ; //error
        if (!attachInterruptDirect(TIM4_IRQn, Wiring_TIM4_Interrupt_Handler_override)) ; //error
        if (!attachInterruptDirect(TIM5_IRQn, Wiring_TIM5_Interrupt_Handler_override)) ; //error
        if (!attachInterruptDirect(TIM6_DAC_IRQn, Wiring_TIM6_Interrupt_Handler_override));  //error
        if (!attachInterruptDirect(TIM7_IRQn, Wiring_TIM7_Interrupt_Handler_override));  //error

and used the example provided with it, and it does not crash. Don't have a scope at hand, but at the very least D7 is flashing as intended.

EDIT:
Tested on both Electron and Photon.

@pkourany

This comment has been minimized.

Copy link
Contributor

commented Nov 15, 2017

@avtolstoy, as I read your post I realized that with all my testing, I failed to update the system firmware parts! I'll test again just to confirm. Thanks!

@pkourany

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2017

@avtolstoy, I must be missing something. I checked out the branch, go to the firmware/modules directory and build/flash the system firmware and app using:

make clean all PLATFORM=photon APP=rgbpcFastInt program-dfu

Everything compiles and flashes but same hard fault. What am I missing?

@pkourany

This comment has been minimized.

Copy link
Contributor

commented Nov 22, 2017

Tested with SparkIntervalTimer (with some overdue mods) and it works. Good to go!

@pkourany
Copy link
Contributor

left a comment

Tested successfully with SparkIntervalTimer library.

@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Nov 24, 2017

Paul, what was the cause of the hard fault? Anything we need to look into?

@m-mcgowan m-mcgowan added this to the 0.8.0-rc.1 milestone Nov 24, 2017

@m-mcgowan m-mcgowan self-requested a review Dec 13, 2017

@m-mcgowan m-mcgowan merged commit dc24e0c into develop Dec 13, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2017

Who's going to write up the docs for this? We need to make clear the interplay between the normal wiring interrupts and the direct interrupts, and provide guidance on when to use which.

avtolstoy added a commit to particle-iot/docs that referenced this pull request Feb 23, 2018
@ScruffR

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2018

Will there be a version of attachInterruptDirect() that also allows to provide a priority parameter as attachInterrupt() already does?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.