Selaa lähdekoodia

Function-style critical section macros

Scott Lahteine 4 vuotta sitten
vanhempi
commit
fa6e7cb733

+ 2
- 2
Marlin/src/HAL/HAL_AVR/HAL.h Näytä tiedosto

@@ -53,8 +53,8 @@
53 53
 //#define analogInputToDigitalPin(IO) IO
54 54
 
55 55
 #ifndef CRITICAL_SECTION_START
56
-  #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli()
57
-  #define CRITICAL_SECTION_END    SREG = _sreg
56
+  #define CRITICAL_SECTION_START()  unsigned char _sreg = SREG; cli()
57
+  #define CRITICAL_SECTION_END()    SREG = _sreg
58 58
 #endif
59 59
 #define ISRS_ENABLED() TEST(SREG, SREG_I)
60 60
 #define ENABLE_ISRS()  sei()

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL.h Näytä tiedosto

@@ -119,8 +119,8 @@ typedef int8_t pin_t;
119 119
 //
120 120
 // Interrupts
121 121
 //
122
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
123
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
122
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_PRIMASK(); __disable_irq()
123
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
124 124
 #define ISRS_ENABLED() (!__get_PRIMASK())
125 125
 #define ENABLE_ISRS()  __enable_irq()
126 126
 #define DISABLE_ISRS() __disable_irq()

+ 4
- 4
Marlin/src/HAL/HAL_DUE/InterruptVectors.cpp Näytä tiedosto

