Skip to content

Commit 54e5e39

Browse files
committed
Add some missing info to the notes.
1 parent 40deaf1 commit 54e5e39

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/gpio_interrupt.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ configure peripherals etc. `Option` allows us to initialize an "empty" object fi
5252

5353
Next, let's look how we can define an interrupt handler function.
5454

55+
Import the `handler` macro:
56+
57+
```rust
58+
use esp_hal::handler;
59+
```
60+
61+
Then define the handler function at the bottom of the file, like this:
62+
5563
```rust
5664
#[handler]
5765
fn button_handler() {
@@ -98,6 +106,12 @@ io.set_interrupt_handler(button_handler);
98106
Finally, we start to listen to the button events and move the button object into our global state.
99107
We will use a "rising edge" event, which means that the interrupt will be triggered on button release.
100108

109+
Import `Event`:
110+
111+
```rust
112+
use esp_hal::gpio::Event;
113+
```
114+
101115
Add this code right after the existing declaration of `button`.
102116

103117
```rust
@@ -109,7 +123,7 @@ critical_section::with(|cs| {
109123

110124
## Experiment
111125

112-
Try changing the event type to rising edge. Do you observe any difference?
126+
Try changing the event type to falling edge. Do you observe any difference?
113127

114128

115129
[1]: https://docs.espressif.com/projects/rust/esp-hal/1.0.0-rc.0/esp32c6/esp_hal/attr.handler.html

0 commit comments

Comments
 (0)