Skip to content

Commit

Permalink
Rename DM type parameter to Dm
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajSadel committed Dec 17, 2024
1 parent 85d30e9 commit 20e5ea1
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 177 deletions.
12 changes: 6 additions & 6 deletions esp-hal/src/i2c/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,16 @@ impl Default for Config {
}

/// I2C driver
pub struct I2c<'d, DM: Mode, T = AnyI2c> {
pub struct I2c<'d, Dm: Mode, T = AnyI2c> {
i2c: PeripheralRef<'d, T>,
phantom: PhantomData<DM>,
phantom: PhantomData<Dm>,
config: Config,
guard: PeripheralGuard,
}

#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
impl<T: Instance, DM: Mode> SetConfig for I2c<'_, DM, T> {
impl<T: Instance, Dm: Mode> SetConfig for I2c<'_, Dm, T> {
type Config = Config;
type ConfigError = ConfigError;

Expand All @@ -292,11 +292,11 @@ impl<T: Instance, DM: Mode> SetConfig for I2c<'_, DM, T> {
}
}

impl<T, DM: Mode> embedded_hal::i2c::ErrorType for I2c<'_, DM, T> {
impl<T, Dm: Mode> embedded_hal::i2c::ErrorType for I2c<'_, Dm, T> {
type Error = Error;
}

impl<T, DM: Mode> embedded_hal::i2c::I2c for I2c<'_, DM, T>
impl<T, Dm: Mode> embedded_hal::i2c::I2c for I2c<'_, Dm, T>
where
T: Instance,
{
Expand All @@ -310,7 +310,7 @@ where
}
}

impl<'d, T, DM: Mode> I2c<'d, DM, T>
impl<'d, T, Dm: Mode> I2c<'d, Dm, T>
where
T: Instance,
{
Expand Down
36 changes: 18 additions & 18 deletions esp-hal/src/i2s/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ impl<'d> TxPins<'d> for TxEightBits<'d> {
}

/// I2S Parallel Interface
pub struct I2sParallel<'d, DM, I = AnyI2s>
pub struct I2sParallel<'d, Dm, I = AnyI2s>
where
DM: Mode,
Dm: Mode,
I: Instance,
{
instance: PeripheralRef<'d, I>,
tx_channel: ChannelTx<'d, DM, PeripheralTxChannel<I>>,
tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel<I>>,
_guard: PeripheralGuard,
}

Expand Down Expand Up @@ -323,16 +323,16 @@ where
}
}

impl<'d, I, DM> I2sParallel<'d, DM, I>
impl<'d, I, Dm> I2sParallel<'d, Dm, I>
where
I: Instance,
DM: Mode,
Dm: Mode,
{
/// Write data to the I2S peripheral
pub fn send<BUF: DmaTxBuffer>(
mut self,
mut data: BUF,
) -> Result<I2sParallelTransfer<'d, BUF, DM, I>, (DmaError, Self, BUF)> {
) -> Result<I2sParallelTransfer<'d, BUF, Dm, I>, (DmaError, Self, BUF)> {
self.instance.tx_reset();
self.instance.tx_fifo_reset();
let result = unsafe {
Expand All @@ -354,29 +354,29 @@ where

/// Represents an ongoing (or potentially finished) transfer using the i2s
/// parallel interface
pub struct I2sParallelTransfer<'d, BUF, DM, I = AnyI2s>
pub struct I2sParallelTransfer<'d, BUF, Dm, I = AnyI2s>
where
I: Instance,
BUF: DmaTxBuffer,
DM: Mode,
Dm: Mode,
{
i2s: ManuallyDrop<I2sParallel<'d, DM, I>>,
i2s: ManuallyDrop<I2sParallel<'d, Dm, I>>,
buf_view: ManuallyDrop<BUF::View>,
}

impl<'d, I, BUF, DM> I2sParallelTransfer<'d, BUF, DM, I>
impl<'d, I, BUF, Dm> I2sParallelTransfer<'d, BUF, Dm, I>
where
I: Instance,
BUF: DmaTxBuffer,
DM: Mode,
Dm: Mode,
{
/// Returns true when [Self::wait] will not block.
pub fn is_done(&self) -> bool {
self.i2s.instance.is_tx_done()
}

/// Wait for the transfer to finish
pub fn wait(mut self) -> (I2sParallel<'d, DM, I>, BUF) {
pub fn wait(mut self) -> (I2sParallel<'d, Dm, I>, BUF) {
self.i2s.instance.tx_wait_done();
let i2s = unsafe { ManuallyDrop::take(&mut self.i2s) };
let view = unsafe { ManuallyDrop::take(&mut self.buf_view) };
Expand All @@ -401,11 +401,11 @@ where
}
}

impl<I, BUF, DM> Deref for I2sParallelTransfer<'_, BUF, DM, I>
impl<I, BUF, Dm> Deref for I2sParallelTransfer<'_, BUF, Dm, I>
where
I: Instance,
BUF: DmaTxBuffer,
DM: Mode,
Dm: Mode,
{
type Target = BUF::View;

Expand All @@ -414,22 +414,22 @@ where
}
}

impl<I, BUF, DM> DerefMut for I2sParallelTransfer<'_, BUF, DM, I>
impl<I, BUF, Dm> DerefMut for I2sParallelTransfer<'_, BUF, Dm, I>
where
I: Instance,
BUF: DmaTxBuffer,
DM: Mode,
Dm: Mode,
{
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.buf_view
}
}

