|
AS5047U Driver 0.1.0
API reference
|
The SPI port of the AS5047U driver: the CRTP base, the SpiPort concept and the frame layer.
More...
#include <array>#include <concepts>#include <cstddef>#include <cstdint>#include "as5047u_detail.hpp"#include "as5047u_registers.hpp"#include "as5047u_types.hpp"Go to the source code of this file.
Classes | |
| class | as5047u::SpiInterface< Derived > |
| CRTP base of the platform SPI port. More... | |
Namespaces | |
| namespace | as5047u |
The AS5047U driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | as5047u::SpiPort |
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool. | |
Functions | |
| constexpr uint8_t | as5047u::Crc8 (uint16_t word) noexcept |
| CRC-8 of a 16-bit frame word: polynomial 0x1D, initial value 0xC4, final XOR 0xFF, not reflected (datasheet "CRC Checksum", Figure 31). Table-driven; equal to the bitwise definition for every word (tests/test_as5047u.cpp). | |
Variables | |
Bus requirements | |
What the AS5047U needs from the SPI bus (datasheet "SPI Interface (Slave)", "SPI Timing", Figures 18 and 19, and "SPI Transaction", Figures 20 to 28). A port and a board configuration check their settings against these with | |
| constexpr uint8_t | as5047u::kSpiMode = 1 |
| SPI mode 1: CPOL 0, CPHA 1. The chip samples MOSI on the falling edge of CLK. | |
| constexpr bool | as5047u::kMsbFirst = true |
| Each frame is clocked most significant bit first. | |
| constexpr uint32_t | as5047u::kMaxClockHz = 10'000'000 |
| Highest CLK frequency: t_clk min 100 ns, so 10 MHz. | |
| constexpr uint32_t | as5047u::kMinCsHighNs = 350 |
| constexpr uint32_t | as5047u::kCsSetupNs = 350 |
| CS falling edge to the first CLK rising edge, t_L. | |
| constexpr uint32_t | as5047u::kCsHoldNs = 50 |
Last CLK falling edge to CS rising edge, t_H: t_clk / 2, so 50 ns at kMaxClockHz. | |
| constexpr bool | as5047u::kContinuousWord = false |
| constexpr std::array< uint8_t, 3 > | as5047u::kFrameBits = {16, 24, 32} |
| Frame lengths in bits the chip accepts: 16 (reads only, no CRC), 24 and 32 (Figures 20, 23, 26). | |
The SPI port of the AS5047U driver: the CRTP base, the SpiPort concept and the frame layer.
The driver never calls an SDK. It calls hooks on a class you derive from as5047u::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 frame, CS low for all len bytes |
The port moves raw bytes: it never retries and never interprets a frame. What the chip needs from the bus is below as constexpr values (kSpiMode to kContinuousWord, datasheet DS000637, "SPI
Interface (Slave)" and "SPI Timing", Figures 18 and 19); a port checks its settings against them with static_assert (handbook KB-CPP-123). CS must go high between frames, because the chip executes a frame on the rising CS edge and finds its length from the clocks while CS was low. The hooks DelayUs (required) and Log (optional) are described in as5047u.hpp.