|
AS5047U Driver 0.1.0
API reference
|
AS5047U register map: addresses, field masks and shifts. More...
#include <cstddef>#include <cstdint>Go to the source code of this file.
Namespaces | |
| namespace | as5047u |
The AS5047U driver: everything it declares lives here; internals in detail. | |
| namespace | as5047u::reg |
| Register addresses and fields of the AS5047U (datasheet section "Register Description"). | |
Enumerations | |
| enum class | as5047u::reg::NvIndex : uint8_t { as5047u::reg::Disable = 0 , as5047u::reg::Zposm = 1 , as5047u::reg::Zposl = 2 , as5047u::reg::Settings1 = 3 , as5047u::reg::Settings2 = 4 , as5047u::reg::Settings3 = 5 , as5047u::reg::Ecc = 6 } |
Index of a non-volatile register in NonVolatileRegisters (address order from DISABLE). More... | |
Functions | |
| constexpr std::size_t | as5047u::reg::At (NvIndex index) noexcept |
| The array index of a non-volatile register. | |
| constexpr uint16_t | as5047u::reg::NvImplementedBits (std::size_t index) noexcept |
| The bits a non-volatile register implements; the datasheet describes no others, so the driver expects them to read 0 whatever was written there. | |
Variables | |
| constexpr uint16_t | as5047u::reg::kNop = 0x0000 |
| NOP: no operation (Figure 32). | |
| constexpr uint16_t | as5047u::reg::kErrfl = 0x0001 |
| ERRFL: error flags, cleared by a read (Figure 33). | |
| constexpr uint16_t | as5047u::reg::kProg = 0x0003 |
| PROG: OTP programming control (Figure 34). | |
| constexpr uint16_t | as5047u::reg::kDia = 0x3FF5 |
| DIA: diagnostics (Figure 35). | |
| constexpr uint16_t | as5047u::reg::kAgc = 0x3FF9 |
| AGC: automatic gain control value. | |
| constexpr uint16_t | as5047u::reg::kSinData = 0x3FFA |
| SINDATA: raw sine channel (signed 14 bit). | |
| constexpr uint16_t | as5047u::reg::kCosData = 0x3FFB |
| COSDATA: raw cosine channel (signed 14 bit). | |
| constexpr uint16_t | as5047u::reg::kVel = 0x3FFC |
| VEL: angular velocity (signed 14 bit). | |
| constexpr uint16_t | as5047u::reg::kMag = 0x3FFD |
| MAG: CORDIC magnitude. | |
| constexpr uint16_t | as5047u::reg::kAngleUnc = 0x3FFE |
| ANGLEUNC: angle without DAEC. | |
| constexpr uint16_t | as5047u::reg::kAngleCom = 0x3FFF |
| ANGLECOM: angle with DAEC. | |
| constexpr uint16_t | as5047u::reg::kEccChecksum = 0x3FD0 |
| ECC_Checksum: ECC key of the OTP content. | |
| constexpr uint8_t | as5047u::reg::kCrcPolynomial = 0x1D |
| x^8 + x^4 + x^3 + x^2 + 1, not reflected. | |
| constexpr uint8_t | as5047u::reg::kCrcInit = 0xC4 |
| Initial value. | |
| constexpr uint8_t | as5047u::reg::kCrcFinalXor = 0xFF |
| XORed into the result. | |
| constexpr uint16_t | as5047u::reg::kDisable = 0x0015 |
| DISABLE: output and filter disable. | |
| constexpr uint16_t | as5047u::reg::kZposm = 0x0016 |
| ZPOSM: zero position, bits 13..6. | |
| constexpr uint16_t | as5047u::reg::kZposl = 0x0017 |
| ZPOSL: zero position, bits 5..0, and Dia1/Dia2. | |
| constexpr uint16_t | as5047u::reg::kSettings1 = 0x0018 |
| SETTINGS1: velocity filter K_max, K_min. | |
| constexpr uint16_t | as5047u::reg::kSettings2 = 0x0019 |
| SETTINGS2: direction, DAEC, outputs. | |
| constexpr uint16_t | as5047u::reg::kSettings3 = 0x001A |
| SETTINGS3: UVW pole pairs, hysteresis, ABIRES. | |
| constexpr uint16_t | as5047u::reg::kEcc = 0x001B |
| ECC: ECC checksum and enable. | |
| constexpr uint16_t | as5047u::reg::kFirstNonVolatile = kDisable |
| First non-volatile register (DISABLE). | |
| constexpr uint16_t | as5047u::reg::kNonVolatileCount = 7 |
| Number of non-volatile registers, DISABLE to ECC. | |
| constexpr uint16_t | as5047u::reg::kDisableImplemented = 0x7F |
| DISABLE implements bits 6..0 (UVW_off, ABI_off, bits 5..2 "na", FILTER_disable; Figure 43). | |
| constexpr uint16_t | as5047u::reg::kNvByteImplemented = 0xFF |
| ZPOSM to ECC implement bits 7..0 (Figures 44 to 49). | |
| constexpr uint16_t | as5047u::reg::kDataMask = 0x3FFF |
| The 14 address or data bits of a frame word. | |
| constexpr uint16_t | as5047u::reg::kReadBit = 1U << 14 |
| MOSI command word: bit 14 = 1 read, 0 write (Figures 21, 24, 27). | |
| constexpr uint16_t | as5047u::reg::kReplyErrorBit = 1U << 14 |
| MISO word: bit 14, an error flag is set in ERRFL (Figures 22, 25, 28). | |
| constexpr uint16_t | as5047u::reg::kReplyWarningBit = 1U << 15 |
| MISO word: bit 15, a warning flag is set in ERRFL (Figures 22, 25, 28). | |
| constexpr uint16_t | as5047u::reg::kReplyFlagBits = uint32_t{kReplyErrorBit} | uint32_t{kReplyWarningBit} |
| Both flag bits of a MISO word: when neither is set, the data bits are the whole answer. | |
| constexpr uint16_t | as5047u::reg::kErrflAgcWarning = 1U << 0 |
| AGC at its minimum or maximum. | |
| constexpr uint16_t | as5047u::reg::kErrflMagHalf = 1U << 1 |
| Field at half the regulated value. | |
| constexpr uint16_t | as5047u::reg::kErrflP2ramWarning = 1U << 2 |
| ECC corrected one bit in P2RAM. | |
| constexpr uint16_t | as5047u::reg::kErrflP2ramError = 1U << 3 |
| ECC found an uncorrectable P2RAM error. | |
| constexpr uint16_t | as5047u::reg::kErrflFraming = 1U << 4 |
| SPI framing error. | |
| constexpr uint16_t | as5047u::reg::kErrflCommand = 1U << 5 |
| Invalid SPI command. | |
| constexpr uint16_t | as5047u::reg::kErrflCrc = 1U << 6 |
| CRC error on a MOSI frame. | |
| constexpr uint16_t | as5047u::reg::kErrflWatchdog = 1U << 7 |
| Internal oscillator or watchdog fault. | |
| constexpr uint16_t | as5047u::reg::kErrflOffComp = 1U << 9 |
| Offset compensation not finished. | |
| constexpr uint16_t | as5047u::reg::kErrflCordic = 1U << 10 |
| constexpr uint16_t | as5047u::reg::kErrflFrameRejected |
| The flags that mean the last frame was rejected. | |
| constexpr uint16_t | as5047u::reg::kErrflDeviceFault |
| The flags that mean the measurement path is faulty. | |
| constexpr uint16_t | as5047u::reg::kErrflFieldWarning = uint32_t{kErrflAgcWarning} | uint32_t{kErrflMagHalf} |
| constexpr uint16_t | as5047u::reg::kErrflReserved = 1U << 8 |
| ERRFL bit 8 has no function and reads 0 (Figure 33): set, the reply cannot be ERRFL. | |
| constexpr uint16_t | as5047u::reg::kErrflResetHint = uint32_t{kErrflOffComp} | uint32_t{kErrflWatchdog} |
| constexpr uint16_t | as5047u::reg::kProgEnable = 1U << 0 |
| PROGEN: enable OTP programming. | |
| constexpr uint16_t | as5047u::reg::kProgRefresh = 1U << 2 |
| OTPREF: reload the registers from the OTP. | |
| constexpr uint16_t | as5047u::reg::kProgBurn = 1U << 3 |
| PROGOTP: start burning the OTP. | |
| constexpr uint16_t | as5047u::reg::kProgVerify = 1U << 6 |
| constexpr uint16_t | as5047u::reg::kProgDone = kProgEnable |
| PROG reads PROGEN alone once a burn has finished (OTP flowchart, Figure 60). | |
| constexpr uint16_t | as5047u::reg::kDiaVdd5V = 1U << 0 |
| VDD_mode: 1 = 5 V operation. | |
| constexpr uint16_t | as5047u::reg::kDiaLoopsFinished = 1U << 1 |
| All magnetic loops have settled. | |
| constexpr uint16_t | as5047u::reg::kDiaCordicOverflow = 1U << 2 |
| CORDIC overflow. | |
| constexpr uint16_t | as5047u::reg::kDiaCompLow = 1U << 3 |
| AGC at its low limit. | |
| constexpr uint16_t | as5047u::reg::kDiaCompHigh = 1U << 4 |
| AGC at its high limit. | |
| constexpr uint16_t | as5047u::reg::kDiaMagHalf = 1U << 5 |
| Field at half the regulated value. | |
| constexpr uint16_t | as5047u::reg::kDiaCosOffsetDone = 1U << 6 |
| Cosine offset loop finished. | |
| constexpr uint16_t | as5047u::reg::kDiaSinOffsetDone = 1U << 7 |
| Sine offset loop finished. | |
| constexpr uint16_t | as5047u::reg::kDiaOffsetCompDone = 1U << 8 |
| Offset compensation finished. | |
| constexpr uint16_t | as5047u::reg::kDiaAgcDone = 1U << 9 |
| AGC loop finished. | |
| constexpr uint16_t | as5047u::reg::kDiaSpiCountShift = 11 |
| SPI_cnt: frame counter, bits 12..11. | |
| constexpr uint16_t | as5047u::reg::kDiaSpiCountMask = 0x3U << 11 |
| constexpr uint16_t | as5047u::reg::kDiaReserved = 1U << 10 |
| constexpr uint16_t | as5047u::reg::kDiaReadyValue = 0x03C2 |
| DIA after power-up once every loop has settled, 3.3 V mode, SPI_cnt 0 (Figure 32: 0xX3C2). | |
| constexpr uint16_t | as5047u::reg::kDisableUvwOff = 1U << 0 |
| UVW_off: UVW pins tristate. | |
| constexpr uint16_t | as5047u::reg::kDisableAbiOff = 1U << 1 |
| ABI_off: A, B and I pins tristate. | |
| constexpr uint16_t | as5047u::reg::kDisableFilterOff = 1U << 6 |
| FILTER_disable: adaptive filter off. | |
| constexpr uint16_t | as5047u::reg::kZposmMask = 0xFFU |
| ZPOSM holds zero-position bits 13..6. | |
| constexpr uint16_t | as5047u::reg::kZposlMask = 0x3FU |
| ZPOSL bits 5..0 hold zero-position bits 5..0. | |
| constexpr uint16_t | as5047u::reg::kZposlDiaBits = 0xC0U |
| ZPOSL bits 7..6: Dia1_en, Dia2_en (kept). | |
| constexpr uint16_t | as5047u::reg::kZeroHighShift = 6 |
| Zero position bits 13..6 go in ZPOSM. | |
| constexpr uint16_t | as5047u::reg::kS1KmaxMask = 0x07U |
| K_max code, bits 2..0. | |
| constexpr uint16_t | as5047u::reg::kS1KminShift = 3 |
| K_min code, bits 5..3. | |
| constexpr uint16_t | as5047u::reg::kS1KminMask = 0x07U << 3 |
| K_min mask. | |
| constexpr uint16_t | as5047u::reg::kS1DiaBits = 0xC0U |
| Dia3_en, Dia4_en (kept). | |
| constexpr uint16_t | as5047u::reg::kS2IndexWidth1 = 1U << 0 |
| IWIDTH: 1 = 1 LSB index pulse, 0 = 3 LSB. | |
| constexpr uint16_t | as5047u::reg::kS2NoiseSet = 1U << 1 |
| NOISESET: reduced noise at 150 °C, 3.3 V. | |
| constexpr uint16_t | as5047u::reg::kS2Dir = 1U << 2 |
| DIR: invert the rotation direction. | |
| constexpr uint16_t | as5047u::reg::kS2UvwAbi = 1U << 3 |
| UVW_ABI: 0 = ABI with PWM on W, 1 = UVW. | |
| constexpr uint16_t | as5047u::reg::kS2DaecDis = 1U << 4 |
| DAECDIS: dynamic compensation off. | |
| constexpr uint16_t | as5047u::reg::kS2AbiDecimal = 1U << 5 |
| ABI_DEC: decimal ABI resolution. | |
| constexpr uint16_t | as5047u::reg::kS2DataSelect = 1U << 6 |
| Data_select: 0x3FFF reads ANGLEUNC. | |
| constexpr uint16_t | as5047u::reg::kS2PwmOn = 1U << 7 |
| PWMon: PWM output on. | |
| constexpr uint16_t | as5047u::reg::kS3UvwppMask = 0x07U |
| UVWPP: pole pairs minus one, bits 2..0. | |
| constexpr uint16_t | as5047u::reg::kS3HysShift = 3 |
| HYS, bits 4..3. | |
| constexpr uint16_t | as5047u::reg::kS3HysMask = 0x03U << 3 |
| HYS mask. | |
| constexpr uint16_t | as5047u::reg::kS3AbiresShift = 5 |
| ABIRES, bits 7..5. | |
| constexpr uint16_t | as5047u::reg::kS3AbiresMask = 0x07U << 5 |
| ABIRES mask. | |
| constexpr uint16_t | as5047u::reg::kEccChecksumMask = 0x7FU |
| ECC_chsum / ECC_s: the 7-bit key. | |
| constexpr uint16_t | as5047u::reg::kEccEnable = 1U << 7 |
| ECC_en. | |
AS5047U register map: addresses, field masks and shifts.
Addresses and fields follow the AS5047U datasheet (ams OSRAM DS000637, v1-01), section "Register Description" (Figures 32 to 49). Every register is 14 bits wide on the bus; fields are plain masks and shifts so the code does not depend on how a compiler lays out bit-fields.
The non-volatile registers (kDisable to kEcc) hold a volatile copy that SPI writes change any number of times; it is lost at power-off unless the OTP was burned (AS5047U::ProgramOtp()). Their reset value is 0 on a part whose OTP was never burned.