Skip to content

Commit 7c617d4

Browse files
thinkyheadquiret
andcommitted
Platform updates
Co-Authored-By: Martin Turski <[email protected]>
1 parent 22182d9 commit 7c617d4

File tree

100 files changed

+977
-207
lines changed

Some content is hidden

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

100 files changed

+977
-207
lines changed

Marlin/src/HAL/STM32/MarlinSPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "MarlinSPI.h"
2828

29-
static void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb, uint32_t dataSize) {
29+
static void spi_init(spi_t *obj, uint32_t speed, SPIMode mode, uint8_t msb, uint32_t dataSize) {
3030
spi_init(obj, speed, mode, msb);
3131
// spi_init set 8bit always
3232
// TODO: copy the code from spi_init and handle data size, to avoid double init always!!

Marlin/src/HAL/STM32/MarlinSPI.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class MarlinSPI {
6161
_spi.pin_ssel = digitalPinToPinName(_ssPin);
6262
_dataSize = DATA_SIZE_8BIT;
6363
_bitOrder = MSBFIRST;
64-
_dataMode = SPI_MODE_0;
64+
_dataMode = SPI_MODE0;
6565
_spi.handle.State = HAL_SPI_STATE_RESET;
6666
setClockDivider(SPI_SPEED_CLOCK_DIV2_MHZ);
6767
}
@@ -80,10 +80,10 @@ class MarlinSPI {
8080

8181
void setDataMode(uint8_t _mode) {
8282
switch (_mode) {
83-
case SPI_MODE0: _dataMode = SPI_MODE_0; break;
84-
case SPI_MODE1: _dataMode = SPI_MODE_1; break;
85-
case SPI_MODE2: _dataMode = SPI_MODE_2; break;
86-
case SPI_MODE3: _dataMode = SPI_MODE_3; break;
83+
case SPI_MODE0: _dataMode = SPI_MODE0; break;
84+
case SPI_MODE1: _dataMode = SPI_MODE1; break;
85+
case SPI_MODE2: _dataMode = SPI_MODE2; break;
86+
case SPI_MODE3: _dataMode = SPI_MODE3; break;
8787
}
8888
}
8989

@@ -96,7 +96,7 @@ class MarlinSPI {
9696
DMA_HandleTypeDef _dmaTx;
9797
DMA_HandleTypeDef _dmaRx;
9898
BitOrder _bitOrder;
99-
spi_mode_e _dataMode;
99+
SPIMode _dataMode;
100100
uint8_t _clockDivider;
101101
uint32_t _speed;
102102
uint32_t _dataSize;

Marlin/src/HAL/STM32/pinsDebug.h

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
*/
2222
#pragma once
2323

24+
#ifndef PINS_DEBUGGING
25+
#error "PINS_DEBUGGING not defined but tried to include debug header!"
26+
#endif
27+
2428
/**
2529
* Pins Debugging for STM32
2630
*
@@ -47,6 +51,9 @@
4751
// Only in ST's Arduino core (STM32duino, STM32Core)
4852
#error "Expected NUM_DIGITAL_PINS not found"
4953
#endif
54+
#ifndef NUM_ANALOG_INPUTS
55+
#error "Expected NUM_ANALOG_INPUTS not found"
56+
#endif
5057

5158
/**
5259
* Life gets complicated if you want an easy to use 'M43 I' output (in port/pin order)
@@ -124,10 +131,28 @@ const XrefInfo pin_xref[] PROGMEM = {
124131
#define PORT_NUM(P) (((P) >> 4) & 0x0007)
125132
#define PORT_ALPHA(P) ('A' + ((P) >> 4))
126133

127-
#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
128-
#define HAS_HIGH_ANALOG_PINS 1
134+
/**
135+
* Translation of routines & variables used by pinsDebug.h
136+
*/
137+
#ifndef __STRINGIFY
138+
#define __STRINGIFY(x) #x
139+
#endif
140+
#define TOSTRING(x) __STRINGIFY(x)
141+
#define _STM32_PLATDEFPATH(x) TOSTRING(platdefs/x.h)
142+
#ifdef _STM32_PLATDEFS
143+
#if __has_include(_STM32_PLATDEFPATH(_STM32_PLATDEFS))
144+
#include _STM32_PLATDEFPATH(_STM32_PLATDEFS)
145+
#endif
129146
#endif
130-
#ifndef NUM_ANALOG_LAST
147+
148+
#ifndef NUM_ANALOG_FIRST
149+
#warning "Preprocessor macro NUM_ANALOG_FIRST is not defined but PINS_DEBUGGING is enabled; ignoring analog pin debug functions."
150+
#endif
151+
152+
#ifdef NUM_ANALOG_FIRST
153+
#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
154+
#define HAS_HIGH_ANALOG_PINS 1
155+
#endif
131156
#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
132157
#endif
133158
#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
@@ -186,8 +211,10 @@ bool getValidPinMode(const pin_t pin) {
186211
}
187212

188213
int8_t digital_pin_to_analog_pin(const pin_t pin) {
189-
if (WITHIN(pin, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
190-
return pin - NUM_ANALOG_FIRST;
214+
#ifdef NUM_ANALOG_FIRST
215+
if (WITHIN(pin, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
216+
return pin - NUM_ANALOG_FIRST;
217+
#endif
191218

192219
const int8_t ind = digitalPinToAnalogIndex(pin);
193220
return (ind < NUM_ANALOG_INPUTS) ? ind : -1;
@@ -225,10 +252,12 @@ void printPinPort(const pin_t pin) {
225252

226253
// Print number to be used with M42
227254
int calc_p = pin;
228-
if (pin > NUM_DIGITAL_PINS) {
229-
calc_p -= NUM_ANALOG_FIRST;
230-
if (calc_p > 7) calc_p += 8;
231-
}
255+
#ifdef NUM_ANALOG_FIRST
256+
if (pin > NUM_DIGITAL_PINS) {
257+
calc_p -= NUM_ANALOG_FIRST;
258+
if (calc_p > 7) calc_p += 8;
259+
}
260+
#endif
232261
SERIAL_ECHOPGM(" M42 P", calc_p);
233262
SERIAL_CHAR(' ');
234263
if (calc_p < 100) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST 50
27+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST 35
27+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST 35
27+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST 35
27+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
27+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
27+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#ifndef NUM_ANALOG_FIRST
25+
#error "NUM_ANALOG_FIRST is not defined??"
26+
#define NUM_ANALOG_FIRST 35
27+
#endif

0 commit comments

Comments
 (0)