Fixed hardfault due to broken memory layout
This commit is contained in:
parent
57fdf05f00
commit
f7483fe42a
3 changed files with 39 additions and 37 deletions
|
|
@ -71,7 +71,7 @@ mod app {
|
|||
spi_cs3: gpiob::PB15<Output<PushPull>>,
|
||||
spi1: spi::Spi<SPI1>,
|
||||
|
||||
az_enable: gpioa::PA10<Output<PushPull>>,
|
||||
az_enable: gpiob::PB8<Output<PushPull>>,
|
||||
az_dir: gpioa::PA15<Output<PushPull>>,
|
||||
az_step: gpiob::PB3<Output<PushPull>>,
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ mod app {
|
|||
|
||||
defmt::info!("SPI Setup done");
|
||||
|
||||
let mut az_enable = gpioa.pa10.into_push_pull_output();
|
||||
let mut az_enable = gpiob.pb8.into_push_pull_output();
|
||||
az_enable.set_high();
|
||||
let az_dir = gpioa.pa15.into_push_pull_output();
|
||||
let az_step = gpiob.pb3.into_push_pull_output();
|
||||
|
|
@ -351,7 +351,7 @@ mod app {
|
|||
|
||||
defmt::info!("angle: {:?}", angle_deg);
|
||||
|
||||
Mono::delay(50.millis()).await;
|
||||
Mono::delay(1.millis()).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -361,30 +361,51 @@ mod app {
|
|||
let az_dir = cx.local.az_dir;
|
||||
let az_step = cx.local.az_step;
|
||||
|
||||
let mut counter = 0;
|
||||
let mut az_target = 0;
|
||||
|
||||
loop {
|
||||
let az_target = cx.shared.az_compass.lock(|az_compass| *az_compass);
|
||||
//let az_target = 1800; //cx.shared.az_compass.lock(|az_compass| *az_compass);
|
||||
|
||||
let az_angle = cx.shared.az_angle.lock(|az_angle| *az_angle);
|
||||
let diff = az_angle - az_target;
|
||||
|
||||
defmt::info!("angle diff: {:?}", diff);
|
||||
defmt::info!(
|
||||
"angle diff/target/actual: {:?}/{:?}/{:?}",
|
||||
diff,
|
||||
az_target,
|
||||
az_angle
|
||||
);
|
||||
|
||||
let delay = if diff.abs() < 10 {
|
||||
10.millis()
|
||||
} else if diff < 100 {
|
||||
5.millis()
|
||||
} else {
|
||||
1.millis()
|
||||
};
|
||||
|
||||
if diff.abs() > 5 {
|
||||
az_enable.set_low();
|
||||
if diff > 0 {
|
||||
if diff < 0 {
|
||||
az_dir.set_high();
|
||||
} else {
|
||||
az_dir.set_low();
|
||||
}
|
||||
|
||||
az_step.set_low();
|
||||
Mono::delay(250.micros()).await;
|
||||
Mono::delay(delay / 2).await;
|
||||
az_step.set_high();
|
||||
Mono::delay(250.micros()).await;
|
||||
Mono::delay(delay / 2).await;
|
||||
} else {
|
||||
az_enable.set_high();
|
||||
Mono::delay(500.micros()).await;
|
||||
Mono::delay(delay).await;
|
||||
}
|
||||
|
||||
counter = (counter + 1) % 1000;
|
||||
if counter == 0 {
|
||||
az_target = (az_target + 450) % 3600;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue