updated new code for half bridge motor drivers