wspr-beacon/src/application/mod.rs

81 lines
1.6 KiB
Rust
Raw Normal View History

2021-04-11 17:23:17 +02:00
use cortex_m::prelude::*;
2021-04-12 00:06:18 +02:00
use embedded_hal::digital::v2::{OutputPin, ToggleableOutputPin};
use nb::{self, block};
use nmea0183::{ParseResult, Parser};
2021-04-11 17:23:17 +02:00
use stm32f1xx_hal::{
delay::Delay,
2021-04-12 00:06:18 +02:00
gpio::{gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
prelude::*,
serial::Serial,
stm32,
2021-04-11 17:23:17 +02:00
};
2021-04-14 20:19:33 +02:00
mod gps;
2021-04-11 17:23:17 +02:00
mod setup;
//use crate::exit;
pub use setup::setup;
2021-04-25 19:29:14 +02:00
use crate::si5153;
2021-04-14 20:19:33 +02:00
use crate::time;
2021-04-25 19:29:14 +02:00
// For PLL with 800MHz
const WSPR_SYMBOLS: [si5153::PllParams; 4] = [
// 7040100.000000: 113 + 44687 / 70401
// actual: 7040100.000000
si5153::PllParams {
p1: 14033,
p2: 17455,
p3: 70401,
},
// 7040101.464844: 113 + 447801 / 705503
// actual: 7040101.464844
si5153::PllParams {
p1: 14033,
p2: 172785,
p3: 705503,
},
// 7040102.929688: 113 + 38515 / 60682
// actual: 7040102.929688
si5153::PllParams {
p1: 14033,
p2: 14678,
p3: 60682,
},
// 7040104.394531: 113 + 123233 / 194166
// actual: 7040104.394531
si5153::PllParams {
p1: 14033,
p2: 46378,
p3: 194166,
},
];
2021-04-11 17:23:17 +02:00
pub struct App {
delay: Delay,
board_led: gpioc::PC13<Output<PushPull>>,
2021-04-12 00:06:18 +02:00
serial: Serial<
stm32::USART3,
(
gpiob::PB10<Alternate<PushPull>>,
gpiob::PB11<Input<Floating>>,
),
>,
2021-04-14 20:19:33 +02:00
gps_parser: Parser,
2021-04-25 17:33:35 +02:00
locator: arrayvec::ArrayString<6>,
2021-04-11 17:23:17 +02:00
}
impl App {
pub fn run(mut self) -> ! {
defmt::info!("Application Startup!");
2021-04-14 20:19:33 +02:00
let mut last_ts = 0;
2021-04-11 17:23:17 +02:00
2021-04-12 00:06:18 +02:00
loop {
2021-04-14 20:19:33 +02:00
self.poll_gps();
2021-04-11 17:23:17 +02:00
}
//exit();
}
}