$ show Marzogh/SPIMemory
SPIMemory is an Arduino library providing a high-level interface for SPI Flash and FRAM memory chips. It supports reading, writing, and erasing data of various types (byte, char, word, long, float, string, arrays, structs) across a wide range of microcontrollers (AVR, SAM, SAMD, ESP8266, ESP32, STM32, nRF52, etc.) and memory chip manufacturers. The library automatically identifies chips via JEDEC IDs and the SFDP standard (JESD216B), manages address allocation, and offers optional error checking and high-speed modes. It is not a standalone application but a reusable component for embedded firmware projects requiring external non-volatile storage. The codebase demonstrates solid engineering with template-based I/O, conditional compilation for platform support, and a consistent error-reporting pattern. However, it shows signs of technical drift: dual documentation systems (Sphinx and MkDocs) with stale build artifacts, outdated jQuery in docs, beta features (FRAM, ESP32 custom SPI), and some commented-out debug prints. The library is actively maintained (recent commits, version 3.4.0) but has 71 open issues, indicating ongoing development and community use.
The LLM identified 4 files worth highlighting for reuse:
Defines template functions `readAnything<T>()` and `writeAnything<T>()` that allow reading/writing any trivially-copyable type (including structs) over SPI. This pattern decouples data serialization from the memory protocol and is reusable in any SPI memory library or embedded project requiring type-agnostic storage.
Implements a singleton `diagnostics` class with human-readable error codes and troubleshooting URLs. Provides `error(VERBOSE)` method for detailed diagnostics. This pattern is reusable across embedded libraries for consistent error handling and debugging without tight coupling to the main logic.
Parses JESD216B Serial Flash Discoverable Parameters (SFDP) tables to automatically detect chip capacity, erase sizes, and timing. Demonstrates a clean pattern for reading structured binary data from a device and extracting parameters. Reusable in any project that needs to auto-configure to unknown SPI flash chips.
Contains the low-level SPI transaction management (`_prep`, `_beginSPI`, `_nextByte`, `_nextBuf`, `_endSPI`) that handles chip select, SPI mode, and clock configuration across multiple architectures. This pattern encapsulates platform-specific SPI details behind a consistent interface and can be extracted for other SPI device drivers.