AS5047U Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
as5047u::reg Namespace Reference

Register addresses and fields of the AS5047U (datasheet section "Register Description"). More...

Enumerations

enum class  NvIndex : uint8_t {
  Disable = 0 , Zposm = 1 , Zposl = 2 , Settings1 = 3 ,
  Settings2 = 4 , Settings3 = 5 , Ecc = 6
}
 Index of a non-volatile register in NonVolatileRegisters (address order from DISABLE). More...
 

Functions

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

Detailed Description

Register addresses and fields of the AS5047U (datasheet section "Register Description").

Enumeration Type Documentation

◆ NvIndex

enum class as5047u::reg::NvIndex : uint8_t
strong

Index of a non-volatile register in NonVolatileRegisters (address order from DISABLE).

Enumerator
Disable 

DISABLE (0x0015).

Zposm 

ZPOSM (0x0016).

Zposl 

ZPOSL (0x0017).

Settings1 

SETTINGS1 (0x0018).

Settings2 

SETTINGS2 (0x0019).

Settings3 

SETTINGS3 (0x001A).

Ecc 

ECC (0x001B).

Function Documentation

◆ At()

constexpr std::size_t as5047u::reg::At ( NvIndex  index)
constexprnoexcept

The array index of a non-volatile register.

Parameters
indexThe register.
Returns
Its position in NonVolatileRegisters, 0 to 6.

◆ NvImplementedBits()

constexpr uint16_t as5047u::reg::NvImplementedBits ( std::size_t  index)
constexprnoexcept

The bits a non-volatile register implements; the datasheet describes no others, so the driver expects them to read 0 whatever was written there.

Parameters
indexPosition in NonVolatileRegisters, 0 to 6.
Returns
kDisableImplemented for DISABLE, kNvByteImplemented for the rest.

Variable Documentation

◆ kDiaReserved

constexpr uint16_t as5047u::reg::kDiaReserved = 1U << 10
inlineconstexpr

DIA bit 10 has no function and reads 0 (Figure 35): a reply with it set does not come from an AS5047U. Bit 13 is not described (the reset value 0xX3C2 leaves bits 15..12 open), so it is not checked; all ones is caught as a line pattern.

◆ kDiaSpiCountMask

constexpr uint16_t as5047u::reg::kDiaSpiCountMask = 0x3U << 11
inlineconstexpr

SPI_cnt mask.

◆ kErrflCordic

constexpr uint16_t as5047u::reg::kErrflCordic = 1U << 10
inlineconstexpr

CORDIC overflow.

◆ kErrflDeviceFault

constexpr uint16_t as5047u::reg::kErrflDeviceFault
inlineconstexpr
Initial value:
= uint32_t{kErrflP2ramError} |
uint32_t{kErrflWatchdog} | uint32_t{kErrflOffComp} |
uint32_t{kErrflCordic}
constexpr uint16_t kErrflP2ramError
ECC found an uncorrectable P2RAM error.
Definition as5047u_registers.hpp:117
constexpr uint16_t kErrflWatchdog
Internal oscillator or watchdog fault.
Definition as5047u_registers.hpp:121

The flags that mean the measurement path is faulty.

◆ kErrflFieldWarning

constexpr uint16_t as5047u::reg::kErrflFieldWarning = uint32_t{kErrflAgcWarning} | uint32_t{kErrflMagHalf}
inlineconstexpr

The warnings about the magnetic field: an angle read under either is not a measurement (handbook KB-CPP-127).

◆ kErrflFrameRejected

constexpr uint16_t as5047u::reg::kErrflFrameRejected
inlineconstexpr
Initial value:
=
uint32_t{kErrflFraming} | uint32_t{kErrflCommand} | uint32_t{kErrflCrc}
constexpr uint16_t kErrflCommand
Invalid SPI command.
Definition as5047u_registers.hpp:119
constexpr uint16_t kErrflFraming
SPI framing error.
Definition as5047u_registers.hpp:118

The flags that mean the last frame was rejected.

◆ kErrflResetHint

constexpr uint16_t as5047u::reg::kErrflResetHint = uint32_t{kErrflOffComp} | uint32_t{kErrflWatchdog}
inlineconstexpr

ERRFL flags that may follow a reset of the chip after start-up: offset compensation not finished (it restarts at power-up) and the watchdog (Figure 33). The driver then compares the settings registers with what it wrote (AS5047U::CheckForReset()).

◆ kProgVerify

constexpr uint16_t as5047u::reg::kProgVerify = 1U << 6
inlineconstexpr

PROGVER: guard-band verification.