85
85
//! fn get_timeout(&self) -> Self::Time;
86
86
//!
87
87
//! /// Pauses the timer
88
- //! fn pause(&self);
88
+ //! fn pause(&mut self);
89
89
//!
90
90
//! /// Restarts the timer count
91
- //! fn restart(&self);
91
+ //! fn restart(&mut self);
92
92
//!
93
93
//! /// Resumes the timer count
94
- //! fn resume(&self);
94
+ //! fn resume(&mut self);
95
95
//!
96
96
//! /// Sets a new timeout
97
- //! fn set_timeout<T>(&self, ticks: T) where T: Into<Self::Time>;
97
+ //! fn set_timeout<T>(&mut self, ticks: T) where T: Into<Self::Time>;
98
98
//!
99
99
//! /// "waits" until the timer times out
100
100
//! fn wait(&self) -> nb::Result<(), !>;
146
146
//! {
147
147
//! type Error = Error;
148
148
//!
149
- //! fn read(&self) -> nb::Result<u8, Error> {
149
+ //! fn read(&mut self) -> nb::Result<u8, Error> {
150
150
//! // read the status register
151
151
//! let sr = self.0.sr.read();
152
152
//!
172
172
//! {
173
173
//! type Error = Error;
174
174
//!
175
- //! fn write(&self, byte: u8) -> nb::Result<(), Error> {
175
+ //! fn write(&mut self, byte: u8) -> nb::Result<(), Error> {
176
176
//! // Very similar to the above implementation
177
177
//! Ok(())
178
178
//! }
203
203
//! impl hal::serial::Read<u8> for Serial1 {
204
204
//! type Error = !;
205
205
//!
206
- //! fn read(&self) -> Result<u8, nb::Error<Self::Error>> {
206
+ //! fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> {
207
207
//! hal::serial::Read::read(&Serial(&*USART1.lock()))
208
208
//! }
209
209
//! }
419
419
//!
420
420
//! use hal::prelude::*;
421
421
//!
422
- //! fn write_all<S>(serial: &S, buffer: &[u8]) -> Result<(), S::Error>
422
+ //! fn write_all<S>(serial: &mut S, buffer: &[u8]) -> Result<(), S::Error>
423
423
//! where
424
424
//! S: hal::serial::Write<u8>
425
425
//! {
446
446
//! }
447
447
//!
448
448
//! fn read_with_timeout<S, T>(
449
- //! serial: &S,
450
- //! timer: &T,
449
+ //! serial: &mut S,
450
+ //! timer: &mut T,
451
451
//! timeout: T::Time,
452
452
//! ) -> Result<u8, Error<S::Error>>
453
453
//! where
519
519
//!
520
520
//! use hal::prelude::*;
521
521
//!
522
- //! fn flush<S>(serial: &S, cb: &mut CircularBuffer) -> Result<(), S::Error>
522
+ //! fn flush<S>(serial: &mut S, cb: &mut CircularBuffer) -> Result<(), S::Error>
523
523
//! where
524
524
//! S: hal::serial::Write<u8>,
525
525
//! {
565
565
//! let serial = SERIAL.lock();
566
566
//! let buffer = BUFFER.lock();
567
567
//!
568
- //! flush(&serial, &mut buffer).unwrap();
568
+ //! flush(&mut serial, &mut buffer).unwrap();
569
569
//! }
570
570
//! ```
571
571
//!
@@ -660,21 +660,21 @@ pub trait Capture {
660
660
/// NOTE that you must multiply the returned value by the *resolution* of
661
661
/// this `Capture` interface to get a human time unit (e.g. seconds)
662
662
fn capture (
663
- & self ,
663
+ & mut self ,
664
664
channel : Self :: Channel ,
665
665
) -> nb:: Result < Self :: Capture , Self :: Error > ;
666
666
667
667
/// Disables a capture `channel`
668
- fn disable ( & self , channel : Self :: Channel ) ;
668
+ fn disable ( & mut self , channel : Self :: Channel ) ;
669
669
670
670
/// Enables a capture `channel`
671
- fn enable ( & self , channel : Self :: Channel ) ;
671
+ fn enable ( & mut self , channel : Self :: Channel ) ;
672
672
673
673
/// Returns the current resolution
674
674
fn get_resolution ( & self ) -> Self :: Time ;
675
675
676
676
/// Sets the resolution of the capture timer
677
- fn set_resolution < R > ( & self , resolution : R )
677
+ fn set_resolution < R > ( & mut self , resolution : R )
678
678
where
679
679
R : Into < Self :: Time > ;
680
680
}
@@ -715,10 +715,10 @@ pub trait Pwm {
715
715
type Duty ;
716
716
717
717
/// Disables a PWM `channel`
718
- fn disable ( & self , channel : Self :: Channel ) ;
718
+ fn disable ( & mut self , channel : Self :: Channel ) ;
719
719
720
720
/// Enables a PWM `channel`
721
- fn enable ( & self , channel : Self :: Channel ) ;
721
+ fn enable ( & mut self , channel : Self :: Channel ) ;
722
722
723
723
/// Returns the current PWM period
724
724
fn get_period ( & self ) -> Self :: Time ;
@@ -730,10 +730,10 @@ pub trait Pwm {
730
730
fn get_max_duty ( & self ) -> Self :: Duty ;
731
731
732
732
/// Sets a new duty cycle
733
- fn set_duty ( & self , channel : Self :: Channel , duty : Self :: Duty ) ;
733
+ fn set_duty ( & mut self , channel : Self :: Channel , duty : Self :: Duty ) ;
734
734
735
735
/// Sets a new PWM period
736
- fn set_period < P > ( & self , period : P )
736
+ fn set_period < P > ( & mut self , period : P )
737
737
where
738
738
P : Into < Self :: Time > ;
739
739
}
@@ -805,10 +805,10 @@ pub trait Spi<Word> {
805
805
///
806
806
/// **NOTE** A word must be sent to the slave before attempting to call this
807
807
/// method.
808
- fn read ( & self ) -> nb:: Result < Word , Self :: Error > ;
808
+ fn read ( & mut self ) -> nb:: Result < Word , Self :: Error > ;
809
809
810
810
/// Sends a word to the slave
811
- fn send ( & self , word : Word ) -> nb:: Result < ( ) , Self :: Error > ;
811
+ fn send ( & mut self , word : Word ) -> nb:: Result < ( ) , Self :: Error > ;
812
812
}
813
813
814
814
/// Timer used for timeouts
@@ -837,16 +837,16 @@ pub trait Timer {
837
837
fn get_timeout ( & self ) -> Self :: Time ;
838
838
839
839
/// Pauses the timer
840
- fn pause ( & self ) ;
840
+ fn pause ( & mut self ) ;
841
841
842
842
/// Restarts the timer count to zero
843
- fn restart ( & self ) ;
843
+ fn restart ( & mut self ) ;
844
844
845
845
/// Resumes the timer count
846
- fn resume ( & self ) ;
846
+ fn resume ( & mut self ) ;
847
847
848
848
/// Sets a new timeout
849
- fn set_timeout < T > ( & self , timeout : T )
849
+ fn set_timeout < T > ( & mut self , timeout : T )
850
850
where
851
851
T : Into < Self :: Time > ;
852
852
0 commit comments