diff options
| author | dvdsk <[email protected]> | 2024-06-07 23:06:30 +0200 |
|---|---|---|
| committer | dvdsk <[email protected]> | 2024-06-07 23:06:30 +0200 |
| commit | 72c2b06520a2e25e180df6d89d5b3b39a8380f0c (patch) | |
| tree | a592957df24e87b03b0131c7ec3b71f59625b839 | |
| parent | 5f9bc6def7ea8698a6ce45d8e12e1d1bd8cce876 (diff) | |
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.
| -rw-r--r-- | embassy-net-wiznet/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/embassy-net-wiznet/src/lib.rs b/embassy-net-wiznet/src/lib.rs index da70d22bd..545b2a2e4 100644 --- a/embassy-net-wiznet/src/lib.rs +++ b/embassy-net-wiznet/src/lib.rs | |||
| @@ -17,12 +17,22 @@ use embedded_hal_async::spi::SpiDevice; | |||
| 17 | use crate::chip::Chip; | 17 | use crate::chip::Chip; |
| 18 | use crate::device::WiznetDevice; | 18 | use crate::device::WiznetDevice; |
| 19 | 19 | ||
| 20 | // If you change this update the docs of State | ||
| 20 | const MTU: usize = 1514; | 21 | const MTU: usize = 1514; |
| 21 | 22 | ||
| 22 | /// Type alias for the embassy-net driver. | 23 | /// Type alias for the embassy-net driver. |
| 23 | pub type Device<'d> = embassy_net_driver_channel::Device<'d, MTU>; | 24 | pub type Device<'d> = embassy_net_driver_channel::Device<'d, MTU>; |
| 24 | 25 | ||
| 25 | /// Internal state for the embassy-net integration. | 26 | /// Internal state for the embassy-net integration. |
| 27 | /// | ||
| 28 | /// The two generic arguments `N_RX` and `N_TX` set the size of the receive and | ||
| 29 | /// send packet queue. With a the ethernet MTU of _1514_ this takes up `N_RX + | ||
| 30 | /// NTX * 1514` bytes. While setting these both to 1 is the minimum this might | ||
| 31 | /// hurt performance as a packet can not be received while processing another. | ||
| 32 | /// | ||
| 33 | /// # Warning | ||
| 34 | /// On devices with a small amount of ram (think ~64k) watch out with the size | ||
| 35 | /// of there parameters. They will quickly use too much RAM. | ||
| 26 | pub struct State<const N_RX: usize, const N_TX: usize> { | 36 | pub struct State<const N_RX: usize, const N_TX: usize> { |
| 27 | ch_state: ch::State<MTU, N_RX, N_TX>, | 37 | ch_state: ch::State<MTU, N_RX, N_TX>, |
| 28 | } | 38 | } |
