Skip to content

Commit 549b61e

Browse files
committed
Add common mistakes sections to all function docs
1 parent f034939 commit 549b61e

46 files changed

Lines changed: 276 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/api/functions/begin.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Returns `true` on successful initialization and chip identification. Returns `fa
2525

2626
Failure usually indicates wiring issues, wrong CS pin, unsupported chip, incorrect voltage levels, or SPI bus mismatch. Check `error(VERBOSE)` immediately.
2727

28+
## Common Mistakes
29+
30+
- Calling memory I/O before `begin()` has succeeded.
31+
- Passing a custom `flashChipSize` that does not match real hardware.
32+
- Ignoring a `false` return and continuing instead of checking `error(VERBOSE)`.
33+
2834
## Example
2935

3036
```cpp

docs/api/functions/constructors-spiflash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Constructors do not return values. They create the object and store interface co
2828

2929
Misconfigured pins or bus selection are usually detected at `begin()` time via failed ID reads or error codes.
3030

31+
## Common Mistakes
32+
33+
- Using wrong CS pin relative to your wiring diagram.
34+
- Selecting alternate SPI bus constructor on a board/core that does not support it.
35+
- Passing custom SPI pin arrays that do not match board capabilities.
36+
3137
## Example
3238

3339
```cpp

docs/api/functions/constructors-spifram.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Constructors do not return values; they prepare the instance.
2626

2727
Incorrect bus/pin choices usually surface during `begin()` with zero IDs or non-zero error codes.
2828

29+
## Common Mistakes
30+
31+
- Using incorrect CS pin or alternate bus for your board wiring.
32+
- Assuming constructor validates wiring immediately (validation happens at `begin()`).
33+
- Reusing examples with different board pin numbering conventions without adjustment.
34+
2935
## Example
3036

3137
```cpp

docs/api/functions/eraseBlock32k.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Returns `true` when erase completes.
2424

2525
May fail on chips lacking 32 KB erase opcode or when write/ready checks fail.
2626

27+
## Common Mistakes
28+
29+
- Using 32 KB erase for tiny updates, causing unnecessary data loss.
30+
- Assuming all chips support 32 KB erase opcode.
31+
- Not preserving neighboring data in same erase block.
32+
2733
## Example
2834

2935
```cpp

docs/api/functions/eraseBlock64k.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Returns `true` on success.
2424

2525
Unsupported opcode/chip profile mismatch or bus errors can fail this call.
2626

27+
## Common Mistakes
28+
29+
- Erasing a 64 KB block when only a small region needed reset.
30+
- Failing to back up adjacent data in same block.
31+
- Treating block erase boundaries as page boundaries.
32+
2733
## Example
2834

2935
```cpp

docs/api/functions/eraseChip.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Returns `true` when full erase/clear succeeds.
2525

2626
Operation can be long on large flash chips. Power loss mid-operation may leave partially erased contents.
2727

28+
## Common Mistakes
29+
30+
- Running chip erase in normal flow instead of explicit maintenance/reset paths.
31+
- Not warning users that operation is destructive and long-running.
32+
- Power-cycling mid-erase and assuming data integrity afterwards.
33+
2834
## Example
2935

3036
```cpp

docs/api/functions/eraseSection.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Returns `true` when clear operation completed successfully.
2626

2727
Invalid ranges, protected states, busy chip state, or unsupported erase granularity can cause failure.
2828

29+
## Common Mistakes
30+
31+
- Erasing too small a region before rewriting larger payloads.
32+
- Assuming section erase aligns exactly to your object boundaries.
33+
- Not accounting for erase latency in time-sensitive loops.
34+
2935
## Example
3036

3137
```cpp

docs/api/functions/eraseSector.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Returns `true` on successful sector erase.
2424

2525
Fails if chip is busy, write-enable path fails, address invalid, or erase opcode unsupported.
2626

27+
## Common Mistakes
28+
29+
- Expecting arbitrary byte-range erase; this targets 4 KB sector granularity.
30+
- Erasing wrong sector by passing nearby but unintended address.
31+
- Not checking return code before writing new data.
32+
2733
## Example
2834

2935
```cpp

docs/api/functions/error.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Returns numeric error code (`0` generally means no current error).
2525

2626
Calling much later can hide root cause because newer operations may overwrite error context.
2727

28+
## Common Mistakes
29+
30+
- Reading `error()` long after the failing call, losing useful context.
31+
- Ignoring non-zero error values during early bring-up.
32+
- Using `error()` without `VERBOSE` while debugging first hardware setup.
33+
2834
## Example
2935

3036
```cpp

docs/api/functions/functionruntime.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Returns elapsed runtime value of previous operation.
2525

2626
Interpret values carefully: runtime depends on operation type, chip state, and diagnostic compile settings.
2727

28+
## Common Mistakes
29+
30+
- Comparing runtimes from different operation types directly.
31+
- Benchmarking with unstable wiring and reading too much into variance.
32+
- Forgetting that diagnostics/build settings can affect reported timing.
33+
2834
## Example
2935

3036
```cpp

0 commit comments

Comments
 (0)