-
Notifications
You must be signed in to change notification settings - Fork 14
Add GPIO interrupt managing methods #44
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d9a917f
Add GPIO interrupt managing methods
b4d03f3
Formatting and changelog
365aba5
GPIO Pull Request corrections
981be9f
Change enable_interrupts, disable_interrupts and clear_interrupts fro…
d397a9c
Change interrupt methods so they are mutable
8cc7004
Increase GPIO interrupt example clarity
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| //! Device resources available in FE310-G000 and FE310-G002 chip packages | ||||||
|
|
||||||
| use crate::core::CorePeripherals; | ||||||
| use crate::gpio::{gpio0::*, GpioExt, Unknown}; | ||||||
| use crate::gpio::{gpio0::*, EventType, GpioExt, Unknown}; | ||||||
| use e310x::{ | ||||||
| Aonclk, Backup, Gpio0, Otp, Peripherals, Pmu, Prci, Pwm0, Pwm1, Pwm2, Qspi0, Qspi1, Rtc, Uart0, | ||||||
| Wdog, | ||||||
|
|
@@ -92,6 +92,117 @@ pub struct DeviceGpioPins { | |||||
| pub pin23: Pin23<Unknown>, | ||||||
| } | ||||||
|
|
||||||
| impl DeviceGpioPins { | ||||||
| /// Enables the specified interrupt event for all the GPIO pins. | ||||||
| /// | ||||||
| /// # Note | ||||||
| /// | ||||||
| /// This function does not enable the interrupts in the PLIC, it only sets the | ||||||
| /// interrupt enable bits in the GPIO peripheral. You must call the | ||||||
| /// [`enable_exti()`](super::gpio::gpio0::Pin0::enable_exti) method of every pin | ||||||
| /// to enable their interrupt in the PLIC. | ||||||
| pub fn enable_interrupts(&self, event: EventType) { | ||||||
| let gpio = unsafe { Gpio0::steal() }; | ||||||
|
|
||||||
| match event { | ||||||
| EventType::High => { | ||||||
| unsafe { gpio.high_ie().write(|w| w.bits(0xFFFFFFFF)) }; | ||||||
| } | ||||||
| EventType::Low => { | ||||||
| unsafe { gpio.low_ie().write(|w| w.bits(0xFFFFFFFF)) }; | ||||||
| } | ||||||
| EventType::BothLevels => unsafe { | ||||||
| gpio.high_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| gpio.low_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| }, | ||||||
| EventType::Rise => { | ||||||
| unsafe { gpio.rise_ie().write(|w| w.bits(0xFFFFFFFF)) }; | ||||||
| } | ||||||
| EventType::Fall => { | ||||||
| unsafe { gpio.fall_ie().write(|w| w.bits(0xFFFFFFFF)) }; | ||||||
| } | ||||||
| EventType::BothEdges => unsafe { | ||||||
| gpio.rise_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| gpio.fall_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| }, | ||||||
| EventType::All => unsafe { | ||||||
| gpio.high_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| gpio.low_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| gpio.rise_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| gpio.fall_ie().write(|w| w.bits(0xFFFFFFFF)); | ||||||
| }, | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /// Disables the specified interrupt event for all the GPIO pins. | ||||||
| pub fn disable_interrupts(&self, event: EventType) { | ||||||
|
||||||
| pub fn disable_interrupts(&self, event: EventType) { | |
| pub fn disable_interrupts(&mut self, event: EventType) { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| pub fn clear_interrupts(&self, event: EventType) { | |
| pub fn clear_interrupts(&mut self, event: EventType) { |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.