|  | 
| 1 | 1 | //! # Quadrature Encoder Interface | 
| 2 |  | -use crate::{ | 
| 3 |  | -    hal::{self, Direction}, | 
| 4 |  | -    pac::RCC, | 
| 5 |  | -    rcc, | 
| 6 |  | -}; | 
|  | 2 | +
 | 
|  | 3 | +use crate::{pac::RCC, rcc}; | 
| 7 | 4 | 
 | 
| 8 | 5 | pub trait Pins<TIM> {} | 
| 9 | 6 | use crate::timer::PinC1; | 
| @@ -48,22 +45,39 @@ impl<TIM: Instance, PINS> Qei<TIM, PINS> { | 
| 48 | 45 |     } | 
| 49 | 46 | } | 
| 50 | 47 | 
 | 
| 51 |  | -impl<TIM: Instance, PINS> hal::Qei for Qei<TIM, PINS> { | 
|  | 48 | +impl<TIM: Instance, PINS> embedded_hal::Qei for Qei<TIM, PINS> { | 
| 52 | 49 |     type Count = TIM::Count; | 
| 53 | 50 | 
 | 
| 54 | 51 |     fn count(&self) -> Self::Count { | 
| 55 | 52 |         self.tim.read_count() as Self::Count | 
| 56 | 53 |     } | 
| 57 | 54 | 
 | 
| 58 |  | -    fn direction(&self) -> Direction { | 
|  | 55 | +    fn direction(&self) -> embedded_hal::Direction { | 
| 59 | 56 |         if self.tim.read_direction() { | 
| 60 |  | -            hal::Direction::Upcounting | 
|  | 57 | +            embedded_hal::Direction::Upcounting | 
| 61 | 58 |         } else { | 
| 62 |  | -            hal::Direction::Downcounting | 
|  | 59 | +            embedded_hal::Direction::Downcounting | 
| 63 | 60 |         } | 
| 64 | 61 |     } | 
| 65 | 62 | } | 
| 66 | 63 | 
 | 
|  | 64 | +impl<TIM: Instance, PINS> embedded_hal_one::qei::blocking::Qei for Qei<TIM, PINS> { | 
|  | 65 | +    type Error = core::convert::Infallible; | 
|  | 66 | +    type Count = TIM::Count; | 
|  | 67 | + | 
|  | 68 | +    fn count(&self) -> Result<Self::Count, Self::Error> { | 
|  | 69 | +        Ok(self.tim.read_count() as Self::Count) | 
|  | 70 | +    } | 
|  | 71 | + | 
|  | 72 | +    fn direction(&self) -> Result<embedded_hal_one::qei::Direction, Self::Error> { | 
|  | 73 | +        Ok(if self.tim.read_direction() { | 
|  | 74 | +            embedded_hal_one::qei::Direction::Upcounting | 
|  | 75 | +        } else { | 
|  | 76 | +            embedded_hal_one::qei::Direction::Downcounting | 
|  | 77 | +        }) | 
|  | 78 | +    } | 
|  | 79 | +} | 
|  | 80 | + | 
| 67 | 81 | pub trait Instance: crate::Sealed + rcc::Enable + rcc::Reset { | 
| 68 | 82 |     type Count; | 
| 69 | 83 | 
 | 
|  | 
0 commit comments