1
0
Fork 0
mirror of https://github.com/italicsjenga/rp-hal-boards.git synced 2025-02-23 23:57:43 +11:00

Make Spi::set_baudrate public ()

This commit is contained in:
Jonathan Nilsson 2021-09-22 12:41:21 +02:00 committed by GitHub
parent 58242bcc00
commit be4a7e0498
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,20 +72,11 @@ impl<S: State, D: SpiDevice, const DS: u8> Spi<S, D, DS> {
pub fn free(self) -> D { pub fn free(self) -> D {
self.device self.device
} }
}
impl<D: SpiDevice, const DS: u8> Spi<Disabled, D, DS> {
/// Create new spi device
pub fn new(device: D) -> Spi<Disabled, D, DS> {
Spi {
device,
state: PhantomData,
}
}
/// Set baudrate based on peripheral clock /// Set baudrate based on peripheral clock
/// ///
/// Typically the peripheral clock is set to 125_000_000 /// Typically the peripheral clock is set to 125_000_000
fn set_baudrate<F: Into<Hertz<u32>>, B: Into<Hertz<u32>>>( pub fn set_baudrate<F: Into<Hertz<u32>>, B: Into<Hertz<u32>>>(
&mut self, &mut self,
peri_frequency: F, peri_frequency: F,
baudrate: B, baudrate: B,
@ -129,6 +120,16 @@ impl<D: SpiDevice, const DS: u8> Spi<Disabled, D, DS> {
// Return the frequency we were able to achieve // Return the frequency we were able to achieve
(freq_in / (prescale as u32 * (1 + postdiv as u32))).Hz() (freq_in / (prescale as u32 * (1 + postdiv as u32))).Hz()
} }
}
impl<D: SpiDevice, const DS: u8> Spi<Disabled, D, DS> {
/// Create new spi device
pub fn new(device: D) -> Spi<Disabled, D, DS> {
Spi {
device,
state: PhantomData,
}
}
/// Set format and datasize /// Set format and datasize
fn set_format(&mut self, data_bits: u8, mode: &Mode) { fn set_format(&mut self, data_bits: u8, mode: &Mode) {