diff --git a/src/main.rs b/src/main.rs index eb29d54a2d075007b975194916016a140c2e2b4e..29c691a9f3306c9c79e96a4fc9c1e000fd44a957 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,14 +13,14 @@ mod status; pub const MAX_PACKET_LEN: usize = 8191; -#[rtic::app(device = stm32f4xx_hal::pac, peripherals = true, dispatchers = [USART2, USART6])] +#[rtic::app(device = stm32f4xx_hal::pac, peripherals = true, dispatchers = [USART6])] mod app { use cortex_m::singleton; use hal::{ flash::LockedFlash, gpio, otg_fs::{UsbBus, UsbBusType, USB}, - pac::USART1, + pac::USART2, prelude::*, rcc::{Clocks, Rcc}, serial::{self, Serial}, @@ -62,7 +62,7 @@ mod app { struct Local { green: gpio::Pin<'B', 15, gpio::Output>, usb_detect: gpio::Pin<'A', 5, gpio::Input>, - gps_serial: Serial<USART1>, + gps_serial: Serial<USART2>, flash: LockedFlash, buf: &'static mut [u8; MAX_PACKET_LEN], } @@ -95,6 +95,7 @@ mod app { let dp = ctx.device; let gpioa = dp.GPIOA.split(); let gpiob = dp.GPIOB.split(); + let gpioc = dp.GPIOC.split(); let clocks = setup_clocks(dp.RCC.constrain()); @@ -138,10 +139,13 @@ mod app { radio }; + // Setup GPS power + let mut gps_enable = gpioc.pc8.into_open_drain_output(); + // Setup GPS serial - let pins = (gpioa.pa9, gpioa.pa10); + let pins = (gpioa.pa2, gpioa.pa3); let mut gps_serial = Serial::new( - dp.USART1, + dp.USART2, pins, serial::Config::default() .baudrate(9600.bps()) @@ -193,6 +197,7 @@ mod app { Status::TxDisabled(false) } else { green.set_high(); + gps_enable.set_low(); // enable GPS Status::Normal }; @@ -226,7 +231,7 @@ mod app { ) } - #[task(priority = 3, local = [], shared = [red, radio, config, status])] + #[task(priority = 2, local = [], shared = [red, radio, config, status])] fn radio_tick(mut ctx: radio_tick::Context) { (ctx.shared.radio, ctx.shared.config).lock(|r, c| { r.as_mut() @@ -311,7 +316,7 @@ mod app { } } - #[task(priority = 3, local = [green, usb_detect], shared = [red, status])] + #[task(priority = 2, local = [green, usb_detect], shared = [red, status])] fn led_handler(mut ctx: led_handler::Context) { led_handler::spawn_after(LED_BLINK_RATE.millis()).unwrap(); @@ -342,7 +347,7 @@ mod app { }); } - #[task(binds=USART1, priority = 3, shared=[gps], local=[gps_serial])] + #[task(binds=USART2, priority = 3, shared=[gps], local=[gps_serial])] fn gps_uart(mut ctx: gps_uart::Context) { let gps_serial = ctx.local.gps_serial;