Przeglądaj źródła

Add macros for delays by machine cycle

Scott Lahteine 7 lat temu
rodzic
commit
e02a5a6371
3 zmienionych plików z 41 dodań i 8 usunięć
  1. 40
    0
      Marlin/macros.h
  2. 1
    1
      Marlin/servo.h
  3. 0
    7
      Marlin/ultralcd_st7920_u8glib_rrd.h

+ 40
- 0
Marlin/macros.h Wyświetl plik

@@ -39,6 +39,46 @@
39 39
 // Clock speed factor
40 40
 #define CYCLES_PER_MICROSECOND (F_CPU / 1000000UL) // 16 or 20
41 41
 
42
+// Highly granular delays for step pulses, etc.
43
+#define DELAY_0_NOP NOOP
44
+#define DELAY_1_NOP __asm__("nop\n\t")
45
+#define DELAY_2_NOP DELAY_1_NOP; DELAY_1_NOP
46
+#define DELAY_3_NOP DELAY_1_NOP; DELAY_2_NOP
47
+#define DELAY_4_NOP DELAY_1_NOP; DELAY_3_NOP
48
+#define DELAY_5_NOP DELAY_1_NOP; DELAY_4_NOP
49
+
50
+#define DELAY_NOPS(X) \
51
+  switch (X) { \
52
+    case 20: DELAY_1_NOP; case 19: DELAY_1_NOP; \
53
+    case 18: DELAY_1_NOP; case 17: DELAY_1_NOP; \
54
+    case 16: DELAY_1_NOP; case 15: DELAY_1_NOP; \
55
+    case 14: DELAY_1_NOP; case 13: DELAY_1_NOP; \
56
+    case 12: DELAY_1_NOP; case 11: DELAY_1_NOP; \
57
+    case 10: DELAY_1_NOP; case 9:  DELAY_1_NOP; \
58
+    case 8:  DELAY_1_NOP; case 7:  DELAY_1_NOP; \
59
+    case 6:  DELAY_1_NOP; case 5:  DELAY_1_NOP; \
60
+    case 4:  DELAY_1_NOP; case 3:  DELAY_1_NOP; \
61
+    case 2:  DELAY_1_NOP; case 1:  DELAY_1_NOP; \
62
+  }
63
+
64
+#define DELAY_10_NOP DELAY_5_NOP;  DELAY_5_NOP
65
+#define DELAY_20_NOP DELAY_10_NOP; DELAY_10_NOP
66
+
67
+#if CYCLES_PER_MICROSECOND == 16
68
+  #define DELAY_1US DELAY_10_NOP; DELAY_5_NOP; DELAY_1_NOP
69
+#else
70
+  #define DELAY_1US DELAY_20_NOP
71
+#endif
72
+#define DELAY_2US  DELAY_1US; DELAY_1US
73
+#define DELAY_3US  DELAY_1US; DELAY_2US
74
+#define DELAY_4US  DELAY_1US; DELAY_3US
75
+#define DELAY_5US  DELAY_1US; DELAY_4US
76
+#define DELAY_6US  DELAY_1US; DELAY_5US
77
+#define DELAY_7US  DELAY_1US; DELAY_6US
78
+#define DELAY_8US  DELAY_1US; DELAY_7US
79
+#define DELAY_9US  DELAY_1US; DELAY_8US
80
+#define DELAY_10US DELAY_1US; DELAY_9US
81
+
42 82
 // Remove compiler warning on an unused variable
43 83
 #define UNUSED(x) (void) (x)
44 84
 

+ 1
- 1
Marlin/servo.h Wyświetl plik

@@ -82,7 +82,7 @@
82 82
 
83 83
 // Say which 16 bit timers can be used and in what order
84 84
 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
85
-  //#define _useTimer1
85
+  //#define _useTimer1 // Timer 1 is used by the stepper ISR
86 86
   #define _useTimer3
87 87
   #define _useTimer4
88 88
   #if !HAS_MOTOR_CURRENT_PWM

+ 0
- 7
Marlin/ultralcd_st7920_u8glib_rrd.h Wyświetl plik

@@ -43,13 +43,6 @@
43 43
 //set optimization so ARDUINO optimizes this file
44 44
 #pragma GCC optimize (3)
45 45
 
46
-#define DELAY_0_NOP  NOOP
47
-#define DELAY_1_NOP  __asm__("nop\n\t")
48
-#define DELAY_2_NOP  __asm__("nop\n\t" "nop\n\t")
49
-#define DELAY_3_NOP  __asm__("nop\n\t" "nop\n\t" "nop\n\t")
50
-#define DELAY_4_NOP  __asm__("nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t")
51
-
52
-
53 46
 // If you want you can define your own set of delays in Configuration.h
54 47
 //#define ST7920_DELAY_1 DELAY_0_NOP
55 48
 //#define ST7920_DELAY_2 DELAY_0_NOP

Ładowanie…
Anuluj
Zapisz