56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
use cortex_m::prelude::*;
|
|
use embedded_hal::digital::v2::{OutputPin, ToggleableOutputPin};
|
|
use nb::{self, block};
|
|
use nmea0183::{ParseResult, Parser};
|
|
use stm32f1xx_hal::{
|
|
delay::Delay,
|
|
gpio::{gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
|
|
prelude::*,
|
|
serial::Serial,
|
|
stm32,
|
|
};
|
|
|
|
mod setup;
|
|
|
|
//use crate::exit;
|
|
pub use setup::setup;
|
|
|
|
pub struct App {
|
|
delay: Delay,
|
|
board_led: gpioc::PC13<Output<PushPull>>,
|
|
serial: Serial<
|
|
stm32::USART3,
|
|
(
|
|
gpiob::PB10<Alternate<PushPull>>,
|
|
gpiob::PB11<Input<Floating>>,
|
|
),
|
|
>,
|
|
}
|
|
|
|
impl App {
|
|
pub fn run(mut self) -> ! {
|
|
defmt::info!("Application Startup!");
|
|
|
|
let mut parser = Parser::new();
|
|
|
|
loop {
|
|
match self.serial.read() {
|
|
Ok(byte) => {
|
|
self.board_led.toggle().unwrap();
|
|
if let Some(result) = parser.parse_from_byte(byte) {
|
|
match result {
|
|
Ok(ParseResult::GGA(Some(_))) => defmt::info!("Got GGA"), // Got GGA sentence
|
|
Ok(_) => {} // Some other sentences..
|
|
Err(_) => {} // Got parse error
|
|
}
|
|
}
|
|
}
|
|
Err(nb::Error::WouldBlock) => {}
|
|
Err(nb::Error::Other(_)) => {}
|
|
}
|
|
}
|
|
|
|
//exit();
|
|
}
|
|
}
|