Browse Source

Decrease the needed nops to 1

by shitfing the left shift into the high phase.

```
2	cbi 0x2,1 ;set CLK                      //
1	in r18,__SREG__                         //1
1-3	sbrc r24,7                              //2-4
2	rjmp .L19                               //4
1	cli                  .L19:              //5
2	lds r25,258          lds r25,258        //7
1	andi r25,lo8(-2)     ori r25,lo8(1)     //8
2	sts 258,r25          sts 258,r25        //10
1	out __SREG__,r18     out __SREG__,r18   //11
2	.L3:                 rjmp .L3           //13     //2
2	sbi 0x2,1 ;reset CLK //                 //13-15  //2-4
1	lsl r24	 ;  val      //1
1	nop                  //2
2	cbi 0x2,1 ;set CLK   //4
...
```
AnHardt 8 years ago
parent
commit
4454d80276
1 changed files with 12 additions and 14 deletions
  1. 12
    14
      Marlin/ultralcd_st7920_u8glib_rrd.h

+ 12
- 14
Marlin/ultralcd_st7920_u8glib_rrd.h View File

@@ -41,7 +41,6 @@
41 41
 #include <U8glib.h>
42 42
 
43 43
 //set optimization so ARDUINO optimizes this file
44
-#pragma GCC push_options
45 44
 #pragma GCC optimize (3)
46 45
 
47 46
 #define DELAY_0_NOP  ;
@@ -64,9 +63,9 @@
64 63
     #define ST7920_DELAY_2 DELAY_0_NOP
65 64
   #endif
66 65
   #ifndef ST7920_DELAY_3
67
-    #define ST7920_DELAY_3 DELAY_2_NOP
66
+    #define ST7920_DELAY_3 DELAY_1_NOP
68 67
   #endif
69
-#elif MOTHERBOARD == BOARD_3DRAG
68
+#elif (MOTHERBOARD == BOARD_3DRAG) || (MOTHERBOARD == BOARD_K8200)
70 69
   #ifndef ST7920_DELAY_1
71 70
     #define ST7920_DELAY_1 DELAY_0_NOP
72 71
   #endif
@@ -74,7 +73,7 @@
74 73
     #define ST7920_DELAY_2 DELAY_0_NOP
75 74
   #endif
76 75
   #ifndef ST7920_DELAY_3
77
-    #define ST7920_DELAY_3 DELAY_2_NOP
76
+    #define ST7920_DELAY_3 DELAY_1_NOP
78 77
   #endif
79 78
 #elif F_CPU == 16000000
80 79
   #ifndef ST7920_DELAY_1
@@ -84,7 +83,7 @@
84 83
     #define ST7920_DELAY_2 DELAY_0_NOP
85 84
   #endif
86 85
   #ifndef ST7920_DELAY_3
87
-    #define ST7920_DELAY_3 DELAY_2_NOP
86
+    #define ST7920_DELAY_3 DELAY_1_NOP
88 87
   #endif
89 88
 #else
90 89
   #error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd.h'"
@@ -94,63 +93,62 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
94 93
     WRITE(ST7920_CLK_PIN,0);
95 94
     ST7920_DELAY_1
96 95
     WRITE(ST7920_DAT_PIN,val&0x80);
97
-    val<<=1;
98 96
     ST7920_DELAY_2
99 97
     WRITE(ST7920_CLK_PIN,1);
98
+    val<<=1;
100 99
     ST7920_DELAY_3
101 100
 
102 101
     WRITE(ST7920_CLK_PIN,0);
103 102
     ST7920_DELAY_1
104 103
     WRITE(ST7920_DAT_PIN,val&0x80);
105
-    val<<=1;
106 104
     ST7920_DELAY_2
107 105
     WRITE(ST7920_CLK_PIN,1);
106
+    val<<=1;
108 107
     ST7920_DELAY_3
109 108
 
110 109
     WRITE(ST7920_CLK_PIN,0);
111 110
     ST7920_DELAY_1
112 111
     WRITE(ST7920_DAT_PIN,val&0x80);
113
-    val<<=1;
114 112
     ST7920_DELAY_2
115 113
     WRITE(ST7920_CLK_PIN,1);
114
+    val<<=1;
116 115
     ST7920_DELAY_3
117 116
 
118 117
     WRITE(ST7920_CLK_PIN,0);
119 118
     ST7920_DELAY_1
120 119
     WRITE(ST7920_DAT_PIN,val&0x80);
121
-    val<<=1;
122 120
     ST7920_DELAY_2
123 121
     WRITE(ST7920_CLK_PIN,1);
122
+    val<<=1;
124 123
     ST7920_DELAY_3
125 124
 
126 125
     WRITE(ST7920_CLK_PIN,0);
127 126
     ST7920_DELAY_1
128 127
     WRITE(ST7920_DAT_PIN,val&0x80);
129
-    val<<=1;
130 128
     ST7920_DELAY_2
131 129
     WRITE(ST7920_CLK_PIN,1);
130
+    val<<=1;
132 131
     ST7920_DELAY_3
133 132
 
134 133
     WRITE(ST7920_CLK_PIN,0);
135 134
     ST7920_DELAY_1
136 135
     WRITE(ST7920_DAT_PIN,val&0x80);
137
-    val<<=1;
138 136
     ST7920_DELAY_2
139 137
     WRITE(ST7920_CLK_PIN,1);
138
+    val<<=1;
140 139
     ST7920_DELAY_3
141 140
 
142 141
     WRITE(ST7920_CLK_PIN,0);
143 142
     ST7920_DELAY_1
144 143
     WRITE(ST7920_DAT_PIN,val&0x80);
145
-    val<<=1;
146 144
     ST7920_DELAY_2
147 145
     WRITE(ST7920_CLK_PIN,1);
146
+    val<<=1;
148 147
     ST7920_DELAY_3
149 148
 
150 149
     WRITE(ST7920_CLK_PIN,0);
151 150
     ST7920_DELAY_1
152 151
     WRITE(ST7920_DAT_PIN,val&0x80);
153
-    val<<=1;
154 152
     ST7920_DELAY_2
155 153
     WRITE(ST7920_CLK_PIN,1);
156 154
 }
@@ -234,7 +232,7 @@ class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
234 232
   U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) { UNUSED(dummy); }
235 233
 };
236 234
 
237
-#pragma GCC pop_options
235
+#pragma GCC reset_options
238 236
 
239 237
 #endif //U8GLIB_ST7920
240 238
 #endif //ULCDST7920_H

Loading…
Cancel
Save