Skip to content

Commit

Permalink
stm32/spi: rename rxdma, txdma -> rx_dma, tx_dma.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Apr 15, 2024
1 parent 09a284e commit 2eab099
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions embassy-stm32/src/spi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ pub struct Spi<'d, T: Instance, M: PeriMode> {
sck: Option<PeripheralRef<'d, AnyPin>>,
mosi: Option<PeripheralRef<'d, AnyPin>>,
miso: Option<PeripheralRef<'d, AnyPin>>,
txdma: Option<ChannelAndRequest<'d>>,
rxdma: Option<ChannelAndRequest<'d>>,
tx_dma: Option<ChannelAndRequest<'d>>,
rx_dma: Option<ChannelAndRequest<'d>>,
_phantom: PhantomData<M>,
current_word_size: word_impl::Config,
}
Expand All @@ -109,8 +109,8 @@ impl<'d, T: Instance, M: PeriMode> Spi<'d, T, M> {
sck: Option<PeripheralRef<'d, AnyPin>>,
mosi: Option<PeripheralRef<'d, AnyPin>>,
miso: Option<PeripheralRef<'d, AnyPin>>,
txdma: Option<ChannelAndRequest<'d>>,
rxdma: Option<ChannelAndRequest<'d>>,
tx_dma: Option<ChannelAndRequest<'d>>,
rx_dma: Option<ChannelAndRequest<'d>>,
config: Config,
) -> Self {
into_ref!(peri);
Expand Down Expand Up @@ -209,8 +209,8 @@ impl<'d, T: Instance, M: PeriMode> Spi<'d, T, M> {
sck,
mosi,
miso,
txdma,
rxdma,
tx_dma,
rx_dma,
current_word_size: <u8 as SealedWord>::CONFIG,
_phantom: PhantomData,
}
Expand Down Expand Up @@ -479,17 +479,17 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
sck: impl Peripheral<P = impl SckPin<T>> + 'd,
mosi: impl Peripheral<P = impl MosiPin<T>> + 'd,
miso: impl Peripheral<P = impl MisoPin<T>> + 'd,
txdma: impl Peripheral<P = impl TxDma<T>> + 'd,
rxdma: impl Peripheral<P = impl RxDma<T>> + 'd,
tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
config: Config,
) -> Self {
Self::new_inner(
peri,
new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()),
new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh),
new_pin!(miso, AFType::Input, Speed::VeryHigh),
new_dma!(txdma),
new_dma!(rxdma),
new_dma!(tx_dma),
new_dma!(rx_dma),
config,
)
}
Expand All @@ -499,7 +499,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
peri: impl Peripheral<P = T> + 'd,
sck: impl Peripheral<P = impl SckPin<T>> + 'd,
miso: impl Peripheral<P = impl MisoPin<T>> + 'd,
rxdma: impl Peripheral<P = impl RxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
config: Config,
) -> Self {
Self::new_inner(
Expand All @@ -508,7 +508,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
None,
new_pin!(miso, AFType::Input, Speed::VeryHigh),
None,
new_dma!(rxdma),
new_dma!(rx_dma),
config,
)
}
Expand All @@ -518,15 +518,15 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
peri: impl Peripheral<P = T> + 'd,
sck: impl Peripheral<P = impl SckPin<T>> + 'd,
mosi: impl Peripheral<P = impl MosiPin<T>> + 'd,
txdma: impl Peripheral<P = impl TxDma<T>> + 'd,
tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd,
config: Config,
) -> Self {
Self::new_inner(
peri,
new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()),
new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh),
None,
new_dma!(txdma),
new_dma!(tx_dma),
None,
config,
)
Expand All @@ -538,15 +538,15 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
pub fn new_txonly_nosck(
peri: impl Peripheral<P = T> + 'd,
mosi: impl Peripheral<P = impl MosiPin<T>> + 'd,
txdma: impl Peripheral<P = impl TxDma<T>> + 'd,
tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd,
config: Config,
) -> Self {
Self::new_inner(
peri,
None,
new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh),
None,
new_dma!(txdma),
new_dma!(tx_dma),
None,
config,
)
Expand All @@ -556,8 +556,8 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
/// Useful for on chip peripherals like SUBGHZ which are hardwired.
pub fn new_subghz(
peri: impl Peripheral<P = T> + 'd,
txdma: impl Peripheral<P = impl TxDma<T>> + 'd,
rxdma: impl Peripheral<P = impl RxDma<T>> + 'd,
tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
) -> Self {
// see RM0453 rev 1 section 7.2.13 page 291
// The SUBGHZSPI_SCK frequency is obtained by PCLK3 divided by two.
Expand All @@ -569,17 +569,17 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
config.bit_order = BitOrder::MsbFirst;
config.frequency = freq;

Self::new_inner(peri, None, None, None, new_dma!(txdma), new_dma!(rxdma), config)
Self::new_inner(peri, None, None, None, new_dma!(tx_dma), new_dma!(rx_dma), config)
}

#[allow(dead_code)]
pub(crate) fn new_internal(
peri: impl Peripheral<P = T> + 'd,
txdma: impl Peripheral<P = impl TxDma<T>> + 'd,
rxdma: impl Peripheral<P = impl RxDma<T>> + 'd,
tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
config: Config,
) -> Self {
Self::new_inner(peri, None, None, None, new_dma!(txdma), new_dma!(rxdma), config)
Self::new_inner(peri, None, None, None, new_dma!(tx_dma), new_dma!(rx_dma), config)
}

/// SPI write, using DMA.
Expand All @@ -594,7 +594,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
});

let tx_dst = T::REGS.tx_ptr();
let tx_f = unsafe { self.txdma.as_mut().unwrap().write(data, tx_dst, Default::default()) };
let tx_f = unsafe { self.tx_dma.as_mut().unwrap().write(data, tx_dst, Default::default()) };

set_txdmaen(T::REGS, true);
T::REGS.cr1().modify(|w| {
Expand Down Expand Up @@ -632,12 +632,12 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
let clock_byte_count = data.len();

let rx_src = T::REGS.rx_ptr();
let rx_f = unsafe { self.rxdma.as_mut().unwrap().read(rx_src, data, Default::default()) };
let rx_f = unsafe { self.rx_dma.as_mut().unwrap().read(rx_src, data, Default::default()) };

let tx_dst = T::REGS.tx_ptr();
let clock_byte = 0x00u8;
let tx_f = unsafe {
self.txdma
self.tx_dma
.as_mut()
.unwrap()
.write_repeated(&clock_byte, clock_byte_count, tx_dst, Default::default())
Expand Down Expand Up @@ -679,11 +679,11 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
set_rxdmaen(T::REGS, true);

let rx_src = T::REGS.rx_ptr();
let rx_f = unsafe { self.rxdma.as_mut().unwrap().read_raw(rx_src, read, Default::default()) };
let rx_f = unsafe { self.rx_dma.as_mut().unwrap().read_raw(rx_src, read, Default::default()) };

let tx_dst = T::REGS.tx_ptr();
let tx_f = unsafe {
self.txdma
self.tx_dma
.as_mut()
.unwrap()
.write_raw(write, tx_dst, Default::default())
Expand Down

0 comments on commit 2eab099

Please sign in to comment.