@@ -27,18 +27,18 @@ pub enum Half {
27
27
}
28
28
29
29
pub struct CircBuffer < BUFFER , PAYLOAD >
30
- where
31
- BUFFER : ' static ,
30
+ where
31
+ BUFFER : ' static ,
32
32
{
33
33
buffer : & ' static mut [ BUFFER ; 2 ] ,
34
34
payload : PAYLOAD ,
35
35
readable_half : Half ,
36
36
}
37
37
38
38
impl < BUFFER , PAYLOAD > CircBuffer < BUFFER , PAYLOAD >
39
- where
40
- & ' static mut [ BUFFER ; 2 ] : StaticWriteBuffer ,
41
- BUFFER : ' static ,
39
+ where
40
+ & ' static mut [ BUFFER ; 2 ] : StaticWriteBuffer ,
41
+ BUFFER : ' static ,
42
42
{
43
43
pub ( crate ) fn new ( buf : & ' static mut [ BUFFER ; 2 ] , payload : PAYLOAD ) -> Self {
44
44
CircBuffer {
@@ -61,17 +61,17 @@ pub trait TransferPayload {
61
61
}
62
62
63
63
pub struct Transfer < MODE , BUFFER , PAYLOAD >
64
- where
65
- PAYLOAD : TransferPayload ,
64
+ where
65
+ PAYLOAD : TransferPayload ,
66
66
{
67
67
_mode : PhantomData < MODE > ,
68
68
buffer : BUFFER ,
69
69
payload : PAYLOAD ,
70
70
}
71
71
72
72
impl < BUFFER , PAYLOAD > Transfer < R , BUFFER , PAYLOAD >
73
- where
74
- PAYLOAD : TransferPayload ,
73
+ where
74
+ PAYLOAD : TransferPayload ,
75
75
{
76
76
pub ( crate ) fn r ( buffer : BUFFER , payload : PAYLOAD ) -> Self {
77
77
Transfer {
@@ -83,8 +83,8 @@ impl<BUFFER, PAYLOAD> Transfer<R, BUFFER, PAYLOAD>
83
83
}
84
84
85
85
impl < BUFFER , PAYLOAD > Transfer < W , BUFFER , PAYLOAD >
86
- where
87
- PAYLOAD : TransferPayload ,
86
+ where
87
+ PAYLOAD : TransferPayload ,
88
88
{
89
89
pub ( crate ) fn w ( buffer : BUFFER , payload : PAYLOAD ) -> Self {
90
90
Transfer {
@@ -96,8 +96,8 @@ impl<BUFFER, PAYLOAD> Transfer<W, BUFFER, PAYLOAD>
96
96
}
97
97
98
98
impl < MODE , BUFFER , PAYLOAD > Drop for Transfer < MODE , BUFFER , PAYLOAD >
99
- where
100
- PAYLOAD : TransferPayload ,
99
+ where
100
+ PAYLOAD : TransferPayload ,
101
101
{
102
102
fn drop ( & mut self ) {
103
103
self . payload . stop ( ) ;
@@ -126,8 +126,8 @@ macro_rules! dma {
126
126
pub mod $dmaX {
127
127
use core:: { sync:: atomic:: { self , Ordering } , ptr, mem} ;
128
128
129
- use stm32f0xx_hal :: pac:: { $DMAX, dma1} ;
130
- use stm32f0xx_hal :: rcc:: Rcc ;
129
+ use crate :: pac:: { $DMAX, dma1} ;
130
+ use crate :: rcc:: Rcc ;
131
131
132
132
use crate :: dma:: { CircBuffer , DmaExt , Error , Event , Half , Transfer , W , RxDma , TxDma , TransferPayload } ;
133
133
@@ -145,15 +145,15 @@ macro_rules! dma {
145
145
///
146
146
/// `inc` indicates whether the address will be incremented after every byte transfer
147
147
pub fn set_peripheral_address( & mut self , address: u32 , inc: bool ) {
148
- self . ch( ) . par. write( |w| w. pa( ) . bits( address) ) ;
148
+ self . ch( ) . par. write( |w| unsafe { w. pa( ) . bits( address) } ) ;
149
149
self . ch( ) . cr. modify( |_, w| w. pinc( ) . bit( inc) ) ;
150
150
}
151
151
152
152
/// `address` where from/to data will be read/write
153
153
///
154
154
/// `inc` indicates whether the address will be incremented after every byte transfer
155
155
pub fn set_memory_address( & mut self , address: u32 , inc: bool ) {
156
- self . ch( ) . mar. write( |w| w. ma( ) . bits( address) ) ;
156
+ self . ch( ) . mar. write( |w| unsafe { w. ma( ) . bits( address) } ) ;
157
157
self . ch( ) . cr. modify( |_, w| w. minc( ) . bit( inc) ) ;
158
158
}
159
159
@@ -393,7 +393,7 @@ macro_rules! dma {
393
393
type Channels = Channels ;
394
394
395
395
fn split( self , rcc: & mut Rcc ) -> Channels {
396
- rcc. ahbenr. modify( |_, w| w. $dmaen( ) . set_bit( ) ) ;
396
+ rcc. regs . ahbenr. modify( |_, w| w. $dmaen( ) . set_bit( ) ) ;
397
397
398
398
// reset the DMA control registers (stops all on-going transfers)
399
399
$(
@@ -409,7 +409,7 @@ macro_rules! dma {
409
409
}
410
410
411
411
dma ! {
412
- DMA1 : ( dma1, dmaen , {
412
+ DMA1 : ( dma1, dma1en , {
413
413
C1 : (
414
414
ch1,
415
415
htif1, tcif1,
@@ -479,28 +479,28 @@ pub trait Transmit {
479
479
480
480
/// Trait for circular DMA readings from peripheral to memory.
481
481
pub trait CircReadDma < B , RS > : Receive
482
- where
483
- & ' static mut [ B ; 2 ] : StaticWriteBuffer < Word = RS > ,
484
- B : ' static ,
485
- Self : core:: marker:: Sized ,
482
+ where
483
+ & ' static mut [ B ; 2 ] : StaticWriteBuffer < Word = RS > ,
484
+ B : ' static ,
485
+ Self : core:: marker:: Sized ,
486
486
{
487
487
fn circ_read ( self , buffer : & ' static mut [ B ; 2 ] ) -> CircBuffer < B , Self > ;
488
488
}
489
489
490
490
/// Trait for DMA readings from peripheral to memory.
491
491
pub trait ReadDma < B , RS > : Receive
492
- where
493
- B : StaticWriteBuffer < Word = RS > ,
494
- Self : core:: marker:: Sized + TransferPayload ,
492
+ where
493
+ B : StaticWriteBuffer < Word = RS > ,
494
+ Self : core:: marker:: Sized + TransferPayload ,
495
495
{
496
496
fn read ( self , buffer : B ) -> Transfer < W , B , Self > ;
497
497
}
498
498
499
499
/// Trait for DMA writing from memory to peripheral.
500
500
pub trait WriteDma < B , TS > : Transmit
501
- where
502
- B : StaticReadBuffer < Word = TS > ,
503
- Self : core:: marker:: Sized + TransferPayload ,
501
+ where
502
+ B : StaticReadBuffer < Word = TS > ,
503
+ Self : core:: marker:: Sized + TransferPayload ,
504
504
{
505
505
fn write ( self , buffer : B ) -> Transfer < R , B , Self > ;
506
506
}
0 commit comments