Merge pull request #274 from rukai/fix_warnings_again_rp_std

Fix warnings in std and rp
This commit is contained in:
Dario Nieuwenhuis 2021-07-05 01:51:47 +02:00 committed by GitHub
commit c4561324e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 21 deletions

View File

@ -115,7 +115,7 @@ pub unsafe fn init() {
reset::unreset_wait(peris); reset::unreset_wait(peris);
} }
pub(crate) fn clk_sys_freq() -> u32 { pub(crate) fn _clk_sys_freq() -> u32 {
125_000_000 125_000_000
} }
@ -123,7 +123,7 @@ pub(crate) fn clk_peri_freq() -> u32 {
125_000_000 125_000_000
} }
pub(crate) fn clk_rtc_freq() -> u32 { pub(crate) fn _clk_rtc_freq() -> u32 {
46875 46875
} }

View File

@ -31,11 +31,11 @@ pub trait AsyncBufRead {
/// This function is a lower-level call. It needs to be paired with the /// This function is a lower-level call. It needs to be paired with the
/// [`consume`] method to function properly. When calling this /// [`consume`] method to function properly. When calling this
/// method, none of the contents will be "read" in the sense that later /// method, none of the contents will be "read" in the sense that later
/// calling [`poll_read`] may return the same contents. As such, [`consume`] must /// calling [`poll_fill_buf`] may return the same contents. As such, [`consume`] must
/// be called with the number of bytes that are consumed from this buffer to /// be called with the number of bytes that are consumed from this buffer to
/// ensure that the bytes are never returned twice. /// ensure that the bytes are never returned twice.
/// ///
/// [`poll_read`]: AsyncBufRead::poll_read /// [`poll_fill_buf`]: AsyncBufRead::poll_fill_buf
/// [`consume`]: AsyncBufRead::consume /// [`consume`]: AsyncBufRead::consume
/// ///
/// An empty buffer returned indicates that the stream has reached EOF. /// An empty buffer returned indicates that the stream has reached EOF.
@ -49,7 +49,7 @@ pub trait AsyncBufRead {
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>; fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>;
/// Tells this buffer that `amt` bytes have been consumed from the buffer, /// Tells this buffer that `amt` bytes have been consumed from the buffer,
/// so they should no longer be returned in calls to [`poll_read`]. /// so they should no longer be returned in calls to [`poll_fill_buf`].
/// ///
/// This function is a lower-level call. It needs to be paired with the /// This function is a lower-level call. It needs to be paired with the
/// [`poll_fill_buf`] method to function properly. This function does /// [`poll_fill_buf`] method to function properly. This function does
@ -61,7 +61,6 @@ pub trait AsyncBufRead {
/// The `amt` must be `<=` the number of bytes in the buffer returned by /// The `amt` must be `<=` the number of bytes in the buffer returned by
/// [`poll_fill_buf`]. /// [`poll_fill_buf`].
/// ///
/// [`poll_read`]: AsyncBufRead::poll_read
/// [`poll_fill_buf`]: AsyncBufRead::poll_fill_buf /// [`poll_fill_buf`]: AsyncBufRead::poll_fill_buf
fn consume(self: Pin<&mut Self>, amt: usize); fn consume(self: Pin<&mut Self>, amt: usize);
} }

View File

@ -12,7 +12,6 @@ mod example_common;
use embassy::executor::Spawner; use embassy::executor::Spawner;
use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::gpio::{Input, Level, Output, Pull};
use embassy_rp::Peripherals; use embassy_rp::Peripherals;
use embedded_hal::digital::v2::{InputPin, OutputPin};
#[embassy::main] #[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) { async fn main(_spawner: Spawner, p: Peripherals) {

View File

@ -18,7 +18,8 @@ mod tuntap;
use crate::tuntap::TunTapDevice; use crate::tuntap::TunTapDevice;
static DEVICE: Forever<TunTapDevice> = Forever::new(); static DEVICE: Forever<TunTapDevice> = Forever::new();
static CONFIG: Forever<DhcpConfigurator> = Forever::new(); static CONFIG_STATIC: Forever<StaticConfigurator> = Forever::new();
static CONFIG_DYNAMIC: Forever<DhcpConfigurator> = Forever::new();
static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new(); static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
#[derive(Clap)] #[derive(Clap)]
@ -28,6 +29,9 @@ struct Opts {
/// TAP device name /// TAP device name
#[clap(long, default_value = "tap0")] #[clap(long, default_value = "tap0")]
tap: String, tap: String,
/// use a static IP instead of DHCP
#[clap(long)]
static_ip: bool,
} }
#[embassy::task] #[embassy::task]
@ -42,20 +46,21 @@ async fn main_task(spawner: Spawner) {
// Init network device // Init network device
let device = TunTapDevice::new(&opts.tap).unwrap(); let device = TunTapDevice::new(&opts.tap).unwrap();
// Static IP configuration // Choose between dhcp or static ip
let config = StaticConfigurator::new(Config { let config: &'static mut dyn Configurator = if opts.static_ip {
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), CONFIG_STATIC.put(StaticConfigurator::new(Config {
dns_servers: Vec::new(), address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
gateway: Some(Ipv4Address::new(192, 168, 69, 1)), dns_servers: Vec::new(),
}); gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
}))
// DHCP configruation } else {
let config = DhcpConfigurator::new(); CONFIG_DYNAMIC.put(DhcpConfigurator::new())
};
let net_resources = StackResources::new(); let net_resources = StackResources::new();
// Init network stack // Init network stack
embassy_net::init(DEVICE.put(device), CONFIG.put(config), NET_RESOURCES.put(net_resources)); embassy_net::init(DEVICE.put(device), config, NET_RESOURCES.put(net_resources));
// Launch network task // Launch network task
spawner.spawn(net_task()).unwrap(); spawner.spawn(net_task()).unwrap();

View File

@ -7,10 +7,10 @@ use std::io::{Read, Write};
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
pub const SIOCGIFMTU: libc::c_ulong = 0x8921; pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
pub const SIOCGIFINDEX: libc::c_ulong = 0x8933; pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933;
pub const ETH_P_ALL: libc::c_short = 0x0003; pub const _ETH_P_ALL: libc::c_short = 0x0003;
pub const TUNSETIFF: libc::c_ulong = 0x400454CA; pub const TUNSETIFF: libc::c_ulong = 0x400454CA;
pub const IFF_TUN: libc::c_int = 0x0001; pub const _IFF_TUN: libc::c_int = 0x0001;
pub const IFF_TAP: libc::c_int = 0x0002; pub const IFF_TAP: libc::c_int = 0x0002;
pub const IFF_NO_PI: libc::c_int = 0x1000; pub const IFF_NO_PI: libc::c_int = 0x1000;