Code review request - moving OutputType to mod sealed

This commit is contained in:
Mariusz Ryndzionek 2021-09-24 19:56:48 +02:00
parent d371298a27
commit e4b37c40c9
7 changed files with 17 additions and 15 deletions

View file

@ -5,7 +5,7 @@ use embassy::util::Unborrow;
use embassy_hal_common::unborrow;
use crate::gpio::{
OutputType::{OpenDrain, PushPull},
sealed::OutputType::{OpenDrain, PushPull},
Pin,
};
use crate::{peripherals, rcc::RccPeripheral};

View file

@ -10,7 +10,7 @@ use embassy_net::{Device, DeviceCapabilities, LinkState, PacketBuf, MTU};
use crate::gpio::sealed::Pin as __GpioPin;
use crate::gpio::Pin as GpioPin;
use crate::gpio::{AnyPin, OutputType::PushPull};
use crate::gpio::{sealed::OutputType::PushPull, AnyPin};
use crate::pac::gpio::vals::Ospeedr;
use crate::pac::{ETH, RCC, SYSCFG};
use crate::peripherals;

View file

@ -55,14 +55,6 @@ impl From<Speed> for vals::Ospeedr {
}
}
/// Type settings
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum OutputType {
PushPull,
OpenDrain,
}
/// GPIO input driver.
pub struct Input<'d, T: Pin> {
pub(crate) pin: T,
@ -272,6 +264,14 @@ impl<'d, T: Pin> InputPin for OutputOpenDrain<'d, T> {
pub(crate) mod sealed {
use super::*;
/// Output type settings
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum OutputType {
PushPull,
OpenDrain,
}
pub trait Pin {
fn pin_port(&self) -> u8;

View file

@ -9,7 +9,7 @@ use embedded_hal::blocking::i2c::WriteRead;
use crate::pac::i2c;
use crate::gpio::OutputType::OpenDrain;
use crate::gpio::sealed::OutputType::OpenDrain;
pub struct I2c<'d, T: Instance> {
phantom: PhantomData<&'d mut T>,

View file

@ -2,9 +2,11 @@
use crate::dma::NoDma;
use crate::gpio::{
sealed::Pin,
sealed::{
OutputType::{OpenDrain, PushPull},
Pin,
},
AnyPin,
OutputType::{OpenDrain, PushPull},
};
use crate::pac::spi;
use crate::spi::{

View file

@ -1,4 +1,4 @@
use crate::gpio::OutputType::{OpenDrain, PushPull};
use crate::gpio::sealed::OutputType::{OpenDrain, PushPull};
use core::future::Future;
use core::marker::PhantomData;
use embassy::util::Unborrow;

View file

@ -13,7 +13,7 @@ use futures::TryFutureExt;
use super::*;
use crate::dma::NoDma;
use crate::gpio::OutputType::{OpenDrain, PushPull};
use crate::gpio::sealed::OutputType::{OpenDrain, PushPull};
use crate::pac::usart::{regs, vals};
pub struct Uart<'d, T: Instance, TxDma = NoDma, RxDma = NoDma> {