Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f7525a9f3 |
4 changed files with 4 additions and 116 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
|
@ -624,21 +624,6 @@ dependencies = [
|
|||
"heapless 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embassy_gps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/jbeyerstedt/embassy_gps.git?branch=feat%2Frework-gpsfix#75f1a67a69372234330c0c9618a953c415380b99"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"embassy-futures",
|
||||
"embassy-time",
|
||||
"embedded-io-async 0.7.0",
|
||||
"esp-hal",
|
||||
"heapless 0.9.2",
|
||||
"log",
|
||||
"nmea",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-can"
|
||||
version = "0.4.1"
|
||||
|
|
@ -1194,7 +1179,6 @@ dependencies = [
|
|||
"embassy-futures",
|
||||
"embassy-sync 0.7.2",
|
||||
"embassy-time",
|
||||
"embassy_gps",
|
||||
"embedded-graphics",
|
||||
"embedded-hal-bus",
|
||||
"embedded-io 0.7.1",
|
||||
|
|
@ -1782,20 +1766,6 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
|
||||
|
||||
[[package]]
|
||||
name = "nmea"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2086c773d18da556c05ca235596d163c00379027189bafe2209ae40ebd19717c"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"cfg-if",
|
||||
"chrono",
|
||||
"heapless 0.8.0",
|
||||
"nom",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ std = ["c-its-parser/std", "esp32-cits-core/std"]
|
|||
|
||||
# enable u-blox GNSS module
|
||||
gnss_ubx = ["_gnss", "_uart", "dep:ublox"]
|
||||
# enable L67K GNSS module
|
||||
gnss_l67k = ["_gnss", "dep:embassy_gps"]
|
||||
# echo CAM data on serial
|
||||
cam = ["c-its-parser/cam"]
|
||||
# send CAM autonomously
|
||||
|
|
@ -105,7 +103,6 @@ esp-radio = { version = "0.18.0", optional = true, features = [
|
|||
trouble-host = { version = "0.6.0", features = ["gatt", "central", "derive", "default-packet-pool"] }
|
||||
static_cell = "2"
|
||||
|
||||
embassy_gps = { version = "0.1.0", optional = true, default-features = false, features = ["esp", "log-04"], git = "https://github.com/jbeyerstedt/embassy_gps.git", branch = "feat/rework-gpsfix" }
|
||||
esp32-cits-core = { version = "0.1.0", default-features = false, git = "https://git.hamburg.ccc.de/jtbx/esp32-cits-core", branch = "main" }
|
||||
embedded-hal-bus = { version = "0.3.0", optional = true }
|
||||
embedded-graphics = { version = "0.8.2", optional = true }
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@ Displays different C-ITS receive-only use cases for cheap.
|
|||
The code is currently tailored to:
|
||||
- Seeed XIAO ESP32-C5 (8MB PSRAM)
|
||||
- U-Blox M10Q GNSS (connected on GPIO12 (RX), GPIO11 (TX), and GPIO25 (reset))
|
||||
or Seeed XIAO L67K (connected on GPIO12 (RX), GPIO11 (TX), GPIO1 (wakeup) and GPIO25 (reset))
|
||||
only available with `gnss_ubx` or `gnss_l67k` feature (which is included in `spat` feature)
|
||||
only available with `gnss_ubx` feature (which is included in `spat` feature)
|
||||
- Some ST7789 240*280px screen (connected on GPIO8 (SCL/ SCK), GPIO10 (SDA/ MOSI), GPIO7 (reset), GPIO23 (DC), GPIO24 (CS), GPIO0 (BL))
|
||||
only available with `screen` feature (which is included in `spat` feature)
|
||||
|
||||
## Features
|
||||
|
||||
### GNSS
|
||||
Enable u-blox or L67K GNSS module and in main application logic/ state.
|
||||
Enable u-blox GNSS module and in main application logic/ state.
|
||||
|
||||
### SPAT
|
||||
Takes the current position and heading from the GNSS receiver and displays the signal phases of the upcoming intersection.
|
||||
|
|
|
|||
82
src/main.rs
82
src/main.rs
|
|
@ -8,16 +8,11 @@
|
|||
// #![deny(clippy::large_stack_frames)]
|
||||
|
||||
// we can't use UART I/O and GNSS at the same time
|
||||
#[cfg(all(feature = "uart", feature = "gnss_ubx", feature = "gnss_l67k"))]
|
||||
compile_error!(
|
||||
"feature \"uart\" and features \"gnss_ubx\" or \"gnss_l67k\" cannot be enabled at the same time"
|
||||
);
|
||||
#[cfg(all(feature = "uart", feature = "gnss_ubx"))]
|
||||
compile_error!("feature \"uart\" and feature \"gnss_ubx\" cannot be enabled at the same time");
|
||||
// autonomous CAM generation need a time and position source (aka _gnss)
|
||||
#[cfg(all(feature = "cam_tx", not(feature = "_gnss")))]
|
||||
compile_error!("feature \"cam_tx\" needs a time and position source (either GNSS or UART)");
|
||||
// we can't have both GNSS drivers enabled at the same time
|
||||
#[cfg(all(feature = "gnss_ubx", feature = "gnss_l67k"))]
|
||||
compile_error!("feature \"gnss_ubx\" and feature \"gnss_l67k\" cannot be enabled at the same time");
|
||||
// at least one V2X feature needs to be enabled
|
||||
#[cfg(not(any(feature = "spat", feature = "cam", feature = "denm")))]
|
||||
compile_error!("at least one V2X feature (\"spat\", \"cam\" or \"denm\") needs to be enabled");
|
||||
|
|
@ -34,8 +29,6 @@ use c_its_parser::standards::extensions::ItsStationType;
|
|||
use critical_section::Mutex;
|
||||
use crossbeam_queue::ArrayQueue;
|
||||
use embassy_executor::Spawner;
|
||||
#[cfg(feature = "gnss_l67k")]
|
||||
use embassy_gps::gps::l76k;
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
|
|
@ -222,24 +215,6 @@ async fn main(spawner: Spawner) -> ! {
|
|||
spawner.spawn(ble::run(controller).expect("Failed to spawn BLE task"));
|
||||
}
|
||||
|
||||
// Setup GNSS:
|
||||
// Seeed XIAO L67K:
|
||||
// RX: D7/ GPIO12
|
||||
// TX: D6/ GPIO11
|
||||
// WAKEUP: D0/ GPIO1 -> HIGH for active, LOW for Sleep
|
||||
// RESET: D2/ GPIO25 -> HIGH for normal, LOW for Reset
|
||||
#[cfg(feature = "gnss_l67k")]
|
||||
spawner.spawn(
|
||||
gnss_l67k_task(
|
||||
peripherals.GPIO1,
|
||||
peripherals.GPIO25,
|
||||
peripherals.UART0,
|
||||
peripherals.GPIO12,
|
||||
peripherals.GPIO11,
|
||||
)
|
||||
.expect("Failed to spawn GNSS task"),
|
||||
);
|
||||
|
||||
// U-Blox module:
|
||||
// RX: D7/ GPIO12
|
||||
// TX: D6/ GPIO11
|
||||
|
|
@ -760,59 +735,6 @@ fn get_its_header<'p>(
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gnss_l67k")]
|
||||
#[allow(clippy::large_stack_frames, reason = "GNSS driver needs some space")]
|
||||
#[embassy_executor::task]
|
||||
async fn gnss_l67k_task(
|
||||
gps_wakeup: esp_hal::peripherals::GPIO1<'static>,
|
||||
gps_reset: esp_hal::peripherals::GPIO25<'static>,
|
||||
uart: esp_hal::peripherals::UART0<'static>,
|
||||
uart_rx: esp_hal::peripherals::GPIO12<'static>,
|
||||
uart_tx: esp_hal::peripherals::GPIO11<'static>,
|
||||
) {
|
||||
use embassy_gps::gps::GpsFsm;
|
||||
|
||||
let mut gps = l76k::esp::L76kFsm::new_sep(
|
||||
l76k::esp::GpsHw {
|
||||
reinit: gps_reset,
|
||||
standby: gps_wakeup,
|
||||
},
|
||||
|| {
|
||||
esp_hal::uart::Uart::new(uart, esp_hal::uart::Config::default().with_baudrate(9600))
|
||||
.expect("Failed to create UART for GNSS")
|
||||
.with_rx(uart_rx)
|
||||
.with_tx(uart_tx)
|
||||
.into_async()
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut fix_drop_message = false;
|
||||
loop {
|
||||
if let Ok(Some(embassy_gps::types::GpsEvent::Fix(fix))) = gps.step().await {
|
||||
// drop every second message as we always get each fix twice
|
||||
fix_drop_message = !fix_drop_message;
|
||||
if fix_drop_message {
|
||||
// send to main thread
|
||||
let pos_state = applogic::GnssFix {
|
||||
time: fix.get_timestamp(),
|
||||
latitude_deg: fix.latitude_deg,
|
||||
longitude_deg: fix.longitude_deg,
|
||||
heading_deg: fix.true_course_deg,
|
||||
speed_mps: fix.speed_over_ground,
|
||||
};
|
||||
|
||||
critical_section::with(|cs| {
|
||||
let gnss_update_ref = GNSS_UPDATE.borrow(cs);
|
||||
gnss_update_ref.replace(Some(pos_state));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// FSM will recover automatically from errors and ignore other event types
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gnss_ubx")]
|
||||
#[embassy_executor::task]
|
||||
async fn gnss_ubx_config(reset_pin: esp_hal::peripherals::GPIO25<'static>) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue