Init I/O later
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 15 Mar 2018 08:55:40 +0000 (01:55 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 15 Mar 2018 08:55:40 +0000 (01:55 -0700)
src/avr/src/motor.c

index 90d1f9dea508fd6d1f089187f795f92917c131c2..d06eb61c5a81ed9013446f1e9ef29d539db3cc9d 100644 (file)
@@ -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();