Okay,
here is a very simple test program I used to drive a brushless motor that was in an actuator for something I was working on. It had 3 hall sensors built in.
To determine the order in which this thing operated I made a degree wheel and hot glued it to the motor shaft. then I read the hall sensors and turned the shaft by hand and recorded the beginning and ending positions of each sensors on-off states, next I applied power to the motor's coils in all combinations and recorded the shaft position of each combo.
using this data I was able to come up with a commutation table.
The program simply reads the hall sensors and generates a value based on the reading. there are 6 valid states and two invalid states. In testing an invalid state was never detected. The hall sensor state is checked against the table in a select-case method. I am using Infineron BTN79xx or BTS79xx fets which contain a p-channel and N-channel together with some protection logic. Extremely simple, definitely far simpler ,and also about the same final price high side driver schemes.
I had this working with a pot on an ADC channel at one point, but this version is just using a fixed pwm value of 20 which IIRC was a very low speed rotation.
This was written in Bascom and running on a mega168 at 8mhz. I'm sure this could be done much more elegantly in C++ (maybe even stm32duino) on a much faster 32bit ARM.
I no longer have a schematic for this, but it's irrelevant. there were 6 basic outputs, 3 pwm's for the enable lines of the fets, and 3 lines to determine the polarity of the fets.