aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-07-08 15:59:39 -0400
committerBob McWhirter <[email protected]>2021-07-13 10:09:35 -0400
commit30a1d9bf933831cc310e1d1eb719d0ec7f431099 (patch)
tree6bb7f1a5c5e990b094859406eb6e99e022d42041
parentf01ddd5f5c2ec9505037663db8b1d54d7c153b0f (diff)
Move to copying regs instead of &'static referencing.
Remove unneeded stuff from the DMAMUX end of the stick.
-rw-r--r--embassy-stm32/src/bdma/v1.rs4
-rw-r--r--embassy-stm32/src/dmamux/mod.rs30
2 files changed, 9 insertions, 25 deletions
diff --git a/embassy-stm32/src/bdma/v1.rs b/embassy-stm32/src/bdma/v1.rs
index fd3bf699c..5d612367b 100644
--- a/embassy-stm32/src/bdma/v1.rs
+++ b/embassy-stm32/src/bdma/v1.rs
@@ -92,7 +92,7 @@ pub(crate) async unsafe fn transfer_m2p(
92 state_number: usize, 92 state_number: usize,
93 src: &[u8], 93 src: &[u8],
94 dst: *mut u8, 94 dst: *mut u8,
95 #[cfg(dmamux)] dmamux_regs: &'static pac::dmamux::Dmamux, 95 #[cfg(dmamux)] dmamux_regs: pac::dmamux::Dmamux,
96 #[cfg(dmamux)] dmamux_ch_num: u8, 96 #[cfg(dmamux)] dmamux_ch_num: u8,
97 #[cfg(dmamux)] request: u8, 97 #[cfg(dmamux)] request: u8,
98) { 98) {
@@ -272,7 +272,7 @@ macro_rules! impl_dma_channel {
272 use crate::dmamux::sealed::Channel as _MuxChannel; 272 use crate::dmamux::sealed::Channel as _MuxChannel;
273 use crate::dmamux::sealed::PeripheralChannel; 273 use crate::dmamux::sealed::PeripheralChannel;
274 let dmamux_regs = self.dmamux_regs(); 274 let dmamux_regs = self.dmamux_regs();
275 let dmamux_ch_num = self.dma_ch_num(); 275 let dmamux_ch_num = self.dmamux_ch_num();
276 let request = PeripheralChannel::<T, crate::dmamux::M2P>::request(self); 276 let request = PeripheralChannel::<T, crate::dmamux::M2P>::request(self);
277 unsafe { 277 unsafe {
278 transfer_m2p( 278 transfer_m2p(
diff --git a/embassy-stm32/src/dmamux/mod.rs b/embassy-stm32/src/dmamux/mod.rs
index 745906cdd..79dea2960 100644
--- a/embassy-stm32/src/dmamux/mod.rs
+++ b/embassy-stm32/src/dmamux/mod.rs
@@ -101,7 +101,7 @@ pub(crate) async unsafe fn transfer_m2p(
101 */ 101 */
102 102
103pub(crate) unsafe fn configure_dmamux( 103pub(crate) unsafe fn configure_dmamux(
104 dmamux_regs: &pac::dmamux::Dmamux, 104 dmamux_regs: pac::dmamux::Dmamux,
105 dmamux_ch_num: u8, 105 dmamux_ch_num: u8,
106 request: u8, 106 request: u8,
107) { 107) {
@@ -123,15 +123,11 @@ pub(crate) mod sealed {
123 use super::*; 123 use super::*;
124 124
125 pub trait DmaMux { 125 pub trait DmaMux {
126 fn regs() -> &'static pac::dmamux::Dmamux; 126 fn regs() -> pac::dmamux::Dmamux;
127 } 127 }
128 128
129 pub trait Channel { 129 pub trait Channel {
130 fn num(&self) -> usize; 130 fn dmamux_regs(&self) -> pac::dmamux::Dmamux;
131 fn dma_regs() -> &'static pac::bdma::Dma;
132 fn dma_ch_num(&self) -> u8;
133
134 fn dmamux_regs(&self) -> &'static pac::dmamux::Dmamux;
135 fn dmamux_ch_num(&self) -> u8; 131 fn dmamux_ch_num(&self) -> u8;
136 } 132 }
137 133
@@ -151,20 +147,8 @@ macro_rules! impl_dma_channel {
151 ($channel_peri:ident, $dmamux_peri:ident, $channel_num:expr, $dma_peri: ident, $dma_num:expr) => { 147 ($channel_peri:ident, $dmamux_peri:ident, $channel_num:expr, $dma_peri: ident, $dma_num:expr) => {
152 impl Channel for peripherals::$channel_peri {} 148 impl Channel for peripherals::$channel_peri {}
153 impl sealed::Channel for peripherals::$channel_peri { 149 impl sealed::Channel for peripherals::$channel_peri {
154 fn num(&self) -> usize { 150 fn dmamux_regs(&self) -> pac::dmamux::Dmamux {
155 ($dma_num * 8) + $channel_num 151 crate::pac::$dmamux_peri
156 }
157
158 fn dma_regs() -> &'static pac::bdma::Dma {
159 &crate::pac::$dma_peri
160 }
161
162 fn dma_ch_num(&self) -> u8 {
163 $channel_num
164 }
165
166 fn dmamux_regs(&self) -> &'static pac::dmamux::Dmamux {
167 &crate::pac::$dmamux_peri
168 } 152 }
169 153
170 fn dmamux_ch_num(&self) -> u8 { 154 fn dmamux_ch_num(&self) -> u8 {
@@ -177,8 +161,8 @@ macro_rules! impl_dma_channel {
177macro_rules! impl_dmamux { 161macro_rules! impl_dmamux {
178 ($peri:ident) => { 162 ($peri:ident) => {
179 impl sealed::DmaMux for peripherals::$peri { 163 impl sealed::DmaMux for peripherals::$peri {
180 fn regs() -> &'static pac::dmamux::Dmamux { 164 fn regs() -> pac::dmamux::Dmamux {
181 &pac::$peri 165 pac::$peri
182 } 166 }
183 } 167 }
184 impl DmaMux for peripherals::$peri {} 168 impl DmaMux for peripherals::$peri {}