Skip to content

Commit 45f2139

Browse files
committed
tweak formatting
1 parent 5334ced commit 45f2139

File tree

12 files changed

+3639
-3865
lines changed

12 files changed

+3639
-3865
lines changed

Marlin/src/HAL/DUE/HAL_SPI.cpp

+210-249
Large diffs are not rendered by default.

Marlin/src/HAL/ESP32/HAL_SPI_HW.cpp

+171-192
Large diffs are not rendered by default.

Marlin/src/HAL/ESP32/HAL_SPI_HWgen.cpp

+53-62
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Marlin 3D Printer Firmware
3-
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
44
*
55
* Based on Sprinter and grbl.
66
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
@@ -26,57 +26,57 @@
2626

2727
#include "../shared/HAL_SPI.h"
2828

29-
#if !ENABLED(SOFTWARE_SPI) && ENABLED(HALSPI_HW_GENERIC)
29+
#if DISABLED(SOFTWARE_SPI) && ENABLED(HALSPI_HW_GENERIC)
3030

3131
// ------------------------
3232
// Hardware SPI
3333
// ------------------------
3434

3535
static void _spi_on_error() {
3636
for (;;) {
37-
#if defined(HALSPI_DO_ERRORBEEPS) && PIN_EXISTS(BEEPER)
38-
OUT_WRITE(BEEPER_PIN, HIGH);
39-
delay(500);
40-
OUT_WRITE(BEEPER_PIN, LOW);
41-
delay(500);
42-
OUT_WRITE(BEEPER_PIN, HIGH);
43-
delay(500);
44-
OUT_WRITE(BEEPER_PIN, LOW);
45-
delay(500);
46-
OUT_WRITE(BEEPER_PIN, HIGH);
47-
delay(150);
48-
OUT_WRITE(BEEPER_PIN, LOW);
49-
delay(150);
50-
OUT_WRITE(BEEPER_PIN, HIGH);
51-
delay(150);
52-
OUT_WRITE(BEEPER_PIN, LOW);
53-
delay(150);
54-
OUT_WRITE(BEEPER_PIN, HIGH);
55-
delay(150);
56-
OUT_WRITE(BEEPER_PIN, LOW);
57-
delay(3000);
58-
#endif
37+
#if defined(HALSPI_DO_ERRORBEEPS) && PIN_EXISTS(BEEPER)
38+
OUT_WRITE(BEEPER_PIN, HIGH);
39+
delay(500);
40+
OUT_WRITE(BEEPER_PIN, LOW);
41+
delay(500);
42+
OUT_WRITE(BEEPER_PIN, HIGH);
43+
delay(500);
44+
OUT_WRITE(BEEPER_PIN, LOW);
45+
delay(500);
46+
OUT_WRITE(BEEPER_PIN, HIGH);
47+
delay(150);
48+
OUT_WRITE(BEEPER_PIN, LOW);
49+
delay(150);
50+
OUT_WRITE(BEEPER_PIN, HIGH);
51+
delay(150);
52+
OUT_WRITE(BEEPER_PIN, LOW);
53+
delay(150);
54+
OUT_WRITE(BEEPER_PIN, HIGH);
55+
delay(150);
56+
OUT_WRITE(BEEPER_PIN, LOW);
57+
delay(3000);
58+
#endif
5959
}
6060
}
6161

6262
static void __attribute__((unused)) _spi_infobeep(uint32_t code) {
63-
#if PIN_EXISTS(BEEPER)
64-
OUT_WRITE(BEEPER_PIN, HIGH);
65-
delay(500);
66-
OUT_WRITE(BEEPER_PIN, LOW);
67-
delay(500);
68-
for (uint32_t n = 0; n < code; n++) {
63+
#if PIN_EXISTS(BEEPER)
6964
OUT_WRITE(BEEPER_PIN, HIGH);
70-
delay(200);
65+
delay(500);
7166
OUT_WRITE(BEEPER_PIN, LOW);
72-
delay(200);
73-
}
74-
delay(300);
75-
OUT_WRITE(BEEPER_PIN, HIGH);
76-
delay(400);
77-
OUT_WRITE(BEEPER_PIN, LOW);
78-
delay(1000);
79-
#endif
67+
delay(500);
68+
for (uint32_t n = 0; n < code; n++) {
69+
OUT_WRITE(BEEPER_PIN, HIGH);
70+
delay(200);
71+
OUT_WRITE(BEEPER_PIN, LOW);
72+
delay(200);
73+
}
74+
delay(300);
75+
OUT_WRITE(BEEPER_PIN, HIGH);
76+
delay(400);
77+
OUT_WRITE(BEEPER_PIN, LOW);
78+
delay(1000);
79+
#endif
8080
}
8181

