External Storage (microSD)
External Storage (microSD)
The Snake V1 utilizes an external microSD card slot to facilitate long-term data logging, firmware updates, and storage for captured peripheral data (such as Sub-GHz sequences or IR codes).
Hardware Overview: Molex 47352-1001
The device features a Molex 47352-1001 microSD connector. This is a high-quality, top-mount, push-push type connector designed for durability in portable devices.
| Feature | Specification | | :--- | :--- | | Connector Type | microSD Card (TransFlash) | | Mechanism | Push-Push (Ejector type) | | Mounting | Surface Mount (SMT) | | Durability | 10,000 Mating Cycles | | Card Detection | Integrated detection switch |
Communication Protocols
The STM32WB35CEU6A microcontroller interfaces with the microSD card via the SDMMC (Secure Digital Multi-Media Card) interface, though it can fall back to SPI depending on software configuration.
SDMMC (Recommended)
By default, the system is designed to use the SDMMC interface. This provides higher throughput compared to SPI, which is critical when logging high-frequency Sub-GHz traffic or performing bulk transfers.
- Bus Width: 1-bit or 4-bit modes.
- Clock Speed: Configurable up to 48MHz (depending on card class and MCU stability).
SPI Mode
For low-power scenarios or specific debugging configurations, the microSD slot can be accessed via the Serial Peripheral Interface (SPI).
- Interface: SPI1 or SPI2 (MCU dependent).
- Usage: Primarily for basic file read/write operations where high-speed data transfer is not a priority.
Data Logging and Filesystem
The Snake V1 typically employs the FatFs (Generic FAT File System) module to handle data organization. This allows logs to be easily read on a PC or mobile device.
Usage Example: Logging Peripheral Data
To log data from a peripheral (e.g., an IR receiver), initialize the SD card and open a file handle. The following logic illustrates the standard implementation for writing logs:
/* Simple data logging workflow */
// 1. Mount the filesystem
if (f_mount(&SDFatFS, SDPath, 1) == FR_OK) {
// 2. Open or create a log file
if (f_open(&SDFile, "LOG.TXT", FA_OPEN_APPEND | FA_WRITE) == FR_OK) {
// 3. Write data (e.g., IR signal capture)
char *log_entry = "IR_CODE: 0xE0E040BF\n";
uint32_t bytes_written;
f_write(&SDFile, log_entry, strlen(log_entry), &bytes_written);
// 4. Close the file to ensure data is flushed
f_close(&SDFile);
}
}
Card Detection
The Molex connector includes a mechanical detection switch. The system monitors this pin to handle "Hot Plugging." It is recommended to check the card presence status before initiating any filesystem operations to prevent system hangs or data corruption.
- Status Check: Accessible via a GPIO input pin (configured with internal pull-up).
- Internal Logic: When a card is inserted, the detection pin is shorted to ground, signaling the system that the storage media is ready for mounting.