aboutsummaryrefslogtreecommitdiff
path: root/embassy-net-esp-hosted/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-net-esp-hosted/src/lib.rs')
-rw-r--r--embassy-net-esp-hosted/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/embassy-net-esp-hosted/src/lib.rs b/embassy-net-esp-hosted/src/lib.rs
index d61eaef3a..ce7f39dc1 100644
--- a/embassy-net-esp-hosted/src/lib.rs
+++ b/embassy-net-esp-hosted/src/lib.rs
@@ -97,12 +97,14 @@ enum InterfaceType {
97const MAX_SPI_BUFFER_SIZE: usize = 1600; 97const MAX_SPI_BUFFER_SIZE: usize = 1600;
98const HEARTBEAT_MAX_GAP: Duration = Duration::from_secs(20); 98const HEARTBEAT_MAX_GAP: Duration = Duration::from_secs(20);
99 99
100/// Shared driver state.
100pub struct State { 101pub struct State {
101 shared: Shared, 102 shared: Shared,
102 ch: ch::State<MTU, 4, 4>, 103 ch: ch::State<MTU, 4, 4>,
103} 104}
104 105
105impl State { 106impl State {
107 /// Shared state for the
106 pub fn new() -> Self { 108 pub fn new() -> Self {
107 Self { 109 Self {
108 shared: Shared::new(), 110 shared: Shared::new(),
@@ -111,8 +113,13 @@ impl State {
111 } 113 }
112} 114}
113 115
116/// Type alias for network driver.
114pub type NetDriver<'a> = ch::Device<'a, MTU>; 117pub type NetDriver<'a> = ch::Device<'a, MTU>;
115 118
119/// Create a new esp-hosted driver using the provided state, SPI peripheral and pins.
120///
121/// Returns a device handle for interfacing with embassy-net, a control handle for
122/// interacting with the driver, and a runner for communicating with the WiFi device.
116pub async fn new<'a, SPI, IN, OUT>( 123pub async fn new<'a, SPI, IN, OUT>(
117 state: &'a mut State, 124 state: &'a mut State,
118 spi: SPI, 125 spi: SPI,
@@ -144,6 +151,7 @@ where
144 (device, Control::new(state_ch, &state.shared), runner) 151 (device, Control::new(state_ch, &state.shared), runner)
145} 152}
146 153
154/// Runner for communicating with the WiFi device.
147pub struct Runner<'a, SPI, IN, OUT> { 155pub struct Runner<'a, SPI, IN, OUT> {
148 ch: ch::Runner<'a, MTU>, 156 ch: ch::Runner<'a, MTU>,
149 state_ch: ch::StateRunner<'a>, 157 state_ch: ch::StateRunner<'a>,
@@ -166,6 +174,7 @@ where
166{ 174{
167 async fn init(&mut self) {} 175 async fn init(&mut self) {}
168 176
177 /// Run the packet processing.
169 pub async fn run(mut self) -> ! { 178 pub async fn run(mut self) -> ! {
170 debug!("resetting..."); 179 debug!("resetting...");
171 self.reset.set_low().unwrap(); 180 self.reset.set_low().unwrap();