Code review request - moving OutputType to mod sealed
				
					
				
			This commit is contained in:
		
							parent
							
								
									d371298a27
								
							
						
					
					
						commit
						e4b37c40c9
					
				@ -5,7 +5,7 @@ use embassy::util::Unborrow;
 | 
				
			|||||||
use embassy_hal_common::unborrow;
 | 
					use embassy_hal_common::unborrow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::gpio::{
 | 
					use crate::gpio::{
 | 
				
			||||||
    OutputType::{OpenDrain, PushPull},
 | 
					    sealed::OutputType::{OpenDrain, PushPull},
 | 
				
			||||||
    Pin,
 | 
					    Pin,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use crate::{peripherals, rcc::RccPeripheral};
 | 
					use crate::{peripherals, rcc::RccPeripheral};
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ use embassy_net::{Device, DeviceCapabilities, LinkState, PacketBuf, MTU};
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use crate::gpio::sealed::Pin as __GpioPin;
 | 
					use crate::gpio::sealed::Pin as __GpioPin;
 | 
				
			||||||
use crate::gpio::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::gpio::vals::Ospeedr;
 | 
				
			||||||
use crate::pac::{ETH, RCC, SYSCFG};
 | 
					use crate::pac::{ETH, RCC, SYSCFG};
 | 
				
			||||||
use crate::peripherals;
 | 
					use crate::peripherals;
 | 
				
			||||||
 | 
				
			|||||||
@ -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.
 | 
					/// GPIO input driver.
 | 
				
			||||||
pub struct Input<'d, T: Pin> {
 | 
					pub struct Input<'d, T: Pin> {
 | 
				
			||||||
    pub(crate) pin: T,
 | 
					    pub(crate) pin: T,
 | 
				
			||||||
@ -272,6 +264,14 @@ impl<'d, T: Pin> InputPin for OutputOpenDrain<'d, T> {
 | 
				
			|||||||
pub(crate) mod sealed {
 | 
					pub(crate) mod sealed {
 | 
				
			||||||
    use super::*;
 | 
					    use super::*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Output type settings
 | 
				
			||||||
 | 
					    #[derive(Debug)]
 | 
				
			||||||
 | 
					    #[cfg_attr(feature = "defmt", derive(defmt::Format))]
 | 
				
			||||||
 | 
					    pub enum OutputType {
 | 
				
			||||||
 | 
					        PushPull,
 | 
				
			||||||
 | 
					        OpenDrain,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub trait Pin {
 | 
					    pub trait Pin {
 | 
				
			||||||
        fn pin_port(&self) -> u8;
 | 
					        fn pin_port(&self) -> u8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ use embedded_hal::blocking::i2c::WriteRead;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use crate::pac::i2c;
 | 
					use crate::pac::i2c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::gpio::OutputType::OpenDrain;
 | 
					use crate::gpio::sealed::OutputType::OpenDrain;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct I2c<'d, T: Instance> {
 | 
					pub struct I2c<'d, T: Instance> {
 | 
				
			||||||
    phantom: PhantomData<&'d mut T>,
 | 
					    phantom: PhantomData<&'d mut T>,
 | 
				
			||||||
 | 
				
			|||||||
@ -2,9 +2,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use crate::dma::NoDma;
 | 
					use crate::dma::NoDma;
 | 
				
			||||||
use crate::gpio::{
 | 
					use crate::gpio::{
 | 
				
			||||||
    sealed::Pin,
 | 
					    sealed::{
 | 
				
			||||||
    AnyPin,
 | 
					 | 
				
			||||||
        OutputType::{OpenDrain, PushPull},
 | 
					        OutputType::{OpenDrain, PushPull},
 | 
				
			||||||
 | 
					        Pin,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    AnyPin,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use crate::pac::spi;
 | 
					use crate::pac::spi;
 | 
				
			||||||
use crate::spi::{
 | 
					use crate::spi::{
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
use crate::gpio::OutputType::{OpenDrain, PushPull};
 | 
					use crate::gpio::sealed::OutputType::{OpenDrain, PushPull};
 | 
				
			||||||
use core::future::Future;
 | 
					use core::future::Future;
 | 
				
			||||||
use core::marker::PhantomData;
 | 
					use core::marker::PhantomData;
 | 
				
			||||||
use embassy::util::Unborrow;
 | 
					use embassy::util::Unborrow;
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ use futures::TryFutureExt;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use super::*;
 | 
					use super::*;
 | 
				
			||||||
use crate::dma::NoDma;
 | 
					use crate::dma::NoDma;
 | 
				
			||||||
use crate::gpio::OutputType::{OpenDrain, PushPull};
 | 
					use crate::gpio::sealed::OutputType::{OpenDrain, PushPull};
 | 
				
			||||||
use crate::pac::usart::{regs, vals};
 | 
					use crate::pac::usart::{regs, vals};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct Uart<'d, T: Instance, TxDma = NoDma, RxDma = NoDma> {
 | 
					pub struct Uart<'d, T: Instance, TxDma = NoDma, RxDma = NoDma> {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user