impl<I, BUF, DM> Drop for I2sParallelTransfer<'_, BUF, DM, I>
impl<I, BUF, Dm> Drop for I2sParallelTransfer<'_, BUF, Dm, I>
where
I: Instance,
BUF: DmaTxBuffer,
DM: Mode,
Dm: Mode,
{
fn drop(&mut self) {
self.stop_peripherals();
Expand Down
30 changes: 15 additions & 15 deletions esp-hal/src/lcd_cam/lcd/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ pub enum ConfigError {
}

/// Represents the RGB LCD interface.
pub struct Dpi<'d, DM: Mode> {
pub struct Dpi<'d, Dm: Mode> {
lcd_cam: PeripheralRef<'d, LCD_CAM>,
tx_channel: ChannelTx<'d, Blocking, PeripheralTxChannel<LCD_CAM>>,
_mode: PhantomData<DM>,
_mode: PhantomData<Dm>,
}

impl<'d, DM> Dpi<'d, DM>
impl<'d, Dm> Dpi<'d, Dm>
where
DM: Mode,
Dm: Mode,
{
/// Create a new instance of the RGB/DPI driver.
pub fn new<CH>(
lcd: Lcd<'d, DM>,
lcd: Lcd<'d, Dm>,
channel: impl Peripheral<P = CH> + 'd,
config: Config,
) -> Result<Self, ConfigError>
Expand Down Expand Up @@ -548,7 +548,7 @@ where
mut self,
next_frame_en: bool,
mut buf: TX,
) -> Result<DpiTransfer<'d, TX, DM>, (DmaError, Self, TX)> {
) -> Result<DpiTransfer<'d, TX, Dm>, (DmaError, Self, TX)> {
let result = unsafe {
self.tx_channel
.prepare_transfer(DmaPeripheral::LcdCam, &mut buf)
Expand Down Expand Up @@ -587,12 +587,12 @@ where

/// Represents an ongoing (or potentially finished) transfer using the RGB LCD
/// interface
pub struct DpiTransfer<'d, BUF: DmaTxBuffer, DM: Mode> {
dpi: ManuallyDrop<Dpi<'d, DM>>,
pub struct DpiTransfer<'d, BUF: DmaTxBuffer, Dm: Mode> {
dpi: ManuallyDrop<Dpi<'d, Dm>>,
buffer_view: ManuallyDrop<BUF::View>,
}

impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> {
impl<'d, BUF: DmaTxBuffer, Dm: Mode> DpiTransfer<'d, BUF, Dm> {
/// Returns true when [Self::wait] will not block.
pub fn is_done(&self) -> bool {
self.dpi
Expand All @@ -604,7 +604,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> {
}

/// Stops this transfer on the spot and returns the peripheral and buffer.
pub fn stop(mut self) -> (Dpi<'d, DM>, BUF) {
pub fn stop(mut self) -> (Dpi<'d, Dm>, BUF) {
self.stop_peripherals();
let (dpi, view) = self.release();
(dpi, BUF::from_view(view))
Expand All @@ -614,7 +614,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> {
///
/// Note: If you specified `next_frame_en` as true in [Dpi::send], you're
/// just waiting for a DMA error when you call this.
pub fn wait(mut self) -> (Result<(), DmaError>, Dpi<'d, DM>, BUF) {
pub fn wait(mut self) -> (Result<(), DmaError>, Dpi<'d, Dm>, BUF) {
while !self.is_done() {
core::hint::spin_loop();
}
Expand All @@ -637,7 +637,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> {
(result, dpi, BUF::from_view(view))
}

fn release(mut self) -> (Dpi<'d, DM>, BUF::View) {
fn release(mut self) -> (Dpi<'d, Dm>, BUF::View) {
// SAFETY: Since forget is called on self, we know that self.dpi and
// self.buffer_view won't be touched again.
let result = unsafe {
Expand All @@ -661,21 +661,21 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> {
}
}

impl<BUF: DmaTxBuffer, DM: Mode> Deref for DpiTransfer<'_, BUF, DM> {
impl<BUF: DmaTxBuffer, Dm: Mode> Deref for DpiTransfer<'_, BUF, Dm> {
type Target = BUF::View;

fn deref(&self) -> &Self::Target {
&self.buffer_view
}
}

impl<BUF: DmaTxBuffer, DM: Mode> DerefMut for DpiTransfer<'_, BUF, DM> {
impl<BUF: DmaTxBuffer, Dm: Mode> DerefMut for DpiTransfer<'_, BUF, Dm> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.buffer_view
}
}

impl<BUF: DmaTxBuffer, DM: Mode> Drop for DpiTransfer<'_, BUF, DM> {
impl<BUF: DmaTxBuffer, Dm: Mode> Drop for DpiTransfer<'_, BUF, Dm> {
fn drop(&mut self) {
self.stop_peripherals();

Expand Down
30 changes: 15 additions & 15 deletions esp-hal/src/lcd_cam/lcd/i8080.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ pub enum ConfigError {
}

/// Represents the I8080 LCD interface.
pub struct I8080<'d, DM: Mode> {
pub struct I8080<'d, Dm: Mode> {
lcd_cam: PeripheralRef<'d, LCD_CAM>,
tx_channel: ChannelTx<'d, Blocking, PeripheralTxChannel<LCD_CAM>>,
_mode: PhantomData<DM>,
_mode: PhantomData<Dm>,
}

impl<'d, DM> I8080<'d, DM>
impl<'d, Dm> I8080<'d, Dm>
where
DM: Mode,
Dm: Mode,
{
/// Creates a new instance of the I8080 LCD interface.
pub fn new<P, CH>(
lcd: Lcd<'d, DM>,
lcd: Lcd<'d, Dm>,
channel: impl Peripheral<P = CH> + 'd,
mut pins: P,
config: Config,
Expand Down Expand Up @@ -300,7 +300,7 @@ where
cmd: impl Into<Command<W>>,
dummy: u8,
mut data: BUF,
) -> Result<I8080Transfer<'d, BUF, DM>, (DmaError, Self, BUF)> {
) -> Result<I8080Transfer<'d, BUF, Dm>, (DmaError, Self, BUF)> {
let cmd = cmd.into();

// Reset LCD control unit and Async Tx FIFO
Expand Down Expand Up @@ -396,20 +396,20 @@ where
}
}

impl<DM: Mode> core::fmt::Debug for I8080<'_, DM> {
impl<Dm: Mode> core::fmt::Debug for I8080<'_, Dm> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.debug_struct("I8080").finish()
}
}

/// Represents an ongoing (or potentially finished) transfer using the I8080 LCD
/// interface
pub struct I8080Transfer<'d, BUF: DmaTxBuffer, DM: Mode> {
i8080: ManuallyDrop<I8080<'d, DM>>,
pub struct I8080Transfer<'d, BUF: DmaTxBuffer, Dm: Mode> {
i8080: ManuallyDrop<I8080<'d, Dm>>,
buf_view: ManuallyDrop<BUF::View>,
}

impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> {
impl<'d, BUF: DmaTxBuffer, Dm: Mode> I8080Transfer<'d, BUF, Dm> {
/// Returns true when [Self::wait] will not block.
pub fn is_done(&self) -> bool {
self.i8080
Expand All @@ -421,7 +421,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> {
}

/// Stops this transfer on the spot and returns the peripheral and buffer.
pub fn cancel(mut self) -> (I8080<'d, DM>, BUF) {
pub fn cancel(mut self) -> (I8080<'d, Dm>, BUF) {
self.stop_peripherals();
let (_, i8080, buf) = self.wait();
(i8080, buf)
Expand All @@ -431,7 +431,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> {
///
/// Note: This also clears the transfer interrupt so it can be used in
/// interrupt handlers to "handle" the interrupt.
pub fn wait(mut self) -> (Result<(), DmaError>, I8080<'d, DM>, BUF) {
pub fn wait(mut self) -> (Result<(), DmaError>, I8080<'d, Dm>, BUF) {
while !self.is_done() {}

// Clear "done" interrupt.
Expand Down Expand Up @@ -470,15 +470,15 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> {
}
}

impl<BUF: DmaTxBuffer, DM: Mode> Deref for I8080Transfer<'_, BUF, DM> {
impl<BUF: DmaTxBuffer, Dm: Mode> Deref for I8080Transfer<'_, BUF, Dm> {
type Target = BUF::View;

fn deref(&self) -> &Self::Target {
&self.buf_view
}
}

impl<BUF: DmaTxBuffer, DM: Mode> DerefMut for I8080Transfer<'_, BUF, DM> {
impl<BUF: DmaTxBuffer, Dm: Mode> DerefMut for I8080Transfer<'_, BUF, Dm> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.buf_view
}
Expand Down Expand Up @@ -523,7 +523,7 @@ impl<'d, BUF: DmaTxBuffer> I8080Transfer<'d, BUF, crate::Async> {
}
}

impl<BUF: DmaTxBuffer, DM: Mode> Drop for I8080Transfer<'_, BUF, DM> {
impl<BUF: DmaTxBuffer, Dm: Mode> Drop for I8080Transfer<'_, BUF, Dm> {
fn drop(&mut self) {
self.stop_peripherals();

Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/lcd_cam/lcd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub mod dpi;
pub mod i8080;

/// Represents an LCD interface.
pub struct Lcd<'d, DM: crate::Mode> {
pub struct Lcd<'d, Dm: crate::Mode> {
/// The `LCD_CAM` peripheral reference for managing the LCD functionality.
pub(crate) lcd_cam: PeripheralRef<'d, LCD_CAM>,

/// A marker for the mode of operation (blocking or asynchronous).
pub(crate) _mode: core::marker::PhantomData<DM>,
pub(crate) _mode: core::marker::PhantomData<Dm>,

pub(super) _guard: GenericPeripheralGuard<{ system::Peripheral::LcdCam as u8 }>,
}
Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/lcd_cam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use crate::{
};

/// Represents a combined LCD and Camera interface.
pub struct LcdCam<'d, DM: crate::Mode> {
pub struct LcdCam<'d, Dm: crate::Mode> {
/// The LCD interface.
pub lcd: Lcd<'d, DM>,
pub lcd: Lcd<'d, Dm>,
/// The Camera interface.
pub cam: Cam<'d>,
}
Expand Down
Loading

0 comments on commit 20e5ea1

Please sign in to comment.