Skip to content

Commit

Permalink
Adjust for rebase on top of dmac-api
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed Oct 24, 2024
1 parent c5c4cb1 commit eba50e1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion hal/src/dmac/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ use atsamd_hal_macros::{hal_cfg, hal_macro_helper};

use super::{
dma_controller::{ChId, PriorityLevel, TriggerAction, TriggerSource},
sram::DmacDescriptor,
transfer::{BufferPair, Transfer},
Buffer, DmacDescriptor, Error,
Buffer, Error,
};
use crate::typelevel::{Is, Sealed};
use modular_bitfield::prelude::*;
Expand Down
18 changes: 9 additions & 9 deletions hal/src/dmac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ macro_rules! get {
pub const NUM_CHANNELS: usize = with_num_channels!(get);

/// DMAC SRAM registers
mod sram {
pub(crate) mod sram {
#![allow(dead_code, unused_braces)]

use super::{BeatSize, NUM_CHANNELS};
Expand Down Expand Up @@ -391,7 +391,7 @@ mod sram {
/// Descriptor representing a SRAM register. Datasheet section 19.8.2
#[derive(Clone, Copy)]
#[repr(C, align(16))]
pub(super) struct DmacDescriptor {
pub struct DmacDescriptor {
pub(super) btctrl: BlockTransferControl,
pub(super) btcnt: u16,
pub(super) srcaddr: *const (),
Expand All @@ -400,37 +400,37 @@ mod sram {
}

impl DmacDescriptor {
pub(crate) const fn default() -> Self {
pub const fn default() -> Self {
Self {
btctrl: BlockTransferControl::default(),
btctrl: BlockTransferControl::new(),
btcnt: 0,
srcaddr: 0 as *mut _,
dstaddr: 0 as *mut _,
descaddr: 0 as *mut _,
}
}
pub(crate) fn next_descriptor(&self) -> *const DmacDescriptor {
pub fn next_descriptor(&self) -> *const DmacDescriptor {
self.descaddr
}

pub(crate) fn set_next_descriptor(&mut self, next: *mut DmacDescriptor) {
pub fn set_next_descriptor(&mut self, next: *mut DmacDescriptor) {
self.descaddr = next;
}

pub(crate) fn beat_count(&self) -> u16 {
pub fn beat_count(&self) -> u16 {
self.btcnt
}
}

/// Writeback section. This static variable should never be written to in an
/// interrupt or thread context.
pub(super) static mut WRITEBACK: [DmacDescriptor; NUM_CHANNELS] =
[DEFAULT_DESCRIPTOR; NUM_CHANNELS];
[DmacDescriptor::default(); NUM_CHANNELS];

/// Descriptor section. This static variable should never be written to in
/// an interrupt or thread context.
pub(super) static mut DESCRIPTOR_SECTION: [DmacDescriptor; NUM_CHANNELS] =
[DEFAULT_DESCRIPTOR; NUM_CHANNELS];
[DmacDescriptor::default(); NUM_CHANNELS];
}

pub mod channel;
Expand Down
7 changes: 4 additions & 3 deletions hal/src/dmac/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
use super::{
channel::{AnyChannel, Busy, CallbackStatus, Channel, ChannelId, InterruptFlags, Ready},
dma_controller::{ChId, TriggerAction, TriggerSource},
sram, Error, Result,
sram::{self, DmacDescriptor},
Error, Result,
};
use crate::typelevel::{Is, Sealed};
use core::{ptr::null_mut, sync::atomic};
Expand Down Expand Up @@ -374,7 +375,7 @@ where
// belonging to OUR channel. We assume this is the only place
// in the entire library that this section of the array
// will be accessed.
let descriptor = &mut DESCRIPTOR_SECTION[id];
let descriptor = &mut sram::DESCRIPTOR_SECTION[id];

// Enable support for circular transfers. If circular_xfer is true,
// we set the address of the "next" block descriptor to actually
Expand All @@ -396,7 +397,7 @@ where
pub(super) unsafe fn link_next(next: *mut DmacDescriptor) {
let id = <C as AnyChannel>::Id::USIZE;

DESCRIPTOR_SECTION[id].descaddr = next;
sram::DESCRIPTOR_SECTION[id].descaddr = next;
}

/// Generate a [`DmacDescriptor`], and write it to the provided descriptor
Expand Down
3 changes: 2 additions & 1 deletion hal/src/sercom/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use crate::{
dmac::{
self,
channel::{AnyChannel, Busy, CallbackStatus, Channel, InterruptFlags, Ready},
sram::DmacDescriptor,
transfer::BufferPair,
Beat, Buffer, DmacDescriptor, Error, Transfer, TriggerAction,
Beat, Buffer, Error, Transfer, TriggerAction,
},
sercom::{
i2c::{self, I2c},
Expand Down
2 changes: 1 addition & 1 deletion hal/src/sercom/i2c/impl_ehal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<C: AnyConfig> i2c::I2c for I2c<C> {
#[cfg(feature = "dma")]
mod dma {
use super::*;
use crate::dmac::{AnyChannel, DmacDescriptor, Ready};
use crate::dmac::{sram::DmacDescriptor, AnyChannel, Ready};
use crate::sercom::dma::{read_dma_linked, write_dma_linked, SercomPtr, SharedSliceBuffer};
use crate::sercom::{self, Sercom};

Expand Down
2 changes: 1 addition & 1 deletion hal/src/sercom/spi/impl_ehal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ where
#[cfg(feature = "dma")]
mod dma {
use super::*;
use crate::dmac::{channel::Ready, AnyChannel, Beat, Buffer, DmacDescriptor};
use crate::dmac::{channel::Ready, sram::DmacDescriptor, AnyChannel, Beat, Buffer};
use crate::sercom::dma::{
read_dma, read_dma_linked, write_dma, write_dma_linked, SercomPtr, SharedSliceBuffer,
};
Expand Down

0 comments on commit eba50e1

Please sign in to comment.