main: Add feature flag for GNSS module
This commit is contained in:
parent
7463adb038
commit
57a6b7983d
4 changed files with 19 additions and 4 deletions
|
|
@ -30,16 +30,17 @@ esp = [
|
|||
"dep:esp-backtrace",
|
||||
"dep:esp-println",
|
||||
"dep:esp-radio",
|
||||
"dep:embassy_gps",
|
||||
]
|
||||
std = ["c-its-parser/std"]
|
||||
|
||||
# enable L67K GNSS module
|
||||
gnss = ["dep:embassy_gps"]
|
||||
# echo CAM data on serial
|
||||
cam = ["c-its-parser/cam"]
|
||||
# echo DENM events on serial and BLE
|
||||
denm = ["c-its-parser/denm"]
|
||||
# evaluate SPAT information
|
||||
spat = ["c-its-parser/spatem", "c-its-parser/mapem"]
|
||||
spat = ["gnss", "c-its-parser/spatem", "c-its-parser/mapem"]
|
||||
# enable some debug printing (without enabling debug logging of the ESP RTOS)
|
||||
spat_debug = []
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@ Displays different C-ITS receive-only use cases for cheap.
|
|||
The code is currently tailored to:
|
||||
- Seeed XIAO ESP32-C5 (8MB PSRAM)
|
||||
- Seeed XIAO L67K (connected on GPIO12 (RX), GPIO11 (TX), GPIO1 (wakeup) and GPIO25 (reset))
|
||||
TODO: only enable in `spat` feature?
|
||||
only available with `gnss` feature (which is included in `spat` feature)
|
||||
- TODO: display (when using `spat` feature)
|
||||
|
||||
## Features
|
||||
|
||||
### GNSS
|
||||
Enable L67K 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.
|
||||
The upcoming intersection is selected when the own position is "inside" some ingress approach of the intersection.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use alloc::vec::Vec;
|
|||
use esp_println::println;
|
||||
#[cfg(feature = "spat")]
|
||||
use log::{debug, error};
|
||||
#[cfg(feature = "gnss")]
|
||||
use log::{info, warn};
|
||||
|
||||
#[cfg(feature = "spat")]
|
||||
|
|
@ -39,12 +40,16 @@ const GLOSA_LANE_LEFT_OFFSET_M: f64 = 20.;
|
|||
#[cfg(feature = "spat")]
|
||||
const GLOSA_STOP_LINE_PASSED_M: f64 = 10.;
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct State {
|
||||
initialized: bool,
|
||||
time: chrono::NaiveDateTime,
|
||||
|
||||
#[allow(unused)]
|
||||
position: geo_types::Point,
|
||||
#[allow(unused)]
|
||||
heading_deg: Option<f32>,
|
||||
#[allow(unused)]
|
||||
speed_mps: Option<f32>,
|
||||
|
||||
#[cfg(feature = "spat")]
|
||||
|
|
@ -96,7 +101,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "esp")]
|
||||
#[cfg(all(feature = "esp", feature = "gnss"))]
|
||||
pub fn update_with_gpsfix(&mut self, fix: &embassy_gps::types::GpsFix) {
|
||||
self.position = geo_types::Point::new(fix.longitude_deg, fix.latitude_deg);
|
||||
|
||||
|
|
@ -122,6 +127,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gnss")]
|
||||
pub fn print_fix(&self) -> alloc::string::String {
|
||||
alloc::format!(
|
||||
"{:?}, {:.4} N, {:.4} E, {:.0}°, {:.2} m/s",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use core::cell::RefCell;
|
|||
use critical_section::Mutex;
|
||||
use crossbeam_queue::ArrayQueue;
|
||||
use embassy_executor::Spawner;
|
||||
#[cfg(feature = "gnss")]
|
||||
use embassy_gps::gps::l76k;
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::clock::CpuClock;
|
||||
|
|
@ -34,6 +35,7 @@ const WIFI_CHANNEL: radio::Channel = 180;
|
|||
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
||||
esp_bootloader_esp_idf::esp_app_desc!();
|
||||
|
||||
#[cfg(feature = "gnss")]
|
||||
static GNSS_UPDATE: Mutex<RefCell<Option<embassy_gps::types::GpsFix>>> =
|
||||
Mutex::new(RefCell::new(None));
|
||||
static WIFI_RX_QUEUE: Mutex<RefCell<Option<ArrayQueue<Vec<u8>>>>> = Mutex::new(RefCell::new(None));
|
||||
|
|
@ -93,6 +95,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||
// TX: D6/ GPIO11
|
||||
// WAKEUP: D0/ GPIO1 -> HIGH for active, LOW for Sleep
|
||||
// RESET: D2/ GPIO25 -> HIGH for normal, LOW for Reset
|
||||
#[cfg(feature = "gnss")]
|
||||
spawner.spawn(
|
||||
gnss_task(
|
||||
peripherals.GPIO1,
|
||||
|
|
@ -109,6 +112,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||
loop {
|
||||
embassy_time::Timer::after(embassy_time::Duration::from_millis(5)).await;
|
||||
|
||||
#[cfg(feature = "gnss")]
|
||||
critical_section::with(|cs| {
|
||||
let gnss_update_ref = GNSS_UPDATE.borrow(cs);
|
||||
|
||||
|
|
@ -236,6 +240,7 @@ fn handle_frame(frame: wifi::sniffer::PromiscuousPkt<'_>) {
|
|||
});
|
||||
}
|
||||
|
||||
#[cfg(feature = "gnss")]
|
||||
#[allow(clippy::large_stack_frames, reason = "GNSS driver needs some space")]
|
||||
#[embassy_executor::task]
|
||||
async fn gnss_task(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue