Detecting a coil is fully energized
Have you considered a IC? Several companies have made these for years.  They control the coil charging etc for you and no software!  ST has them listed under: Ignition Controllers and Drivers.