aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-03-01 01:32:42 +0100
committerDario Nieuwenhuis <[email protected]>2023-03-01 01:32:42 +0100
commit6dbb631f1ecb75361ee70da91f50779c29f23482 (patch)
treed84accfcb94bae68b3983a8a2518689cf868bcc1
parent711ce1014552b715190b1ee6780cafc92fe54240 (diff)
Example fixes.
-rw-r--r--examples/nrf52840/src/bin/usb_ethernet.rs23
-rw-r--r--examples/nrf5340/Cargo.toml23
-rw-r--r--examples/stm32f4/Cargo.toml6
-rw-r--r--examples/stm32f4/src/bin/usb_ethernet.rs11
-rw-r--r--examples/stm32l4/Cargo.toml2
-rw-r--r--examples/stm32l5/Cargo.toml2
6 files changed, 11 insertions, 56 deletions
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs
index 430468adf..979780896 100644
--- a/examples/nrf52840/src/bin/usb_ethernet.rs
+++ b/examples/nrf52840/src/bin/usb_ethernet.rs
@@ -46,31 +46,8 @@ async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! {
46 stack.run().await 46 stack.run().await
47} 47}
48 48
49#[inline(never)]
50pub fn test_function() -> (usize, u32, [u32; 2]) {
51 let mut array = [3; 2];
52
53 let mut index = 0;
54 let mut result = 0;
55
56 for x in [1, 2] {
57 if x == 1 {
58 array[1] = 99;
59 } else {
60 index = if x == 2 { 1 } else { 0 };
61
62 // grabs value from array[0], not array[1]
63 result = array[index];
64 }
65 }
66
67 (index, result, array)
68}
69
70#[embassy_executor::main] 49#[embassy_executor::main]
71async fn main(spawner: Spawner) { 50async fn main(spawner: Spawner) {
72 info!("{:?}", test_function());
73
74 let p = embassy_nrf::init(Default::default()); 51 let p = embassy_nrf::init(Default::default());
75 let clock: pac::CLOCK = unsafe { mem::transmute(()) }; 52 let clock: pac::CLOCK = unsafe { mem::transmute(()) };
76 53
diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml
index eed493012..e88ddf2f7 100644
--- a/examples/nrf5340/Cargo.toml
+++ b/examples/nrf5340/Cargo.toml
@@ -4,24 +4,13 @@ name = "embassy-nrf5340-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6 6
7[features]
8default = ["nightly"]
9nightly = [
10 "embassy-executor/nightly",
11 "embassy-nrf/nightly",
12 "embassy-net/nightly",
13 "embassy-nrf/unstable-traits",
14 "embassy-usb",
15 "embedded-io/async",
16 "embassy-net",
17]
18
19[dependencies] 7[dependencies]
20embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 8embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
21embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = [ 9embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = [
22 "defmt", 10 "defmt",
23] } 11] }
24embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = [ 12embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = [
13 "nightly",
25 "defmt", 14 "defmt",
26 "integrated-timers", 15 "integrated-timers",
27] } 16] }
@@ -30,6 +19,8 @@ embassy-time = { version = "0.1.0", path = "../../embassy-time", features = [
30 "defmt-timestamp-uptime", 19 "defmt-timestamp-uptime",
31] } 20] }
32embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [ 21embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [
22 "nightly",
23 "unstable-traits",
33 "defmt", 24 "defmt",
34 "nrf5340-app-s", 25 "nrf5340-app-s",
35 "time-driver-rtc1", 26 "time-driver-rtc1",
@@ -37,16 +28,16 @@ embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [
37 "unstable-pac", 28 "unstable-pac",
38] } 29] }
39embassy-net = { version = "0.1.0", path = "../../embassy-net", features = [ 30embassy-net = { version = "0.1.0", path = "../../embassy-net", features = [
31 "nightly",
40 "defmt", 32 "defmt",
41 "tcp", 33 "tcp",
42 "dhcpv4", 34 "dhcpv4",
43 "medium-ethernet", 35 "medium-ethernet",
44], optional = true } 36] }
45embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = [ 37embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = [
46 "defmt", 38 "defmt",
47], optional = true } 39] }
48embedded-io = "0.4.0" 40embedded-io = { version = "0.4.0", features = [ "async" ]}
49
50 41
51defmt = "0.3" 42defmt = "0.3"
52defmt-rtt = "0.4" 43defmt-rtt = "0.4"
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml
index e2b17bfcb..7a7bab5bb 100644
--- a/examples/stm32f4/Cargo.toml
+++ b/examples/stm32f4/Cargo.toml
@@ -10,7 +10,7 @@ embassy-executor = { version = "0.1.0", path = "../../embassy-executor", feature
10embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
12embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 12embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
13embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"], optional = true } 13embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
14 14
15defmt = "0.3" 15defmt = "0.3"
16defmt-rtt = "0.4" 16defmt-rtt = "0.4"
@@ -27,9 +27,5 @@ embedded-storage = "0.3.0"
27micromath = "2.0.0" 27micromath = "2.0.0"
28static_cell = "1.0" 28static_cell = "1.0"
29 29
30[[bin]]
31name = "usb_ethernet"
32required-features = ["embassy-net"]
33
34[profile.release] 30[profile.release]
35debug = 2 31debug = 2
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs
index 4a16aac07..db9e18393 100644
--- a/examples/stm32f4/src/bin/usb_ethernet.rs
+++ b/examples/stm32f4/src/bin/usb_ethernet.rs
@@ -100,8 +100,8 @@ async fn main(spawner: Spawner) {
100 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr); 100 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr);
101 unwrap!(spawner.spawn(usb_ncm_task(runner))); 101 unwrap!(spawner.spawn(usb_ncm_task(runner)));
102 102
103 let config = embassy_net::ConfigStrategy::Dhcp; 103 let config = embassy_net::Config::Dhcp(Default::default());
104 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 104 //let config = embassy_net::Config::Static(embassy_net::StaticConfig {
105 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 105 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
106 // dns_servers: Vec::new(), 106 // dns_servers: Vec::new(),
107 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 107 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
@@ -114,12 +114,7 @@ async fn main(spawner: Spawner) {
114 let seed = u64::from_le_bytes(seed); 114 let seed = u64::from_le_bytes(seed);
115 115
116 // Init network stack 116 // Init network stack
117 let stack = &*singleton!(Stack::new( 117 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<2>::new()), seed));
118 device,
119 config,
120 singleton!(StackResources::<1, 2, 8>::new()),
121 seed
122 ));
123 118
124 unwrap!(spawner.spawn(net_task(stack))); 119 unwrap!(spawner.spawn(net_task(stack)));
125 120
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml
index 5627760ef..644c90b1a 100644
--- a/examples/stm32l4/Cargo.toml
+++ b/examples/stm32l4/Cargo.toml
@@ -4,8 +4,6 @@ name = "embassy-stm32l4-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6 6
7[features]
8
9[dependencies] 7[dependencies]
10embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } 9embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml
index c0accb0d6..f880328dc 100644
--- a/examples/stm32l5/Cargo.toml
+++ b/examples/stm32l5/Cargo.toml
@@ -4,8 +4,6 @@ name = "embassy-stm32l5-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6 6
7[features]
8
9[dependencies] 7[dependencies]
10embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } 9embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }