File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,14 @@ configure peripherals etc. `Option` allows us to initialize an "empty" object fi
5252
5353Next, 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]
5765fn button_handler () {
@@ -98,6 +106,12 @@ io.set_interrupt_handler(button_handler);
98106Finally, we start to listen to the button events and move the button object into our global state.
99107We 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+
101115Add 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
You can’t perform that action at this time.
0 commit comments