🔧 Support more CONTROLLER_FAN pins (#27961)

This commit is contained in:
ellensp
2025-08-14 05:26:51 +12:00
committed by GitHub
parent 02fe1ff95e
commit 081458a3c8
5 changed files with 73 additions and 31 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ const XrefInfo pin_xref[] PROGMEM = {
#ifndef M43_NEVER_TOUCH
#define _M43_NEVER_TOUCH(x) WITHIN(x, 9, 12) // SERIAL/USB pins: PA9(TX) PA10(RX) PA11(USB_DM) PA12(USB_DP)
#ifdef KILL_PIN
#if PIN_EXISTS(KILL)
#define M43_NEVER_TOUCH(x) m43_never_touch(x)
bool m43_never_touch(const pin_t index) {
+5 -3
View File
@@ -33,12 +33,14 @@
#include <stdint.h>
#include <wirish.h>
#include "../../core/macros.h" // for PIN_EXISTS
// Number of SPI ports
#ifdef BOARD_SPI3_SCK_PIN
#if PIN_EXISTS(BOARD_SPI3_SCK)
#define BOARD_NR_SPI 3
#elif defined(BOARD_SPI2_SCK_PIN)
#elif PIN_EXISTS(BOARD_SPI2_SCK)
#define BOARD_NR_SPI 2
#elif defined(BOARD_SPI1_SCK_PIN)
#elif PIN_EXISTS(BOARD_SPI1_SCK)
#define BOARD_NR_SPI 1
#endif
+53 -13
View File
@@ -44,9 +44,30 @@ uint8_t ControllerFan::speed;
void ControllerFan::setup() {
SET_OUTPUT(CONTROLLER_FAN_PIN);
#ifdef CONTROLLER_FAN2_PIN
#if PIN_EXISTS(CONTROLLER_FAN2)
SET_OUTPUT(CONTROLLER_FAN2_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN3)
SET_OUTPUT(CONTROLLER_FAN3_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN4)
SET_OUTPUT(CONTROLLER_FAN4_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN5)
SET_OUTPUT(CONTROLLER_FAN5_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN6)
SET_OUTPUT(CONTROLLER_FAN6_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN7)
SET_OUTPUT(CONTROLLER_FAN7_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN8)
SET_OUTPUT(CONTROLLER_FAN8_PIN);
#endif
#if PIN_EXISTS(CONTROLLER_FAN9)
SET_OUTPUT(CONTROLLER_FAN9_PIN);
#endif
init();
}
@@ -73,10 +94,10 @@ void ControllerFan::update() {
#if ALL(HAS_HEATED_BED, CONTROLLER_FAN_BED_HEATING)
|| thermalManager.temp_bed.soft_pwm_amount > 0
#endif
#ifdef CONTROLLER_FAN_MIN_BOARD_TEMP
#if PIN_EXISTS(CONTROLLER_FAN_MIN_BOARD_)
|| thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP
#endif
#ifdef CONTROLLER_FAN_MIN_SOC_TEMP
#if PIN_EXISTS(CONTROLLER_FAN_MIN_SOC_)
|| thermalManager.wholeDegSoc() >= CONTROLLER_FAN_MIN_SOC_TEMP
#endif
) lastComponentOn = ms; //... set time to NOW so the fan will turn on
@@ -107,19 +128,38 @@ void ControllerFan::update() {
fan_kick_end = 0;
#endif
#define SET_CONTROLLER_FAN(N) do { \
if (PWM_PIN(CONTROLLER_FAN##N##_PIN)) hal.set_pwm_duty(pin_t(CONTROLLER_FAN##N##_PIN), speed); \
else WRITE(CONTROLLER_FAN##N##_PIN, speed > 0);\
} while (0)
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_speed = speed;
#else
if (PWM_PIN(CONTROLLER_FAN_PIN))
hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed);
else
WRITE(CONTROLLER_FAN_PIN, speed > 0);
#ifdef CONTROLLER_FAN2_PIN
if (PWM_PIN(CONTROLLER_FAN2_PIN))
hal.set_pwm_duty(pin_t(CONTROLLER_FAN2_PIN), speed);
else
WRITE(CONTROLLER_FAN2_PIN, speed > 0);
SET_CONTROLLER_FAN();
#if PIN_EXISTS(CONTROLLER_FAN2)
SET_CONTROLLER_FAN(2);
#endif
#if PIN_EXISTS(CONTROLLER_FAN3)
SET_CONTROLLER_FAN(3);
#endif
#if PIN_EXISTS(CONTROLLER_FAN4)
SET_CONTROLLER_FAN(4);
#endif
#if PIN_EXISTS(CONTROLLER_FAN5)
SET_CONTROLLER_FAN(5);
#endif
#if PIN_EXISTS(CONTROLLER_FAN6)
SET_CONTROLLER_FAN(6);
#endif
#if PIN_EXISTS(CONTROLLER_FAN7)
SET_CONTROLLER_FAN(7);
#endif
#if PIN_EXISTS(CONTROLLER_FAN8)
SET_CONTROLLER_FAN(8);
#endif
#if PIN_EXISTS(CONTROLLER_FAN9)
SET_CONTROLLER_FAN(9);
#endif
#endif
}
+11 -11
View File
@@ -629,7 +629,7 @@
//
#if HAS_X_AXIS
#ifdef X_STOP_PIN
#if PIN_EXISTS(X_STOP)
#if X_HOME_TO_MIN
#define X_MIN_PIN X_STOP_PIN
#elif X_HOME_TO_MAX
@@ -657,7 +657,7 @@
#endif
#if HAS_Y_AXIS
#ifdef Y_STOP_PIN
#if PIN_EXISTS(Y_STOP)
#if Y_HOME_TO_MIN
#define Y_MIN_PIN Y_STOP_PIN
#elif Y_HOME_TO_MAX
@@ -685,7 +685,7 @@
#endif
#if HAS_Z_AXIS
#ifdef Z_STOP_PIN
#if PIN_EXISTS(Z_STOP)
#if Z_HOME_TO_MIN
#define Z_MIN_PIN Z_STOP_PIN
#elif Z_HOME_TO_MAX
@@ -716,7 +716,7 @@
#endif
#if HAS_I_AXIS
#ifdef I_STOP_PIN
#if PIN_EXISTS(I_STOP)
#if I_HOME_TO_MIN
#define I_MIN_PIN I_STOP_PIN
#elif I_HOME_TO_MAX
@@ -730,7 +730,7 @@
#endif
#if HAS_J_AXIS
#ifdef J_STOP_PIN
#if PIN_EXISTS(J_STOP)
#if J_HOME_TO_MIN
#define J_MIN_PIN J_STOP_PIN
#elif J_HOME_TO_MAX
@@ -744,7 +744,7 @@
#endif
#if HAS_K_AXIS
#ifdef K_STOP_PIN
#if PIN_EXISTS(K_STOP)
#if K_HOME_TO_MIN
#define K_MIN_PIN K_STOP_PIN
#elif K_HOME_TO_MAX
@@ -758,7 +758,7 @@
#endif
#if HAS_U_AXIS
#ifdef U_STOP_PIN
#if PIN_EXISTS(U_STOP)
#if U_HOME_TO_MIN
#define U_MIN_PIN U_STOP_PIN
#elif U_HOME_TO_MAX
@@ -772,7 +772,7 @@
#endif
#if HAS_V_AXIS
#ifdef V_STOP_PIN
#if PIN_EXISTS(V_STOP)
#if V_HOME_TO_MIN
#define V_MIN_PIN V_STOP_PIN
#elif V_HOME_TO_MAX
@@ -786,7 +786,7 @@
#endif
#if HAS_W_AXIS
#ifdef W_STOP_PIN
#if PIN_EXISTS(W_STOP)
#if W_HOME_TO_MIN
#define W_MIN_PIN W_STOP_PIN
#elif W_HOME_TO_MAX
@@ -1871,9 +1871,9 @@
// Get a NeoPixel pin from the LCD or board, if provided
#ifndef NEOPIXEL_PIN
#ifdef LCD_NEOPIXEL_PIN
#if PIN_EXISTS(LCD_NEOPIXEL)
#define NEOPIXEL_PIN LCD_NEOPIXEL_PIN
#elif defined(BOARD_NEOPIXEL_PIN)
#elif PIN_EXISTS(BOARD_NEOPIXEL)
#define NEOPIXEL_PIN BOARD_NEOPIXEL_PIN
#endif
#endif
@@ -303,7 +303,7 @@ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) {
pinMode(ss_pin, OUTPUT);
MARLIN_UHS_WRITE_SS(HIGH);
#ifdef USB_HOST_SHIELD_TIMING_PIN
#if PIN_EXISTS(USB_HOST_SHIELD_TIMING)
pinMode(USB_HOST_SHIELD_TIMING_PIN, OUTPUT);
// My counter/timer can't work on an inverted gate signal
// so we gate using a high pulse -- AJK
@@ -863,7 +863,7 @@ void UHS_NI MAX3421E_HOST::ISRbottom() {
interrupts();
}
#endif
#ifdef USB_HOST_SHIELD_TIMING_PIN
#if PIN_EXISTS(USB_HOST_SHIELD_TIMING)
// My counter/timer can't work on an inverted gate signal
// so we gate using a high pulse -- AJK
UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW);
@@ -969,7 +969,7 @@ void UHS_NI MAX3421E_HOST::ISRbottom() {
if (!sof_countdown && !counted && !usb_task_polling_disabled) {
DisablePoll();
//usb_task_polling_disabled++;
#ifdef USB_HOST_SHIELD_TIMING_PIN
#if PIN_EXISTS(USB_HOST_SHIELD_TIMING)
// My counter/timer can't work on an inverted gate signal
// so we gate using a high pulse -- AJK
UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH);