HardFOC driver
MAX22200 Driver¶
A C++20 driver for the Analog Devices MAX22200 octal solenoid and motor driver. It brings the chip up, configures each half-bridge for current or voltage drive with HIT and HOLD levels, switches channels, runs bridges and reads faults, on any MCU with SPI.
The driver has no platform code. You give it a small class that moves bytes over SPI and drives the ENABLE and CMD pins; it does the rest: the two-phase command and data protocol, the power-up sequence, register encoding in milliamps, percent and milliseconds, and fault decoding.
- Outputs
- 8 push-pull half-bridges, 0.2 Ω typical, up to 1 A RMS each; pairs in parallel or as full bridges
- Drive
- Current regulation (CDR, integrated current sensing, low side) or voltage regulation (VDR, PWM duty)
- HIT and HOLD
- 7-bit HIT and HOLD level and 8-bit HIT time per channel; chopping at 20 kHz to 100 kHz
- Host interface
- SPI mode 0 up to 10 MHz (5 MHz daisy-chained); the CMD pin selects command or data
- Control pins
- ENABLE, CMD, TRIGA, TRIGB (inputs); FAULT (open-drain output)
- Supply
- VM 4.5 V to 36 V; logic inputs switch at 1.2 V and take up to 6 V
- Package
- 32-pin TQFN 5 mm × 5 mm, −40 °C to +85 °C; the MAX22200A adds selective fault clear
What you get¶
- One object per chip.
MAX22200<YourSpi>takes your port and the board's full-scale current, and runs the datasheet's start-up flow inInitialize(). See API guide. - Real units. HIT and HOLD in milliamps (CDR) or percent (VDR), HIT time in milliseconds, converted with the board's RREF and the chip's chopping frequency. See Drive modes.
- Fast switching. Turning channels on and off is one 8-bit write of the ONCH byte; full-bridge pairs take forward, reverse, brake and Hi-Z. See API guide.
- Faults by channel. STATUS flags, per-channel OCP, HHF, open-load and plunger-movement flags, selective clear on the MAX22200A and the FAULT pin. See API guide.
- Zero-overhead portability. The port is a CRTP class: no virtual calls, no heap, no RTOS dependency. See Porting.
- Tested without hardware. Host unit tests run the driver against a model of the chip's SPI protocol. See Testing and CI.
Where to go next¶
-
Wire the chip, write the port, pull in a solenoid in about 15 lines.
-
Pins, bus settings, timing, supply and the full-scale current resistor.
-
The three layers and what each one owns.
-
Configure, switch, read and handle faults, task by task.
-
Implement the SPI interface for your MCU.
-
Every class and member, generated from the headers.