Add tx_ptr and rx_ptr methods

This commit is contained in:
Grant Miller
2021-12-06 16:33:06 -06:00
parent a35f337bd6
commit a35b7d90bc
4 changed files with 49 additions and 34 deletions

View File

@ -290,6 +290,29 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
}
}
trait RegsExt {
fn tx_ptr<W>(&self) -> *mut W;
fn rx_ptr<W>(&self) -> *mut W;
}
impl RegsExt for crate::pac::spi::Spi {
fn tx_ptr<W>(&self) -> *mut W {
#[cfg(not(spi_v3))]
let dr = self.dr();
#[cfg(spi_v3)]
let dr = self.txdr();
dr.ptr() as *mut W
}
fn rx_ptr<W>(&self) -> *mut W {
#[cfg(not(spi_v3))]
let dr = self.dr();
#[cfg(spi_v3)]
let dr = self.rxdr();
dr.ptr() as *mut W
}
}
pub(crate) mod sealed {
use super::*;