From: Joseph Coffland Date: Thu, 15 Mar 2018 08:55:40 +0000 (-0700) Subject: Init I/O later X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=825b69d982cce5113a88eda43c69a628b077f8ae;p=bbctrl-firmware Init I/O later --- diff --git a/src/avr/src/motor.c b/src/avr/src/motor.c index 90d1f9d..d06eb61 100644 --- a/src/avr/src/motor.c +++ b/src/avr/src/motor.c @@ -141,11 +141,6 @@ void motor_init() { _update_config(motor); - // IO pins - PINCTRL_PIN(m->step_pin) = PORT_INVEN_bm; // Inverted output - DIRSET_PIN(m->step_pin); // Output - DIRSET_PIN(m->dir_pin); // Output - // Setup motor timer m->timer->CTRLB = TC_WGMODE_SINGLESLOPE_gc | TC1_CCAEN_bm; m->timer->CCA = F_CPU * 0.000002 / 2; // Step pulse width, 2uS w/ clk/2 @@ -167,6 +162,11 @@ void motor_init() { m->dma->REPCNT = 0; m->dma->CTRLB = 0; m->dma->CTRLA = DMA_CH_SINGLE_bm | DMA_CH_BURSTLEN_1BYTE_gc; + + // IO pins + PINCTRL_PIN(m->step_pin) = PORT_INVEN_bm; // Inverted output + DIRSET_PIN(m->step_pin); // Output + DIRSET_PIN(m->dir_pin); // Output } axis_map_motors();