You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ender3V2S1/Marlin/src/HAL/AVR/fastio.cpp

289 lines
6.5 KiB
C++

**New Year 2024 (20240107)** * The background of hot-end icon and bed icon blinks when they are being heating * Fix for https://github.com/mriscoc/Ender3V2S1/issues/1175 * Adds mesh inset to the mesh validation test * Fix screen background in trammingWizard regardless an error in the first corner **New in source code:** * Enabled M48 menu item only if Z_MIN_PROBE_REPEATABILITY_TEST is enabled * Moves Bed size menu items after XY MIN/MAX position * Enables the storage of parameters in the EEPROM only if the respective feature is enabled **From Marlin Bugfix** * Slimmer null T command (#26615) * Followup to optional M111/M115 (#26626) * Fix hangs in DUE native USB (#26572) * Fix Bed PID Autotune output (#26606) * CONFIGURE_FILAMENT_CHANGE - Optional M603 (#26613) * I3DBEE TECH Beez Mini 12864 (#26596) * Options to slim M111, remove M115 (#26603) * BSD string workaround (#26532) * Fix homing with FT_MOTION (#26595) * Fix, extend FAN / AUTOFAN confict check (#26591) * BigTreeTech Manta M8P V2.0 (STM32H723ZE) (#26578) * Optimize FT_MOTION (#26557) * TriGorilla Pro default to ONBOARD_SDIO (#26586) * Specify U8glib-HAL@0.5.4 (#26582) * Newer Platform & Toolchain for STM32G0 (#26585) * Initial support for HC32 U8G LCD (#26568) * Move U8G defines to HALs * BigTreeTech Kraken V1.0 (STM32H723ZG) (#26565) * Fix string buffer warning (#26550) * Fix MARKFORGED_INVERSE typos (#26558) * Creality Free Runs fixups (#26562) * Orca 3D Modular Controller (#26534) * Jerk correction for LIN_ADVANCE + CLASSIC_JERK (#26551) * Optional FAN_INVERTING * Just "warn" on SD fail * FT_MOTION improvements (#26074) * Fix Creality E3 "Free-runs" (#26533) * Creality E3 Free-runs Silent Motherboard (#25636) * Fix planner jerk limits (#26529) * MARKFORGED_INVERSE (#26516) * Fix MKS TS35 with BTT SKR 1.3/1.4 (#26176) * SERIAL_DMA (for some STM32Fx) (#26328) * Adjust Progress / Completion (#26466) * Encoder improvements (#26501) * Use strlcpy with buffer size (#26513) * Use PIO versioning (including HC32) (#26512) * Voxelab Aquila N32 (via Maple) (#26470) * Fix tool-change E prime (#26494) * Fix thermistor 14 & 60 constexprness (#26499) * UI refresh for some events (#26487) * Fix a NeoPixel override (#26492) * Fix ftostrX3sign (#26497) * DOUBLE_LCD_FRAMERATE (#26500) * Fix some action labels (#26490) * More num-to-string digits / precisions (#26343) * Fix BLTouch HSMode deploy (#26311) * Touch fixes (#26455) * XY_AFTER_HOMING, EVENT_GCODE_AFTER_HOMING (#26469) * BlackBeezMini 3D by I3DBEE (#26406) * HAL for HC32F460 (#26414) * MAX Thermocouples for Heated Bed (#26441) * Pins for FYSETC Spider King 4.07 (#26461) * Use ftpl for item strings (#26462) * BD_SENSOR_PROBE_NO_STOP (#26353) * Fix PANDA ZHU missing #endif (#26460) * Update Teensy 4.0/4.1 Serial (#26457) * Configurable FR/Flow edit ranges (#26446) * Fix MMU2 sscanf bug, optimize (#26449) * Fix GT2560_V41b Z2 pin (#26370) * BTT Octopus Pro V1.0.1 (STM32H723ZE) (#26159) * Fix Ender-5 S1 env * Fix more MarlinUI title centering (#26440) * Fix MarlinUI axis move / UBL strings (#26439) * Minor touch calibration improvement (#26445) * Fix rotational AxisFlags (#26444) * Rotational move items (#26438) * Define MarlinUI axis moves with lists (#26344) * Creality STM32F401RC w/out bootloader (#26373) * Fix runout state in menu (#26394) And many other Bug fixes and improvements from the Marlin bugfix branch
5 months ago
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 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/>.
*
*/
/**
* Fast I/O for extended pins
*/
#ifdef __AVR__
#include "fastio.h"
#ifdef FASTIO_EXT_START
#include "../shared/Marduino.h"
#define _IS_EXT(P) WITHIN(P, FASTIO_EXT_START, FASTIO_EXT_END)
void extDigitalWrite(const int8_t pin, const uint8_t state) {
#define _WCASE(N) case N: WRITE(N, state); break
switch (pin) {
default: digitalWrite(pin, state);
#if _IS_EXT(70)
_WCASE(70);
#endif
#if _IS_EXT(71)
_WCASE(71);
#endif
#if _IS_EXT(72)
_WCASE(72);
#endif
#if _IS_EXT(73)
_WCASE(73);
#endif
#if _IS_EXT(74)
_WCASE(74);
#endif
#if _IS_EXT(75)
_WCASE(75);
#endif
#if _IS_EXT(76)
_WCASE(76);
#endif
#if _IS_EXT(77)
_WCASE(77);
#endif
#if _IS_EXT(78)
_WCASE(78);
#endif
#if _IS_EXT(79)
_WCASE(79);
#endif
#if _IS_EXT(80)
_WCASE(80);
#endif
#if _IS_EXT(81)
_WCASE(81);
#endif
#if _IS_EXT(82)
_WCASE(82);
#endif
#if _IS_EXT(83)
_WCASE(83);
#endif
#if _IS_EXT(84)
_WCASE(84);
#endif
#if _IS_EXT(85)
_WCASE(85);
#endif
#if _IS_EXT(86)
_WCASE(86);
#endif
#if _IS_EXT(87)
_WCASE(87);
#endif
#if _IS_EXT(88)
_WCASE(88);
#endif
#if _IS_EXT(89)
_WCASE(89);
#endif
#if _IS_EXT(90)
_WCASE(90);
#endif
#if _IS_EXT(91)
_WCASE(91);
#endif
#if _IS_EXT(92)
_WCASE(92);
#endif
#if _IS_EXT(93)
_WCASE(93);
#endif
#if _IS_EXT(94)
_WCASE(94);
#endif
#if _IS_EXT(95)
_WCASE(95);
#endif
#if _IS_EXT(96)
_WCASE(96);
#endif
#if _IS_EXT(97)
_WCASE(97);
#endif
#if _IS_EXT(98)
_WCASE(98);
#endif
#if _IS_EXT(99)
_WCASE(99);
#endif
#if _IS_EXT(100)
_WCASE(100);
#endif
}
}
uint8_t extDigitalRead(const int8_t pin) {
#define _RCASE(N) case N: return READ(N)
switch (pin) {
default: return digitalRead(pin);
#if _IS_EXT(70)
_RCASE(70);
#endif
#if _IS_EXT(71)
_RCASE(71);
#endif
#if _IS_EXT(72)
_RCASE(72);
#endif
#if _IS_EXT(73)
_RCASE(73);
#endif
#if _IS_EXT(74)
_RCASE(74);
#endif
#if _IS_EXT(75)
_RCASE(75);
#endif
#if _IS_EXT(76)
_RCASE(76);
#endif
#if _IS_EXT(77)
_RCASE(77);
#endif
#if _IS_EXT(78)
_RCASE(78);
#endif
#if _IS_EXT(79)
_RCASE(79);
#endif
#if _IS_EXT(80)
_RCASE(80);
#endif
#if _IS_EXT(81)
_RCASE(81);
#endif
#if _IS_EXT(82)
_RCASE(82);
#endif
#if _IS_EXT(83)
_RCASE(83);
#endif
#if _IS_EXT(84)
_RCASE(84);
#endif
#if _IS_EXT(85)
_RCASE(85);
#endif
#if _IS_EXT(86)
_RCASE(86);
#endif
#if _IS_EXT(87)
_RCASE(87);
#endif
#if _IS_EXT(88)
_RCASE(88);
#endif
#if _IS_EXT(89)
_RCASE(89);
#endif
#if _IS_EXT(90)
_RCASE(90);
#endif
#if _IS_EXT(91)
_RCASE(91);
#endif
#if _IS_EXT(92)
_RCASE(92);
#endif
#if _IS_EXT(93)
_RCASE(93);
#endif
#if _IS_EXT(94)
_RCASE(94);
#endif
#if _IS_EXT(95)
_RCASE(95);
#endif
#if _IS_EXT(96)
_RCASE(96);
#endif
#if _IS_EXT(97)
_RCASE(97);
#endif
#if _IS_EXT(98)
_RCASE(98);
#endif
#if _IS_EXT(99)
_RCASE(99);
#endif
#if _IS_EXT(100)
_RCASE(100);
#endif
}
}
#if 0
/**
* Set Timer 5 PWM frequency in Hz, from 3.8Hz up to ~16MHz
* with a minimum resolution of 100 steps.
*
* DC values -1.0 to 1.0. Negative duty cycle inverts the pulse.
*/
uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb, const float dcc) {
float count = 0;
if (hz > 0 && (dca || dcb || dcc)) {
count = float(F_CPU) / hz; // 1x prescaler, TOP for 16MHz base freq.
uint16_t prescaler; // Range of 30.5Hz (65535) 64.5kHz (>31)
if (count >= 255. * 256.) { prescaler = 1024; SET_CS(5, PRESCALER_1024); }
else if (count >= 255. * 64.) { prescaler = 256; SET_CS(5, PRESCALER_256); }
else if (count >= 255. * 8.) { prescaler = 64; SET_CS(5, PRESCALER_64); }
else if (count >= 255.) { prescaler = 8; SET_CS(5, PRESCALER_8); }
else { prescaler = 1; SET_CS(5, PRESCALER_1); }
count /= float(prescaler);
const float pwm_top = round(count); // Get the rounded count
ICR5 = (uint16_t)pwm_top - 1; // Subtract 1 for TOP
OCR5A = pwm_top * ABS(dca); // Update and scale DCs
OCR5B = pwm_top * ABS(dcb);
OCR5C = pwm_top * ABS(dcc);
_SET_COM(5, A, dca ? (dca < 0 ? COM_SET_CLEAR : COM_CLEAR_SET) : COM_NORMAL); // Set compare modes
_SET_COM(5, B, dcb ? (dcb < 0 ? COM_SET_CLEAR : COM_CLEAR_SET) : COM_NORMAL);
_SET_COM(5, C, dcc ? (dcc < 0 ? COM_SET_CLEAR : COM_CLEAR_SET) : COM_NORMAL);
SET_WGM(5, FAST_PWM_ICRn); // Fast PWM with ICR5 as TOP
//SERIAL_ECHOLNPGM("Timer 5 Settings:");
//SERIAL_ECHOLNPGM(" Prescaler=", prescaler);
//SERIAL_ECHOLNPGM(" TOP=", ICR5);
//SERIAL_ECHOLNPGM(" OCR5A=", OCR5A);
//SERIAL_ECHOLNPGM(" OCR5B=", OCR5B);
//SERIAL_ECHOLNPGM(" OCR5C=", OCR5C);
}
else {
// Restore the default for Timer 5
SET_WGM(5, PWM_PC_8); // PWM 8-bit (Phase Correct)
SET_COMS(5, NORMAL, NORMAL, NORMAL); // Do nothing
SET_CS(5, PRESCALER_64); // 16MHz / 64 = 250kHz
OCR5A = OCR5B = OCR5C = 0;
}
return round(count);
}
#endif
#endif // FASTIO_EXT_START
#endif // __AVR__