For your custom driver logic you can look at nuttx/drivers/motor/motor.c which implements the general motor controller interface to interact with user-space. Then your all custom motor control logic goes to your board files.
For driving high voltage relays you can look at dedicated smart relay drivers, smart/intelligent power switches, solid state relays, or even half-bridge drivers if your application needs it. Semiconductor vendors that are in the power electronics market have such chips on offer (ST, TI, Infineon). Some of these chips have a built-in diagnostic and enable pin. This can be used to provide additional safety/control logic independent of the MCU. One of the techniques is to control power stage enable pins with a latched-failure hardware watchdog that is fed by MCU. This can ensure an emergency power-off state for all high voltage switches in case of MCU failure. pon., 20 lut 2023 o 16:13 Tomek CEDRO <to...@cedro.info> napisaĆ(a): > On Mon, Feb 20, 2023 at 3:47 PM Nathan Hartman wrote: > > One thing to be careful with hardware watchdogs: Most have a cyclic > > behavior, so if your MCU locks up, the hardware watchdog might output > > a square wave that causes motor to turn on, off, on, off, rapidly, > > instead of killing it. > > ACK! :-) > > I would prefer to make my own "control" circuit (aka hardware > watchdog) based on a generic part.. I have bad experiences with using > custom / specific parts that may be out of stock or skyrocketing price > :-P > > I will focus on the basic KISS PoC for now. But I know the > possibilities for next version. Thank you! :-) > > -- > CeDeROM, SQ7MHZ, http://www.tomek.cedro.info >