Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • software/dc-motor-driver-hat
1 result
Show changes
Commits on Source (2)
......@@ -467,7 +467,7 @@ checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b"
[[package]]
name = "embassy-embedded-hal"
version = "0.2.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"defmt",
"embassy-futures",
......@@ -484,7 +484,7 @@ dependencies = [
[[package]]
name = "embassy-executor"
version = "0.6.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"cortex-m",
"critical-section",
......@@ -498,7 +498,7 @@ dependencies = [
[[package]]
name = "embassy-executor-macros"
version = "0.5.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"darling",
"proc-macro2",
......@@ -509,12 +509,12 @@ dependencies = [
[[package]]
name = "embassy-futures"
version = "0.1.1"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
[[package]]
name = "embassy-hal-internal"
version = "0.2.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"cortex-m",
"critical-section",
......@@ -525,7 +525,7 @@ dependencies = [
[[package]]
name = "embassy-net-driver"
version = "0.2.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"defmt",
]
......@@ -533,7 +533,7 @@ dependencies = [
[[package]]
name = "embassy-stm32"
version = "0.1.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"aligned",
"bit_field",
......@@ -579,7 +579,7 @@ dependencies = [
[[package]]
name = "embassy-sync"
version = "0.6.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"cfg-if",
"critical-section",
......@@ -592,7 +592,7 @@ dependencies = [
[[package]]
name = "embassy-time"
version = "0.3.2"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"cfg-if",
"critical-section",
......@@ -610,7 +610,7 @@ dependencies = [
[[package]]
name = "embassy-time-driver"
version = "0.1.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"document-features",
]
......@@ -618,12 +618,12 @@ dependencies = [
[[package]]
name = "embassy-time-queue-driver"
version = "0.1.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
[[package]]
name = "embassy-usb-driver"
version = "0.1.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"defmt",
]
......@@ -631,7 +631,7 @@ dependencies = [
[[package]]
name = "embassy-usb-synopsys-otg"
version = "0.1.0"
source = "git+https://github.com/embassy-rs/embassy#b8fa5cdf06f54cda1895b6d5e8d3b436dbce08ac"
source = "git+https://github.com/embassy-rs/embassy#0ede8479dc4c6a58cfab0a5d4df41c0592405971"
dependencies = [
"critical-section",
"embassy-sync",
......@@ -1252,7 +1252,7 @@ dependencies = [
[[package]]
name = "stm32-metapac"
version = "15.0.0"
source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-5ef354f3e49f790e47f5c818f243459742c9b83b#d94c7ea2bd05428ba9fd2b5a39edb8ed99f65daa"
source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-9b7414490b10ffbd5beb1b0dcf14adb018cbe37f#dc782d51865ba6a0a8dd79a4d6972864b33b6f00"
dependencies = [
"cortex-m",
"cortex-m-rt",
......
......@@ -30,18 +30,16 @@ fn bkp() -> Bkp {
fn write_backup_data(data: &[u16]) {
let bkp = bkp();
for (i, v) in data.iter().enumerate() {
// TODO: remove +1 when https://github.com/embassy-rs/stm32-data/pull/507 is merged
bkp.dr(i + 1).write(|w| w.set_d(*v));
bkp.dr(i).write(|w| w.set_d(*v));
}
}
// Check if the first backup registers contain data
fn backup_data_present(data: &[u16]) -> bool {
let bkp = bkp();
// TODO: remove +1 when https://github.com/embassy-rs/stm32-data/pull/507 is merged
data.iter()
.enumerate()
.all(|(i, v)| bkp.dr(i + 1).read().d() == *v)
.all(|(i, v)| bkp.dr(i).read().d() == *v)
}
pub fn reboot() -> ! {
......
......@@ -42,3 +42,7 @@ required-features = ["controller"]
[[example]]
name = "check-firmware"
required-features = ["controller", "float"]
[[example]]
name = "encoder-curves"
required-features = ["controller"]
use color_eyre::eyre::Context;
use std::{fs::File, io::Write, time::Duration};
use tele0592::Controller as _;
const PERIOD: Duration = Duration::from_millis(20);
const STEPS: usize = 200;
const RAW: bool = true;
fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
let mut controller = rppal::i2c::I2c::with_bus(8).with_context(|| "opening I²C bus")?;
println!(
"Firmware version: {:?}",
controller.check_firmware_version()?
);
controller.set_motor_shutdown_timeout(Duration::from_secs(1))?;
controller.set_raw_pid_coefficients(0x80, 0x03, 0x00)?;
let mut relative = controller.new_relative()?;
let mut csv = File::create("encoders.csv")?;
for speed in [
10, 20, 30, 40, 50, 60, 70, 80, 0, -10, -20, -30, -40, -50, -60, -70, -80, 0,
] {
if RAW {
println!("Setting raw motor speeds to {speed}");
controller.set_raw_motor_speed(Some(speed), Some(speed))?;
} else {
println!("Setting motor speeds to {speed}");
controller.set_motor_speed(i16::from(speed), i16::from(speed))?;
}
for _ in 1..STEPS {
std::thread::sleep(PERIOD);
let (left, right) = controller.get_relative_encoder_ticks(&mut relative)?;
writeln!(csv, "{speed},{left},{right}")?;
}
}
Ok(())
}