Driver
AT25040B Driver¶
A C++20 driver for the Microchip (formerly Atmel) AT25010B, AT25020B and AT25040B SPI serial EEPROMs. It checks that a chip really answers before trusting it, reads any range, writes page by page with the write enable latch, the write cycle and a read-back checked at every step, drives the WP pin and sets the block protection, on any MCU.
The driver has no platform code. You give it a small class that brings the bus up, moves bytes and waits; it does the rest: the identity check, the instruction framing with A8, the page split, the write cycle, the WP pin and the checks that catch a dead or noisy bus.
- Memory
- 128, 256 or 512 bytes; 8-byte pages; 1,000,000 write cycles, 100 years retention
- Interface
- SPI mode 0 or 3; 20 MHz from 4.5 V, 10 MHz from 2.5 V, 5 MHz from 1.8 V
- Write cycle
- Self-timed, 5 ms at most; no erase before a write
- Protection
- WP pin, write enable latch (WREN, WRDI), non-volatile block protection of a quarter, a half or all of the array
- Supply
- 1.8 V to 5.5 V
What you get¶
- One object per chip.
AT25040B<YourPort>takes a reference to your port and does no I/O untilEnsureInitialized(). See API guide. - A probe that a dead bus cannot pass. The start-up check reads the status twice and toggles the write enable latch, so a floating, stuck or echoing MISO fails it. See Contract.
- Writes you can trust. Page split, WREN per page, WEN checked, the write cycle waited for, each page read back. See API guide.
- Errors you can act on. Every call returns
Result<T>with anErrorsuch asNoDevice,BusNoiseorWriteProtected. See API guide. - No heap, no exceptions, no RTTI. The host tests build with
-fno-exceptions -fno-rtti. See Contract. - Tested without hardware. Host tests and a fuzzer run the driver against a protocol model of the chip. See Testing and CI. Not yet verified on hardware: Status and limitations.
Datasheet¶
| Document | Revision | Get it |
|---|---|---|
| Datasheet: AT25010B, AT25020B, AT25040B SPI Serial EEPROM (Microchip (Atmel) Atmel-8707) | F, 2015-01 | PDF ยท vendor page |
Written against these revisions; the SHA-256 of each file is in docs/datasheets.yml. Where each part
of the driver is in the datasheet: Datasheet map.
Where to go next¶
-
Wire the chip, write the port, read the first bytes in about 15 lines.
-
Pins, instructions, timing, WP and HOLD, block protection.
-
What the driver promises, what it needs, threading and errors.
-
Probe, read, write, protect, and use it from a handler.
-
Implement the port for your MCU.
-
Every class and member, generated from the headers.