AS5047U Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
as5047u_types.hpp File Reference

Public types of the AS5047U driver: errors, Result<T>, configuration, decoded registers. More...

#include <array>
#include <cstdint>
#include "as5047u_detail.hpp"
#include "as5047u_registers.hpp"
#include "as5047u_version.h"

Go to the source code of this file.

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...
 

Namespaces

namespace  as5047u
 The AS5047U driver: everything it declares lives here; internals in detail.
 

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).
 

Enumerations

enum class  as5047u::Error : uint8_t {
  as5047u::Error::Ok = 0 , as5047u::Error::NotInitialized , as5047u::Error::InvalidArgument = 2 , as5047u::Error::Bus = 3 ,
  as5047u::Error::Timeout = 4 , as5047u::Error::DeviceIdMismatch = 5 , as5047u::Error::Crc = 6 , as5047u::Error::Busy = 7 ,
  as5047u::Error::DeviceFault = 8 , as5047u::Error::Unsupported = 9 , as5047u::Error::Framing = 16 , as5047u::Error::Command = 17 ,
  as5047u::Error::WriteMismatch = 18 , as5047u::Error::OtpVerify = 19 , as5047u::Error::NoDevice = 20 , as5047u::Error::NotReady = 21 ,
  as5047u::Error::MagnetWarning = 22 , as5047u::Error::DeviceReset = 23
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  as5047u::LogLevel : uint8_t { as5047u::LogLevel::Error = 0 , as5047u::LogLevel::Warning , as5047u::LogLevel::Info , as5047u::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  as5047u::FrameFormat : uint8_t { as5047u::FrameFormat::Bits16 = 0 , as5047u::FrameFormat::Bits24 = 1 , as5047u::FrameFormat::Bits32 = 2 }
 SPI frame length. The chip recognises the length of each frame, so the driver may mix them. More...
 
enum class  as5047u::Direction : uint8_t { as5047u::Direction::Clockwise = 0 , as5047u::Direction::CounterClockwise = 1 }
 Direction in which the angle increases (SETTINGS2.DIR). More...
 
enum class  as5047u::IncrementalOutput : uint8_t { as5047u::IncrementalOutput::Abi = 0 , as5047u::IncrementalOutput::Uvw = 1 }
 Which incremental interface the A/B/I-U/V/W pins carry (SETTINGS2.UVW_ABI). More...
 
enum class  as5047u::IndexWidth : uint8_t { as5047u::IndexWidth::ThreeLsb = 0 , as5047u::IndexWidth::OneLsb = 1 }
 Length of the ABI index pulse (SETTINGS2.IWIDTH). More...
 
enum class  as5047u::Verify : uint8_t { as5047u::Verify::None = 0 , as5047u::Verify::ReadBack = 1 }
 Whether a run-time write reads the register back, chosen per call. More...
 

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.
 

Detailed Description

Public types of the AS5047U driver: errors, Result<T>, configuration, decoded registers.

Everything here is plain data with no platform dependency, so handlers, tests and tools can include it without the driver template. The configuration defaults are the register reset values of a part whose OTP was never burned (datasheet DS000637, "Register Description"), so Config{} describes a freshly powered chip; only the SPI frame format is a driver-side choice.