|
AS5047U Driver 0.1.0
API reference
|
Errors, results, configuration and decoded registers. More...
Classes | |
| struct | as5047u::Result< T > |
| The value of a call, or why there is none. More... | |
| struct | as5047u::Result< void > |
| The result of a call that returns no value. More... | |
| struct | as5047u::Config |
Everything EnsureInitialized() and ApplyConfig() write to the chip. More... | |
| struct | as5047u::OtpBurnConfirm |
The typed confirmation ProgramOtp() requires: burning the OTP cannot be undone, so the call names its intent and a stray integer cannot stand in for it (KB-CPP-045, KB-CPP20-030). More... | |
| struct | as5047u::ErrorFlags |
| ERRFL, decoded. Reading ERRFL clears it on the chip. More... | |
| struct | as5047u::Diagnostics |
| DIA, decoded: the state of the chip's internal loops. More... | |
| struct | as5047u::OtpReport |
Outcome of AS5047U::ProgramOtp(). More... | |
Typedefs | |
| using | as5047u::NonVolatileRegisters = std::array< uint16_t, reg::kNonVolatileCount > |
The non-volatile registers DISABLE to ECC, in address order; index with reg::At(reg::NvIndex). | |
Functions | |
| constexpr const char * | as5047u::ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr Error | as5047u::Validate (const Config &config) noexcept |
| Check a configuration without touching the chip. | |
| constexpr float | as5047u::CountsToDegrees (uint16_t counts) noexcept |
| Convert angle counts to degrees. | |
| constexpr float | as5047u::CountsToRadians (uint16_t counts) noexcept |
| Convert angle counts to radians. | |
| constexpr const char * | as5047u::GetDriverVersion () noexcept |
| constexpr uint32_t | as5047u::GetDriverVersionMajor () noexcept |
| constexpr uint32_t | as5047u::GetDriverVersionMinor () noexcept |
| constexpr uint32_t | as5047u::GetDriverVersionPatch () noexcept |
Variables | |
| constexpr uint32_t | as5047u::kPowerOnTimeMs = 10 |
| constexpr uint32_t | as5047u::kStartupTimeoutMaxMs = 1000 |
Largest Config::startup_timeout_ms that Validate() accepts. | |
| constexpr uint16_t | as5047u::kCountsPerRevolution = 16384 |
| Angle counts per revolution (14 bits). | |
| constexpr uint16_t | as5047u::kMaxAngleCount = kCountsPerRevolution - 1U |
| Highest angle count. | |
| constexpr float | as5047u::kVelocityDegPerSecPerLsb = 24.141F |
| Velocity resolution in degrees per second per LSB (datasheet, VEL register). | |
| constexpr float | as5047u::kPi = 3.14159265358979323846F |
Pi, as a float (C++20's std::numbers is not on every embedded toolchain). | |
| constexpr uint32_t | as5047u::kOtpBurnTimeoutMs = 100 |
| constexpr OtpBurnConfirm | as5047u::kOtpConfirm {0x0B7B'0B7BU} |
The confirmation to pass to ProgramOtp(). | |
| constexpr uint8_t | as5047u::kMax3BitCode = 7 |
The highest field code for 3-bit fields (filter_k_*_code, abi_resolution_code). | |
| constexpr uint8_t | as5047u::kMaxHysteresisCode = 3 |
| The highest hysteresis code (2-bit field). | |
| constexpr uint8_t | as5047u::kMaxUvwPolePairs = 7 |
| Highest UVW pole-pair count. | |
Errors, results, configuration and decoded registers.
|
strong |
|
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. The type is [[nodiscard]]: a call whose Error is dropped does not compile quietly (KB-CPP20-037).
| Enumerator | |
|---|---|
| Ok | The call succeeded. |
| NotInitialized |
|
| InvalidArgument | An argument or a |
| Bus | A port hook returned |
| Timeout | The OTP burn did not finish in |
| DeviceIdMismatch | Something answers at start-up, but DIA has bit 10 set, which reads 0 on an AS5047U: not this chip. |
| Crc | A reply's CRC was wrong, or the chip saw a wrong CRC (ERRFL.CRC_error). |
| Busy | Not returned by this driver (the chip has no busy state). |
| DeviceFault | ERRFL reports a fault of the measurement path (P2RAM, watchdog, CORDIC, offset compensation): the value is not a measurement. |
| Unsupported | Not returned by this driver. |
| Framing | The chip saw an SPI framing error (ERRFL.Framing_error). |
| Command | The chip saw an invalid command (ERRFL.Command_error). |
| WriteMismatch | A register read back different from what was written. |
| OtpVerify | The OTP burn finished, but the guard-band read-back differs: do not use the part (datasheet OTP procedure, step 19). |
| NoDevice | A reply that a stuck, floating or looped-back line produces: all zeros or all ones with a wrong CRC, an ERRFL with its reserved bit set, an error bit with no error in ERRFL, or a DIA that stayed 0 (KB-CPP-116). |
| NotReady | The chip answers, but DIA did not report every loop finished within |
| MagnetWarning | The reply carried the warning bit and ERRFL holds an AGC or magnetic-half warning: the field is out of range and the angle is not a measurement (KB-CPP-127). |
| DeviceReset | The chip was reset, or a reset could not be ruled out: after OffCompNotFinished or WDTST in ERRFL, or in |
|
strong |
SPI frame length. The chip recognises the length of each frame, so the driver may mix them.
Writes always use a CRC-protected frame: with Bits16 the driver sends writes as 24-bit frames (the datasheet allows 16-bit frames for reads only).
|
strong |
|
strong |
|
strong |
|
strong |
Whether a run-time write reads the register back, chosen per call.
A write is the two frames the datasheet needs (command and data, CRC-protected, the reply's error bit checked). ReadBack adds one frame pair per register and fails with WriteMismatch when the chip holds something else: it catches a write the chip lost, or a read-only bit. EnsureInitialized() and ProgramOtp() read their writes back whatever is passed elsewhere.
| Enumerator | |
|---|---|
| None | Command and data frames only. The default: nothing extra on a timed path. |
| ReadBack | Read each written register back and compare. |
|
constexprnoexcept |
Convert angle counts to degrees.
| counts | 0 to 16383. |
|
constexprnoexcept |
Convert angle counts to radians.
| counts | 0 to 16383. |
|
constexprnoexcept |
"0.1.0", from the generated as5047u_version.h. No I/O.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
The name of an error, for logs.
| error | The error. |
"Crc"; "Unknown" for a value that is not an enumerator. Check a configuration without touching the chip.
Fails when an enum holds a value that is not an enumerator or a code or count is out of its field's range.
| config | The configuration. |
Error::Ok or Error::InvalidArgument.
|
inlineconstexpr |
Longest wait for an OTP burn to finish, in milliseconds (polled once per millisecond). The datasheet gives no burn time; this bound is the driver's choice, not verified on hardware.
|
inlineconstexpr |
Longest wait from power-on to the first valid angle, t_pon (datasheet "Timing Characteristics", Figure 9): the default start-up deadline.