@@ -63,13 +63,13 @@ static pfnISR_Handler* get_relocated_table_addr() {
63 63
   memcpy(&ram_tab, romtab, sizeof(ram_tab));
64 64
 
65 65
   // Disable global interrupts
66
-  CRITICAL_SECTION_START;
66
+  CRITICAL_SECTION_START();
67 67
 
68 68
   // Set the vector table base address to the SRAM copy
69 69
   SCB->VTOR = (uint32_t)(&ram_tab);
70 70
 
71 71
   // Reenable interrupts
72
-  CRITICAL_SECTION_END;
72
+  CRITICAL_SECTION_END();
73 73
 
74 74
   // Return the address of the table
75 75
   return (pfnISR_Handler*)(&ram_tab);
@@ -80,7 +80,7 @@ pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler) {
80 80
   pfnISR_Handler *isrtab = get_relocated_table_addr();
81 81
 
82 82
   // Disable global interrupts
83
-  CRITICAL_SECTION_START;
83
+  CRITICAL_SECTION_START();
84 84
 
85 85
   // Get the original handler
86 86
   pfnISR_Handler oldHandler = isrtab[irq + 16];
@@ -89,7 +89,7 @@ pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler) {
89 89
   isrtab[irq + 16] = newHandler;
90 90
 
91 91
   // Reenable interrupts
92
-  CRITICAL_SECTION_END;
92
+  CRITICAL_SECTION_END();
93 93
 
94 94
   // Return the original one
95 95
   return oldHandler;

+ 2
- 2
Marlin/src/HAL/HAL_ESP32/HAL.h Näytä tiedosto

@@ -65,8 +65,8 @@ extern portMUX_TYPE spinlock;
65 65
   #define NUM_SERIAL 1
66 66
 #endif
67 67
 
68
-#define CRITICAL_SECTION_START portENTER_CRITICAL(&spinlock)
69
-#define CRITICAL_SECTION_END   portEXIT_CRITICAL(&spinlock)
68
+#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
69
+#define CRITICAL_SECTION_END()   portEXIT_CRITICAL(&spinlock)
70 70
 #define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL)
71 71
 #define ENABLE_ISRS()  if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
72 72
 #define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)

+ 2
- 2
Marlin/src/HAL/HAL_LINUX/HAL.h Näytä tiedosto

@@ -72,8 +72,8 @@ extern HalSerial usb_serial;
72 72
 //
73 73
 // Interrupts
74 74
 //
75
-#define CRITICAL_SECTION_START
76
-#define CRITICAL_SECTION_END
75
+#define CRITICAL_SECTION_START()
76
+#define CRITICAL_SECTION_END()
77 77
 #define ISRS_ENABLED()
78 78
 #define ENABLE_ISRS()
79 79
 #define DISABLE_ISRS()

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/HAL.h Näytä tiedosto

@@ -119,8 +119,8 @@ extern "C" volatile uint32_t _millis;
119 119
 //
120 120
 // Interrupts
121 121
 //
122
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
123
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
122
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_PRIMASK(); __disable_irq()
123
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
124 124
 #define ISRS_ENABLED() (!__get_PRIMASK())
125 125
 #define ENABLE_ISRS()  __enable_irq()
126 126
 #define DISABLE_ISRS() __disable_irq()

+ 2
- 2
Marlin/src/HAL/HAL_SAMD51/HAL.h Näytä tiedosto

@@ -101,8 +101,8 @@ typedef int8_t pin_t;
101 101
 //
102 102
 // Interrupts
103 103
 //
104
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
105
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
104
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_PRIMASK(); __disable_irq()
105
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
106 106
 #define ISRS_ENABLED() (!__get_PRIMASK())
107 107
 #define ENABLE_ISRS()  __enable_irq()
108 108
 #define DISABLE_ISRS() __disable_irq()

+ 2
- 2
Marlin/src/HAL/HAL_STM32/HAL.h Näytä tiedosto

@@ -127,8 +127,8 @@
127 127
   #define analogInputToDigitalPin(p) (p)
128 128
 #endif
129 129
 
130
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
131
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
130
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_PRIMASK(); __disable_irq()
131
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
132 132
 #define ISRS_ENABLED() (!__get_PRIMASK())
133 133
 #define ENABLE_ISRS()  __enable_irq()
134 134
 #define DISABLE_ISRS() __disable_irq()

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/HAL.h Näytä tiedosto

@@ -162,8 +162,8 @@ void HAL_idletask();
162 162
   #define digitalPinHasPWM(P) (PIN_MAP[P].timer_device != nullptr)
163 163
 #endif
164 164
 
165
-#define CRITICAL_SECTION_START  uint32_t primask = __get_primask(); (void)__iCliRetVal()
166
-#define CRITICAL_SECTION_END    if (!primask) (void)__iSeiRetVal()
165
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_primask(); (void)__iCliRetVal()
166
+#define CRITICAL_SECTION_END()    if (!primask) (void)__iSeiRetVal()
167 167
 #define ISRS_ENABLED() (!__get_primask())
168 168
 #define ENABLE_ISRS()  ((void)__iSeiRetVal())
169 169
 #define DISABLE_ISRS() ((void)__iCliRetVal())

+ 2
- 2
Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h Näytä tiedosto

@@ -127,8 +127,8 @@
127 127
   #define analogInputToDigitalPin(p) (p)
128 128
 #endif
129 129
 
130
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
131
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
130
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_PRIMASK(); __disable_irq()
131
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
132 132
 #define ISRS_ENABLED() (!__get_PRIMASK())
133 133
 #define ENABLE_ISRS()  __enable_irq()
134 134
 #define DISABLE_ISRS() __disable_irq()

+ 2
- 2
Marlin/src/HAL/HAL_TEENSY31_32/HAL.h Näytä tiedosto

@@ -70,8 +70,8 @@ typedef int8_t pin_t;
70 70
   #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
71 71
 #endif
72 72
 
73
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
74
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
73
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_PRIMASK(); __disable_irq()
74
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
75 75
 #define ISRS_ENABLED() (!__get_PRIMASK())
76 76
 #define ENABLE_ISRS()  __enable_irq()
77 77
 #define DISABLE_ISRS() __disable_irq()

+ 2
- 2
Marlin/src/HAL/HAL_TEENSY35_36/HAL.h Näytä tiedosto

@@ -73,8 +73,8 @@ typedef int8_t pin_t;
73 73
   #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
74 74
 #endif
75 75
 
76
-#define CRITICAL_SECTION_START  uint32_t primask = __get_primask(); __disable_irq()
77
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
76
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_primask(); __disable_irq()
77
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
78 78
 #define ISRS_ENABLED() (!__get_primask())
79 79
 #define ENABLE_ISRS()  __enable_irq()
80 80
 #define DISABLE_ISRS() __disable_irq()

+ 2
- 2
Marlin/src/HAL/shared/servo.cpp Näytä tiedosto

@@ -129,9 +129,9 @@ void Servo::writeMicroseconds(int value) {
129 129
     value = constrain(value, SERVO_MIN(min), SERVO_MAX(max)) - (TRIM_DURATION);
130 130
     value = usToTicks(value);  // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
131 131
 
132
-    CRITICAL_SECTION_START;
132
+    CRITICAL_SECTION_START();
133 133
     servo_info[channel].ticks = value;
134
-    CRITICAL_SECTION_END;
134
+    CRITICAL_SECTION_END();
135 135
   }
136 136
 }
137 137
 

+ 10
- 10
Marlin/src/feature/Max7219_Debug_LEDs.cpp Näytä tiedosto

@@ -125,8 +125,8 @@ uint8_t Max7219::led_line[MAX7219_LINES]; // = { 0 };
125 125
   #define SIG_DELAY() DELAY_US(1)   // Approximate a 1µs delay on 32-bit ARM
