aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-19 03:51:20 +0100
committerGitHub <[email protected]>2021-03-19 03:51:20 +0100
commit01fd0cd92d93306502dbe9714432cb00264c8e03 (patch)
tree7ab313f59c039764374257a1a8fcc29d5f214ae3
parent456e04c79fb5070fadffa6e80832e78aec7c2e59 (diff)
parent88a25b042aee96a73bdfbc44409bd8f6cd15035a (diff)
Merge pull request #93 from thalesfragoso/fix-comp
F4: Fix compilation for other MCUs
-rwxr-xr-xci.sh2
-rw-r--r--embassy-stm32f4-examples/Cargo.toml22
-rw-r--r--embassy-stm32f4-examples/src/bin/can.rs4
-rw-r--r--embassy-stm32f4-examples/src/bin/serial.rs2
-rw-r--r--embassy-stm32f4/src/can.rs4
-rw-r--r--embassy-stm32f4/src/exti.rs1
-rw-r--r--embassy-stm32f4/src/lib.rs2
-rw-r--r--embassy-stm32f4/src/qei.rs6
-rw-r--r--embassy-stm32f4/src/serial.rs56
9 files changed, 80 insertions, 19 deletions
diff --git a/ci.sh b/ci.sh
index d169246bd..05b1d0ad7 100755
--- a/ci.sh
+++ b/ci.sh
@@ -30,7 +30,7 @@ cargo fmt --all -- --check
30 30
31# embassy-stm32f4 31# embassy-stm32f4
32 32
33(cd embassy-stm32f4-examples; cargo build --target thumbv7em-none-eabi --bins) 33(cd embassy-stm32f4-examples; cargo build --target thumbv7em-none-eabi --bins --features stm32f405)
34(cd embassy-stm32f4; cargo build --target thumbv7em-none-eabi --features stm32f405) 34(cd embassy-stm32f4; cargo build --target thumbv7em-none-eabi --features stm32f405)
35(cd embassy-stm32f4; cargo build --target thumbv7em-none-eabi --features stm32f405,defmt) 35(cd embassy-stm32f4; cargo build --target thumbv7em-none-eabi --features stm32f405,defmt)
36 36
diff --git a/embassy-stm32f4-examples/Cargo.toml b/embassy-stm32f4-examples/Cargo.toml
index 60ba44554..5bbaecc58 100644
--- a/embassy-stm32f4-examples/Cargo.toml
+++ b/embassy-stm32f4-examples/Cargo.toml
@@ -15,11 +15,29 @@ defmt-info = []
15defmt-warn = [] 15defmt-warn = []
16defmt-error = [] 16defmt-error = []
17 17
18stm32f401 = ["stm32f4xx-hal/stm32f401", "embassy-stm32f4/stm32f401"]
19stm32f405 = ["stm32f4xx-hal/stm32f405", "embassy-stm32f4/stm32f405"]
20stm32f407 = ["stm32f4xx-hal/stm32f407", "embassy-stm32f4/stm32f407"]
21stm32f410 = ["stm32f4xx-hal/stm32f410", "embassy-stm32f4/stm32f410"]
22stm32f411 = ["stm32f4xx-hal/stm32f411", "embassy-stm32f4/stm32f411"]
23stm32f412 = ["stm32f4xx-hal/stm32f412", "embassy-stm32f4/stm32f412"]
24stm32f413 = ["stm32f4xx-hal/stm32f413", "embassy-stm32f4/stm32f413"]
25stm32f415 = ["stm32f4xx-hal/stm32f405", "embassy-stm32f4/stm32f405"]
26stm32f417 = ["stm32f4xx-hal/stm32f407", "embassy-stm32f4/stm32f407"]
27stm32f423 = ["stm32f4xx-hal/stm32f413", "embassy-stm32f4/stm32f413"]
28stm32f427 = ["stm32f4xx-hal/stm32f427", "embassy-stm32f4/stm32f427"]
29stm32f429 = ["stm32f4xx-hal/stm32f429", "embassy-stm32f4/stm32f429"]
30stm32f437 = ["stm32f4xx-hal/stm32f427", "embassy-stm32f4/stm32f427"]
31stm32f439 = ["stm32f4xx-hal/stm32f429", "embassy-stm32f4/stm32f429"]
32stm32f446 = ["stm32f4xx-hal/stm32f446", "embassy-stm32f4/stm32f446"]
33stm32f469 = ["stm32f4xx-hal/stm32f469", "embassy-stm32f4/stm32f469"]
34stm32f479 = ["stm32f4xx-hal/stm32f469", "embassy-stm32f4/stm32f469"]
35
18 36
19[dependencies] 37[dependencies]
20embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] } 38embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] }
21embassy-traits = { version = "0.1.0", path = "../embassy-traits", features = ["defmt"] } 39embassy-traits = { version = "0.1.0", path = "../embassy-traits", features = ["defmt"] }
22embassy-stm32f4 = { version = "*", path = "../embassy-stm32f4", features = ["stm32f405"] } 40embassy-stm32f4 = { version = "*", path = "../embassy-stm32f4" }
23 41
24defmt = "0.2.0" 42defmt = "0.2.0"
25defmt-rtt = "0.2.0" 43defmt-rtt = "0.2.0"
@@ -28,7 +46,7 @@ cortex-m = "0.7.1"
28cortex-m-rt = "0.6.13" 46cortex-m-rt = "0.6.13"
29embedded-hal = { version = "0.2.4" } 47embedded-hal = { version = "0.2.4" }
30panic-probe = "0.1.0" 48panic-probe = "0.1.0"
31stm32f4xx-hal = { version = "0.8.3", features = ["rt", "stm32f405"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git"} 49stm32f4xx-hal = { version = "0.8.3", features = ["rt"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git"}
32futures = { version = "0.3.8", default-features = false, features = ["async-await"] } 50futures = { version = "0.3.8", default-features = false, features = ["async-await"] }
33rtt-target = { version = "0.3", features = ["cortex-m"] } 51rtt-target = { version = "0.3", features = ["cortex-m"] }
34bxcan = "0.5.0" \ No newline at end of file 52bxcan = "0.5.0" \ No newline at end of file
diff --git a/embassy-stm32f4-examples/src/bin/can.rs b/embassy-stm32f4-examples/src/bin/can.rs
index 701a277ec..5ffde2471 100644
--- a/embassy-stm32f4-examples/src/bin/can.rs
+++ b/embassy-stm32f4-examples/src/bin/can.rs
@@ -12,10 +12,8 @@ use example_common::{panic, *};
12use bxcan::filter::Mask32; 12use bxcan::filter::Mask32;
13use cortex_m_rt::entry; 13use cortex_m_rt::entry;
14use embassy::executor::{task, Executor}; 14use embassy::executor::{task, Executor};
15use embassy::traits::gpio::*;
16use embassy::util::Forever; 15use embassy::util::Forever;
17use embassy_stm32f4::{can, interrupt}; 16use embassy_stm32f4::{can, interrupt};
18use futures::pin_mut;
19use stm32f4xx_hal::prelude::*; 17use stm32f4xx_hal::prelude::*;
20use stm32f4xx_hal::{can::Can, stm32}; 18use stm32f4xx_hal::{can::Can, stm32};
21 19
@@ -35,7 +33,7 @@ async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
35 33
36 let mut can = can::Can::new(can, interrupt::take!(CAN1_TX), interrupt::take!(CAN1_RX0)); 34 let mut can = can::Can::new(can, interrupt::take!(CAN1_TX), interrupt::take!(CAN1_RX0));
37 35
38 let frame = can.receive().await; 36 let _frame = can.receive().await;
39} 37}
40 38
41static EXECUTOR: Forever<Executor> = Forever::new(); 39static EXECUTOR: Forever<Executor> = Forever::new();
diff --git a/embassy-stm32f4-examples/src/bin/serial.rs b/embassy-stm32f4-examples/src/bin/serial.rs
index b138bfdd8..49a588c25 100644
--- a/embassy-stm32f4-examples/src/bin/serial.rs
+++ b/embassy-stm32f4-examples/src/bin/serial.rs
@@ -43,7 +43,7 @@ async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
43 43
44 let streams = StreamsTuple::new(dp.DMA2); 44 let streams = StreamsTuple::new(dp.DMA2);
45 45
46 let mut serial = unsafe { 46 let _serial = unsafe {
47 serial::Serial::new( 47 serial::Serial::new(
48 dp.USART1, 48 dp.USART1,
49 (streams.7, streams.2), 49 (streams.7, streams.2),
diff --git a/embassy-stm32f4/src/can.rs b/embassy-stm32f4/src/can.rs
index 7c5311a9d..526d002c0 100644
--- a/embassy-stm32f4/src/can.rs
+++ b/embassy-stm32f4/src/can.rs
@@ -42,7 +42,8 @@ impl<T: Instance> Can<T> {
42 pub fn transmit<'a>(&'a mut self, frame: &'a bxcan::Frame) -> impl Future<Output = ()> + 'a { 42 pub fn transmit<'a>(&'a mut self, frame: &'a bxcan::Frame) -> impl Future<Output = ()> + 'a {
43 async move { 43 async move {
44 let fut = InterruptFuture::new(&mut self.tx_int); 44 let fut = InterruptFuture::new(&mut self.tx_int);
45 self.can.transmit(frame); 45 // Infallible
46 self.can.transmit(frame).unwrap();
46 47
47 fut.await; 48 fut.await;
48 } 49 }
@@ -94,7 +95,6 @@ macro_rules! can {
94 } 95 }
95} 96}
96 97
97#[cfg(any(feature = "stm32f405",))]
98can! { 98can! {
99 CAN1 => (CAN1_TX, CAN1_RX0), 99 CAN1 => (CAN1_TX, CAN1_RX0),
100 CAN2 => (CAN2_TX, CAN2_RX0), 100 CAN2 => (CAN2_TX, CAN2_RX0),
diff --git a/embassy-stm32f4/src/exti.rs b/embassy-stm32f4/src/exti.rs
index 9df021634..154ca45c1 100644
--- a/embassy-stm32f4/src/exti.rs
+++ b/embassy-stm32f4/src/exti.rs
@@ -1,4 +1,3 @@
1use core::cell::UnsafeCell;
2use core::future::Future; 1use core::future::Future;
3use core::mem; 2use core::mem;
4use core::pin::Pin; 3use core::pin::Pin;
diff --git a/embassy-stm32f4/src/lib.rs b/embassy-stm32f4/src/lib.rs
index 19375d962..82d26d952 100644
--- a/embassy-stm32f4/src/lib.rs
+++ b/embassy-stm32f4/src/lib.rs
@@ -313,9 +313,11 @@ pub use stm32f4xx_hal::stm32 as pac;
313// This mod MUST go first, so that the others see its macros. 313// This mod MUST go first, so that the others see its macros.
314pub(crate) mod fmt; 314pub(crate) mod fmt;
315 315
316#[cfg(not(any(feature = "stm32f401", feature = "stm32f410", feature = "stm32f411",)))]
316pub mod can; 317pub mod can;
317pub mod exti; 318pub mod exti;
318pub mod interrupt; 319pub mod interrupt;
320#[cfg(not(feature = "stm32f410"))]
319pub mod qei; 321pub mod qei;
320pub mod rtc; 322pub mod rtc;
321pub mod serial; 323pub mod serial;
diff --git a/embassy-stm32f4/src/qei.rs b/embassy-stm32f4/src/qei.rs
index 391c8f7c2..5973e62d9 100644
--- a/embassy-stm32f4/src/qei.rs
+++ b/embassy-stm32f4/src/qei.rs
@@ -7,7 +7,7 @@ use stm32f4xx_hal::pac::TIM2;
7use stm32f4xx_hal::{qei, qei::Pins}; 7use stm32f4xx_hal::{qei, qei::Pins};
8 8
9pub struct Qei<T: Instance, PINS> { 9pub struct Qei<T: Instance, PINS> {
10 qei: qei::Qei<T, PINS>, 10 _qei: qei::Qei<T, PINS>,
11 int: T::Interrupt, 11 int: T::Interrupt,
12} 12}
13 13
@@ -25,7 +25,7 @@ impl<PINS: Pins<TIM2>> Qei<TIM2, PINS> {
25 tim.dier.write(|w| w.uie().set_bit()); 25 tim.dier.write(|w| w.uie().set_bit());
26 26
27 Qei { 27 Qei {
28 qei: qei, 28 _qei: qei,
29 int: interrupt, 29 int: interrupt,
30 } 30 }
31 } 31 }
@@ -85,9 +85,7 @@ pub trait Instance: sealed::Sealed {
85 type Interrupt: interrupt::Interrupt; 85 type Interrupt: interrupt::Interrupt;
86} 86}
87 87
88#[cfg(feature = "stm32f405")]
89impl sealed::Sealed for TIM2 {} 88impl sealed::Sealed for TIM2 {}
90#[cfg(feature = "stm32f405")]
91impl Instance for TIM2 { 89impl Instance for TIM2 {
92 type Interrupt = interrupt::TIM2; 90 type Interrupt = interrupt::TIM2;
93} 91}
diff --git a/embassy-stm32f4/src/serial.rs b/embassy-stm32f4/src/serial.rs
index 97b365a11..87d0caaaf 100644
--- a/embassy-stm32f4/src/serial.rs
+++ b/embassy-stm32f4/src/serial.rs
@@ -6,7 +6,6 @@
6 6
7use core::future::Future; 7use core::future::Future;
8use core::marker::PhantomData; 8use core::marker::PhantomData;
9use core::sync::atomic::{self, Ordering};
10 9
11use embassy::interrupt::Interrupt; 10use embassy::interrupt::Interrupt;
12use embassy::traits::uart::{Error, Uart}; 11use embassy::traits::uart::{Error, Uart};
@@ -37,7 +36,7 @@ pub struct Serial<
37 usart: Option<USART>, 36 usart: Option<USART>,
38 tx_int: TSTREAM::Interrupt, 37 tx_int: TSTREAM::Interrupt,
39 rx_int: RSTREAM::Interrupt, 38 rx_int: RSTREAM::Interrupt,
40 usart_int: USART::Interrupt, 39 _usart_int: USART::Interrupt,
41 channel: PhantomData<CHANNEL>, 40 channel: PhantomData<CHANNEL>,
42} 41}
43 42
@@ -84,7 +83,7 @@ where
84 usart: Some(usart), 83 usart: Some(usart),
85 tx_int: tx_int, 84 tx_int: tx_int,
86 rx_int: rx_int, 85 rx_int: rx_int,
87 usart_int: usart_int, 86 _usart_int: usart_int,
88 channel: core::marker::PhantomData, 87 channel: core::marker::PhantomData,
89 } 88 }
90 } 89 }
@@ -207,7 +206,6 @@ macro_rules! usart {
207 } 206 }
208} 207}
209 208
210#[cfg(any(feature = "stm32f405",))]
211dma! { 209dma! {
212 DMA2_STREAM0 => (DMA2, Stream0), 210 DMA2_STREAM0 => (DMA2, Stream0),
213 DMA2_STREAM1 => (DMA2, Stream1), 211 DMA2_STREAM1 => (DMA2, Stream1),
@@ -226,12 +224,60 @@ dma! {
226 DMA1_STREAM6 => (DMA1, Stream6), 224 DMA1_STREAM6 => (DMA1, Stream6),
227} 225}
228 226
229#[cfg(any(feature = "stm32f405",))] 227#[cfg(any(feature = "stm32f401", feature = "stm32f410", feature = "stm32f411",))]
228usart! {
229 USART1 => (USART1),
230 USART2 => (USART2),
231 USART6 => (USART6),
232}
233
234#[cfg(any(feature = "stm32f405", feature = "stm32f407"))]
230usart! { 235usart! {
231 USART1 => (USART1), 236 USART1 => (USART1),
232 USART2 => (USART2), 237 USART2 => (USART2),
233 USART3 => (USART3), 238 USART3 => (USART3),
239 USART6 => (USART6),
240
234 UART4 => (UART4), 241 UART4 => (UART4),
235 UART5 => (UART5), 242 UART5 => (UART5),
243}
244
245#[cfg(feature = "stm32f412")]
246usart! {
247 USART1 => (USART1),
248 USART2 => (USART2),
249 USART3 => (USART3),
236 USART6 => (USART6), 250 USART6 => (USART6),
237} 251}
252
253#[cfg(feature = "stm32f413")]
254usart! {
255 USART1 => (USART1),
256 USART2 => (USART2),
257 USART3 => (USART3),
258 USART6 => (USART6),
259 USART7 => (USART7),
260 USART8 => (USART8),
261
262 UART5 => (UART5),
263 UART9 => (UART9),
264 UART10 => (UART10),
265}
266
267#[cfg(any(
268 feature = "stm32f427",
269 feature = "stm32f429",
270 feature = "stm32f446",
271 feature = "stm32f469"
272))]
273usart! {
274 USART1 => (USART1),
275 USART2 => (USART2),
276 USART3 => (USART3),
277 USART6 => (USART6),
278
279 UART4 => (UART4),
280 UART5 => (UART5),
281 UART7 => (UART7),
282 UART8 => (UART8),
283}