Skip to content

Commit

Permalink
Fix compilation errors find using CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
matoushybl committed Nov 14, 2020
1 parent df7ccdd commit f897726
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ pub enum Half {
}

pub struct CircBuffer<BUFFER, PAYLOAD>
where
BUFFER: 'static,
where
BUFFER: 'static,
{
buffer: &'static mut [BUFFER; 2],
payload: PAYLOAD,
readable_half: Half,
}

impl<BUFFER, PAYLOAD> CircBuffer<BUFFER, PAYLOAD>
where
&'static mut [BUFFER; 2]: StaticWriteBuffer,
BUFFER: 'static,
where
&'static mut [BUFFER; 2]: StaticWriteBuffer,
BUFFER: 'static,
{
pub(crate) fn new(buf: &'static mut [BUFFER; 2], payload: PAYLOAD) -> Self {
CircBuffer {
Expand All @@ -61,17 +61,17 @@ pub trait TransferPayload {
}

pub struct Transfer<MODE, BUFFER, PAYLOAD>
where
PAYLOAD: TransferPayload,
where
PAYLOAD: TransferPayload,
{
_mode: PhantomData<MODE>,
buffer: BUFFER,
payload: PAYLOAD,
}

impl<BUFFER, PAYLOAD> Transfer<R, BUFFER, PAYLOAD>
where
PAYLOAD: TransferPayload,
where
PAYLOAD: TransferPayload,
{
pub(crate) fn r(buffer: BUFFER, payload: PAYLOAD) -> Self {
Transfer {
Expand All @@ -83,8 +83,8 @@ impl<BUFFER, PAYLOAD> Transfer<R, BUFFER, PAYLOAD>
}

impl<BUFFER, PAYLOAD> Transfer<W, BUFFER, PAYLOAD>
where
PAYLOAD: TransferPayload,
where
PAYLOAD: TransferPayload,
{
pub(crate) fn w(buffer: BUFFER, payload: PAYLOAD) -> Self {
Transfer {
Expand All @@ -96,8 +96,8 @@ impl<BUFFER, PAYLOAD> Transfer<W, BUFFER, PAYLOAD>
}

impl<MODE, BUFFER, PAYLOAD> Drop for Transfer<MODE, BUFFER, PAYLOAD>
where
PAYLOAD: TransferPayload,
where
PAYLOAD: TransferPayload,
{
fn drop(&mut self) {
self.payload.stop();
Expand Down Expand Up @@ -126,8 +126,8 @@ macro_rules! dma {
pub mod $dmaX {
use core::{sync::atomic::{self, Ordering}, ptr, mem};

use stm32f0xx_hal::pac::{$DMAX, dma1};
use stm32f0xx_hal::rcc::Rcc;
use crate::pac::{$DMAX, dma1};
use crate::rcc::Rcc;

use crate::dma::{CircBuffer, DmaExt, Error, Event, Half, Transfer, W, RxDma, TxDma, TransferPayload};

Expand All @@ -145,15 +145,15 @@ macro_rules! dma {
///
/// `inc` indicates whether the address will be incremented after every byte transfer
pub fn set_peripheral_address(&mut self, address: u32, inc: bool) {
self.ch().par.write(|w| w.pa().bits(address) );
self.ch().par.write(|w| unsafe { w.pa().bits(address) } );
self.ch().cr.modify(|_, w| w.pinc().bit(inc) );
}

/// `address` where from/to data will be read/write
///
/// `inc` indicates whether the address will be incremented after every byte transfer
pub fn set_memory_address(&mut self, address: u32, inc: bool) {
self.ch().mar.write(|w| w.ma().bits(address) );
self.ch().mar.write(|w| unsafe { w.ma().bits(address) } );
self.ch().cr.modify(|_, w| w.minc().bit(inc) );
}

Expand Down Expand Up @@ -393,7 +393,7 @@ macro_rules! dma {
type Channels = Channels;

fn split(self, rcc: &mut Rcc) -> Channels {
rcc.ahbenr.modify(|_, w| w.$dmaen().set_bit());
rcc.regs.ahbenr.modify(|_, w| w.$dmaen().set_bit());

// reset the DMA control registers (stops all on-going transfers)
$(
Expand All @@ -409,7 +409,7 @@ macro_rules! dma {
}

dma! {
DMA1: (dma1, dmaen, {
DMA1: (dma1, dma1en, {
C1: (
ch1,
htif1, tcif1,
Expand Down Expand Up @@ -479,28 +479,28 @@ pub trait Transmit {

/// Trait for circular DMA readings from peripheral to memory.
pub trait CircReadDma<B, RS>: Receive
where
&'static mut [B; 2]: StaticWriteBuffer<Word = RS>,
B: 'static,
Self: core::marker::Sized,
where
&'static mut [B; 2]: StaticWriteBuffer<Word = RS>,
B: 'static,
Self: core::marker::Sized,
{
fn circ_read(self, buffer: &'static mut [B; 2]) -> CircBuffer<B, Self>;
}

/// Trait for DMA readings from peripheral to memory.
pub trait ReadDma<B, RS>: Receive
where
B: StaticWriteBuffer<Word = RS>,
Self: core::marker::Sized + TransferPayload,
where
B: StaticWriteBuffer<Word = RS>,
Self: core::marker::Sized + TransferPayload,
{
fn read(self, buffer: B) -> Transfer<W, B, Self>;
}

/// Trait for DMA writing from memory to peripheral.
pub trait WriteDma<B, TS>: Transmit
where
B: StaticReadBuffer<Word = TS>,
Self: core::marker::Sized + TransferPayload,
where
B: StaticReadBuffer<Word = TS>,
Self: core::marker::Sized + TransferPayload,
{
fn write(self, buffer: B) -> Transfer<R, B, Self>;
}

0 comments on commit f897726

Please sign in to comment.