126 126
   #undef CRITICAL_SECTION_START
127 127
   #undef CRITICAL_SECTION_END
128
-  #define CRITICAL_SECTION_START NOOP
129
-  #define CRITICAL_SECTION_END   NOOP
128
+  #define CRITICAL_SECTION_START() NOOP
129
+  #define CRITICAL_SECTION_END()   NOOP
130 130
 #else
131 131
   #define SIG_DELAY() DELAY_NS(188) // Delay for 0.1875µs (16MHz AVR) or 0.15µs (20MHz AVR)
132 132
 #endif
@@ -163,7 +163,7 @@ inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) {
163 163
 }
164 164
 
165 165
 void Max7219::noop() {
166
-  CRITICAL_SECTION_START;
166
+  CRITICAL_SECTION_START();
167 167
   SIG_DELAY();
168 168
   WRITE(MAX7219_DIN_PIN, LOW);
169 169
   for (uint8_t i = 16; i--;) {
@@ -174,11 +174,11 @@ void Max7219::noop() {
174 174
     WRITE(MAX7219_CLK_PIN, HIGH);
175 175
     SIG_DELAY();
176 176
   }
177
-  CRITICAL_SECTION_END;
177
+  CRITICAL_SECTION_END();
178 178
 }
179 179
 
180 180
 void Max7219::putbyte(uint8_t data) {
181
-  CRITICAL_SECTION_START;
181
+  CRITICAL_SECTION_START();
182 182
   for (uint8_t i = 8; i--;) {
183 183
     SIG_DELAY();
184 184
     WRITE(MAX7219_CLK_PIN, LOW);       // tick
@@ -189,7 +189,7 @@ void Max7219::putbyte(uint8_t data) {
189 189
     SIG_DELAY();
190 190
     data <<= 1;
191 191
   }
192
-  CRITICAL_SECTION_END;
192
+  CRITICAL_SECTION_END();
193 193
 }
194 194
 
195 195
 void Max7219::pulse_load() {
@@ -202,12 +202,12 @@ void Max7219::pulse_load() {
202 202
 
203 203
 void Max7219::send(const uint8_t reg, const uint8_t data) {
204 204
   SIG_DELAY();
205
-  CRITICAL_SECTION_START;
205
+  CRITICAL_SECTION_START();
206 206
   SIG_DELAY();
207 207
   putbyte(reg);          // specify register
208 208
   SIG_DELAY();
209 209
   putbyte(data);         // put data
210
-  CRITICAL_SECTION_END;
210
+  CRITICAL_SECTION_END();
211 211
 }
212 212
 
213 213
 // Send out a single native row of bits to just one unit
@@ -574,14 +574,14 @@ void Max7219::idle_tasks() {
574 574
   #define MAX7219_USE_HEAD (defined(MAX7219_DEBUG_PLANNER_HEAD) || defined(MAX7219_DEBUG_PLANNER_QUEUE))
575 575
   #define MAX7219_USE_TAIL (defined(MAX7219_DEBUG_PLANNER_TAIL) || defined(MAX7219_DEBUG_PLANNER_QUEUE))
576 576
   #if MAX7219_USE_HEAD || MAX7219_USE_TAIL
577
-    CRITICAL_SECTION_START;
577
+    CRITICAL_SECTION_START();
578 578
     #if MAX7219_USE_HEAD
579 579
       const uint8_t head = planner.block_buffer_head;
580 580
     #endif
581 581
     #if MAX7219_USE_TAIL
582 582
       const uint8_t tail = planner.block_buffer_tail;
583 583
     #endif
584
-    CRITICAL_SECTION_END;
584
+    CRITICAL_SECTION_END();
585 585
   #endif
586 586
 
587 587
   #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)

+ 4
- 4
Marlin/src/libs/buzzer.cpp Näytä tiedosto

@@ -63,13 +63,13 @@ void Buzzer::tick() {
63 63
 
64 64
     if (state.tone.frequency > 0) {
65 65
       #if ENABLED(EXTENSIBLE_UI)
66
-        CRITICAL_SECTION_START;
66
+        CRITICAL_SECTION_START();
67 67
         ExtUI::onPlayTone(state.tone.frequency, state.tone.duration);
68
-        CRITICAL_SECTION_END;
68
+        CRITICAL_SECTION_END();
69 69
       #elif ENABLED(SPEAKER)
70
-        CRITICAL_SECTION_START;
70
+        CRITICAL_SECTION_START();
71 71
         ::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration);
72
-        CRITICAL_SECTION_END;
72
+        CRITICAL_SECTION_END();
73 73
       #else
74 74
         on();
75 75
       #endif

Loading…
Peruuta
Tallenna