moved command to common
This commit is contained in:
parent
18d0a57583
commit
d900308c5d
5 changed files with 17 additions and 19 deletions
|
@ -4,3 +4,4 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
serde = { version = "1.0.219", default-features = false, features = ["serde_derive", "derive"] }
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
#![no_std]
|
||||||
left + right
|
use serde::Deserialize;
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[derive(Deserialize, Default)]
|
||||||
mod tests {
|
pub struct Command {
|
||||||
use super::*;
|
pub left: f32,
|
||||||
|
pub right: f32,
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
8
robot-controller/Cargo.lock
generated
8
robot-controller/Cargo.lock
generated
|
@ -105,6 +105,13 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "critical-section"
|
name = "critical-section"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
@ -238,6 +245,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arduino-hal",
|
"arduino-hal",
|
||||||
"avr-device",
|
"avr-device",
|
||||||
|
"common",
|
||||||
"embedded-hal 1.0.0",
|
"embedded-hal 1.0.0",
|
||||||
"nb 1.1.0",
|
"nb 1.1.0",
|
||||||
"panic-halt",
|
"panic-halt",
|
||||||
|
|
|
@ -18,6 +18,7 @@ embedded-hal = "1.0"
|
||||||
avr-device = "0.7.0"
|
avr-device = "0.7.0"
|
||||||
serde = { version = "1.0.219", default-features = false, features = ["serde_derive", "derive"] }
|
serde = { version = "1.0.219", default-features = false, features = ["serde_derive", "derive"] }
|
||||||
postcard = "1.1.2"
|
postcard = "1.1.2"
|
||||||
|
common = { path = "../common" }
|
||||||
|
|
||||||
[dependencies.arduino-hal]
|
[dependencies.arduino-hal]
|
||||||
git = "https://github.com/rahix/avr-hal"
|
git = "https://github.com/rahix/avr-hal"
|
||||||
|
|
|
@ -12,8 +12,8 @@ use arduino_hal::pac::USART0;
|
||||||
use arduino_hal::port::mode::*;
|
use arduino_hal::port::mode::*;
|
||||||
use arduino_hal::prelude::*;
|
use arduino_hal::prelude::*;
|
||||||
use avr_device::interrupt::{self, Mutex};
|
use avr_device::interrupt::{self, Mutex};
|
||||||
|
use common::Command;
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
fn shift_out(data_pin: &mut Pin<Output, PB0>, clock_pin: &mut Pin<Output, PD4>, data: &u8) {
|
fn shift_out(data_pin: &mut Pin<Output, PB0>, clock_pin: &mut Pin<Output, PD4>, data: &u8) {
|
||||||
for i in 0..8 {
|
for i in 0..8 {
|
||||||
|
@ -157,12 +157,6 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
|
||||||
struct Command {
|
|
||||||
left: f32,
|
|
||||||
right: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decode_command() -> Command {
|
fn decode_command() -> Command {
|
||||||
let mut input = interrupt::free(|cs| {
|
let mut input = interrupt::free(|cs| {
|
||||||
INPUT_LINE.borrow(cs).borrow().clone()
|
INPUT_LINE.borrow(cs).borrow().clone()
|
||||||
|
|
Loading…
Reference in a new issue