Expand description
§External Interrupt Controller
This module provides typesafe APIs for interacting with the EIC peripheral, which is used to generate interrupts based on the state of a GPIO.
Each chip has a number of EXTINT channels:
- SAMD11: 8 channels
- SAMD21/SAMx5x: 16 channels
Each channel can operate independently, and sense state changes for a single
GPIO pin at a time. Refer to the datasheet for GPIO pin/EXTINT channel
compatibility. In this module, an ExtInt
represents an EXTINT channel
which is tied to a GPIO Pin
, and is capable of sensing state changes.
§Steps to create an ExtInt
-
Start by creating an
Eic
struct, by callingEic::new
. This initializes the EIC peripheral and sets up the correct clocking. -
Turn the
Eic
into a tuple ofChannel
s by callingEic::split
. Each channel represents a single EXTINT channel. -
Assign a pin to a channel by calling
Channel::with_pin
. This returns a fully configured and ready to useExtInt
. APin
can also be directly converted into anExtInt
by calling one of the methods provided by theEicPin
trait.
§Example setup
let eic_clock = clocks.eic(&gclk0).unwrap();
// Initialize the EIC peripheral
let eic = Eic::new(&mut peripherals.pm, eic_clock, peripherals.eic);
// Split into channels
let eic_channels = eic.split();
// Take the pin that we want to use
let button: Pin<_, PullUpInterrupt> = pins.d10.into();
// Turn the EXTINT[2] channel into an ExtInt struct
let mut extint = eic_channels.2.with_pin(button);
§async
operation async
ExtInt
s can be used for async operations. Configuring the Eic
in
async mode is relatively simple:
-
Bind the corresponding
EIC
interrupt source to the SPIInterruptHandler
(refer to the module-levelasync_hal
documentation for more information). -
SAMD11/SAMD21: Turn an
Eic
into an async-enabledEic
by calling [Eic::into_future
]. Since there is only a single interrupt handler for the EIC peripheral, all EXTINT channels must be turned into async channels at once. -
SAMx5x: Turn an individuel
ExtInt
into an async-enabledExtInt
by callingExtInt::into_future
. Each channel has a dedicated interrupt source, therefore you must individually choose which channels to turn into async channels. -
Use the provided
wait
method. async-enabledExtInt
s also implementembedded_hal_async::digital::Wait
.
Structs§
- EIC channel.
- Struct generating individual handles to each EXTINT channel
- External Interrupt Controller.
- A numbered external interrupt, which can be used to sense state changes on its pin.
- Struct generating individual handles to each EXTINT channel for
async
operation - Interrupt handler used for
async
operations.
Enums§
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Type alias for a channel number
- Marker type that represents an EXTINT channel capable of doing async operations.
Constants§
- The number of EXTINT channels on this chip.
Traits§
- Trait representing an EXTINT channel ID.
- Trait representing a GPIO pin which can be used as an external interrupt.