Skip to content

Commit 5fd71c5

Browse files
committed
feat(dmac): Updates the dmac::DmacController to use the clock::v2 API for thumbv7 targets.
* Updates the examples in the `dmac` module documentation to reflect the API changes. * Updates all applicable Tier 1 BSP examples, while others are broken, requiring additional peripheral migrations before they can be fixed.
1 parent 76ec8c4 commit 5fd71c5

File tree

16 files changed

+140
-125
lines changed

16 files changed

+140
-125
lines changed

boards/feather_m0/examples/async_dmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn main(_s: embassy_executor::Spawner) {
3232
);
3333

3434
// Initialize DMA Controller
35-
let dmac = DmaController::init(peripherals.dmac, &mut peripherals.pm);
35+
let dmac = DmaController::new(peripherals.dmac, &mut peripherals.pm);
3636

3737
// Turn dmac into an async controller
3838
let mut dmac = dmac.into_future(crate::Irqs);

boards/feather_m0/examples/async_i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main(_s: embassy_executor::Spawner) {
4141
let i2c_sercom = bsp::periph_alias!(peripherals.i2c_sercom);
4242

4343
// Initialize DMA Controller
44-
let dmac = DmaController::init(peripherals.dmac, &mut peripherals.pm);
44+
let dmac = DmaController::new(peripherals.dmac, &mut peripherals.pm);
4545

4646
// Turn dmac into an async controller
4747
let mut dmac = dmac.into_future(Irqs);

boards/feather_m0/examples/async_spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main(_s: embassy_executor::Spawner) {
4141
let spi_sercom = bsp::periph_alias!(peripherals.spi_sercom);
4242

4343
// Initialize DMA Controller
44-
let dmac = DmaController::init(peripherals.dmac, &mut peripherals.pm);
44+
let dmac = DmaController::new(peripherals.dmac, &mut peripherals.pm);
4545

4646
// Turn dmac into an async controller
4747
let mut dmac = dmac.into_future(Irqs);

boards/feather_m0/examples/async_uart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main(spawner: embassy_executor::Spawner) {
4141
let uart_sercom = periph_alias!(peripherals.uart_sercom);
4242

4343
// Initialize DMA Controller
44-
let dmac = DmaController::init(peripherals.dmac, &mut peripherals.pm);
44+
let dmac = DmaController::new(peripherals.dmac, &mut peripherals.pm);
4545
// Turn dmac into an async controller
4646
let mut dmac = dmac.into_future(Irqs);
4747
// Get individual handles to DMA channels

boards/feather_m0/examples/dmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() -> ! {
4141
cortex_m::singleton!(: [u8; LENGTH] = [0x00; LENGTH]).unwrap();
4242

4343
// Initialize DMA Controller
44-
let mut dmac = DmaController::init(dmac, &mut pm);
44+
let mut dmac = DmaController::new(dmac, &mut pm);
4545
// Get individual handles to DMA channels
4646
let mut channels = dmac.split();
4747

boards/feather_m0/examples/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() -> ! {
4646
let (sda, scl) = (pins.sda, pins.scl);
4747

4848
// Setup DMA channels for later use
49-
let mut dmac = DmaController::init(dmac, &mut pm);
49+
let mut dmac = DmaController::new(dmac, &mut pm);
5050
let channels = dmac.split();
5151
let chan0 = channels.0.init(PriorityLevel::Lvl0);
5252

boards/feather_m0/examples/spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn main() -> ! {
4040
let (miso, mosi, sclk) = (pins.miso, pins.mosi, pins.sclk);
4141

4242
// Setup DMA channels for later use
43-
let mut dmac = DmaController::init(dmac, &mut pm);
43+
let mut dmac = DmaController::new(dmac, &mut pm);
4444
let channels = dmac.split();
4545
let chan0 = channels.0.init(PriorityLevel::Lvl0);
4646
let chan1 = channels.1.init(PriorityLevel::Lvl0);

boards/feather_m0/examples/uart_dma_blocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> ! {
3636
let pins = bsp::Pins::new(peripherals.port);
3737

3838
// Setup DMA channels for later use
39-
let mut dmac = DmaController::init(dmac, &mut pm);
39+
let mut dmac = DmaController::new(dmac, &mut pm);
4040
let channels = dmac.split();
4141

4242
let chan0 = channels.0.init(PriorityLevel::Lvl0);

boards/feather_m0/examples/uart_dma_nonblocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> ! {
3636
let pins = bsp::Pins::new(peripherals.port);
3737

3838
// Setup DMA channels for later use
39-
let mut dmac = DmaController::init(dmac, &mut pm);
39+
let mut dmac = DmaController::new(dmac, &mut pm);
4040
let channels = dmac.split();
4141

4242
let chan0 = channels.0.init(PriorityLevel::Lvl0);

boards/feather_m4/examples/dmac.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,21 @@ use cortex_m::asm;
99
use feather_m4 as bsp;
1010
use panic_halt as _;
1111

12-
use hal::{
13-
clock::GenericClockController,
14-
pac::{CorePeripherals, Peripherals},
15-
};
16-
1712
use hal::dmac::{DmaController, PriorityLevel, Transfer, TriggerAction, TriggerSource};
13+
use hal::pac::Peripherals;
1814

1915
#[bsp::entry]
2016
fn main() -> ! {
2117
let mut peripherals = Peripherals::take().unwrap();
22-
let core = CorePeripherals::take().unwrap();
23-
let _clocks = GenericClockController::with_external_32kosc(
18+
let (mut _buses, clocks, _tokens) = hal::clock::v2::clock_system_at_reset(
19+
peripherals.oscctrl,
20+
peripherals.osc32kctrl,
2421
peripherals.gclk,
25-
&mut peripherals.mclk,
26-
&mut peripherals.osc32kctrl,
27-
&mut peripherals.oscctrl,
22+
peripherals.mclk,
2823
&mut peripherals.nvmctrl,
2924
);
3025

31-
let mut pm = peripherals.pm;
3226
let dmac = peripherals.dmac;
33-
let _nvic = core.NVIC;
3427

3528
// Initialize buffers
3629
const LENGTH: usize = 50;
@@ -40,7 +33,7 @@ fn main() -> ! {
4033
cortex_m::singleton!(: [u8; LENGTH] = [0x00; LENGTH]).unwrap();
4134

4235
// Initialize DMA Controller
43-
let mut dmac = DmaController::init(dmac, &mut pm);
36+
let mut dmac = DmaController::new(dmac, clocks.ahbs.dmac);
4437
// Get individual handles to DMA channels
4538
let mut channels = dmac.split();
4639

@@ -95,7 +88,7 @@ fn main() -> ! {
9588
// Move split channels back into the Channels struct
9689
channels.0 = chan0.into();
9790
// Free the DmaController and return the PAC DMAC struct
98-
let _dmac = dmac.free(channels, &mut pm);
91+
let (_dmac, _ahb_clk) = dmac.free(channels);
9992

10093
loop {
10194
asm::nop();

0 commit comments

Comments
 (0)