Fixed up nostd support, verified that sqrt and cbrt routines work to within 1ULP

This commit is contained in:
2022-04-25 22:36:05 +02:00
parent 8016a8c7f8
commit 1e1cac4f06
7 changed files with 75 additions and 39 deletions

View File

@@ -20,7 +20,7 @@ rustflags = [
]
[build]
target = "thumbv7em-none-eabihf"
target = "thumbv6m-none-eabi"
[env]
DEFMT_LOG = "debug"

View File

@@ -15,8 +15,10 @@ mod app {
use core::num::Wrapping;
use embedded_hal::digital::v2::OutputPin;
use embedded_time::duration::Extensions;
use jerk_control::executor::CommandQueue;
use jerk_control::planner::Planner;
use rp_pico::hal;
use rp_pico::hal::{self, gpio::pin::{Output, PushPull, PullDownDisabled, Pin}};
use rp_pico::pac;
use rp_pico::XOSC_CRYSTAL_FREQ;
use rtic::mutex_prelude::{TupleExt04, TupleExt05};
@@ -69,11 +71,26 @@ mod app {
pub active: bool,
}
pub struct StepperProcess<Pin> {
pub struct StepperProcess<StepPin, DirPin>
where StepPin: rp2040_hal::gpio::PinId,
DirPin: rp2040_hal::gpio::PinId {
pub executor: executor::CommandQueue,
pub pin: Pin,
pub step: rp_pico::hal::gpio::Pin<StepPin, Output<PushPull>>,
pub dir: rp_pico::hal::gpio::Pin<DirPin, Output<PushPull>>,
}
impl<StepPin, DirPin> StepperProcess<StepPin, DirPin>
where StepPin: rp2040_hal::gpio::PinId,
DirPin: rp2040_hal::gpio::PinId {
pub fn new(step: Pin<StepPin, PullDownDisabled>, dir: Pin<DirPin, PullDownDisabled>) -> Self {
Self {
executor: CommandQueue::new(),
step: step.into_push_pull_output(),
dir: dir.into_push_pull_output(),
}
}
}
#[shared]
struct Shared {
@@ -89,9 +106,11 @@ mod app {
}
use rp2040_hal::gpio::pin::bank0;
#[local]
struct Local {
executor1: StepperProcess<rp_pico::hal::gpio::Pin<hal::gpio::pin::bank0::>>,
executor1: StepperProcess<bank0::Gpio1, bank0::Gpio2>,
}
#[init(local = [usb_bus: Option<usb_device::bus::UsbBusAllocator<hal::usb::UsbBus>> = None])]
@@ -178,7 +197,9 @@ mod app {
serial,
usb_dev,
},
Local {},
Local {
executor1: StepperProcess::new(pins.gpio1, pins.gpio2),
},
init::Monotonics(),
)
}
@@ -188,9 +209,24 @@ mod app {
binds = TIMER_IRQ_0,
priority = 4,
shared = [timer, alarm, serial],
local = [tog: bool = true],
local = [executor1],
)]
fn timer_irq(mut _cx: timer_irq::Context) {
let executor: &mut StepperProcess<_, _> = _cx.local.executor1;
if executor.executor.direction() {
executor.dir.set_high();
} else {
executor.dir.set_low();
}
if executor.executor.step_early() {
executor.step.set_high();
} else {
executor.step.set_low();
}
executor.executor.step_late();
}
/// Usb interrupt handler. Runs every time the host requests new data.