97 bool updateRegister(uint8_t address, uint16_t mask, uint16_t value);
107 return updateRegister(
static_cast<uint8_t
>(address), mask, value);
454 bool isValidAddress(uint8_t address)
const;
463 bool writeRegisterVerified(uint8_t address, uint16_t value, uint16_t verifyMask);
473 bool updateRegisterVerified(uint8_t address, uint16_t mask, uint16_t value, uint16_t verifyMask);
478 void seedDefaultRegisterCache();
485 bool checkDefaultRegisters(uint8_t& matchCount);
493 void logDefaultRegisterMismatch(uint8_t address, uint16_t expected, uint16_t actual)
const;
500 float senseGainValue(
SenseGain gain)
const;
507 float shuntResistance(
BridgeId bridge)
const;
513 float currentLimitReferenceShunt()
const;
544 bool applyBridgeState(
BridgeId bridge);
550 bool performWriteReadbackProbe();
555 void beginTransaction();
560 void endTransaction();
567 uint16_t transferFrame(uint16_t frame);
575 void setBridgePins(int8_t in1Pin, int8_t in2Pin,
BridgeMode mode);
592 bool setBridgePwm(int8_t in1Pin, int8_t in2Pin,
Direction direction,
float speedPercent);
596 SPISettings spiSettings_;
601 float bridgeSpeedPercents_[2];
605 bool currentLimitEnabled_;
609 bool pwmModeEnabled_;
Abstract board-specific PWM backend used for DRV8704 bridge inputs.
Definition: drv8704_pwm.h:16
Arduino-facing DRV8704 device driver class.
Definition: drv8704.h:21
bool setCurrent(BridgeId bridge, Direction direction, float amps)
Compatibility overload retained during the control-model refactor.
Definition: drv8704.h:399
void wake()
Bring the DRV8704 out of sleep mode when the sleep pin is available.
Definition: drv8704.cpp:147
void setBridgeMode(BridgeId bridge, BridgeMode mode)
Low-level static bridge helper retained for compatibility.
Definition: drv8704_bridge.cpp:165
bool begin()
Initialize GPIO and SPI state for the device.
Definition: drv8704.cpp:35
DRV8704PwmCapability pwmCapability() const
Return the resolved capability of the active PWM backend.
Definition: drv8704.h:407
bool updateRegister(uint8_t address, uint16_t mask, uint16_t value)
Update selected register bits while preserving other bits.
Definition: drv8704_comm.cpp:61
bool setCurrent(BridgeId bridge, float amps)
Program the chip for current drive on one bridge using the stored direction.
Definition: drv8704_current.cpp:263
bool writeRegister(uint8_t address, uint16_t value)
Write a 12-bit register payload to the device.
Definition: drv8704_comm.cpp:33
DRV8704CurrentLimitResult currentLimitResult() const
Return the most recent derived chip-global current-limit settings.
Definition: drv8704.h:286
bool setOffTime(uint8_t offTime)
Set the fixed PWM off time.
Definition: drv8704_config.cpp:66
bool setBlankTime(uint8_t blankTime)
Set the current blanking time.
Definition: drv8704_config.cpp:75
bool setGateDriveCurrents(GateDriveSinkCurrent iDriveN, GateDriveSourceCurrent iDriveP)
Set the gate-drive current fields.
Definition: drv8704_config.cpp:124
bool setTorque(uint8_t torque)
Set the torque DAC value.
Definition: drv8704_config.cpp:58
bool writeRegister(RegisterAddress address, uint16_t value)
Write a register by symbolic address.
Definition: drv8704.h:86
bool setGateDriveTimes(GateDriveTime tDriveN, GateDriveTime tDriveP)
Set the gate-drive timing fields.
Definition: drv8704_config.cpp:115
bool beginPwmMode(const DRV8704PwmConfig &config=DRV8704PwmConfig())
Enable board-specific PWM generation for the DRV8704 input pins.
Definition: drv8704_bridge.cpp:190
bool hasFault()
Check whether any reported fault bit is active.
Definition: drv8704_status.cpp:31
bool enableBridgeDriver(bool enabled)
Enable or disable the bridge driver through the CTRL register.
Definition: drv8704_config.cpp:34
bool setOcpThreshold(OcpThreshold threshold)
Set the overcurrent threshold.
Definition: drv8704_config.cpp:99
void sleep()
Put the DRV8704 into sleep mode when the sleep pin is available.
Definition: drv8704.cpp:141
bool updateRegister(RegisterAddress address, uint16_t mask, uint16_t value)
Update selected register bits using a symbolic address.
Definition: drv8704.h:106
bool setShuntResistance(float ohms)
Set one shunt resistance value for both bridges in current mode.
Definition: drv8704_current.cpp:108
void reset()
Pulse the reset pin when available.
Definition: drv8704.cpp:154
DRV8704CurrentPresetConfig currentModePresetConfig() const
Return the preset configuration currently selected for current-limit operation.
Definition: drv8704.h:280
bool setSenseGain(SenseGain gain)
Set the current-sense amplifier gain.
Definition: drv8704_config.cpp:42
bool setCurrentModePreset(CurrentModePreset preset)
Select the predefined timing and decay preset used by current mode.
Definition: drv8704_current.cpp:122
void brake(BridgeId bridge)
Drive one bridge to brake.
Definition: drv8704_bridge.cpp:155
uint16_t cachedRegister(uint8_t address) const
Return the cached contents of a register.
Definition: drv8704.cpp:182
bool setOcpDeglitch(OcpDeglitch deglitch)
Set the overcurrent deglitch interval.
Definition: drv8704_config.cpp:107
uint16_t readRegister(uint8_t address)
Read a 12-bit register payload from the device.
Definition: drv8704_comm.cpp:9
bool setDecayMode(DecayMode mode)
Set the decay mode.
Definition: drv8704_config.cpp:83
void endPwmMode()
Disable platform PWM generation and return bridge inputs to coast.
Definition: drv8704_bridge.cpp:236
bool isFaultPinActive() const
Read the state of the optional FAULTn pin.
Definition: drv8704_status.cpp:23
bool disableCurrentLimit()
Disable the high-level current-limit configuration without forcing a bridge-state change.
Definition: drv8704_current.cpp:281
DRV8704BridgeState bridgeState(BridgeId bridge) const
Return the stored direction/runtime-state report for one bridge.
Definition: drv8704_bridge.cpp:186
Direction direction(BridgeId bridge) const
Return the configured high-level direction for one bridge.
Definition: drv8704_current.cpp:160
bool setDecayTime(uint8_t decayTime)
Set the mixed-decay transition time.
Definition: drv8704_config.cpp:91
DRV8704(const DRV8704Pins &pins, SPIClass &spi=SPI)
Construct a DRV8704 device instance.
Definition: drv8704.cpp:9
bool isCurrentLimitEnabled() const
Return whether a high-level current limit is currently configured.
Definition: drv8704.h:274
bool applyConfig(const DRV8704Config &config)
Apply a high-level configuration snapshot to the device.
Definition: drv8704_config.cpp:154
bool clearFault(FaultBit bit)
Clear one fault bit in the STATUS register.
Definition: drv8704_status.cpp:50
bool setSpeed(BridgeId bridge, Direction direction, float speedPercent)
Compatibility overload retained during the control-model refactor.
Definition: drv8704.h:388
bool isPwmModeEnabled() const
Return whether PWM mode is currently active.
Definition: drv8704.h:421
void end()
End driver operation.
Definition: drv8704.cpp:136
bool setPwmFrequency(uint32_t frequencyHz)
Update the requested PWM frequency.
Definition: drv8704_bridge.cpp:269
float smallestDutyIncrementPercent() const
Return the smallest duty-percent step of the active PWM backend.
Definition: drv8704.h:413
bool setDeadTime(DeadTime deadTime)
Set the bridge dead time.
Definition: drv8704_config.cpp:50
bool isInitialized() const
Report whether the driver completed initialization.
Definition: drv8704.h:433
bool syncRegisterCache()
Refresh the local register cache from device reads.
Definition: drv8704.cpp:190
bool hasFaultPin() const
Report whether a dedicated FAULTn pin was provided.
Definition: drv8704.h:304
void coast(BridgeId bridge)
Drive one bridge to coast.
Definition: drv8704_bridge.cpp:145
bool setCurrentLimit(float amps)
Program the chip-global current limit in amperes without changing bridge state.
Definition: drv8704_current.cpp:248
uint16_t readRegister(RegisterAddress address)
Read a register by symbolic address.
Definition: drv8704.h:68
DRV8704Status readStatus()
Read and decode the STATUS register.
Definition: drv8704_status.cpp:9
bool setDirection(BridgeId bridge, Direction direction)
Set the direction used by high-level current-drive and PWM-drive commands.
Definition: drv8704_current.cpp:148
bool setGateDrive(const GateDriveConfig &gateDrive)
Apply the complete DRIVE register configuration.
Definition: drv8704_config.cpp:133
bool clearFaults()
Clear all clearable fault bits in the STATUS register.
Definition: drv8704_status.cpp:42
DRV8704HealthCheck healthCheck()
Perform a minimal transport/status health check.
Definition: drv8704.cpp:165
bool setSpeed(BridgeId bridge, float speedPercent)
Apply an open-loop speed command to one bridge using hardware PWM.
Definition: drv8704_bridge.cpp:292
Constants, register addresses, masks, and defaults for the DRV8704 driver.
#define DRV8704_REGISTER_COUNT
Definition: drv8704_defs.h:35
Typed register views for the DRV8704 register set.
Public enums and data structures for the DRV8704 driver.
GateDriveSourceCurrent
Supported source current values for the predriver.
Definition: drv8704_types.h:76
FaultBit
Selectable fault bits in the STATUS register.
Definition: drv8704_types.h:155
OcpDeglitch
Supported OCP deglitch durations.
Definition: drv8704_types.h:56
Direction
High-level direction selector for current mode and PWM mode.
Definition: drv8704_types.h:124
CurrentModePreset
Predefined load presets for current-mode timing and decay behavior.
Definition: drv8704_types.h:144
RegisterAddress
Supported register addresses.
Definition: drv8704_types.h:167
GateDriveTime
Supported gate-drive timing values.
Definition: drv8704_types.h:66
GateDriveSinkCurrent
Supported sink current values for the predriver.
Definition: drv8704_types.h:86
DecayMode
Supported current-decay modes.
Definition: drv8704_types.h:36
OcpThreshold
Supported overcurrent thresholds.
Definition: drv8704_types.h:46
BridgeId
Bridge selector.
Definition: drv8704_types.h:96
DeadTime
Supported dead-time settings.
Definition: drv8704_types.h:26
SenseGain
Supported sense amplifier gain settings.
Definition: drv8704_types.h:16
BridgeMode
Runtime bridge command.
Definition: drv8704_types.h:104
Reported direction and runtime mode of one bridge.
Definition: drv8704_types.h:270
High-level DRV8704 configuration snapshot.
Definition: drv8704_types.h:225
Derived chip-global current-limit settings and per-bridge consequences.
Definition: drv8704_types.h:286
Timing and decay recommendation associated with a current-mode preset.
Definition: drv8704_types.h:250
Minimal transport/bring-up health result.
Definition: drv8704_types.h:378
Pin assignment bundle for a DRV8704 instance.
Definition: drv8704_types.h:181
int8_t faultPin
Definition: drv8704_types.h:185
Resolved platform PWM capabilities for the active backend.
Definition: drv8704_types.h:334
float smallestDutyIncrementPercent
Definition: drv8704_types.h:341
Requested PWM generator settings.
Definition: drv8704_types.h:322
Decoded device status and fault state.
Definition: drv8704_types.h:356
Gate-drive configuration group.
Definition: drv8704_types.h:205