From c7a42e9590e02a629ace812624ef8ab81e5a1651 Mon Sep 17 00:00:00 2001 From: Stephen D <webmaster@scd31.com> Date: Sun, 26 Nov 2023 17:06:53 -0400 Subject: [PATCH] rev 2 gps --- src/main.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index eb29d54..29c691a 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; -- GitLab