bump embedded_hal to 1.0
This commit is contained in:
parent
aeb0e91bc7
commit
32604cc16c
2 changed files with 10 additions and 10 deletions
|
@ -11,7 +11,7 @@ keywords = ["mpu6050", "imu", "embedded"]
|
|||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
embedded-hal = "0.2.4"
|
||||
embedded-hal = "1"
|
||||
libm = "0.2.1"
|
||||
|
||||
[dependencies.nalgebra]
|
||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -12,7 +12,7 @@
|
|||
//! **More Examples** can be found [here](https://github.com/juliangaal/mpu6050/tree/master/examples).
|
||||
//! ```no_run
|
||||
//! use mpu6050::*;
|
||||
//! use linux_embedded_hal::{I2cdev, Delay};
|
||||
//! use linux_embedded_hal::{I2cdev, DelayNs};
|
||||
//! use i2cdev::linux::LinuxI2CError;
|
||||
//!
|
||||
//! fn main() -> Result<(), Mpu6050Error<LinuxI2CError>> {
|
||||
|
@ -53,9 +53,9 @@ use crate::device::*;
|
|||
use libm::{powf, atan2f, sqrtf};
|
||||
use nalgebra::{Vector3, Vector2};
|
||||
use embedded_hal::{
|
||||
blocking::delay::DelayMs,
|
||||
blocking::i2c::{Write, WriteRead},
|
||||
i2c::I2c
|
||||
};
|
||||
use embedded_hal::delay::DelayNs;
|
||||
|
||||
/// PI, f32
|
||||
pub const PI: f32 = core::f32::consts::PI;
|
||||
|
@ -83,7 +83,7 @@ pub struct Mpu6050<I> {
|
|||
|
||||
impl<I, E> Mpu6050<I>
|
||||
where
|
||||
I: Write<Error = E> + WriteRead<Error = E>,
|
||||
I: I2c<Error = E>,
|
||||
{
|
||||
/// Side effect free constructor with default sensitivies, no calibration
|
||||
pub fn new(i2c: I) -> Self {
|
||||
|
@ -126,11 +126,11 @@ where
|
|||
}
|
||||
|
||||
/// Wakes MPU6050 with all sensors enabled (default)
|
||||
fn wake<D: DelayMs<u8>>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||
fn wake<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||
// MPU6050 has sleep enabled by default -> set bit 0 to wake
|
||||
// Set clock source to be PLL with x-axis gyroscope reference, bits 2:0 = 001 (See Register Map )
|
||||
self.write_byte(PWR_MGMT_1::ADDR, 0x01)?;
|
||||
delay.delay_ms(100u8);
|
||||
delay.delay_ms(100);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ where
|
|||
}
|
||||
|
||||
/// Init wakes MPU6050 and verifies register addr, e.g. in i2c
|
||||
pub fn init<D: DelayMs<u8>>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||
pub fn init<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||
self.wake(delay)?;
|
||||
self.verify()?;
|
||||
self.set_accel_range(AccelRange::G2)?;
|
||||
|
@ -253,9 +253,9 @@ where
|
|||
}
|
||||
|
||||
/// reset device
|
||||
pub fn reset_device<D: DelayMs<u8>>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||
pub fn reset_device<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||
self.write_bit(PWR_MGMT_1::ADDR, PWR_MGMT_1::DEVICE_RESET, true)?;
|
||||
delay.delay_ms(100u8);
|
||||
delay.delay_ms(100);
|
||||
// Note: Reset sets sleep to true! Section register map: resets PWR_MGMT to 0x40
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue