|
AT25040B Driver 0.1.0
API reference
|
Errors, results, variants and configuration. More...
Classes | |
| struct | at25040b::Result< T > |
| The value of a call, or why there is none. More... | |
| struct | at25040b::Result< void > |
| The result of a call that returns no value. More... | |
| struct | at25040b::Status |
| The status register, decoded (Tables 6-2 and 6-3). More... | |
| struct | at25040b::Config |
What the driver is told about the board. The chip itself has nothing to configure: its only setting, the block protection, is non-volatile and set with SetBlockProtection(). More... | |
Functions | |
| constexpr const char * | at25040b::ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr std::size_t | at25040b::CapacityBytes (Variant variant) noexcept |
| Array size of a variant. | |
| constexpr std::size_t | at25040b::ProtectedFrom (Variant variant, BlockProtect level) noexcept |
| First protected address of a protection level (Table 6-4). | |
| constexpr Error | at25040b::Validate (const Config &config) noexcept |
| Check a configuration without touching the chip. | |
| constexpr const char * | at25040b::GetDriverVersion () noexcept |
| constexpr uint32_t | at25040b::GetDriverVersionMajor () noexcept |
| constexpr uint32_t | at25040b::GetDriverVersionMinor () noexcept |
| constexpr uint32_t | at25040b::GetDriverVersionPatch () noexcept |
Variables | |
| constexpr std::size_t | at25040b::kPageSizeBytes = 8 |
| Bytes per page: a WRITE never crosses an 8-byte page (section 6, "Write Sequence"). | |
| constexpr std::size_t | at25040b::kReadChunkBytes = 16 |
Data bytes per READ transfer: Read() splits longer requests into transfers of at most this many data bytes. | |
| constexpr std::size_t | at25040b::kMaxTransferBytes = 2 + kReadChunkBytes |
Longest transfer the driver asks of the port: opcode, address byte and kReadChunkBytes. | |
| constexpr uint32_t | at25040b::kWriteCycleMaxUs = 5000 |
| Longest self-timed write cycle t_WC, in microseconds (Table 4-3, maximum, every supply). | |
| constexpr uint32_t | at25040b::kPollIntervalUs = 100 |
| Time between two status reads while the driver waits for a write cycle, in microseconds. | |
| constexpr uint32_t | at25040b::kWriteTimeoutMaxUs = 1000000 |
Longest Config::write_timeout_us the driver accepts, in microseconds (one second). | |
| constexpr std::size_t | at25040b::kIdentityReadBytes = 8 |
Bytes from address 0 that EnsureInitialized() reads twice when check_write_enable is off. | |
Errors, results, variants and configuration.
|
strong |
Block write protection level, BP1:BP0 in the status register (Table 6-4).
The protected part is always at the top of the array; the addresses depend on the variant (ProtectedFrom()).
| Enumerator | |
|---|---|
| None | BP1:BP0 = 00: nothing protected. The value of a new part. |
| UpperQuarter | 01: the top quarter is read-only (0x180 to 0x1FF on the AT25040B). |
| UpperHalf | 10: the top half is read-only (0x100 to 0x1FF on the AT25040B). |
| All | 11: the whole array is read-only. |
|
strong |
Why a call failed. Every call of the driver returns one of these in its Result.
Values 0 to 9 are the shared base set; chip-specific values start at 16. [[nodiscard]] on the type: a function that returns a bare Error cannot have it ignored either (KB-CPP20-037).
| Enumerator | |
|---|---|
| Ok | The call succeeded. |
| NotInitialized |
|
| InvalidArgument | An argument or a |
| Bus | A transfer hook ( |
| Timeout | After the start, the status read busy (0xFF) for longer than |
| DeviceIdMismatch | At start-up, the bus answers but not like an AT25xxxB: the status is neither idle nor busy (0x05 is MOSI echoed onto MISO), or the write enable latch did not follow WREN and WRDI (MISO stuck low, no chip, or WP held low with |
| Crc | Not returned by this driver (the chip sends no CRC). |
| Busy | Not returned by this driver: every call waits for a write cycle. |
| DeviceFault | Not returned by this driver (the chip reports no faults). |
| Unsupported | Not returned by this driver. |
| NoDevice | At start-up, the status read 0xFF for longer than |
| BusNoise | A reply no working chip gives: two reads of the same thing differed, or after the start a status byte was neither idle nor busy. |
| WriteProtected | WREN did not set the write enable latch: the WP pin is low (tied low, or the port's WP hook did not release it), or the WREN frame was lost. Nothing was written. |
| BlockProtected | The range lies in the block-protected part of the array (BP1, BP0); only the status was read, nothing was written. |
| WriteMismatch | After a write the chip does not hold what was sent: the read-back differed ( |
| Pin | The port's |
|
strong |
|
strong |
Which part of the family is fitted. The chip cannot tell its size, so it is configured.
The three parts share the instruction set, the 8-byte page and the status register; only the array size differs, and only the AT25040B uses address bit A8 (datasheet "Description", Table 6-1 note 1).
| Enumerator | |
|---|---|
| At25010b | 128 bytes (1 Kbit). |
| At25020b | 256 bytes (2 Kbit). |
| At25040b | 512 bytes (4 Kbit), A8 in the opcode. The default. |
|
strong |
Extra verification for one Read() or Write() call, chosen per call.
The datasheet needs neither: Verify::None, the default, sends only what it needs, plus the status reads that keep a call off a busy chip. Verify::ReadBack costs transfers on the bus and is for a caller that has no CRC or signature of its own over the data.
|
constexprnoexcept |
Array size of a variant.
| variant | The part. |
|
constexprnoexcept |
"0.1.0", from the generated at25040b_version.h. No I/O.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
First protected address of a protection level (Table 6-4).
| variant | The part. |
| level | The level. |
CapacityBytes(variant) when nothing is protected.
|
constexprnoexcept |
The name of an error, for logs.
| error | The error. |
"Timeout"; "Unknown" for a value that is not an enumerator. Check a configuration without touching the chip.
| config | The configuration. |
Error::Ok, or Error::InvalidArgument when the variant is not an enumerator or the timeout is below kWriteCycleMaxUs or above kWriteTimeoutMaxUs.
|
inlineconstexpr |
Data bytes per READ transfer: Read() splits longer requests into transfers of at most this many data bytes.
The datasheet sets no limit (a READ continues through the array, section 6, "Read Sequence"), so this is a design choice, sized by what it costs:
kMaxTransferBytes (18) is the longest transfer a port must take, and the driver object holds two buffers of that size (36 bytes, see detail::EepromBus). A whole-array chunk would make that 2 x 514 bytes in every driver object and every port's DMA descriptor.Read() never holds a shared bus for more than 18 x 8 = 144 SCK cycles: 29 us at the 5 MHz of the full supply range, 7.2 us at 20 MHz.Verify::ReadBack: two whole pages per chunk, so the compare buffer is 16 bytes.Not a Config value: the buffers are sized at compile time from it, and no setting of it changes what the chip does. A port with a smaller transfer limit cannot use this driver as it is.