39 lines
978 B
Markdown
39 lines
978 B
Markdown
|
|
## Exercise 05: SD Card Watcher
|
||
|
|
|
||
|
|
This exercise continuously watches SD card presence and prints state-change events.
|
||
|
|
|
||
|
|
Watcher behavior:
|
||
|
|
|
||
|
|
1. Initializes PMU and enables SD power rail (AXP2101 BLDO1).
|
||
|
|
2. Polls for card changes with debounced state transitions.
|
||
|
|
3. Emits events only on change:
|
||
|
|
- `EVENT: card inserted/mounted`
|
||
|
|
- `EVENT: card removed/unavailable`
|
||
|
|
- `EVENT: no card detected`
|
||
|
|
4. On mount event, prints card info and runs SD write workflow.
|
||
|
|
5. Every 15 seconds while mounted, runs a periodic write/permission check.
|
||
|
|
6. Uses fast preferred probe (`HSPI @ 400k`) and occasional full fallback scan.
|
||
|
|
|
||
|
|
Files used in this exercise:
|
||
|
|
- `/Exercise_05_test.txt`
|
||
|
|
- `/test/testsub1/testsubsub1/Exercise_05_test.txt`
|
||
|
|
|
||
|
|
## Build
|
||
|
|
|
||
|
|
```bash
|
||
|
|
source /home/jlpoole/rnsenv/bin/activate
|
||
|
|
pio run -e node_a
|
||
|
|
```
|
||
|
|
|
||
|
|
## Upload
|
||
|
|
|
||
|
|
```bash
|
||
|
|
source /home/jlpoole/rnsenv/bin/activate
|
||
|
|
pio run -e node_a -t upload --upload-port /dev/ttyACM0
|
||
|
|
```
|
||
|
|
|
||
|
|
## Monitor
|
||
|
|
|
||
|
|
```bash
|
||
|
|
screen /dev/ttyACM0 115200
|
||
|
|
```
|