PWM controlled moter with limit switch

I have to control moter. Its driver card required fixed 30KHz pwm signal and variable duty cycle of pwm ie >50% and <50% to change rotation direction of motor by external keyboard or switch .
PWM must stop at receiveing of input analog signal from limit switch. Please suggest me the scatch.

(deleted)