8282
#include <pins_arduino.h>
@@ -102,21 +102,12 @@ void spiSetupChipSelect(int pin) {
102102
}
103103

104104
void spiInitEx(uint32_t maxClockFreq, int hint_sck, int hint_miso, int hint_mosi, int hint_cs) {
105-
if (hint_sck != -1) {
106-
SET_OUTPUT(hint_sck);
107-
}
108-
if (hint_miso != -1) {
109-
SET_INPUT(hint_miso);
110-
}
111-
if (hint_mosi != -1) {
112-
SET_OUTPUT(hint_mosi);
113-
}
114-
if (hint_cs != -1) {
115-
SET_OUTPUT(hint_cs);
116-
}
105+
if (hint_sck != -1) SET_OUTPUT(hint_sck);
106+
if (hint_miso != -1) SET_INPUT(hint_miso);
107+
if (hint_mosi != -1) SET_OUTPUT(hint_mosi);
108+
if (hint_cs != -1) SET_OUTPUT(hint_cs);
117109

118-
if (_spi_initialized)
119-
_spi_on_error();
110+
if (_spi_initialized) _spi_on_error();
120111

121112
_spi_clock = maxClockFreq;
122113
_spi_bitOrder = MSBFIRST;
@@ -134,13 +125,13 @@ void spiInit(uint8_t spiRate, int hint_sck, int hint_miso, int hint_mosi, int hi
134125

135126
switch (spiRate) {
136127
case SPI_FULL_SPEED: clock = 16000000; break;
137-
case SPI_HALF_SPEED: clock = 8000000; break;
138-
case SPI_QUARTER_SPEED: clock = 4000000; break;
139-
case SPI_EIGHTH_SPEED: clock = 2000000; break;
140-
case SPI_SIXTEENTH_SPEED: clock = 1000000; break;
141-
case SPI_SPEED_5: clock = 500000; break;
142-
case SPI_SPEED_6: clock = 250000; break;
143-
default: clock = 1000000; // Default from the SPI library
128+
case SPI_HALF_SPEED: clock = 8000000; break;
129+
case SPI_QUARTER_SPEED: clock = 4000000; break;
130+
case SPI_EIGHTH_SPEED: clock = 2000000; break;
131+
case SPI_SIXTEENTH_SPEED: clock = 1000000; break;
132+
case SPI_SPEED_5: clock = 500000; break;
133+
case SPI_SPEED_6: clock = 250000; break;
134+
default: clock = 1000000; // Default from the SPI library
144135
}
145136
spiInitEx(clock, hint_sck, hint_miso, hint_mosi, hint_cs);
146137
}
@@ -280,6 +271,6 @@ void spiWriteRepeat16(uint16_t val, uint16_t repcnt) {
280271
}
281272
}
282273

283-
#endif
274+
#endif // !SOFTWARE_SPI && HALSPI_HW_GENERIC
284275

285-
#endif
276+
#endif // ARDUINO_ARCH_ESP32

Marlin/src/HAL/ESP32/HAL_SPI_SW.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/**
22
* Marlin 3D Printer Firmware
3-
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
44
*
55
* Based on Sprinter and grbl.
66
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7-
* Copyright (c) 2017 Victor Perez
87
*
98
* This program is free software: you can redistribute it and/or modify
109
* it under the terms of the GNU General Public License as published by
@@ -35,4 +34,4 @@
3534

3635
#endif
3736

38-
#endif
37+
#endif // ARDUINO_ARCH_ESP32

Marlin/src/HAL/LINUX/spi_pins.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "../../inc/MarlinConfigPre.h"
2626

2727
#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
28-
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
28+
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
2929
// needed due to the speed and mode required for communicating with each device being different.
3030
// This requirement can be removed if the SPI access to these devices is updated to use
3131
// spiBeginTransaction.

0 commit comments

Comments
 (0)