Add AFType::Input for input configurations.
This commit is contained in:
parent
259e84e68e
commit
2cbb8a7ece
2 changed files with 16 additions and 14 deletions
|
@ -354,9 +354,7 @@ pub(crate) mod sealed {
|
|||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub enum AFType {
|
||||
// InputFloating,
|
||||
// InputPullUp,
|
||||
// InputPullDown,
|
||||
Input,
|
||||
OutputPushPull,
|
||||
OutputOpenDrain,
|
||||
}
|
||||
|
@ -405,7 +403,12 @@ pub(crate) mod sealed {
|
|||
let n = self._pin() as usize;
|
||||
let crlh = if n < 8 { 0 } else { 1 };
|
||||
match af_type {
|
||||
// TODO: Do we need to configure input AF pins differently?
|
||||
AFType::Input => {
|
||||
r.cr(crlh).modify(|w| {
|
||||
w.set_mode(n % 8, vals::Mode::INPUT);
|
||||
w.set_cnf(n % 8, vals::Cnf::PUSHPULL);
|
||||
});
|
||||
}
|
||||
AFType::OutputPushPull => {
|
||||
r.cr(crlh).modify(|w| {
|
||||
w.set_mode(n % 8, vals::Mode::OUTPUT50);
|
||||
|
@ -428,6 +431,7 @@ pub(crate) mod sealed {
|
|||
.afr(pin / 8)
|
||||
.modify(|w| w.set_afr(pin % 8, vals::Afr(af_num)));
|
||||
match af_type {
|
||||
AFType::Input => {}
|
||||
AFType::OutputPushPull => {
|
||||
block.otyper().modify(|w| w.set_ot(pin, vals::Ot::PUSHPULL))
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#![macro_use]
|
||||
|
||||
use crate::dma::NoDma;
|
||||
use crate::gpio::{
|
||||
sealed::{
|
||||
AFType::{OutputOpenDrain, OutputPushPull},
|
||||
Pin,
|
||||
},
|
||||
AnyPin, NoPin,
|
||||
};
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::gpio::sealed::Pin;
|
||||
use crate::gpio::{AnyPin, NoPin};
|
||||
use crate::pac::spi;
|
||||
use crate::peripherals;
|
||||
use crate::spi::{
|
||||
|
@ -87,9 +83,11 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
|||
let miso = miso.degrade_optional();
|
||||
|
||||
unsafe {
|
||||
sck.as_ref().map(|x| x.set_as_af(sck_af, OutputPushPull));
|
||||
mosi.as_ref().map(|x| x.set_as_af(mosi_af, OutputPushPull));
|
||||
miso.as_ref().map(|x| x.set_as_af(miso_af, OutputOpenDrain));
|
||||
sck.as_ref()
|
||||
.map(|x| x.set_as_af(sck_af, AFType::OutputPushPull));
|
||||
mosi.as_ref()
|
||||
.map(|x| x.set_as_af(mosi_af, AFType::OutputPushPull));
|
||||
miso.as_ref().map(|x| x.set_as_af(miso_af, AFType::Input));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
|
Loading…
Reference in a new issue