Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/MarlinSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "MarlinSPI.h"

static void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb, uint32_t dataSize) {
static void spi_init(spi_t *obj, uint32_t speed, SPIMode mode, uint8_t msb, uint32_t dataSize) {
spi_init(obj, speed, mode, msb);
// spi_init set 8bit always
// TODO: copy the code from spi_init and handle data size, to avoid double init always!!
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/HAL/STM32/MarlinSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MarlinSPI {
_spi.pin_ssel = digitalPinToPinName(_ssPin);
_dataSize = DATA_SIZE_8BIT;
_bitOrder = MSBFIRST;
_dataMode = SPI_MODE_0;
_dataMode = SPI_MODE0;
_spi.handle.State = HAL_SPI_STATE_RESET;
setClockDivider(SPI_SPEED_CLOCK_DIV2_MHZ);
}
Expand All @@ -80,10 +80,10 @@ class MarlinSPI {

void setDataMode(uint8_t _mode) {
switch (_mode) {
case SPI_MODE0: _dataMode = SPI_MODE_0; break;
case SPI_MODE1: _dataMode = SPI_MODE_1; break;
case SPI_MODE2: _dataMode = SPI_MODE_2; break;
case SPI_MODE3: _dataMode = SPI_MODE_3; break;
case SPI_MODE0: _dataMode = SPI_MODE0; break;
case SPI_MODE1: _dataMode = SPI_MODE1; break;
case SPI_MODE2: _dataMode = SPI_MODE2; break;
case SPI_MODE3: _dataMode = SPI_MODE3; break;
}
}

Expand All @@ -96,7 +96,7 @@ class MarlinSPI {
DMA_HandleTypeDef _dmaTx;
DMA_HandleTypeDef _dmaRx;
BitOrder _bitOrder;
spi_mode_e _dataMode;
SPIMode _dataMode;
uint8_t _clockDivider;
uint32_t _speed;
uint32_t _dataSize;
Expand Down
47 changes: 38 additions & 9 deletions Marlin/src/HAL/STM32/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
*/
#pragma once

#ifndef PINS_DEBUGGING
#error "PINS_DEBUGGING not defined but tried to include debug header!"
#endif

/**
* Pins Debugging for STM32
*
Expand All @@ -47,6 +51,9 @@
// Only in ST's Arduino core (STM32duino, STM32Core)
#error "Expected NUM_DIGITAL_PINS not found"
#endif
#ifndef NUM_ANALOG_INPUTS
#error "Expected NUM_ANALOG_INPUTS not found"
#endif

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

#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
#define HAS_HIGH_ANALOG_PINS 1
/**
* Translation of routines & variables used by pinsDebug.h
*/
#ifndef __STRINGIFY
#define __STRINGIFY(x) #x
#endif
#define TOSTRING(x) __STRINGIFY(x)
#define _STM32_PLATDEFPATH(x) TOSTRING(platdefs/x.h)
#ifdef _STM32_PLATDEFS
#if __has_include(_STM32_PLATDEFPATH(_STM32_PLATDEFS))
#include _STM32_PLATDEFPATH(_STM32_PLATDEFS)
#endif
#endif
#ifndef NUM_ANALOG_LAST

#ifndef NUM_ANALOG_FIRST
#warning "Preprocessor macro NUM_ANALOG_FIRST is not defined but PINS_DEBUGGING is enabled; ignoring analog pin debug functions."
#endif

#ifdef NUM_ANALOG_FIRST
#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
#define HAS_HIGH_ANALOG_PINS 1
#endif
#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
#endif
#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
Expand Down Expand Up @@ -186,8 +211,10 @@ bool getValidPinMode(const pin_t pin) {
}

int8_t digital_pin_to_analog_pin(const pin_t pin) {
if (WITHIN(pin, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
return pin - NUM_ANALOG_FIRST;
#ifdef NUM_ANALOG_FIRST
if (WITHIN(pin, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
return pin - NUM_ANALOG_FIRST;
#endif

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

// Print number to be used with M42
int calc_p = pin;
if (pin > NUM_DIGITAL_PINS) {
calc_p -= NUM_ANALOG_FIRST;
if (calc_p > 7) calc_p += 8;
}
#ifdef NUM_ANALOG_FIRST
if (pin > NUM_DIGITAL_PINS) {
calc_p -= NUM_ANALOG_FIRST;
if (calc_p > 7) calc_p += 8;
}
#endif
SERIAL_ECHOPGM(" M42 P", calc_p);
SERIAL_CHAR(' ');
if (calc_p < 100) {
Expand Down
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_ARTILLERY_RUBY.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST 50
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BIGTREE_BTT002.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST 35
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BIGTREE_E3_RRF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST 35
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BIGTREE_GTR_V1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST 35
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BIGTREE_OCTOPUS_V1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BIGTREE_SKR_PRO_11.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST 35
#endif
27 changes: 27 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_BTT_SKR_SE_BX.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef NUM_ANALOG_FIRST
#error "NUM_ANALOG_FIRST is not defined??"
#define NUM_ANALOG_FIRST 108
#endif
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F103Rx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
22 changes: 22 additions & 0 deletions Marlin/src/HAL/STM32/platdefs/MARLIN_F103VE_LONGER.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
Loading
Loading