Browse Source

Use _BV macros, patch up others

Scott Lahteine 8 years ago
parent
commit
ff13070b59

+ 6
- 6
Marlin/Marlin.h View File

@@ -217,12 +217,12 @@ void Stop();
217 217
  * Debug flags - not yet widely applied
218 218
  */
219 219
 enum DebugFlags {
220
-  DEBUG_ECHO          = BIT(0),
221
-  DEBUG_INFO          = BIT(1),
222
-  DEBUG_ERRORS        = BIT(2),
223
-  DEBUG_DRYRUN        = BIT(3),
224
-  DEBUG_COMMUNICATION = BIT(4),
225
-  DEBUG_LEVELING      = BIT(5)
220
+  DEBUG_ECHO          = _BV(0),
221
+  DEBUG_INFO          = _BV(1),
222
+  DEBUG_ERRORS        = _BV(2),
223
+  DEBUG_DRYRUN        = _BV(3),
224
+  DEBUG_COMMUNICATION = _BV(4),
225
+  DEBUG_LEVELING      = _BV(5)
226 226
 };
227 227
 extern uint8_t marlin_debug_flags;
228 228
 

+ 1
- 1
Marlin/MarlinSerial.cpp View File

@@ -79,7 +79,7 @@ void MarlinSerial::begin(long baud) {
79 79
   #endif
80 80
 
81 81
   if (useU2X) {
82
-    M_UCSRxA = BIT(M_U2Xx);
82
+    M_UCSRxA = _BV(M_U2Xx);
83 83
     baud_setting = (F_CPU / 4 / baud - 1) / 2;
84 84
   }
85 85
   else {

+ 10
- 10
Marlin/Marlin_main.cpp View File

@@ -1608,8 +1608,8 @@ static void setup_for_endstop_move() {
1608 1608
 
1609 1609
   enum ProbeAction {
1610 1610
     ProbeStay          = 0,
1611
-    ProbeDeploy        = BIT(0),
1612
-    ProbeStow          = BIT(1),
1611
+    ProbeDeploy        = _BV(0),
1612
+    ProbeStow          = _BV(1),
1613 1613
     ProbeDeployAndStow = (ProbeDeploy | ProbeStow)
1614 1614
   };
1615 1615
 
@@ -6461,33 +6461,33 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
6461 6461
     return;
6462 6462
   }
6463 6463
   float nx, ny, ne, normalized_dist;
6464
-  if (ix > pix && (x_splits) & BIT(ix)) {
6464
+  if (ix > pix && TEST(x_splits, ix)) {
6465 6465
     nx = mbl.get_x(ix);
6466 6466
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6467 6467
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6468 6468
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6469
-    x_splits ^= BIT(ix);
6469
+    CBI(x_splits, ix);
6470 6470
   }
6471
-  else if (ix < pix && (x_splits) & BIT(pix)) {
6471
+  else if (ix < pix && TEST(x_splits, pix)) {
6472 6472
     nx = mbl.get_x(pix);
6473 6473
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6474 6474
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6475 6475
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6476
-    x_splits ^= BIT(pix);
6476
+    CBI(x_splits, pix);
6477 6477
   }
6478
-  else if (iy > piy && (y_splits) & BIT(iy)) {
6478
+  else if (iy > piy && TEST(y_splits, iy)) {
6479 6479
     ny = mbl.get_y(iy);
6480 6480
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
6481 6481
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
6482 6482
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6483
-    y_splits ^= BIT(iy);
6483
+    CBI(y_splits, iy);
6484 6484
   }
6485
-  else if (iy < piy && (y_splits) & BIT(piy)) {
6485
+  else if (iy < piy && TEST(y_splits, piy)) {
6486 6486
     ny = mbl.get_y(piy);
6487 6487
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
6488 6488
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
6489 6489
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6490
-    y_splits ^= BIT(piy);
6490
+    CBI(y_splits, piy);
6491 6491
   }
6492 6492
   else {
6493 6493
     // Already split on a border

+ 2
- 2
Marlin/Sd2Card.cpp View File

@@ -35,8 +35,8 @@
35 35
    */
36 36
   static void spiInit(uint8_t spiRate) {
37 37
     // See avr processor documentation
38
-    SPCR = BIT(SPE) | BIT(MSTR) | (spiRate >> 1);
39
-    SPSR = spiRate & 1 || spiRate == 6 ? 0 : BIT(SPI2X);
38
+    SPCR = _BV(SPE) | _BV(MSTR) | (spiRate >> 1);
39
+    SPSR = spiRate & 1 || spiRate == 6 ? 0 : _BV(SPI2X);
40 40
   }
41 41
   //------------------------------------------------------------------------------
42 42
   /** SPI receive a byte */

+ 4
- 4
Marlin/Sd2PinMap.h View File

@@ -405,10 +405,10 @@ static inline __attribute__((always_inline))
405 405
   void setPinMode(uint8_t pin, uint8_t mode) {
406 406
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
407 407
     if (mode) {
408
-      *digitalPinMap[pin].ddr |= BIT(digitalPinMap[pin].bit);
408
+      SBI(*digitalPinMap[pin].ddr, digitalPinMap[pin].bit);
409 409
     }
410 410
     else {
411
-      *digitalPinMap[pin].ddr &= ~BIT(digitalPinMap[pin].bit);
411
+      CBI(*digitalPinMap[pin].ddr, digitalPinMap[pin].bit);
412 412
     }
413 413
   }
414 414
   else {
@@ -428,10 +428,10 @@ static inline __attribute__((always_inline))
428 428
   void fastDigitalWrite(uint8_t pin, uint8_t value) {
429 429
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
430 430
     if (value) {
431
-      *digitalPinMap[pin].port |= BIT(digitalPinMap[pin].bit);
431
+      SBI(*digitalPinMap[pin].port, digitalPinMap[pin].bit);
432 432
     }
433 433
     else {
434
-      *digitalPinMap[pin].port &= ~BIT(digitalPinMap[pin].bit);
434
+      CBI(*digitalPinMap[pin].port, digitalPinMap[pin].bit);
435 435
     }
436 436
   }
437 437
   else {

+ 1
- 1
Marlin/SdVolume.cpp View File

@@ -364,7 +364,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
364 364
   blocksPerCluster_ = fbs->sectorsPerCluster;
365 365
   // determine shift that is same as multiply by blocksPerCluster_
366 366
   clusterSizeShift_ = 0;
367
-  while (blocksPerCluster_ != BIT(clusterSizeShift_)) {
367
+  while (blocksPerCluster_ != _BV(clusterSizeShift_)) {
368 368
     // error if not power of 2
369 369
     if (clusterSizeShift_++ > 7) goto fail;
370 370
   }

+ 3
- 3
Marlin/dogm_lcd_implementation.h View File

@@ -22,9 +22,9 @@
22 22
   #define BLEN_A 0
23 23
   #define BLEN_B 1
24 24
   #define BLEN_C 2
25
-  #define EN_A BIT(BLEN_A)
26
-  #define EN_B BIT(BLEN_B)
27
-  #define EN_C BIT(BLEN_C)
25
+  #define EN_A (_BV(BLEN_A))
26
+  #define EN_B (_BV(BLEN_B))
27
+  #define EN_C (_BV(BLEN_C))
28 28
   #define LCD_CLICKED (buttons&EN_C)
29 29
 #endif
30 30
 

+ 16
- 16
Marlin/planner.cpp View File

@@ -580,23 +580,23 @@ float junction_deviation = 0.1;
580 580
   // Compute direction bits for this block
581 581
   uint8_t db = 0;
582 582
   #if ENABLED(COREXY)
583
-    if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
584
-    if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
585
-    if (dz < 0) db |= BIT(Z_AXIS);
586
-    if (dx + dy < 0) db |= BIT(A_AXIS); // Motor A direction
587
-    if (dx - dy < 0) db |= BIT(B_AXIS); // Motor B direction
583
+    if (dx < 0) SBI(db, X_HEAD); // Save the real Extruder (head) direction in X Axis
584
+    if (dy < 0) SBI(db, Y_HEAD); // ...and Y
585
+    if (dz < 0) SBI(db, Z_AXIS);
586
+    if (dx + dy < 0) SBI(db, A_AXIS); // Motor A direction
587
+    if (dx - dy < 0) SBI(db, B_AXIS); // Motor B direction
588 588
   #elif ENABLED(COREXZ)
589
-    if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
590
-    if (dy < 0) db |= BIT(Y_AXIS);
591
-    if (dz < 0) db |= BIT(Z_HEAD); // ...and Z
592
-    if (dx + dz < 0) db |= BIT(A_AXIS); // Motor A direction
593
-    if (dx - dz < 0) db |= BIT(C_AXIS); // Motor B direction
589
+    if (dx < 0) SBI(db, X_HEAD); // Save the real Extruder (head) direction in X Axis
590
+    if (dy < 0) SBI(db, Y_AXIS);
591
+    if (dz < 0) SBI(db, Z_HEAD); // ...and Z
592
+    if (dx + dz < 0) SBI(db, A_AXIS); // Motor A direction
593
+    if (dx - dz < 0) SBI(db, C_AXIS); // Motor B direction
594 594
   #else
595
-    if (dx < 0) db |= BIT(X_AXIS);
596
-    if (dy < 0) db |= BIT(Y_AXIS);
597
-    if (dz < 0) db |= BIT(Z_AXIS);
595
+    if (dx < 0) SBI(db, X_AXIS);
596
+    if (dy < 0) SBI(db, Y_AXIS);
597
+    if (dz < 0) SBI(db, Z_AXIS);
598 598
   #endif
599
-  if (de < 0) db |= BIT(E_AXIS);
599
+  if (de < 0) SBI(db, E_AXIS);
600 600
   block->direction_bits = db;
601 601
 
602 602
   block->active_extruder = extruder;
@@ -824,14 +824,14 @@ float junction_deviation = 0.1;
824 824
          ys1 = axis_segment_time[Y_AXIS][1],
825 825
          ys2 = axis_segment_time[Y_AXIS][2];
826 826
 
827
-    if ((direction_change & BIT(X_AXIS)) != 0) {
827
+    if (TEST(direction_change, X_AXIS)) {
828 828
       xs2 = axis_segment_time[X_AXIS][2] = xs1;
829 829
       xs1 = axis_segment_time[X_AXIS][1] = xs0;
830 830
       xs0 = 0;
831 831
     }
832 832
     xs0 = axis_segment_time[X_AXIS][0] = xs0 + segment_time;
833 833
 
834
-    if ((direction_change & BIT(Y_AXIS)) != 0) {
834
+    if (TEST(direction_change, Y_AXIS)) {
835 835
       ys2 = axis_segment_time[Y_AXIS][2] = axis_segment_time[Y_AXIS][1];
836 836
       ys1 = axis_segment_time[Y_AXIS][1] = axis_segment_time[Y_AXIS][0];
837 837
       ys0 = 0;

+ 10
- 8
Marlin/servo.cpp View File

@@ -139,12 +139,12 @@ static void initISR(timer16_Sequence_t timer) {
139 139
       TCCR1B = _BV(CS11);     // set prescaler of 8
140 140
       TCNT1 = 0;              // clear the timer count
141 141
       #if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
142
-        TIFR |= _BV(OCF1A);      // clear any pending interrupts;
143
-        TIMSK |= _BV(OCIE1A);    // enable the output compare interrupt
142
+        SBI(TIFR, OCF1A);      // clear any pending interrupts;
143
+        SBI(TIMSK, OCIE1A);    // enable the output compare interrupt
144 144
       #else
145 145
         // here if not ATmega8 or ATmega128
146
-        TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;
147
-        TIMSK1 |= _BV(OCIE1A);   // enable the output compare interrupt
146
+        SBI(TIFR1, OCF1A);     // clear any pending interrupts;
147
+        SBI(TIMSK1, OCIE1A);   // enable the output compare interrupt
148 148
       #endif
149 149
       #ifdef WIRING
150 150
         timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
@@ -158,8 +158,8 @@ static void initISR(timer16_Sequence_t timer) {
158 158
       TCCR3B = _BV(CS31);     // set prescaler of 8
159 159
       TCNT3 = 0;              // clear the timer count
160 160
       #ifdef __AVR_ATmega128__
161
-        TIFR |= _BV(OCF3A);     // clear any pending interrupts;
162
-        ETIMSK |= _BV(OCIE3A);  // enable the output compare interrupt
161
+        SBI(TIFR, OCF3A);     // clear any pending interrupts;
162
+        SBI(ETIMSK, OCIE3A);  // enable the output compare interrupt
163 163
       #else
164 164
         TIFR3 = _BV(OCF3A);     // clear any pending interrupts;
165 165
         TIMSK3 =  _BV(OCIE3A) ; // enable the output compare interrupt
@@ -195,21 +195,23 @@ static void finISR(timer16_Sequence_t timer) {
195 195
   // Disable use of the given timer
196 196
   #ifdef WIRING
197 197
     if (timer == _timer1) {
198
+      CBI(
198 199
       #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
199 200
         TIMSK1
200 201
       #else
201 202
         TIMSK
202 203
       #endif
203
-          &= ~_BV(OCIE1A);    // disable timer 1 output compare interrupt
204
+          , OCIE1A);    // disable timer 1 output compare interrupt
204 205
       timerDetach(TIMER1OUTCOMPAREA_INT);
205 206
     }
206 207
     else if (timer == _timer3) {
208
+      CBI(
207 209
       #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
208 210
         TIMSK3
209 211
       #else
210 212
         ETIMSK
211 213
       #endif
212
-          &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
214
+          , OCIE3A);    // disable the timer3 output compare A interrupt
213 215
       timerDetach(TIMER3OUTCOMPAREA_INT);
214 216
     }
215 217
   #else //!WIRING

+ 18
- 18
Marlin/stepper.cpp View File

@@ -242,8 +242,8 @@ volatile signed char count_direction[NUM_AXIS] = { 1 };
242 242
 
243 243
 // Some useful constants
244 244
 
245
-#define ENABLE_STEPPER_DRIVER_INTERRUPT()  TIMSK1 |= BIT(OCIE1A)
246
-#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~BIT(OCIE1A)
245
+#define ENABLE_STEPPER_DRIVER_INTERRUPT()  SBI(TIMSK1, OCIE1A)
246
+#define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A)
247 247
 
248 248
 void endstops_hit_on_purpose() {
249 249
   endstop_hit_bits = 0;
@@ -253,20 +253,20 @@ void checkHitEndstops() {
253 253
   if (endstop_hit_bits) {
254 254
     SERIAL_ECHO_START;
255 255
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
256
-    if (endstop_hit_bits & BIT(X_MIN)) {
256
+    if (TEST(endstop_hit_bits, X_MIN)) {
257 257
       SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]);
258 258
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X");
259 259
     }
260
-    if (endstop_hit_bits & BIT(Y_MIN)) {
260
+    if (TEST(endstop_hit_bits, Y_MIN)) {
261 261
       SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]);
262 262
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y");
263 263
     }
264
-    if (endstop_hit_bits & BIT(Z_MIN)) {
264
+    if (TEST(endstop_hit_bits, Z_MIN)) {
265 265
       SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
266 266
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
267 267
     }
268 268
     #if ENABLED(Z_MIN_PROBE_ENDSTOP)
269
-      if (endstop_hit_bits & BIT(Z_MIN_PROBE)) {
269
+      if (TEST(endstop_hit_bits, Z_MIN_PROBE)) {
270 270
         SERIAL_ECHOPAIR(" Z_MIN_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
271 271
         LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
272 272
       }
@@ -309,7 +309,7 @@ inline void update_endstops() {
309 309
   #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
310 310
   #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
311 311
   #define _AXIS(AXIS) AXIS ##_AXIS
312
-  #define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_ENDSTOP(AXIS, MIN))
312
+  #define _ENDSTOP_HIT(AXIS) SBI(endstop_hit_bits, _ENDSTOP(AXIS, MIN))
313 313
   #define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
314 314
 
315 315
   // SET_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
@@ -424,7 +424,7 @@ inline void update_endstops() {
424 424
 
425 425
             if (z_test && current_block->steps[Z_AXIS] > 0) { // z_test = Z_MIN || Z2_MIN
426 426
               endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
427
-              endstop_hit_bits |= BIT(Z_MIN);
427
+              SBI(endstop_hit_bits, Z_MIN);
428 428
               if (!performing_homing || (z_test == 0x3))  //if not performing home or if both endstops were trigged during homing...
429 429
                 step_events_completed = current_block->step_event_count;
430 430
             }
@@ -440,7 +440,7 @@ inline void update_endstops() {
440 440
 
441 441
           if (TEST_ENDSTOP(Z_MIN_PROBE)) {
442 442
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
443
-            endstop_hit_bits |= BIT(Z_MIN_PROBE);
443
+            SBI(endstop_hit_bits, Z_MIN_PROBE);
444 444
           }
445 445
         #endif
446 446
       }
@@ -460,7 +460,7 @@ inline void update_endstops() {
460 460
 
461 461
             if (z_test && current_block->steps[Z_AXIS] > 0) {  // t_test = Z_MAX || Z2_MAX
462 462
               endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
463
-              endstop_hit_bits |= BIT(Z_MIN);
463
+              SBI(endstop_hit_bits, Z_MIN);
464 464
               if (!performing_homing || (z_test == 0x3))  //if not performing home or if both endstops were trigged during homing...
465 465
                 step_events_completed = current_block->step_event_count;
466 466
             }
@@ -963,7 +963,7 @@ void st_init() {
963 963
       WRITE(Z_MIN_PIN,HIGH);
964 964
     #endif
965 965
   #endif
966
-  
966
+
967 967
   #if HAS_Z2_MIN
968 968
     SET_INPUT(Z2_MIN_PIN);
969 969
     #if ENABLED(ENDSTOPPULLUP_ZMIN)
@@ -1052,10 +1052,10 @@ void st_init() {
1052 1052
   #endif
1053 1053
 
1054 1054
   // waveform generation = 0100 = CTC
1055
-  TCCR1B &= ~BIT(WGM13);
1056
-  TCCR1B |=  BIT(WGM12);
1057
-  TCCR1A &= ~BIT(WGM11);
1058
-  TCCR1A &= ~BIT(WGM10);
1055
+  CBI(TCCR1B, WGM13);
1056
+  SBI(TCCR1B, WGM12);
1057
+  CBI(TCCR1A, WGM11);
1058
+  CBI(TCCR1A, WGM10);
1059 1059
 
1060 1060
   // output mode = 00 (disconnected)
1061 1061
   TCCR1A &= ~(3 << COM1A0);
@@ -1073,11 +1073,11 @@ void st_init() {
1073 1073
 
1074 1074
   #if ENABLED(ADVANCE)
1075 1075
     #if defined(TCCR0A) && defined(WGM01)
1076
-      TCCR0A &= ~BIT(WGM01);
1077
-      TCCR0A &= ~BIT(WGM00);
1076
+      CBI(TCCR0A, WGM01);
1077
+      CBI(TCCR0A, WGM00);
1078 1078
     #endif
1079 1079
     e_steps[0] = e_steps[1] = e_steps[2] = e_steps[3] = 0;
1080
-    TIMSK0 |= BIT(OCIE0A);
1080
+    SBI(TIMSK0, OCIE0A);
1081 1081
   #endif //ADVANCE
1082 1082
 
1083 1083
   enable_endstops(true); // Start with endstops active. After homing they can be disabled

+ 21
- 20
Marlin/temperature.cpp View File

@@ -850,8 +850,8 @@ static void updateTemperaturesFromRawValues() {
850 850
 void tp_init() {
851 851
   #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
852 852
     //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
853
-    MCUCR = BIT(JTD);
854
-    MCUCR = BIT(JTD);
853
+    MCUCR = _BV(JTD);
854
+    MCUCR = _BV(JTD);
855 855
   #endif
856 856
 
857 857
   // Finish init of mult extruder arrays
@@ -914,13 +914,13 @@ void tp_init() {
914 914
   #endif //HEATER_0_USES_MAX6675
915 915
 
916 916
   #ifdef DIDR2
917
-    #define ANALOG_SELECT(pin) do{ if (pin < 8) DIDR0 |= BIT(pin); else DIDR2 |= BIT(pin - 8); }while(0)
917
+    #define ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin - 8); }while(0)
918 918
   #else
919
-    #define ANALOG_SELECT(pin) do{ DIDR0 |= BIT(pin); }while(0)
919
+    #define ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
920 920
   #endif
921 921
 
922 922
   // Set analog inputs
923
-  ADCSRA = BIT(ADEN) | BIT(ADSC) | BIT(ADIF) | 0x07;
923
+  ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07;
924 924
   DIDR0 = 0;
925 925
   #ifdef DIDR2
926 926
     DIDR2 = 0;
@@ -960,7 +960,7 @@ void tp_init() {
960 960
   // Use timer0 for temperature measurement
961 961
   // Interleave temperature interrupt with millies interrupt
962 962
   OCR0B = 128;
963
-  TIMSK0 |= BIT(OCIE0B);
963
+  SBI(TIMSK0, OCIE0B);
964 964
 
965 965
   // Wait for temperature measurement to settle
966 966
   delay(250);
@@ -1160,13 +1160,14 @@ void disable_all_heaters() {
1160 1160
 
1161 1161
     max6675_temp = 0;
1162 1162
 
1163
-    #ifdef PRR
1164
-      PRR &= ~BIT(PRSPI);
1165
-    #elif defined(PRR0)
1166
-      PRR0 &= ~BIT(PRSPI);
1167
-    #endif
1168
-
1169
-    SPCR = BIT(MSTR) | BIT(SPE) | BIT(SPR0);
1163
+    CBI(
1164
+      #ifdef PRR
1165
+        PRR
1166
+      #elif defined(PRR0)
1167
+        PRR0
1168
+      #endif
1169
+        , PRSPI);
1170
+    SPCR = _BV(MSTR) | _BV(SPE) | _BV(SPR0);
1170 1171
 
1171 1172
     // enable TT_MAX6675
1172 1173
     WRITE(MAX6675_SS, 0);
@@ -1177,13 +1178,13 @@ void disable_all_heaters() {
1177 1178
 
1178 1179
     // read MSB
1179 1180
     SPDR = 0;
1180
-    for (; (SPSR & BIT(SPIF)) == 0;);
1181
+    for (; !TEST(SPSR, SPIF););
1181 1182
     max6675_temp = SPDR;
1182 1183
     max6675_temp <<= 8;
1183 1184
 
1184 1185
     // read LSB
1185 1186
     SPDR = 0;
1186
-    for (; (SPSR & BIT(SPIF)) == 0;);
1187
+    for (; !TEST(SPSR, SPIF););
1187 1188
     max6675_temp |= SPDR;
1188 1189
 
1189 1190
     // disable TT_MAX6675
@@ -1256,7 +1257,7 @@ ISR(TIMER0_COMPB_vect) {
1256 1257
 
1257 1258
   static unsigned char temp_count = 0;
1258 1259
   static TempState temp_state = StartupDelay;
1259
-  static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
1260
+  static unsigned char pwm_count = _BV(SOFT_PWM_SCALE);
1260 1261
 
1261 1262
   // Static members for each heater
1262 1263
   #if ENABLED(SLOW_PWM_HEATERS)
@@ -1341,7 +1342,7 @@ ISR(TIMER0_COMPB_vect) {
1341 1342
       if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
1342 1343
     #endif
1343 1344
 
1344
-    pwm_count += BIT(SOFT_PWM_SCALE);
1345
+    pwm_count += _BV(SOFT_PWM_SCALE);
1345 1346
     pwm_count &= 0x7f;
1346 1347
 
1347 1348
   #else // SLOW_PWM_HEATERS
@@ -1423,7 +1424,7 @@ ISR(TIMER0_COMPB_vect) {
1423 1424
       if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
1424 1425
     #endif //FAN_SOFT_PWM
1425 1426
 
1426
-    pwm_count += BIT(SOFT_PWM_SCALE);
1427
+    pwm_count += _BV(SOFT_PWM_SCALE);
1427 1428
     pwm_count &= 0x7f;
1428 1429
 
1429 1430
     // increment slow_pwm_count only every 64 pwm_count circa 65.5ms
@@ -1449,9 +1450,9 @@ ISR(TIMER0_COMPB_vect) {
1449 1450
 
1450 1451
   #endif // SLOW_PWM_HEATERS
1451 1452
 
1452
-  #define SET_ADMUX_ADCSRA(pin) ADMUX = BIT(REFS0) | (pin & 0x07); ADCSRA |= BIT(ADSC)
1453
+  #define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC)
1453 1454
   #ifdef MUX5
1454
-    #define START_ADC(pin) if (pin > 7) ADCSRB = BIT(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1455
+    #define START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1455 1456
   #else
1456 1457
     #define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1457 1458
   #endif

+ 2
- 2
Marlin/ultralcd.cpp View File

@@ -1911,7 +1911,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
1911 1911
         WRITE(SHIFT_LD, HIGH);
1912 1912
         for (int8_t i = 0; i < 8; i++) {
1913 1913
           newbutton_reprapworld_keypad >>= 1;
1914
-          if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7);
1914
+          if (READ(SHIFT_OUT)) SBI(newbutton_reprapworld_keypad, 7);
1915 1915
           WRITE(SHIFT_CLK, HIGH);
1916 1916
           WRITE(SHIFT_CLK, LOW);
1917 1917
         }
@@ -1924,7 +1924,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
1924 1924
       unsigned char tmp_buttons = 0;
1925 1925
       for (int8_t i = 0; i < 8; i++) {
1926 1926
         newbutton >>= 1;
1927
-        if (READ(SHIFT_OUT)) newbutton |= BIT(7);
1927
+        if (READ(SHIFT_OUT)) SBI(newbutton, 7);
1928 1928
         WRITE(SHIFT_CLK, HIGH);
1929 1929
         WRITE(SHIFT_CLK, LOW);
1930 1930
       }

+ 19
- 19
Marlin/ultralcd.h View File

@@ -63,19 +63,19 @@
63 63
   void lcd_ignore_click(bool b=true);
64 64
 
65 65
   #if ENABLED(NEWPANEL)
66
-    #define EN_C BIT(BLEN_C)
67
-    #define EN_B BIT(BLEN_B)
68
-    #define EN_A BIT(BLEN_A)
66
+    #define EN_C (_BV(BLEN_C))
67
+    #define EN_B (_BV(BLEN_B))
68
+    #define EN_A (_BV(BLEN_A))
69 69
 
70 70
     #if ENABLED(REPRAPWORLD_KEYPAD)
71
-      #define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3))
72
-      #define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2))
73
-      #define EN_REPRAPWORLD_KEYPAD_F1 (BIT(BLEN_REPRAPWORLD_KEYPAD_F1))
74
-      #define EN_REPRAPWORLD_KEYPAD_UP (BIT(BLEN_REPRAPWORLD_KEYPAD_UP))
75
-      #define EN_REPRAPWORLD_KEYPAD_RIGHT (BIT(BLEN_REPRAPWORLD_KEYPAD_RIGHT))
76
-      #define EN_REPRAPWORLD_KEYPAD_MIDDLE (BIT(BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
77
-      #define EN_REPRAPWORLD_KEYPAD_DOWN (BIT(BLEN_REPRAPWORLD_KEYPAD_DOWN))
78
-      #define EN_REPRAPWORLD_KEYPAD_LEFT (BIT(BLEN_REPRAPWORLD_KEYPAD_LEFT))
71
+      #define EN_REPRAPWORLD_KEYPAD_F3 (_BV(BLEN_REPRAPWORLD_KEYPAD_F3))
72
+      #define EN_REPRAPWORLD_KEYPAD_F2 (_BV(BLEN_REPRAPWORLD_KEYPAD_F2))
73
+      #define EN_REPRAPWORLD_KEYPAD_F1 (_BV(BLEN_REPRAPWORLD_KEYPAD_F1))
74
+      #define EN_REPRAPWORLD_KEYPAD_UP (_BV(BLEN_REPRAPWORLD_KEYPAD_UP))
75
+      #define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(BLEN_REPRAPWORLD_KEYPAD_RIGHT))
76
+      #define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
77
+      #define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(BLEN_REPRAPWORLD_KEYPAD_DOWN))
78
+      #define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(BLEN_REPRAPWORLD_KEYPAD_LEFT))
79 79
 
80 80
       #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
81 81
       #define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
@@ -90,14 +90,14 @@
90 90
     #endif //REPRAPWORLD_KEYPAD
91 91
   #else
92 92
     //atomic, do not change
93
-    #define B_LE BIT(BL_LE)
94
-    #define B_UP BIT(BL_UP)
95
-    #define B_MI BIT(BL_MI)
96
-    #define B_DW BIT(BL_DW)
97
-    #define B_RI BIT(BL_RI)
98
-    #define B_ST BIT(BL_ST)
99
-    #define EN_B BIT(BLEN_B)
100
-    #define EN_A BIT(BLEN_A)
93
+    #define B_LE (_BV(BL_LE))
94
+    #define B_UP (_BV(BL_UP))
95
+    #define B_MI (_BV(BL_MI))
96
+    #define B_DW (_BV(BL_DW))
97
+    #define B_RI (_BV(BL_RI))
98
+    #define B_ST (_BV(BL_ST))
99
+    #define EN_B (_BV(BLEN_B))
100
+    #define EN_A (_BV(BLEN_A))
101 101
 
102 102
     #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
103 103
   #endif//NEWPANEL

+ 17
- 17
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -20,13 +20,13 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
20 20
   #define BLEN_B 1
21 21
   #define BLEN_A 0
22 22
 
23
-  #define EN_B BIT(BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
24
-  #define EN_A BIT(BLEN_A)
23
+  #define EN_B (_BV(BLEN_B)) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
24
+  #define EN_A (_BV(BLEN_A))
25 25
 
26 26
   #if defined(BTN_ENC) && BTN_ENC > -1
27 27
     // encoder click is directly connected
28 28
     #define BLEN_C 2
29
-    #define EN_C BIT(BLEN_C)
29
+    #define EN_C (_BV(BLEN_C))
30 30
   #endif
31 31
 
32 32
   //
@@ -85,14 +85,14 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
85 85
 
86 86
     #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
87 87
 
88
-    #define EN_REPRAPWORLD_KEYPAD_F3 BIT((BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
89
-    #define EN_REPRAPWORLD_KEYPAD_F2 BIT((BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
90
-    #define EN_REPRAPWORLD_KEYPAD_F1 BIT((BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
91
-    #define EN_REPRAPWORLD_KEYPAD_UP BIT((BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
92
-    #define EN_REPRAPWORLD_KEYPAD_RIGHT BIT((BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
93
-    #define EN_REPRAPWORLD_KEYPAD_MIDDLE BIT((BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
94
-    #define EN_REPRAPWORLD_KEYPAD_DOWN BIT((BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
95
-    #define EN_REPRAPWORLD_KEYPAD_LEFT BIT((BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
88
+    #define EN_REPRAPWORLD_KEYPAD_F3 (_BV(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
89
+    #define EN_REPRAPWORLD_KEYPAD_F2 (_BV(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
90
+    #define EN_REPRAPWORLD_KEYPAD_F1 (_BV(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
91
+    #define EN_REPRAPWORLD_KEYPAD_UP (_BV(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
92
+    #define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
93
+    #define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
94
+    #define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
95
+    #define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
96 96
 
97 97
     //#define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
98 98
     //#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
@@ -113,12 +113,12 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
113 113
     #define BL_ST 2
114 114
 
115 115
     //automatic, do not change
116
-    #define B_LE BIT(BL_LE)
117
-    #define B_UP BIT(BL_UP)
118
-    #define B_MI BIT(BL_MI)
119
-    #define B_DW BIT(BL_DW)
120
-    #define B_RI BIT(BL_RI)
121
-    #define B_ST BIT(BL_ST)
116
+    #define B_LE (_BV(BL_LE))
117
+    #define B_UP (_BV(BL_UP))
118
+    #define B_MI (_BV(BL_MI))
119
+    #define B_DW (_BV(BL_DW))
120
+    #define B_RI (_BV(BL_RI))
121
+    #define B_ST (_BV(BL_ST))
122 122
 
123 123
     #define LCD_CLICKED (buttons&(B_MI|B_ST))
124 124
   #endif

Loading…
Cancel
Save