To have a big microcontroller drive a motor control loop can be an issue, why not delegating to a smart IC?

Big microcontrollers (MCU) usually come in wide packages that tend to need a longer layout time, high BOM cost and possibly higher consumption. In case a smaller MCU is required, the control of system actuators and inputs can be delegated to dedicated ICs.
To drive a motor control loop is usually not a task for slow MCUs, especially if the application is functional to the system and requires careful control. In this case, we have a unit designed to operate in a critical environment: the Open Source Ventilator – Open Lung collaboration born to fight COVID-19 related shortage of ventilators in developing countries, where an accurate compression and release of a Bag Valve Mask draws the line between a patient being able to breathe, and not.
The PCB is based on a 4-Layer stackup designed around the TMC5160A motor controller from Trinamic and derived after the TMC5160_BOB board. The TMC5160A can provide a two H-bridge drive, with bridges either incorporated or with external MOSFETs for higher phase currents and bridge voltages.

The IC is configured for SPI control with two diagnostic output pins and a motor drive enable pin (for emergency shutdown). An external clock pin is provided to allow for performance tuning. The supply voltage should we provided with two separate rails to avoid the TMC internal LDOs to overheat as the nominal motor voltage is set to 48V (in this application, but can be between 12-55V).

The IC is therefore controlled via a microcontroller using SPI communication. Once a movement command is issued, the IC will drive the two H-bridges to move either a stepper motor or two brushed DC ones/solenoids.
A control loop can be used by attaching an encoder to the stepper motor, wired then back to the TMC5160A. The ic will then try to drive the motor and correct its commands based on the feedback received on the ENCODER pins (this is great to save on MCU coding and firmware complexity). Two limit switch inputs are also available. Once triggered during movement, these will stop the motor behavior.
When driving inductive loads it is important to provide a certain amount of decoupling capacitance. Around 40uF are provided on board with 1uF MLCC as close as possible to the high side of each H-bridge. More capacitance should be added on the hosting board, about 100uF per phase amp. (i.e. running two phases at 2 Amp would require a minimum of 400uF) as written on the TMC5160A datasheet.

Simulation plays an important role when targeting critical applications. A full Power Delivery Network analysis (DC) needs to be carried out to verify that both voltage drop and current density are not a problem for the thermal management and safety considerations.

Once a low voltage drop is established on power planes and power nets, it is critical to check for high current density spots across the layout and understand if they can lead to hot regions, fusing issues or if they mean that high inductive paths are present in the design.

You can find the full Altium Project source files and PDN simulation reports on the OSV-OL Gitlab page at the following link.
IMPORTANT NOTE: ALWAY CHECK BY YOURSELF ALL THE DESIGNS THAT YOU WANT TO USE FOUND ON THE INTERNET, THEY MAY OR MAY NOT SUFFICE YOUR NEEDS AND/OR CONTAIN ERRORS THAT CAN CAUSE EITHER LOSS OF MONEY OR, POTENTIALLY, LIFE HAZARDS!