-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0251afa
commit 66e0da1
Showing
4 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::types::*; | ||
use atsamd_hal::clock::v2::gclk::Gclk0Id; | ||
use atsamd_hal::clock::v2::pclk::Pclk; | ||
use atsamd_hal::clock::v2::pclk::PclkToken; | ||
use atsamd_hal::clock::v2::Source; | ||
use atsamd_hal::gpio::{Disabled, Floating, Pin, PA12, PA13}; | ||
use atsamd_hal::pac::{MCLK, SERCOM2}; | ||
use atsamd_hal::typelevel::Increment; | ||
use atsamd_hal::{ | ||
sercom, | ||
sercom::{uart, uart::Duplex, uart::Uart}, | ||
}; | ||
use systick_monotonic::fugit::RateExtU32; | ||
|
||
pub struct GpsDevice { | ||
pub uart: Uart<GpsUartConfig, Duplex>, | ||
Check warning on line 16 in boards/communication/src/gps.rs GitHub Actions / clippyfield `uart` is never read
|
||
} | ||
|
||
impl GpsDevice { | ||
pub fn new<S>( | ||
gps_token: PclkToken<SERCOM2>, | ||
mclk: &MCLK, | ||
sercom: SERCOM2, | ||
rx_pin: Pin<PA13, Disabled<Floating>>, | ||
tx_pin: Pin<PA12, Disabled<Floating>>, | ||
gclk0: S, | ||
) -> (Self, S::Inc) | ||
where | ||
S: Source<Id = Gclk0Id> + Increment, | ||
{ | ||
let (pclk_gps, gclk0) = Pclk::enable(gps_token, gclk0); | ||
let pads = uart::Pads::<sercom::Sercom2, _>::default() | ||
.rx(rx_pin) | ||
.tx(tx_pin); | ||
let uart = GpsUartConfig::new(mclk, sercom, pads, pclk_gps.freq()) | ||
.baud( | ||
57600.Hz(), // check this | ||
uart::BaudMode::Fractional(uart::Oversampling::Bits16), | ||
) | ||
.enable(); | ||
(GpsDevice { uart }, gclk0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters