Skip to content

Commit

Permalink
Fix atsame54_xpro mcan example
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed Nov 25, 2024
1 parent a5ef645 commit 82dca2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 4 additions & 5 deletions boards/atsame54_xpro/examples/mcan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use atsame54_xpro as bsp;
use bsp::hal;
use hal::clock::v2 as clock;
use hal::eic::pin::*;
use hal::eic::{Ch15, Eic, ExtInt, Sense};
use hal::gpio::{Interrupt as GpioInterrupt, *};
use hal::prelude::*;

Expand Down Expand Up @@ -87,7 +87,7 @@ type Aux = mcan::bus::Aux<
bsp::pac::Can1,
>,
>;
type Button = ExtInt15<Pin<PB31, GpioInterrupt<PullUp>>>;
type Button = ExtInt<Pin<PB31, GpioInterrupt<PullUp>>, Ch15>;

#[rtic::app(device = hal::pac, peripherals = true, dispatchers = [FREQM])]
mod app {
Expand Down Expand Up @@ -140,9 +140,8 @@ mod app {

let (pclk_eic, gclk0) = clock::pclk::Pclk::enable(tokens.pclks.eic, clocks.gclk0);

let mut eic =
hal::eic::init_with_ulp32k(&mut mclk, pclk_eic.into(), ctx.device.eic).finalize();
let mut button = bsp::pin_alias!(pins.button).into_pull_up_ei(&mut eic);
let eic_channels = Eic::new(&mut mclk, pclk_eic.into(), ctx.device.eic).split();
let mut button = bsp::pin_alias!(pins.button).into_pull_up_ei(eic_channels.15);
button.sense(Sense::Fall);
button.debounce();
button.enable_interrupt();
Expand Down
13 changes: 8 additions & 5 deletions hal/src/peripherals/eic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use core::marker::PhantomData;

use atsamd_hal_macros::{hal_cfg, hal_module};
use seq_macro::seq;

use crate::{
clock::EicClock,
Expand Down Expand Up @@ -79,7 +80,9 @@ where
}
}

/// EIC channel. Use this struct to create an [`ExtInt`](pins::ExtInt)
/// EIC channel.
///
/// Use this struct to create an [`ExtInt`](pins::ExtInt) by calling [`with_pin`](Self::with_pin).
pub struct Channel<Id: ChId, F = NoneT> {
eic: core::mem::ManuallyDrop<pac::Eic>,
_id: PhantomData<Id>,
Expand Down Expand Up @@ -193,7 +196,7 @@ pub const NUM_CHANNELS: usize = with_num_channels!(get);

macro_rules! define_channels_struct {
($num_channels:literal) => {
seq_macro::seq!(N in 0..$num_channels {
seq!(N in 0..$num_channels {
#(
/// Type alias for a channel number
pub struct Ch~N;
Expand All @@ -218,7 +221,7 @@ with_num_channels!(define_channels_struct);
#[cfg(feature = "async")]
macro_rules! define_channels_struct_future {
($num_channels:literal) => {
seq_macro::seq!(N in 0..$num_channels {
seq!(N in 0..$num_channels {
/// Struct generating individual handles to each EXTINT channel for `async` operation
pub struct FutureChannels(
#(
Expand All @@ -234,7 +237,7 @@ with_num_channels!(define_channels_struct_future);

macro_rules! define_split {
($num_channels:literal) => {
seq_macro::seq!(N in 0..$num_channels {
seq!(N in 0..$num_channels {
/// Split the EIC into individual channels.
#[inline]
pub fn split(self) -> Channels {
Expand All @@ -256,7 +259,7 @@ impl Eic {
#[cfg(feature = "async")]
macro_rules! define_split_future {
($num_channels:literal) => {
seq_macro::seq!(N in 0..$num_channels {
seq!(N in 0..$num_channels {
/// Split the EIC into individual channels
#[inline]
pub fn split(self) -> FutureChannels {
Expand Down

0 comments on commit 82dca2f

Please sign in to comment.