|
AT25040B Driver 0.1.0
API reference
|
The SPI port of the AT25040B driver: the bus requirements, the CRTP base, its pin enums, the SpiPort concept and the instruction framing.
More...
#include <array>#include <concepts>#include <cstddef>#include <cstdint>#include <span>#include "at25040b_detail.hpp"#include "at25040b_registers.hpp"#include "at25040b_types.hpp"Go to the source code of this file.
Classes | |
| struct | at25040b::BusTiming |
| The SPI timing limits of one supply range (Table 4-3). More... | |
| class | at25040b::SpiInterface< Derived > |
| CRTP base of the platform SPI port. More... | |
Namespaces | |
| namespace | at25040b |
The AT25040B driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | at25040b::SpiPort |
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool. DelayUs() is checked where the driver first waits. | |
Enumerations | |
| enum class | at25040b::CtrlPin : uint8_t { at25040b::WriteProtect = 0 } |
Control pins the port may drive through the optional GpioSet() hook. More... | |
| enum class | at25040b::GpioSignal : uint8_t { at25040b::INACTIVE = 0 , at25040b::ACTIVE = 1 } |
| Logical level of a control pin; the port maps it to the physical polarity. More... | |
Bus requirements | |
What the AT25010B/020B/040B needs from the SPI bus (datasheet "Features", section 4.3 Table 4-3, section 5). A port and a board configuration check their settings against these with | |
| constexpr uint8_t | at25040b::kSpiMode = 0 |
| constexpr uint8_t | at25040b::kSpiModeAlternate = 3 |
| The other SPI mode the chip accepts: CPOL 1, CPHA 1 ("Features"). | |
| constexpr bool | at25040b::kMsbFirst = true |
| Each byte is clocked most significant bit first (section 5, "MSB"). | |
| constexpr uint32_t | at25040b::kMaxClockHz = 5'000'000 |
| Highest SCK frequency over the whole supply range, f_SCK max at 1.8 V to 5.5 V (Table 4-3). | |
| constexpr uint32_t | at25040b::kMinCsHighNs = 200 |
| Shortest time CS stays high between two transfers, t_CS min at 1.8 V to 5.5 V (Table 4-3). | |
| constexpr uint32_t | at25040b::kCsSetupNs = 200 |
| CS low to the first SCK edge, t_CSS min at 1.8 V to 5.5 V (Table 4-3). | |
| constexpr uint32_t | at25040b::kCsHoldNs = 200 |
| Last SCK edge to CS high, t_CSH min at 1.8 V to 5.5 V (Table 4-3). | |
| constexpr uint32_t | at25040b::kDataSetupNs = 80 |
| SI valid before the sampling SCK edge, t_SU min at 1.8 V to 5.5 V (Table 4-3). | |
| constexpr uint32_t | at25040b::kDataHoldNs = 80 |
| SI held after the sampling SCK edge, t_H min at 1.8 V to 5.5 V (Table 4-3). | |
| constexpr bool | at25040b::kContinuousWord = false |
| constexpr uint32_t | at25040b::kMinSupplyMv = 1800 |
| Lowest supply of the family, in millivolts (Table 4-3). | |
| constexpr uint32_t | at25040b::kMaxSupplyMv = 5500 |
| Highest supply of the family, in millivolts (Table 4-3). | |
| constexpr BusTiming | at25040b::BusTimingAt (uint32_t supply_mv) noexcept |
| The SPI limits at a supply voltage (Table 4-3): 4.5 V to 5.5 V allows 20 MHz, 2.5 V to 5.5 V 10 MHz, 1.8 V to 5.5 V 5 MHz. | |
The SPI port of the AT25040B driver: the bus requirements, the CRTP base, its pin enums, the SpiPort concept and the instruction framing.
The driver never calls an SDK. It calls hooks on a class you derive from at25040b::SpiInterface<Self>:
| Hook | Contract |
|---|---|
bool EnsureInitialized() noexcept | Bring the bus up on the first call; true at once afterwards |
bool Transfer(const uint8_t* tx, uint8_t* rx, std::size_t len) noexcept | One full-duplex transfer, CS low for all len bytes and high after; rx is nullptr when the driver needs no reply |
void DelayUs(uint32_t us) noexcept | Wait at least us microseconds (write cycles, status polls) |
The port moves raw bytes: it never retries, never interprets the frame and never configures the chip. What the chip needs from the bus is below as constexpr values (kSpiMode to kContinuousWord, and BusTimingAt() per supply voltage, datasheet section 4.3, Table 4-3, and section 5); a port checks its settings against them with static_assert. Every instruction starts with a CS falling edge, so CS must go high between transfers. A transfer is at most kMaxTransferBytes long. The optional hooks (GpioSet for the WP pin, Log) are described in at25040b.hpp.