mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 14:22:33 +00:00
Merge pull request #3416 from embassy-rs/update-nightly-324
Update nighlty, fix warnings.
This commit is contained in:
commit
c84495ef2e
@ -326,8 +326,14 @@ pub struct Device<'d, const MTU: usize> {
|
||||
}
|
||||
|
||||
impl<'d, const MTU: usize> embassy_net_driver::Driver for Device<'d, MTU> {
|
||||
type RxToken<'a> = RxToken<'a, MTU> where Self: 'a ;
|
||||
type TxToken<'a> = TxToken<'a, MTU> where Self: 'a ;
|
||||
type RxToken<'a>
|
||||
= RxToken<'a, MTU>
|
||||
where
|
||||
Self: 'a;
|
||||
type TxToken<'a>
|
||||
= TxToken<'a, MTU>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
||||
if self.rx.poll_receive(cx).is_ready() && self.tx.poll_send(cx).is_ready() {
|
||||
|
@ -83,10 +83,12 @@ pub trait Driver {
|
||||
}
|
||||
|
||||
impl<T: ?Sized + Driver> Driver for &mut T {
|
||||
type RxToken<'a> = T::RxToken<'a>
|
||||
type RxToken<'a>
|
||||
= T::RxToken<'a>
|
||||
where
|
||||
Self: 'a;
|
||||
type TxToken<'a> = T::TxToken<'a>
|
||||
type TxToken<'a>
|
||||
= T::TxToken<'a>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
|
@ -635,11 +635,13 @@ where
|
||||
S: SpiDevice,
|
||||
O: OutputPin,
|
||||
{
|
||||
type RxToken<'a> = RxToken<'a>
|
||||
type RxToken<'a>
|
||||
= RxToken<'a>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
type TxToken<'a> = TxToken<'a, S, O>
|
||||
type TxToken<'a>
|
||||
= TxToken<'a, S, O>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
|
@ -152,8 +152,14 @@ impl TunTapDevice {
|
||||
}
|
||||
|
||||
impl Driver for TunTapDevice {
|
||||
type RxToken<'a> = RxToken where Self: 'a;
|
||||
type TxToken<'a> = TxToken<'a> where Self: 'a;
|
||||
type RxToken<'a>
|
||||
= RxToken
|
||||
where
|
||||
Self: 'a;
|
||||
type TxToken<'a>
|
||||
= TxToken<'a>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
||||
let mut buf = vec![0; self.device.get_ref().mtu];
|
||||
|
@ -18,8 +18,14 @@ impl<'d, 'c, T> phy::Device for DriverAdapter<'d, 'c, T>
|
||||
where
|
||||
T: Driver,
|
||||
{
|
||||
type RxToken<'a> = RxTokenAdapter<T::RxToken<'a>> where Self: 'a;
|
||||
type TxToken<'a> = TxTokenAdapter<T::TxToken<'a>> where Self: 'a;
|
||||
type RxToken<'a>
|
||||
= RxTokenAdapter<T::RxToken<'a>>
|
||||
where
|
||||
Self: 'a;
|
||||
type TxToken<'a>
|
||||
= TxTokenAdapter<T::TxToken<'a>>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn receive(&mut self, _timestamp: Instant) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
||||
self.inner
|
||||
|
@ -712,7 +712,10 @@ pub mod client {
|
||||
for TcpClient<'d, N, TX_SZ, RX_SZ>
|
||||
{
|
||||
type Error = Error;
|
||||
type Connection<'m> = TcpConnection<'m, N, TX_SZ, RX_SZ> where Self: 'm;
|
||||
type Connection<'m>
|
||||
= TcpConnection<'m, N, TX_SZ, RX_SZ>
|
||||
where
|
||||
Self: 'm;
|
||||
|
||||
async fn connect<'a>(&'a self, remote: core::net::SocketAddr) -> Result<Self::Connection<'a>, Self::Error> {
|
||||
let addr: crate::IpAddress = match remote.ip() {
|
||||
|
@ -480,7 +480,7 @@ pub fn install_core0_stack_guard() -> Result<(), ()> {
|
||||
|
||||
#[cfg(all(feature = "rp2040", not(feature = "_test")))]
|
||||
#[inline(always)]
|
||||
fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
let core = unsafe { cortex_m::Peripherals::steal() };
|
||||
|
||||
// Fail if MPU is already configured
|
||||
@ -508,7 +508,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
|
||||
#[cfg(all(feature = "_rp235x", not(feature = "_test")))]
|
||||
#[inline(always)]
|
||||
fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
let core = unsafe { cortex_m::Peripherals::steal() };
|
||||
|
||||
// Fail if MPU is already configured
|
||||
@ -528,7 +528,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
// so the compile fails when we try to use ARMv8 peripherals.
|
||||
#[cfg(feature = "_test")]
|
||||
#[inline(always)]
|
||||
fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
unsafe fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ const RESUME_TOKEN: u32 = !0xDEADBEEF;
|
||||
static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
#[inline(always)]
|
||||
fn core1_setup(stack_bottom: *mut usize) {
|
||||
unsafe fn core1_setup(stack_bottom: *mut usize) {
|
||||
if install_stack_guard(stack_bottom).is_err() {
|
||||
// currently only happens if the MPU was already set up, which
|
||||
// would indicate that the core is already in use from outside
|
||||
@ -148,7 +148,7 @@ where
|
||||
entry: *mut ManuallyDrop<F>,
|
||||
stack_bottom: *mut usize,
|
||||
) -> ! {
|
||||
core1_setup(stack_bottom);
|
||||
unsafe { core1_setup(stack_bottom) };
|
||||
|
||||
let entry = unsafe { ManuallyDrop::take(&mut *entry) };
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#![allow(async_fn_in_trait)]
|
||||
#![doc = include_str!("../README.md")]
|
||||
// #![warn(missing_docs)]
|
||||
#![allow(static_mut_refs)] // TODO: Fix
|
||||
|
||||
// This must go FIRST so that all the other modules see its macros.
|
||||
mod fmt;
|
||||
|
@ -371,7 +371,7 @@ pub struct DataRequest {
|
||||
}
|
||||
|
||||
impl DataRequest {
|
||||
pub fn set_buffer<'a>(&'a mut self, buf: &'a [u8]) -> &mut Self {
|
||||
pub fn set_buffer<'a>(&'a mut self, buf: &'a [u8]) -> &'a mut Self {
|
||||
self.msdu_ptr = buf as *const _ as *const u8;
|
||||
self.msdu_length = buf.len() as u8;
|
||||
|
||||
|
@ -23,8 +23,14 @@ impl<'d> Driver<'d> {
|
||||
impl<'d> embassy_net_driver::Driver for Driver<'d> {
|
||||
// type RxToken<'a> = RxToken<'a, 'd> where Self: 'a;
|
||||
// type TxToken<'a> = TxToken<'a, 'd> where Self: 'a;
|
||||
type RxToken<'a> = RxToken<'d> where Self: 'a;
|
||||
type TxToken<'a> = TxToken<'d> where Self: 'a;
|
||||
type RxToken<'a>
|
||||
= RxToken<'d>
|
||||
where
|
||||
Self: 'a;
|
||||
type TxToken<'a>
|
||||
= TxToken<'d>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
||||
if self.runner.rx_channel.poll_ready_to_receive(cx).is_ready()
|
||||
|
@ -74,8 +74,14 @@ impl<const TX: usize, const RX: usize> PacketQueue<TX, RX> {
|
||||
static WAKER: AtomicWaker = AtomicWaker::new();
|
||||
|
||||
impl<'d, T: Instance, P: PHY> embassy_net_driver::Driver for Ethernet<'d, T, P> {
|
||||
type RxToken<'a> = RxToken<'a, 'd> where Self: 'a;
|
||||
type TxToken<'a> = TxToken<'a, 'd> where Self: 'a;
|
||||
type RxToken<'a>
|
||||
= RxToken<'a, 'd>
|
||||
where
|
||||
Self: 'a;
|
||||
type TxToken<'a>
|
||||
= TxToken<'a, 'd>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
||||
WAKER.register(cx.waker());
|
||||
|
@ -51,6 +51,9 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
// TODO: Usage of `static mut` here is unsound. Fix then remove this `allow`.`
|
||||
#![allow(static_mut_refs)]
|
||||
|
||||
use core::arch::asm;
|
||||
use core::marker::PhantomData;
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
|
@ -86,7 +86,7 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) {
|
||||
#[cfg(not(feature = "_dual-core"))]
|
||||
/// Safety: Reads a mutable global.
|
||||
pub(crate) unsafe fn get_freqs() -> &'static Clocks {
|
||||
CLOCK_FREQS.assume_init_ref()
|
||||
(*core::ptr::addr_of_mut!(CLOCK_FREQS)).assume_init_ref()
|
||||
}
|
||||
|
||||
#[cfg(feature = "_dual-core")]
|
||||
@ -171,7 +171,9 @@ impl RccInfo {
|
||||
// Use .get_mut instead of []-operator so that we control how bounds checks happen.
|
||||
// Otherwise, core::fmt will be pulled in here in order to format the integer in the
|
||||
// out-of-bounds error.
|
||||
if let Some(refcount) = unsafe { crate::_generated::REFCOUNTS.get_mut(refcount_idx) } {
|
||||
if let Some(refcount) =
|
||||
unsafe { (*core::ptr::addr_of_mut!(crate::_generated::REFCOUNTS)).get_mut(refcount_idx) }
|
||||
{
|
||||
*refcount += 1;
|
||||
if *refcount > 1 {
|
||||
return;
|
||||
@ -235,7 +237,9 @@ impl RccInfo {
|
||||
// Use .get_mut instead of []-operator so that we control how bounds checks happen.
|
||||
// Otherwise, core::fmt will be pulled in here in order to format the integer in the
|
||||
// out-of-bounds error.
|
||||
if let Some(refcount) = unsafe { crate::_generated::REFCOUNTS.get_mut(refcount_idx) } {
|
||||
if let Some(refcount) =
|
||||
unsafe { (*core::ptr::addr_of_mut!(crate::_generated::REFCOUNTS)).get_mut(refcount_idx) }
|
||||
{
|
||||
*refcount -= 1;
|
||||
if *refcount > 0 {
|
||||
return;
|
||||
|
@ -81,8 +81,9 @@ async fn main(_spawner: Spawner) {
|
||||
rx_config.sync_output = false;
|
||||
|
||||
let tx_buffer: &mut [u32] = unsafe {
|
||||
TX_BUFFER.initialize_all_copied(0);
|
||||
let (ptr, len) = TX_BUFFER.get_ptr_len();
|
||||
let buf = &mut *core::ptr::addr_of_mut!(TX_BUFFER);
|
||||
buf.initialize_all_copied(0);
|
||||
let (ptr, len) = buf.get_ptr_len();
|
||||
core::slice::from_raw_parts_mut(ptr, len)
|
||||
};
|
||||
|
||||
@ -98,8 +99,9 @@ async fn main(_spawner: Spawner) {
|
||||
);
|
||||
|
||||
let rx_buffer: &mut [u32] = unsafe {
|
||||
RX_BUFFER.initialize_all_copied(0);
|
||||
let (ptr, len) = RX_BUFFER.get_ptr_len();
|
||||
let buf = &mut *core::ptr::addr_of_mut!(RX_BUFFER);
|
||||
buf.initialize_all_copied(0);
|
||||
let (ptr, len) = buf.get_ptr_len();
|
||||
core::slice::from_raw_parts_mut(ptr, len)
|
||||
};
|
||||
|
||||
|
@ -22,10 +22,11 @@ static mut RAM_D3: GroundedArrayCell<u8, 256> = GroundedArrayCell::uninit();
|
||||
#[embassy_executor::task]
|
||||
async fn main_task(mut spi: spi::Spi<'static, Async>) {
|
||||
let (read_buffer, write_buffer) = unsafe {
|
||||
RAM_D3.initialize_all_copied(0);
|
||||
let ram = &mut *core::ptr::addr_of_mut!(RAM_D3);
|
||||
ram.initialize_all_copied(0);
|
||||
(
|
||||
RAM_D3.get_subslice_mut_unchecked(0, 128),
|
||||
RAM_D3.get_subslice_mut_unchecked(128, 128),
|
||||
ram.get_subslice_mut_unchecked(0, 128),
|
||||
ram.get_subslice_mut_unchecked(128, 128),
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2024-09-06"
|
||||
channel = "nightly-2024-10-13"
|
||||
components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ]
|
||||
targets = [
|
||||
"thumbv7em-none-eabi",
|
||||
|
@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) {
|
||||
let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(&spam_peri.tasks_starttx as *const _ as _)) };
|
||||
let mut spam_ppi = Ppi::new_one_to_one(p.PPI_CH2, event, task);
|
||||
spam_ppi.enable();
|
||||
let p = unsafe { TX_BUF.as_mut_ptr() };
|
||||
let p = unsafe { core::ptr::addr_of_mut!(TX_BUF) } as *mut u8;
|
||||
spam_peri.txd.ptr.write(|w| unsafe { w.ptr().bits(p as u32) });
|
||||
spam_peri.txd.maxcnt.write(|w| unsafe { w.maxcnt().bits(NSPAM as _) });
|
||||
spam_peri.tasks_starttx.write(|w| unsafe { w.bits(1) });
|
||||
|
@ -43,8 +43,7 @@ async fn main(spawner: Spawner) {
|
||||
let usart = Uart::new(usart, rx, tx, irq, tx_dma, rx_dma, config).unwrap();
|
||||
let (tx, rx) = usart.split();
|
||||
static mut DMA_BUF: [u8; DMA_BUF_SIZE] = [0; DMA_BUF_SIZE];
|
||||
let dma_buf = unsafe { DMA_BUF.as_mut() };
|
||||
let rx = rx.into_ring_buffered(dma_buf);
|
||||
let rx = rx.into_ring_buffered(unsafe { &mut *core::ptr::addr_of_mut!(DMA_BUF) });
|
||||
|
||||
info!("Spawning tasks");
|
||||
spawner.spawn(transmit_task(tx)).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user