2021-05-10 23:29:59 +10:00
|
|
|
//! Single Cycle Input and Output (SIO)
|
2021-05-10 13:33:36 +10:00
|
|
|
//!
|
|
|
|
//! To be able to partition parts of the SIO block to other modules:
|
|
|
|
//!
|
|
|
|
//! ```rust
|
|
|
|
//! let sio = Sio::new(pac.SIO);
|
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! And then for example
|
|
|
|
//!
|
|
|
|
//! ```rust
|
|
|
|
//! let pins = pac.IO_BANK0.split(pac.PADS_BANK0, sio.gpio_bank0, &mut pac.RESETS);
|
|
|
|
//! ```
|
|
|
|
use super::*;
|
|
|
|
use core::marker::PhantomData;
|
|
|
|
|
|
|
|
/// Marker struct for ownership of SIO gpio bank0
|
2021-05-10 23:29:59 +10:00
|
|
|
pub struct SioGpioBank0 {
|
|
|
|
_private: PhantomData<u32>,
|
|
|
|
}
|
2021-05-10 13:33:36 +10:00
|
|
|
|
|
|
|
/// Struct containing ownership markers for managing ownership of the SIO registers.
|
|
|
|
pub struct Sio {
|
2021-05-10 23:29:59 +10:00
|
|
|
_sio: pac::SIO,
|
2021-05-10 13:33:36 +10:00
|
|
|
|
|
|
|
/// GPIO Bank 0 registers
|
2021-05-10 23:29:59 +10:00
|
|
|
pub gpio_bank0: SioGpioBank0,
|
2021-05-10 13:33:36 +10:00
|
|
|
// we can hand out other things here, for example:
|
|
|
|
// gpio_qspi
|
|
|
|
// divider
|
|
|
|
// interp0
|
|
|
|
// interp1
|
|
|
|
}
|
|
|
|
impl Sio {
|
|
|
|
/// Create `Sio` from the PAC.
|
2021-05-10 23:29:59 +10:00
|
|
|
pub fn new(sio: pac::SIO) -> Self {
|
2021-05-10 13:33:36 +10:00
|
|
|
Self {
|
|
|
|
_sio: sio,
|
|
|
|
|
2021-05-10 23:29:59 +10:00
|
|
|
gpio_bank0: SioGpioBank0 {
|
|
|
|
_private: PhantomData,
|
|
|
|
},
|
2021-05-10 13:33:36 +10:00
|
|
|
}
|
|
|
|
}
|
2021-05-10 23:29:59 +10:00
|
|
|
}
|