Fix for readability

This commit is contained in:
yanorei32 2023-10-11 02:54:38 +09:00
parent bf82cfe6dc
commit 6ce8a12bf8

View File

@ -14,7 +14,7 @@ mod app {
can::Can, can::Can,
device::TIM2, device::TIM2,
gpio::{Output, Pin}, gpio::{Output, Pin},
pac::{CAN1, Interrupt}, pac::{Interrupt, CAN1},
prelude::*, prelude::*,
timer::Delay, timer::Delay,
}; };
@ -105,26 +105,25 @@ mod app {
fn idle(cx: idle::Context) -> ! { fn idle(cx: idle::Context) -> ! {
let mut tx_queue = cx.shared.can_tx_queue; let mut tx_queue = cx.shared.can_tx_queue;
loop { for sign in [1, -1].iter().cycle() {
for sign in [1, -1] { for speed in (0..=30_000)
for speed in (0..=120) .step_by(250)
.chain((0..40).map(|_| 120)) .chain(core::iter::repeat(30_000).take(1000 / 25))
.chain((0..=120).map(|i| 120 - i)) .chain((0..=30_000).step_by(250).map(|v| 30_000 - v))
.map(|v| v * sign)
{ {
tx_queue.lock(|mut tx_queue| { tx_queue.lock(|mut tx_queue| {
enqueue_frame( enqueue_frame(
&mut tx_queue, &mut tx_queue,
Frame::new_data( Frame::new_data(StandardId::new(0x1FF).unwrap(), speed2array(speed)),
StandardId::new(0x1FF).unwrap(),
speed2array(speed * 250 * sign),
),
); );
}); });
cx.local.delay.delay(25.millis()); cx.local.delay.delay(25.millis());
} }
} }
}
unreachable!()
} }
#[task(binds = USB_HP_CAN_TX, local = [can_tx, led], shared = [can_tx_queue, tx_count])] #[task(binds = USB_HP_CAN_TX, local = [can_tx, led], shared = [can_tx_queue, tx_count])]