aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRukai <[email protected]>2021-07-04 12:42:39 +1000
committerRukai <[email protected]>2021-07-04 12:46:04 +1000
commit56d0c5ffe1c7f49473e479e791b31685a6faaba7 (patch)
tree5959d5fd9fffa8717b724dd317b3dd355f7c0bf1
parent8615ffb523edbfa10b9bc13c24668da760cf06c5 (diff)
Fix warnings in std and rp
-rw-r--r--embassy-rp/src/clocks.rs4
-rw-r--r--embassy/src/io/traits.rs7
-rw-r--r--examples/rp/src/bin/button.rs1
-rw-r--r--examples/std/src/bin/net.rs27
-rw-r--r--examples/std/src/tuntap.rs6
5 files changed, 24 insertions, 21 deletions
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs
index 364cf452c..6835ecad3 100644
--- a/embassy-rp/src/clocks.rs
+++ b/embassy-rp/src/clocks.rs
@@ -115,7 +115,7 @@ pub unsafe fn init() {
115 reset::unreset_wait(peris); 115 reset::unreset_wait(peris);
116} 116}
117 117
118pub(crate) fn clk_sys_freq() -> u32 { 118pub(crate) fn _clk_sys_freq() -> u32 {
119 125_000_000 119 125_000_000
120} 120}
121 121
@@ -123,7 +123,7 @@ pub(crate) fn clk_peri_freq() -> u32 {
123 125_000_000 123 125_000_000
124} 124}
125 125
126pub(crate) fn clk_rtc_freq() -> u32 { 126pub(crate) fn _clk_rtc_freq() -> u32 {
127 46875 127 46875
128} 128}
129 129
diff --git a/embassy/src/io/traits.rs b/embassy/src/io/traits.rs
index 6138adb40..b59cdc0d4 100644
--- a/embassy/src/io/traits.rs
+++ b/embassy/src/io/traits.rs
@@ -31,11 +31,11 @@ pub trait AsyncBufRead {
31 /// This function is a lower-level call. It needs to be paired with the 31 /// This function is a lower-level call. It needs to be paired with the
32 /// [`consume`] method to function properly. When calling this 32 /// [`consume`] method to function properly. When calling this
33 /// method, none of the contents will be "read" in the sense that later 33 /// method, none of the contents will be "read" in the sense that later
34 /// calling [`poll_read`] may return the same contents. As such, [`consume`] must 34 /// calling [`poll_fill_buf`] may return the same contents. As such, [`consume`] must
35 /// be called with the number of bytes that are consumed from this buffer to 35 /// be called with the number of bytes that are consumed from this buffer to
36 /// ensure that the bytes are never returned twice. 36 /// ensure that the bytes are never returned twice.
37 /// 37 ///
38 /// [`poll_read`]: AsyncBufRead::poll_read 38 /// [`poll_fill_buf`]: AsyncBufRead::poll_fill_buf
39 /// [`consume`]: AsyncBufRead::consume 39 /// [`consume`]: AsyncBufRead::consume
40 /// 40 ///
41 /// An empty buffer returned indicates that the stream has reached EOF. 41 /// An empty buffer returned indicates that the stream has reached EOF.
@@ -49,7 +49,7 @@ pub trait AsyncBufRead {
49 fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>; 49 fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>;
50 50
51 /// Tells this buffer that `amt` bytes have been consumed from the buffer, 51 /// Tells this buffer that `amt` bytes have been consumed from the buffer,
52 /// so they should no longer be returned in calls to [`poll_read`]. 52 /// so they should no longer be returned in calls to [`poll_fill_buf`].
53 /// 53 ///
54 /// This function is a lower-level call. It needs to be paired with the 54 /// This function is a lower-level call. It needs to be paired with the
55 /// [`poll_fill_buf`] method to function properly. This function does 55 /// [`poll_fill_buf`] method to function properly. This function does
@@ -61,7 +61,6 @@ pub trait AsyncBufRead {
61 /// The `amt` must be `<=` the number of bytes in the buffer returned by 61 /// The `amt` must be `<=` the number of bytes in the buffer returned by
62 /// [`poll_fill_buf`]. 62 /// [`poll_fill_buf`].
63 /// 63 ///
64 /// [`poll_read`]: AsyncBufRead::poll_read
65 /// [`poll_fill_buf`]: AsyncBufRead::poll_fill_buf 64 /// [`poll_fill_buf`]: AsyncBufRead::poll_fill_buf
66 fn consume(self: Pin<&mut Self>, amt: usize); 65 fn consume(self: Pin<&mut Self>, amt: usize);
67} 66}
diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs
index 12bc0e0d9..b0c3347f4 100644
--- a/examples/rp/src/bin/button.rs
+++ b/examples/rp/src/bin/button.rs
@@ -12,7 +12,6 @@ mod example_common;
12use embassy::executor::Spawner; 12use embassy::executor::Spawner;
13use embassy_rp::gpio::{Input, Level, Output, Pull}; 13use embassy_rp::gpio::{Input, Level, Output, Pull};
14use embassy_rp::Peripherals; 14use embassy_rp::Peripherals;
15use embedded_hal::digital::v2::{InputPin, OutputPin};
16 15
17#[embassy::main] 16#[embassy::main]
18async fn main(_spawner: Spawner, p: Peripherals) { 17async fn main(_spawner: Spawner, p: Peripherals) {
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs
index 344a6e4d3..73c8e1494 100644
--- a/examples/std/src/bin/net.rs
+++ b/examples/std/src/bin/net.rs
@@ -18,7 +18,8 @@ mod tuntap;
18use crate::tuntap::TunTapDevice; 18use crate::tuntap::TunTapDevice;
19 19
20static DEVICE: Forever<TunTapDevice> = Forever::new(); 20static DEVICE: Forever<TunTapDevice> = Forever::new();
21static CONFIG: Forever<DhcpConfigurator> = Forever::new(); 21static CONFIG_STATIC: Forever<StaticConfigurator> = Forever::new();
22static CONFIG_DYNAMIC: Forever<DhcpConfigurator> = Forever::new();
22static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new(); 23static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
23 24
24#[derive(Clap)] 25#[derive(Clap)]
@@ -28,6 +29,9 @@ struct Opts {
28 /// TAP device name 29 /// TAP device name
29 #[clap(long, default_value = "tap0")] 30 #[clap(long, default_value = "tap0")]
30 tap: String, 31 tap: String,
32 /// use a static IP instead of DHCP
33 #[clap(long)]
34 static_ip: bool,
31} 35}
32 36
33#[embassy::task] 37#[embassy::task]
@@ -42,20 +46,21 @@ async fn main_task(spawner: Spawner) {
42 // Init network device 46 // Init network device
43 let device = TunTapDevice::new(&opts.tap).unwrap(); 47 let device = TunTapDevice::new(&opts.tap).unwrap();
44 48
45 // Static IP configuration 49 // Choose between dhcp or static ip
46 let config = StaticConfigurator::new(Config { 50 let config: &'static mut dyn Configurator = if opts.static_ip {
47 address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), 51 CONFIG_STATIC.put(StaticConfigurator::new(Config {
48 dns_servers: Vec::new(), 52 address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
49 gateway: Some(Ipv4Address::new(192, 168, 69, 1)), 53 dns_servers: Vec::new(),
50 }); 54 gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
51 55 }))
52 // DHCP configruation 56 } else {
53 let config = DhcpConfigurator::new(); 57 CONFIG_DYNAMIC.put(DhcpConfigurator::new())
58 };
54 59
55 let net_resources = StackResources::new(); 60 let net_resources = StackResources::new();
56 61
57 // Init network stack 62 // Init network stack
58 embassy_net::init(DEVICE.put(device), CONFIG.put(config), NET_RESOURCES.put(net_resources)); 63 embassy_net::init(DEVICE.put(device), config, NET_RESOURCES.put(net_resources));
59 64
60 // Launch network task 65 // Launch network task
61 spawner.spawn(net_task()).unwrap(); 66 spawner.spawn(net_task()).unwrap();
diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs
index dd453deb3..53d3afd5c 100644
--- a/examples/std/src/tuntap.rs
+++ b/examples/std/src/tuntap.rs
@@ -7,10 +7,10 @@ use std::io::{Read, Write};
7use std::os::unix::io::{AsRawFd, RawFd}; 7use std::os::unix::io::{AsRawFd, RawFd};
8 8
9pub const SIOCGIFMTU: libc::c_ulong = 0x8921; 9pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
10pub const SIOCGIFINDEX: libc::c_ulong = 0x8933; 10pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933;
11pub const ETH_P_ALL: libc::c_short = 0x0003; 11pub const _ETH_P_ALL: libc::c_short = 0x0003;
12pub const TUNSETIFF: libc::c_ulong = 0x400454CA; 12pub const TUNSETIFF: libc::c_ulong = 0x400454CA;
13pub const IFF_TUN: libc::c_int = 0x0001; 13pub const _IFF_TUN: libc::c_int = 0x0001;
14pub const IFF_TAP: libc::c_int = 0x0002; 14pub const IFF_TAP: libc::c_int = 0x0002;
15pub const IFF_NO_PI: libc::c_int = 0x1000; 15pub const IFF_NO_PI: libc::c_int = 0x1000;
16 16