That’s a good one. However, I’d go a step further and offload the current limiting to a fast hardware solution, rather than rely on the MCU. Or get a driver that current-limits on a built-in silicone level.
Oh, look, what a surprise, the DRV8876 driver allows for current limit to be set with an adjustable external voltage reference. Section 7.3.4.3 OUTx Overcurrent Protection (OCP) from the documentation, page 16.