Skip to content

Commit 0603ba5

Browse files
committed
Revise docs, README, and module docs
Large documentation refresh and minor doc-comment cleanups across the repo. Updates include a reorganized README (status & scope, happy-path quick start, esp-hal sync/async examples, recommended workflow, memory/DMA sizing), a new docs/README.md index, and expanded/rewritten docs: API.md, ARCHITECTURE.md, DESIGN.md, DOCUMENTATION_STANDARDS.md, and TESTING.md. Several src module doc-comments were clarified (boards, driver, hal, integration, smoltcp) and example snippets updated to reference the crate name and recommended usage. These are documentation and comment changes only; no functional logic or behavioral changes were made.
1 parent 66c8dd9 commit 0603ba5

File tree

17 files changed

+581
-621
lines changed

17 files changed

+581
-621
lines changed

README.md

Lines changed: 95 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77
## Table of Contents
88

99
1. [Overview](#overview)
10-
2. [Motivation](#motivation)
11-
3. [Goal](#goal)
12-
4. [Features](#features)
13-
5. [Supported Hardware](#supported-hardware)
14-
6. [Quick Start](#quick-start)
15-
7. [Ergonomic Helpers (esp-hal)](#ergonomic-helpers-esp-hal)
16-
8. [Examples](#examples)
17-
9. [Feature Flags](#feature-flags)
18-
10. [MSRV](#msrv)
19-
11. [Documentation](#documentation)
20-
12. [License](#license)
10+
2. [Status & Scope](#status--scope)
11+
3. [Motivation](#motivation)
12+
4. [Goal](#goal)
13+
5. [Features](#features)
14+
6. [Supported Hardware](#supported-hardware)
15+
7. [Quick Start (Happy Path)](#quick-start-happy-path)
16+
8. [Recommended Workflow](#recommended-workflow)
17+
9. [Examples](#examples)
18+
10. [Memory & DMA Sizing](#memory--dma-sizing)
19+
11. [Feature Flags](#feature-flags)
20+
12. [MSRV](#msrv)
21+
13. [Documentation](#documentation)
22+
14. [License](#license)
2123

2224
---
2325

@@ -27,6 +29,14 @@ This crate implements the ESP32 EMAC peripheral using static DMA descriptors and
2729

2830
---
2931

32+
## Status & Scope
33+
34+
- **Current target**: ESP32 (this release only)
35+
- **ESP32-P4**: Experimental placeholder (not implemented, hidden from docs)
36+
- **Happy path**: esp-hal synchronous and async bring-up on WT32-ETH01
37+
38+
---
39+
3040
## Motivation
3141

3242
There was no existing bare-metal, `no_std`, `no_alloc` Rust driver for the ESP32 MAC, which created a barrier to using `wt32_eth01.rs` in the bare-metal ecosystem.
@@ -57,71 +67,82 @@ Provide an efficient bare-metal, `no_std`, `no_alloc` implementation of the ESP3
5767

5868
---
5969

60-
## Quick Start
61-
62-
```rust
63-
use ph_esp32_mac::{Emac, EmacConfig, Lan8720a, MdioController, PhyDriver, PhyInterface, RmiiClockMode};
64-
use embedded_hal::delay::DelayNs;
65-
66-
// Static allocation is required for DMA descriptors.
67-
static mut EMAC: Emac<10, 10, 1600> = Emac::new();
68-
69-
// Your delay implementation (from esp-hal or custom).
70-
let mut delay = /* DelayNs impl */;
71-
72-
let emac = unsafe { &mut EMAC };
73-
let config = EmacConfig::rmii_esp32_default()
74-
.with_mac_address([0x02, 0x00, 0x00, 0x12, 0x34, 0x56])
75-
.with_phy_interface(PhyInterface::Rmii)
76-
.with_rmii_clock(RmiiClockMode::ExternalInput { gpio: 0 });
70+
## Quick Start (Happy Path)
7771

78-
emac.init(config, &mut delay)?;
72+
These are the recommended esp-hal bring-up paths and match the examples in
73+
`apps/examples/`.
7974

80-
let mut mdio = MdioController::new(delay);
81-
let mut phy = Lan8720a::new(1);
82-
phy.init(&mut mdio)?;
83-
84-
emac.start()?;
85-
# Ok::<(), ph_esp32_mac::Error>(())
86-
```
87-
88-
---
89-
90-
## Ergonomic Helpers (esp-hal)
91-
92-
For esp-hal users, the crate provides opinionated helpers and macros for the
93-
WT32-ETH01 “happy path” to reduce boilerplate:
75+
### esp-hal (sync)
9476

9577
```rust
9678
use esp_hal::delay::Delay;
9779
use ph_esp32_mac::esp_hal::{EmacBuilder, EmacPhyBundle, Wt32Eth01};
9880

99-
ph_esp32_mac::emac_static_sync!(EMAC);
81+
ph_esp32_mac::emac_static_sync!(EMAC, 10, 10, 1600);
10082

10183
let mut delay = Delay::new();
10284
EMAC.with(|emac| {
10385
EmacBuilder::wt32_eth01_with_mac(emac, [0x02, 0x00, 0x00, 0x12, 0x34, 0x56])
10486
.init(&mut delay)
10587
.unwrap();
10688
let mut emac_phy = EmacPhyBundle::wt32_eth01_lan8720a(emac, Delay::new());
107-
let _status = emac_phy.init_and_wait_link_up(&mut delay, 10_000, 200).unwrap();
89+
let _status = emac_phy
90+
.init_and_wait_link_up(&mut delay, 10_000, 200)
91+
.unwrap();
10892
emac.start().unwrap();
10993
});
11094
```
11195

96+
### esp-hal (async)
97+
98+
```rust
99+
use esp_hal::delay::Delay;
100+
use ph_esp32_mac::esp_hal::{EmacBuilder, EmacPhyBundle, Wt32Eth01};
101+
use ph_esp32_mac::{emac_async_isr, emac_static_async};
102+
103+
emac_static_async!(EMAC, EMAC_STATE, 10, 10, 1600);
104+
emac_async_isr!(EMAC_IRQ, esp_hal::interrupt::Priority::Priority1, &EMAC_STATE);
105+
106+
let mut delay = Delay::new();
107+
let emac_ptr = EMAC.init(ph_esp32_mac::Emac::new()) as *mut _;
108+
unsafe {
109+
EmacBuilder::wt32_eth01_with_mac(&mut *emac_ptr, [0x02, 0x00, 0x00, 0x12, 0x34, 0x56])
110+
.init(&mut delay)
111+
.unwrap();
112+
let mut emac_phy = EmacPhyBundle::wt32_eth01_lan8720a(&mut *emac_ptr, Delay::new());
113+
let _status = emac_phy
114+
.init_and_wait_link_up(&mut delay, 10_000, 200)
115+
.unwrap();
116+
(*emac_ptr).start().unwrap();
117+
}
118+
```
119+
120+
---
121+
122+
## Recommended Workflow
123+
124+
From the repo root, use `cargo xtask` to build and flash apps:
125+
126+
```bash
127+
cargo xtask run ex-esp-hal
128+
cargo xtask run ex-esp-hal-async
129+
```
130+
131+
See [xtask/README.md](xtask/README.md) for details.
132+
112133
---
113134

114135
## Examples
115136

116137
Examples are provided as a **separate crate** in this repository and are not
117138
packaged with the published library crate.
118139

119-
See the examples for build and run instructions:
120-
https://github.com/photon-circus/ph-esp32-mac/tree/main/apps/examples
140+
See [apps/examples/README.md](apps/examples/README.md) for build and run
141+
instructions.
121142

122143
Recommended runner (from repo root):
123144
```bash
124-
cargo xtask run ex-embassy
145+
cargo xtask run ex-embassy-net
125146
```
126147

127148
Included examples:
@@ -132,11 +153,31 @@ Included examples:
132153
- `embassy_net`
133154

134155
Hardware QA runner (separate crate):
135-
- https://github.com/photon-circus/ph-esp32-mac/tree/main/apps/qa-runner
156+
- [apps/qa-runner/README.md](apps/qa-runner/README.md)
136157
- `cargo xtask run qa-runner`
137158

138159
---
139160

161+
## Memory & DMA Sizing
162+
163+
Default configuration (10 RX/TX buffers, 1600 bytes each):
164+
165+
| Component | Size |
166+
|-----------|------|
167+
| RX descriptors | 320 bytes |
168+
| TX descriptors | 320 bytes |
169+
| RX buffers | 16,000 bytes |
170+
| TX buffers | 16,000 bytes |
171+
| **Total** | **~32 KB** |
172+
173+
Adjust via the static macros if memory is constrained:
174+
175+
```rust
176+
ph_esp32_mac::emac_static_sync!(EMAC, 4, 4, 1600);
177+
```
178+
179+
---
180+
140181
## Feature Flags
141182

142183
| Feature | Description |
@@ -161,9 +202,11 @@ Hardware QA runner (separate crate):
161202

162203
## Documentation
163204

164-
- [DESIGN.md](docs/DESIGN.md)
165-
- [TESTING.md](docs/TESTING.md)
166-
- [DOCUMENTATION_STANDARDS.md](docs/DOCUMENTATION_STANDARDS.md)
205+
- [docs/README.md](docs/README.md) (documentation index and TOC)
206+
- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
207+
- [CONTRIBUTING.md](CONTRIBUTING.md)
208+
- [SECURITY.md](SECURITY.md)
209+
- [CHANGELOG.md](CHANGELOG.md)
167210

168211
---
169212

0 commit comments

Comments
 (0)