Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"atsamd-hal-macros",
"pac/*",
"boards/*",
"manage",
]

[profile.dev]
Expand Down
11 changes: 11 additions & 0 deletions boards/doit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set +e

for b in *; do
[ "$b" == "$(basename "$0")" ] && continue
for e in "$b"/examples/*.rs; do
newname="$b"-$(basename "$e")
cp "$e" ../examples/"$newname"
done
done
16 changes: 14 additions & 2 deletions boards/feather_m4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ version = "0.3.1"
[dev-dependencies]
heapless = "0.7"
panic-halt = "0.2"
cortex-m-semihosting = "0.5.0"
panic-semihosting = "0.5"
rtic = {version = "2.1.1", features = ["thumbv7-backend"]}
panic-probe = "1.0.0"
cortex-m-semihosting = "0.5.0"
rtic = { version = "2.1.1", features = ["thumbv7-backend"] }
smart-leds = "0.3"
usbd-serial = "0.2"
ws2812-timer-delay = "0.3"
embassy-executor = { version = "0.7.0", features = [
"arch-cortex-m",
"executor-thread",
"task-arena-size-8192",
] }
defmt = "1.0.1"
defmt-rtt = "1.0.0"

[features]
# ask the HAL to enable atsamd51j support
Expand Down Expand Up @@ -126,3 +134,7 @@ name = "uart_poll_echo"
[[example]]
name = "usb_echo"
required-features = ["usb"]

[[example]]
name = "async_dmac"
required-features = ["async", "dma"]
75 changes: 75 additions & 0 deletions boards/feather_m4/examples/async_dmac.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

//! This example shows a safe API to
//! execute a memory-to-memory DMA transfer
#![no_std]
#![no_main]

use defmt_rtt as _;
use panic_probe as _;

use bsp::hal;
use bsp::pac;
use feather_m4 as bsp;

use hal::{
clock::GenericClockController,
dmac::{DmaController, PriorityLevel, TriggerAction, TriggerSource},
};

atsamd_hal::bind_multiple_interrupts!(struct Irqs {
DMAC: [DMAC_0, DMAC_1, DMAC_2, DMAC_OTHER] => atsamd_hal::dmac::InterruptHandler;
});

#[embassy_executor::main]
async fn main(_s: embassy_executor::Spawner) {
let mut peripherals = pac::Peripherals::take().unwrap();
let _core = pac::CorePeripherals::take().unwrap();

let _clocks = GenericClockController::with_external_32kosc(
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);

// Initialize DMA Controller
let dmac = DmaController::init(peripherals.dmac, &mut peripherals.pm);

// Turn dmac into an async controller
let mut dmac = dmac.into_future(crate::Irqs);
// Get individual handles to DMA channels
let channels = dmac.split();

// Initialize DMA Channel 0
let mut channel = channels.0.init(PriorityLevel::Lvl0);

let mut source = [0xff; 100];
let mut dest = [0x0; 100];

defmt::info!(
"Launching a DMA transfer.\n\tSource: {:#x}\n\tDestination: {:#x}",
&source,
&dest
);

channel
.transfer_future(
&mut source,
&mut dest,
TriggerSource::Disable,
TriggerAction::Block,
)
.await
.unwrap();

defmt::info!(
"Finished DMA transfer.\n\tSource: {:#x}\n\tDestination: {:#x}",
&source,
&dest
);

loop {
cortex_m::asm::wfi();
}
}
14 changes: 9 additions & 5 deletions boards/feather_m4/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
#![no_main]

use feather_m4 as bsp;

use bsp::hal;
use bsp::pac;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use bsp::hal;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;
use pac::{CorePeripherals, Peripherals};

use hal::delay::Delay;

#[entry]
fn main() -> ! {
Expand All @@ -29,9 +33,9 @@ fn main() -> ! {
let mut red_led = pins.d13.into_push_pull_output();
let mut delay = Delay::new(core.SYST, &mut clocks);
loop {
delay.delay_ms(2000u16);
delay.delay_ms(200u8);
red_led.set_high().unwrap();
delay.delay_ms(2000u16);
delay.delay_ms(200u8);
red_led.set_low().unwrap();
}
}
13 changes: 13 additions & 0 deletions boards/grand_central_m4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ features = ["critical-section-single-core"]
cortex-m = "0.7"
usbd-serial = "0.2"
panic-halt = "1.0.0"
panic-probe = "1.0.0"
panic-semihosting = "0.6"
smart-leds = "0.3"
ws2812-timer-delay = "0.3"
embassy-executor = { version = "0.7.0", features = [
"arch-cortex-m",
"executor-thread",
"task-arena-size-8192",
] }
defmt = "1.0.1"
defmt-rtt = "1.0.0"

[features]
default = ["rt", "atsamd-hal/samd51p"]
Expand All @@ -41,6 +49,7 @@ max-channels = ["dma", "atsamd-hal/max-channels"]
rt = ["cortex-m-rt", "atsamd-hal/samd51p-rt"]
usb = ["atsamd-hal/usb", "usb-device"]
use_semihosting = []
async = ["atsamd-hal/async"]

# for cargo flash
[package.metadata]
Expand All @@ -62,3 +71,7 @@ name = "neopixel_rainbow"
[[example]]
name = "usb_serial"
required-features = ["usb"]

[[example]]
name = "async_dmac"
required-features = ["async", "dma"]
75 changes: 75 additions & 0 deletions boards/grand_central_m4/examples/async_dmac.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

//! This example shows a safe API to
//! execute a memory-to-memory DMA transfer
#![no_std]
#![no_main]

use defmt_rtt as _;
use panic_probe as _;

use bsp::hal;
use bsp::pac;
use grand_central_m4 as bsp;

use hal::{
clock::GenericClockController,
dmac::{DmaController, PriorityLevel, TriggerAction, TriggerSource},
};

atsamd_hal::bind_multiple_interrupts!(struct Irqs {
DMAC: [DMAC_0, DMAC_1, DMAC_2, DMAC_OTHER] => atsamd_hal::dmac::InterruptHandler;
});

#[embassy_executor::main]
async fn main(_s: embassy_executor::Spawner) {
let mut peripherals = pac::Peripherals::take().unwrap();
let _core = pac::CorePeripherals::take().unwrap();

let _clocks = GenericClockController::with_external_32kosc(
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);

// Initialize DMA Controller
let dmac = DmaController::init(peripherals.dmac, &mut peripherals.pm);

// Turn dmac into an async controller
let mut dmac = dmac.into_future(crate::Irqs);
// Get individual handles to DMA channels
let channels = dmac.split();

// Initialize DMA Channel 0
let mut channel = channels.0.init(PriorityLevel::Lvl0);

let mut source = [0xff; 100];
let mut dest = [0x0; 100];

defmt::info!(
"Launching a DMA transfer.\n\tSource: {:#x}\n\tDestination: {:#x}",
&source,
&dest
);

channel
.transfer_future(
&mut source,
&mut dest,
TriggerSource::Disable,
TriggerAction::Block,
)
.await
.unwrap();

defmt::info!(
"Finished DMA transfer.\n\tSource: {:#x}\n\tDestination: {:#x}",
&source,
&dest
);

loop {
cortex_m::asm::wfi();
}
}
7 changes: 4 additions & 3 deletions boards/metro_m4/examples/async_dmac.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//! This example shows a safe API to
//! execute a memory-to-memory DMA transfer

#![no_std]
#![no_main]

Expand All @@ -9,11 +9,12 @@ use panic_probe as _;

use bsp::hal;
use bsp::pac;
use metro_m4 as bsp;

use hal::{
clock::GenericClockController,
dmac::{DmaController, PriorityLevel, TriggerAction, TriggerSource},
};
use metro_m4 as bsp;

atsamd_hal::bind_multiple_interrupts!(struct Irqs {
DMAC: [DMAC_0, DMAC_1, DMAC_2, DMAC_OTHER] => atsamd_hal::dmac::InterruptHandler;
Expand Down Expand Up @@ -71,4 +72,4 @@ async fn main(_s: embassy_executor::Spawner) {
loop {
cortex_m::asm::wfi();
}
}
}
14 changes: 0 additions & 14 deletions boards/wio_terminal/.cargo/config.toml

This file was deleted.

5 changes: 0 additions & 5 deletions boards/wio_terminal/.rustfmt.toml

This file was deleted.

66 changes: 0 additions & 66 deletions boards/wio_terminal/CHANGELOG.md

This file was deleted.

Loading
Loading