Explain the const params N_RX & N_TX in the docs of State

On chips with a low amount of ram it's easy to run out of ram. When
looking at the current docs for the State struct it is not easy to
see that these params can cause a lot of ram usage.
This commit is contained in:
dvdsk 2024-06-07 23:06:30 +02:00
parent 5f9bc6def7
commit 72c2b06520
No known key found for this signature in database
GPG Key ID: 6CF9D20C5709A836

View File

@ -17,12 +17,22 @@ use embedded_hal_async::spi::SpiDevice;
use crate::chip::Chip;
use crate::device::WiznetDevice;
// If you change this update the docs of State
const MTU: usize = 1514;
/// Type alias for the embassy-net driver.
pub type Device<'d> = embassy_net_driver_channel::Device<'d, MTU>;
/// Internal state for the embassy-net integration.
///
/// The two generic arguments `N_RX` and `N_TX` set the size of the receive and
/// send packet queue. With a the ethernet MTU of _1514_ this takes up `N_RX +
/// NTX * 1514` bytes. While setting these both to 1 is the minimum this might
/// hurt performance as a packet can not be received while processing another.
///
/// # Warning
/// On devices with a small amount of ram (think ~64k) watch out with the size
/// of there parameters. They will quickly use too much RAM.
pub struct State<const N_RX: usize, const N_TX: usize> {
ch_state: ch::State<MTU, N_RX, N_TX>,
}