mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-02-02 14:36:34 +11:00
Make Spi::set_baudrate public (#116)
This commit is contained in:
parent
58242bcc00
commit
be4a7e0498
1 changed files with 11 additions and 10 deletions
|
@ -72,20 +72,11 @@ impl<S: State, D: SpiDevice, const DS: u8> Spi<S, D, DS> {
|
|||
pub fn free(self) -> D {
|
||||
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
|
||||
///
|
||||
/// 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,
|
||||
peri_frequency: F,
|
||||
baudrate: B,
|
||||
|
@ -129,6 +120,16 @@ impl<D: SpiDevice, const DS: u8> Spi<Disabled, D, DS> {
|
|||
// Return the frequency we were able to achieve
|
||||
(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
|
||||
fn set_format(&mut self, data_bits: u8, mode: &Mode) {
|
||||
|
|
Loading…
Add table
Reference in a new issue