Skip to content

Commit ee08814

Browse files
committed
♻️ Remove LOOP macros
1 parent 244c257 commit ee08814

File tree

121 files changed

+344
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+344
-349
lines changed

Marlin/src/HAL/AVR/HAL_SPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void spiBegin() {
198198
// output pin high - like sending 0xFF
199199
WRITE(SD_MOSI_PIN, HIGH);
200200

201-
LOOP_L_N(i, 8) {
201+
for (uint8_t i = 0; i < 8; ++i) {
202202
WRITE(SD_SCK_PIN, HIGH);
203203

204204
nop; // adjust so SCK is nice
@@ -225,7 +225,7 @@ void spiBegin() {
225225
void spiSend(uint8_t data) {
226226
// no interrupts during byte send - about 8µs
227227
cli();
228-
LOOP_L_N(i, 8) {
228+
for (uint8_t i = 0; i < 8; ++i) {
229229
WRITE(SD_SCK_PIN, LOW);
230230
WRITE(SD_MOSI_PIN, data & 0x80);
231231
data <<= 1;

Marlin/src/HAL/AVR/fast_pwm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
132132

133133
DEBUG_ECHOLNPGM("f=", f);
134134
DEBUG_ECHOLNPGM("(prescaler loop)");
135-
LOOP_L_N(i, COUNT(prescaler)) { // Loop through all prescaler values
135+
for (uint8_t i = 0; i < COUNT(prescaler); ++i) { // Loop through all prescaler values
136136
const uint32_t p = prescaler[i]; // Extend to 32 bits for calculations
137137
DEBUG_ECHOLNPGM("prescaler[", i, "]=", p);
138138
uint16_t res_fast_temp, res_pc_temp;
@@ -232,7 +232,7 @@ void MarlinHAL::init_pwm_timers() {
232232
#endif
233233
};
234234

235-
LOOP_L_N(i, COUNT(pwm_pin))
235+
for (uint8_t i = 0; i < COUNT(pwm_pin); ++i)
236236
set_pwm_frequency(pwm_pin[i], 1000);
237237
}
238238

Marlin/src/HAL/AVR/pinsDebug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@
7777

7878
void PRINT_ARRAY_NAME(uint8_t x) {
7979
PGM_P const name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[x].name);
80-
LOOP_L_N(y, MAX_NAME_LENGTH) {
80+
for (uint8_t y = 0; y < MAX_NAME_LENGTH; ++y) {
8181
char temp_char = pgm_read_byte(name_mem_pointer + y);
8282
if (temp_char != 0)
8383
SERIAL_CHAR(temp_char);
8484
else {
85-
LOOP_L_N(i, MAX_NAME_LENGTH - y) SERIAL_CHAR(' ');
85+
for (uint8_t i = 0; i < MAX_NAME_LENGTH - y; ++i) SERIAL_CHAR(' ');
8686
break;
8787
}
8888
}

Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void u8g_spiSend_sw_AVR_mode_0(uint8_t val) {
8888
volatile uint8_t *outData = u8g_outData,
8989
*outClock = u8g_outClock;
9090
U8G_ATOMIC_START();
91-
LOOP_L_N(i, 8) {
91+
for (uint8_t i = 0; i < 8; ++i) {
9292
if (val & 0x80)
9393
*outData |= bitData;
9494
else
@@ -108,7 +108,7 @@ void u8g_spiSend_sw_AVR_mode_3(uint8_t val) {
108108
volatile uint8_t *outData = u8g_outData,
109109
*outClock = u8g_outClock;
110110
U8G_ATOMIC_START();
111-
LOOP_L_N(i, 8) {
111+
for (uint8_t i = 0; i < 8; ++i) {
112112
*outClock &= bitNotClock;
113113
if (val & 0x80)
114114
*outData |= bitData;

Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Pio *SCK_pPio, *MOSI_pPio;
8181
uint32_t SCK_dwMask, MOSI_dwMask;
8282

8383
void u8g_spiSend_sw_DUE_mode_0(uint8_t val) { // 3MHz
84-
LOOP_L_N(i, 8) {
84+
for (uint8_t i = 0; i < 8; ++i) {
8585
if (val & 0x80)
8686
MOSI_pPio->PIO_SODR = MOSI_dwMask;
8787
else
@@ -95,7 +95,7 @@ void u8g_spiSend_sw_DUE_mode_0(uint8_t val) { // 3MHz
9595
}
9696

9797
void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
98-
LOOP_L_N(i, 8) {
98+
for (uint8_t i = 0; i < 8; ++i) {
9999
SCK_pPio->PIO_CODR = SCK_dwMask;
100100
DELAY_NS(50);
101101
if (val & 0x80)

Marlin/src/HAL/DUE/fastio/G2_PWM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extern PWM_map ISR_table[NUM_PWMS];
6363
extern uint32_t motor_current_setting[3];
6464

6565
#define IR_BIT(p) (WITHIN(p, 0, 3) ? (p) : (p) + 4)
66-
#define COPY_ACTIVE_TABLE() do{ LOOP_L_N(i, 6) work_table[i] = active_table[i]; }while(0)
66+
#define COPY_ACTIVE_TABLE() do{ for (uint8_t i = 0; i < 6; ++i) work_table[i] = active_table[i]; }while(0)
6767

6868
#define PWM_MR0 19999 // base repetition rate minus one count - 20mS
6969
#define PWM_PR 24 // prescaler value - prescaler divide by 24 + 1 - 1 MHz output

Marlin/src/HAL/ESP32/i2s.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ void i2s_push_sample() {
356356
// Every 4µs (when space in DMA buffer) toggle each expander PWM output using
357357
// the current duty cycle/frequency so they sync with any steps (once
358358
// through the DMA/FIFO buffers). PWM signal inversion handled by other functions
359-
LOOP_L_N(p, MAX_EXPANDER_BITS) {
359+
for (uint8_t p = 0; p < MAX_EXPANDER_BITS; ++p) {
360360
if (hal.pwm_pin_data[p].pwm_duty_ticks > 0) { // pin has active pwm?
361361
if (hal.pwm_pin_data[p].pwm_tick_count == 0) {
362362
if (TEST32(i2s_port_data, p)) { // hi->lo

Marlin/src/HAL/LPC1768/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void MarlinHAL::init() {
6868
#endif
6969

7070
// Flash status LED 3 times to indicate Marlin has started booting
71-
LOOP_L_N(i, 6) {
71+
for (uint8_t i = 0; i < 6; ++i) {
7272
TOGGLE(LED_PIN);
7373
delay(100);
7474
}

Marlin/src/HAL/LPC1768/tft/tft_spi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
7272
WRITE(TFT_CS_PIN, LOW);
7373
WriteReg(Reg);
7474

75-
LOOP_L_N(i, 4) {
75+
for (uint8_t i = 0; i < 4; ++i) {
7676
SPIx.read((uint8_t*)&d, 1);
7777
data = (data << 8) | d;
7878
}

Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
7777

78-
LOOP_L_N(i, 8) {
78+
for (uint8_t i = 0; i < 8; ++i) {
7979
if (spi_speed == 0) {
8080
LPC176x::gpio_set(mosi_pin, !!(b & 0x80));
8181
LPC176x::gpio_set(sck_pin, HIGH);
@@ -85,16 +85,16 @@ uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck
8585
}
8686
else {
8787
const uint8_t state = (b & 0x80) ? HIGH : LOW;
88-
LOOP_L_N(j, spi_speed)
88+
for (uint8_t j = 0; j < spi_speed; ++j)
8989
LPC176x::gpio_set(mosi_pin, state);
9090

91-
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
91+
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); ++j)
9292
LPC176x::gpio_set(sck_pin, HIGH);
9393

9494
b <<= 1;
9595
if (miso_pin >= 0 && LPC176x::gpio_get(miso_pin)) b |= 1;
9696

97-
LOOP_L_N(j, spi_speed)
97+
for (uint8_t j = 0; j < spi_speed; ++j)
9898
LPC176x::gpio_set(sck_pin, LOW);
9999
}
100100
}
@@ -104,7 +104,7 @@ uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck
104104

105105
uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
106106

107-
LOOP_L_N(i, 8) {
107+
for (uint8_t i = 0; i < 8; ++i) {
108108
const uint8_t state = (b & 0x80) ? HIGH : LOW;
109109
if (spi_speed == 0) {
110110
LPC176x::gpio_set(sck_pin, LOW);
@@ -113,13 +113,13 @@ uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck
113113
LPC176x::gpio_set(sck_pin, HIGH);
114114
}
115115
else {
116-
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
116+
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); ++j)
117117
LPC176x::gpio_set(sck_pin, LOW);
118118

119-
LOOP_L_N(j, spi_speed)
119+
for (uint8_t j = 0; j < spi_speed; ++j)
120120
LPC176x::gpio_set(mosi_pin, state);
121121

122-
LOOP_L_N(j, spi_speed)
122+
for (uint8_t j = 0; j < spi_speed; ++j)
123123
LPC176x::gpio_set(sck_pin, HIGH);
124124
}
125125
b <<= 1;

0 commit comments

Comments
 (0)