gyro
This commit is contained in:
parent
06b955875c
commit
c39fd0727c
3 changed files with 108 additions and 7 deletions
82
controller/Cargo.lock
generated
82
controller/Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aead"
|
||||
|
@ -58,6 +58,15 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.6"
|
||||
|
@ -296,6 +305,7 @@ dependencies = [
|
|||
"heapless 0.8.0",
|
||||
"hex",
|
||||
"log",
|
||||
"mpu6050",
|
||||
"panic-probe",
|
||||
"pio",
|
||||
"pio-proc",
|
||||
|
@ -1458,6 +1468,12 @@ version = "0.2.158"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.3"
|
||||
|
@ -1508,6 +1524,30 @@ version = "1.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94"
|
||||
|
||||
[[package]]
|
||||
name = "mpu6050"
|
||||
version = "0.1.6"
|
||||
source = "git+https://git.ank.dev/ank/mpu6050#32604cc16c6a604fd0a4a35bf66bd9df800da18e"
|
||||
dependencies = [
|
||||
"embedded-hal 1.0.0",
|
||||
"libm",
|
||||
"nalgebra",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra"
|
||||
version = "0.31.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20bd243ab3dbb395b39ee730402d2e5405e448c75133ec49cc977762c4cba3d1"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"num-complex",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"simba",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nb"
|
||||
version = "0.1.3"
|
||||
|
@ -1544,6 +1584,34 @@ dependencies = [
|
|||
"defmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
|
@ -2038,6 +2106,18 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9"
|
||||
|
||||
[[package]]
|
||||
name = "simba"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f3fd720c48c53cace224ae62bef1bbff363a70c68c4802a78b5cc6159618176"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"num-complex",
|
||||
"num-traits",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.11"
|
||||
|
|
|
@ -59,6 +59,8 @@ embedded-sdmmc = "0.7.0"
|
|||
|
||||
bt-hci = { version = "0.1.0", default-features = false, features = ["defmt"] }
|
||||
hex = { version = "0.4.3", default-features=false }
|
||||
mpu6050 = { git = "https://git.ank.dev/ank/mpu6050" }
|
||||
|
||||
|
||||
[profile.release]
|
||||
debug = 2
|
||||
|
|
|
@ -28,8 +28,9 @@ use embassy_rp::gpio::{Level, Output};
|
|||
use embassy_rp::peripherals::{DMA_CH0, PIO0, USB};
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use embassy_rp::usb::Driver;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use embedded_io_async::Write;
|
||||
use mpu6050::Mpu6050;
|
||||
use rand::RngCore;
|
||||
use reqwless::response;
|
||||
use static_cell::StaticCell;
|
||||
|
@ -38,7 +39,7 @@ use vl53l0::RegAddr::*;
|
|||
|
||||
bind_interrupts!(struct Irqs {
|
||||
PIO0_IRQ_0 => InterruptHandler<PIO0>;
|
||||
I2C1_IRQ => embassy_rp::i2c::InterruptHandler<embassy_rp::peripherals::I2C1>;
|
||||
I2C0_IRQ => embassy_rp::i2c::InterruptHandler<embassy_rp::peripherals::I2C0>;
|
||||
USBCTRL_IRQ => embassy_rp::usb::InterruptHandler<USB>;
|
||||
});
|
||||
|
||||
|
@ -83,10 +84,28 @@ async fn main(spawner: Spawner) {
|
|||
let mut pwm = Pwm::new_output_ab(p.PWM_SLICE1, p.PIN_18, p.PIN_19, c.clone());
|
||||
flipper.set_high();
|
||||
|
||||
let sda = p.PIN_26;
|
||||
let scl = p.PIN_27;
|
||||
let sda = p.PIN_20;
|
||||
let scl = p.PIN_21;
|
||||
let config = embassy_rp::i2c::Config::default();
|
||||
let mut bus = embassy_rp::i2c::I2c::new_async(p.I2C1, scl, sda, Irqs, config);
|
||||
let mut bus = embassy_rp::i2c::I2c::new_async(p.I2C0, scl, sda, Irqs, config);
|
||||
|
||||
let mut gyro = Mpu6050::new_with_addr(bus,0x68);
|
||||
let mut gyro2 = Mpu6050::new_with_addr(bus,0x69);
|
||||
|
||||
Timer::after_millis(1300).await;
|
||||
gyro.init(&mut Delay).unwrap();
|
||||
|
||||
gyro.set_gyro_range(mpu6050::device::GyroRange::D2000).unwrap();
|
||||
gyro.set_accel_range(mpu6050::device::AccelRange::G16).unwrap();
|
||||
info!("pinidtd");
|
||||
Timer::after_millis(1300).await;
|
||||
|
||||
loop {
|
||||
info!("pos: {}", gyro.get_gyro().unwrap().x);
|
||||
info!("jerk: {}", gyro.get_acc().unwrap().x);
|
||||
info!("temp: {}", gyro.get_temp().unwrap() * (9./5.) + 32.);
|
||||
Timer::after_millis(13).await;
|
||||
}
|
||||
|
||||
let fw = include_bytes!("../../cyw43-firmware/43439A0.bin");
|
||||
let clm = include_bytes!("../../cyw43-firmware/43439A0_clm.bin");
|
||||
|
|
Loading…
Reference in a new issue