Compare commits
2 commits
cfd7b79eac
...
ceb4dc035f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ceb4dc035f | ||
|
|
475e9621a1 |
11 changed files with 510 additions and 606 deletions
1007
Cargo.lock
generated
1007
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,22 +5,23 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.83"
|
anyhow = "1.0.83"
|
||||||
axum = { version = "0.7.5", features = ["macros"] }
|
axum = { version = "0.8.8", features = ["macros"] }
|
||||||
fern = { version = "0.6.2", features = ["colored"] }
|
fern = { version = "0.7.1", features = ["colored"] }
|
||||||
humantime = "2.1.0"
|
humantime = "2.1.0"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
nom = "7.1.3"
|
nom = "8.0.0"
|
||||||
serde_json = "1.0.118"
|
serde_json = "1.0.118"
|
||||||
serialport = "4.5.1"
|
serialport = "4.5.1"
|
||||||
tokio = {version = "1.37.0", features = ["full"]}
|
tokio = {version = "1.37.0", features = ["full"]}
|
||||||
tower-http = { version = "0.5.2", features = ["fs", "trace"] }
|
tower-http = { version = "0.6.8", features = ["fs", "trace"] }
|
||||||
radomctl-protocol = { path = "../protocol" }
|
radomctl-protocol = { path = "../protocol" }
|
||||||
postcard = {version = "1.0.10", features = ["use-std"]}
|
postcard = {version = "1.0.10", features = ["use-std"]}
|
||||||
dfu-libusb = "0.3.0"
|
dfu-libusb = "0.5.5"
|
||||||
rusb = "0.9"
|
rusb = "0.9"
|
||||||
clap = { version = "4.5.19", features = ["derive"] }
|
clap = { version = "4.5.19", features = ["derive"] }
|
||||||
indicatif = "0.17.8"
|
indicatif = "0.18.3"
|
||||||
tokio-serial = {version = "5.4.4", features = ["codec", "rt"] }
|
tokio-serial = {version = "5.4.4", features = ["codec", "rt"] }
|
||||||
tokio-util = { version = "0.7.13", features = ["codec", "rt"] }
|
tokio-util = { version = "0.7.13", features = ["codec", "rt"] }
|
||||||
bytes = "1.9.0"
|
bytes = "1.9.0"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
|
nom-language = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@ use std::{
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use dfu_libusb::{Dfu, DfuLibusb};
|
use dfu_libusb::{Dfu, DfuLibusb};
|
||||||
use postcard::{from_bytes_cobs, to_stdvec_cobs};
|
use postcard::to_stdvec_cobs;
|
||||||
use radomctl_protocol::*;
|
use radomctl_protocol::*;
|
||||||
use radomctld::logger::setup_logger;
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use fern::colors::{Color, ColoredLevelConfig};
|
use fern::colors::{Color, ColoredLevelConfig};
|
||||||
use log::{debug, error, info, warn};
|
|
||||||
use std::io;
|
|
||||||
|
|
||||||
pub fn setup_logger() -> Result<()> {
|
pub fn setup_logger() -> Result<()> {
|
||||||
let colors = ColoredLevelConfig::new()
|
let colors = ColoredLevelConfig::new()
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,9 @@
|
||||||
|
use anyhow::anyhow;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use anyhow::{anyhow, Context};
|
use axum::{extract::State, routing::get, Json, Router};
|
||||||
use axum::{
|
|
||||||
extract::State,
|
|
||||||
http::StatusCode,
|
|
||||||
routing::{get, post},
|
|
||||||
Json, Router,
|
|
||||||
};
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use fern::colors::{Color, ColoredLevelConfig};
|
use log::{debug, error, info};
|
||||||
use log::{debug, error, info, warn, Level};
|
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use std::time::Duration;
|
|
||||||
use std::{borrow::Borrow, io};
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
self,
|
self,
|
||||||
io::{AsyncBufReadExt, AsyncWriteExt, BufStream},
|
io::{AsyncBufReadExt, AsyncWriteExt, BufStream},
|
||||||
|
|
@ -20,10 +12,7 @@ use tokio::{
|
||||||
task::JoinSet,
|
task::JoinSet,
|
||||||
};
|
};
|
||||||
use tokio_serial;
|
use tokio_serial;
|
||||||
use tower_http::{
|
use tower_http::{services::ServeFile, trace::TraceLayer};
|
||||||
services::{ServeDir, ServeFile},
|
|
||||||
trace::TraceLayer,
|
|
||||||
};
|
|
||||||
|
|
||||||
use radomctld::{
|
use radomctld::{
|
||||||
logger::setup_logger,
|
logger::setup_logger,
|
||||||
|
|
@ -34,7 +23,7 @@ use radomctld::{
|
||||||
async fn process_socket(
|
async fn process_socket(
|
||||||
socket: TcpStream,
|
socket: TcpStream,
|
||||||
cmd_tx: mpsc::Sender<Command>,
|
cmd_tx: mpsc::Sender<Command>,
|
||||||
mut pos_rx: watch::Receiver<(f32, f32)>,
|
pos_rx: watch::Receiver<(f32, f32)>,
|
||||||
) {
|
) {
|
||||||
let mut stream = BufStream::new(socket);
|
let mut stream = BufStream::new(socket);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,14 @@ use nom::{
|
||||||
character::complete::{
|
character::complete::{
|
||||||
alphanumeric1, i8, multispace0, multispace1, newline, none_of, not_line_ending, space1,
|
alphanumeric1, i8, multispace0, multispace1, newline, none_of, not_line_ending, space1,
|
||||||
},
|
},
|
||||||
combinator::{all_consuming, map, opt, recognize, rest},
|
combinator::{all_consuming, map, opt, recognize},
|
||||||
error::{context, convert_error, VerboseError},
|
error::context,
|
||||||
multi::{many0, many1},
|
multi::many1,
|
||||||
number::complete::float,
|
number::complete::float,
|
||||||
sequence::{preceded, separated_pair, terminated},
|
sequence::{preceded, separated_pair, terminated},
|
||||||
Err as NomErr, IResult, Parser,
|
Err as NomErr, IResult, Parser,
|
||||||
};
|
};
|
||||||
|
use nom_language::error::{convert_error, VerboseError};
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,19 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use bytes::{BufMut, BytesMut};
|
use bytes::{BufMut, BytesMut};
|
||||||
use futures::{stream::StreamExt, SinkExt};
|
use futures::{stream::StreamExt, SinkExt};
|
||||||
use log::{debug, error, info, warn};
|
|
||||||
use postcard::{from_bytes_cobs, to_stdvec_cobs};
|
use postcard::{from_bytes_cobs, to_stdvec_cobs};
|
||||||
use radomctl_protocol::{HostMessage, PositionTarget, RadomMessage};
|
use radomctl_protocol::{HostMessage, PositionTarget, RadomMessage};
|
||||||
use std::{env, io, str, time::Duration};
|
use std::{io, time::Duration};
|
||||||
use tokio::time::sleep;
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
self,
|
self,
|
||||||
io::{AsyncBufReadExt, AsyncWriteExt, BufStream},
|
io::AsyncBufReadExt,
|
||||||
net::{TcpListener, TcpStream},
|
sync::{mpsc, watch},
|
||||||
sync::{self, mpsc, watch},
|
|
||||||
time,
|
time,
|
||||||
};
|
};
|
||||||
use tokio_serial::SerialPortBuilderExt;
|
use tokio_serial::SerialPortBuilderExt;
|
||||||
use tokio_util::codec::{Decoder, Encoder};
|
use tokio_util::codec::{Decoder, Encoder};
|
||||||
|
|
||||||
use crate::rotctlprotocol::{parse_command, Command};
|
use crate::rotctlprotocol::Command;
|
||||||
|
|
||||||
struct ProtocolCodec;
|
struct ProtocolCodec;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,25 @@ version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
||||||
defmt = { version = "0.3", features = ["encoding-rzcobs"] }
|
defmt = { version = "1.0", features = ["encoding-rzcobs"] }
|
||||||
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
|
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
|
||||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
panic-probe = { version = "1.0", features = ["print-defmt"] }
|
||||||
rtic = { version = "2.0.1", features = [ "thumbv7-backend" ] }
|
rtic = { version = "2.0.1", features = [ "thumbv7-backend" ] }
|
||||||
defmt-rtt = "0.4"
|
defmt-rtt = "1.1"
|
||||||
stm32f4xx-hal = { version = "0.21.0", features = ["stm32f401", "usb_fs"] }
|
stm32f4xx-hal = { version = "0.23.0", features = ["stm32f401", "usb_fs"] }
|
||||||
embedded-hal = {version = "1.0.0"}
|
embedded-hal = {version = "1.0.0"}
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
||||||
num = {version = "0.4", default-features = false}
|
num = {version = "0.4", default-features = false}
|
||||||
ufmt = "0.2.0"
|
ufmt = "0.2.0"
|
||||||
qmc5883l = "0.0.1"
|
qmc5883l = {version = "0.0.1", git="https://github.com/patrickelectric/qmc5883l", rev="62b8a64b54e0f843ddf0c5942f8ed218b5f3e492"}
|
||||||
rtic-monotonics = {version = "2.0.2", features = ["cortex-m-systick"]}
|
rtic-monotonics = {version = "2.0.2", features = ["cortex-m-systick"]}
|
||||||
xca9548a = "0.2.1"
|
xca9548a = "1.0.0"
|
||||||
as5048a = { git = "https://github.com/LongHairedHacker/as5048a", rev="b15d716bf47ce4975a6cefebf82006c9b09e8fea"}
|
as5048a = { git = "https://github.com/LongHairedHacker/as5048a", rev="b15d716bf47ce4975a6cefebf82006c9b09e8fea"}
|
||||||
usb-device = "0.3.2"
|
usb-device = "0.3.2"
|
||||||
usbd-serial = "0.2.2"
|
usbd-serial = "0.2.2"
|
||||||
postcard = {version = "1.0.10", features = ["use-defmt"]}
|
postcard = {version = "1.0.10", features = ["use-defmt"]}
|
||||||
heapless = {version = "0.8.0", features = ["defmt-03"]}
|
heapless = {version = "0.9.2", features = ["defmt"]}
|
||||||
radomctl-protocol = { path = "../protocol" }
|
radomctl-protocol = { path = "../protocol" }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use core::{mem::MaybeUninit, ptr::addr_of_mut};
|
use core::mem::MaybeUninit;
|
||||||
|
|
||||||
use stm32f4xx_hal::pac;
|
use stm32f4xx_hal::pac;
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ fn jump_to_bootloader() {
|
||||||
let address: u32 = 0x1FFF0000;
|
let address: u32 = 0x1FFF0000;
|
||||||
|
|
||||||
let device = pac::Peripherals::steal();
|
let device = pac::Peripherals::steal();
|
||||||
device.SYSCFG.memrm.modify(|_, w| w.bits(0x01));
|
device.SYSCFG.memrmp().modify(|_, w| w.bits(0x01));
|
||||||
|
|
||||||
let mut p = cortex_m::Peripherals::steal();
|
let mut p = cortex_m::Peripherals::steal();
|
||||||
p.SCB.invalidate_icache();
|
p.SCB.invalidate_icache();
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ mod app {
|
||||||
otg_fs::{UsbBus, UsbBusType, USB},
|
otg_fs::{UsbBus, UsbBusType, USB},
|
||||||
pac::{I2C1, SPI1},
|
pac::{I2C1, SPI1},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
rcc::Config,
|
||||||
signature, spi,
|
signature, spi,
|
||||||
};
|
};
|
||||||
use usb_device::prelude::*;
|
use usb_device::prelude::*;
|
||||||
|
|
@ -93,26 +94,19 @@ mod app {
|
||||||
bootloader::init();
|
bootloader::init();
|
||||||
|
|
||||||
defmt::info!("init");
|
defmt::info!("init");
|
||||||
|
let mut rcc = cx
|
||||||
|
.device
|
||||||
|
.RCC
|
||||||
|
.freeze(Config::hse(25.MHz()).sysclk(84.MHz()).require_pll48clk());
|
||||||
|
|
||||||
let rcc = cx.device.RCC.constrain();
|
Mono::start(cx.core.SYST, rcc.clocks.sysclk().to_Hz());
|
||||||
|
|
||||||
// Freeze the configuration of all the clocks in the system and store the frozen frequencies in
|
|
||||||
// `clocks`
|
|
||||||
let clocks = rcc
|
|
||||||
.cfgr
|
|
||||||
.use_hse(25.MHz())
|
|
||||||
.sysclk(84.MHz())
|
|
||||||
.require_pll48clk()
|
|
||||||
.freeze();
|
|
||||||
|
|
||||||
Mono::start(cx.core.SYST, clocks.sysclk().to_Hz());
|
|
||||||
|
|
||||||
defmt::info!("Clock Setup done");
|
defmt::info!("Clock Setup done");
|
||||||
|
|
||||||
// Acquire the GPIO peripherials
|
// Acquire the GPIO peripherials
|
||||||
let gpioa = cx.device.GPIOA.split();
|
let gpioa = cx.device.GPIOA.split(&mut rcc);
|
||||||
let gpiob = cx.device.GPIOB.split();
|
let gpiob = cx.device.GPIOB.split(&mut rcc);
|
||||||
let gpioc = cx.device.GPIOC.split();
|
let gpioc = cx.device.GPIOC.split(&mut rcc);
|
||||||
|
|
||||||
let board_led = gpioc.pc13.into_push_pull_output();
|
let board_led = gpioc.pc13.into_push_pull_output();
|
||||||
|
|
||||||
|
|
@ -128,7 +122,7 @@ mod app {
|
||||||
cx.device.OTG_FS_PWRCLK,
|
cx.device.OTG_FS_PWRCLK,
|
||||||
),
|
),
|
||||||
(gpioa.pa11, gpioa.pa12),
|
(gpioa.pa11, gpioa.pa12),
|
||||||
&clocks,
|
&rcc.clocks,
|
||||||
);
|
);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
@ -177,7 +171,7 @@ mod app {
|
||||||
i2c::Mode::Standard {
|
i2c::Mode::Standard {
|
||||||
frequency: 400.kHz(),
|
frequency: 400.kHz(),
|
||||||
},
|
},
|
||||||
&clocks,
|
&mut rcc,
|
||||||
);
|
);
|
||||||
|
|
||||||
defmt::info!("I2C Setup done");
|
defmt::info!("I2C Setup done");
|
||||||
|
|
@ -201,13 +195,13 @@ mod app {
|
||||||
let pico = gpioa.pa7.into_push_pull_output();
|
let pico = gpioa.pa7.into_push_pull_output();
|
||||||
let spi1 = spi::Spi::new(
|
let spi1 = spi::Spi::new(
|
||||||
cx.device.SPI1,
|
cx.device.SPI1,
|
||||||
(sck, poci, pico),
|
(Some(sck), Some(poci), Some(pico)),
|
||||||
spi::Mode {
|
spi::Mode {
|
||||||
polarity: spi::Polarity::IdleLow,
|
polarity: spi::Polarity::IdleLow,
|
||||||
phase: spi::Phase::CaptureOnSecondTransition,
|
phase: spi::Phase::CaptureOnSecondTransition,
|
||||||
},
|
},
|
||||||
8.MHz(),
|
8.MHz(),
|
||||||
&clocks,
|
&mut rcc,
|
||||||
);
|
);
|
||||||
|
|
||||||
defmt::info!("SPI Setup done");
|
defmt::info!("SPI Setup done");
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = {version = "1.0.193", default-features = false, features = ["derive"]}
|
serde = {version = "1.0.193", default-features = false, features = ["derive"]}
|
||||||
heapless = {version = "0.8.0", features = ["serde"]}
|
heapless = {version = "0.9.2", features = ["serde"]}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue