state machine enhancement | setup A/B support | misplace code in port1.c |param seperated