Bump to head, feedrate and accel clamping

This commit is contained in:
InsanityAutomation
2019-10-08 15:30:05 -04:00
parent 0eb8b6aec3
commit a63a162f36
727 changed files with 22302 additions and 22440 deletions
+3 -3
View File
@@ -240,10 +240,10 @@ jobs:
build_marlin_pio ./ ${TEST_PLATFORM}
restore_configs
echo testing STM32F1 targets...
export TEST_PLATFORM="-e STM32F103R"
export TEST_PLATFORM="-e STM32F103RE"
restore_configs
echo use_example_configs STM32/STM32F103R
use_example_configs STM32/STM32F103R
echo use_example_configs STM32/STM32F103RE
use_example_configs STM32/STM32F103RE
build_marlin_pio ./ ${TEST_PLATFORM}
restore_configs
echo use_example_configs STM32/stm32f103ret6
+11 -8
View File
@@ -13,10 +13,8 @@ env:
- TEST_PLATFORM="DUE"
- TEST_PLATFORM="esp32"
- TEST_PLATFORM="linux_native"
- TEST_PLATFORM="LPC1768"
- TEST_PLATFORM="LPC1769"
- TEST_PLATFORM="megaatmega2560"
- TEST_PLATFORM="STM32F103R"
- TEST_PLATFORM="STM32F103RE"
- TEST_PLATFORM="teensy31"
- TEST_PLATFORM="teensy35"
@@ -31,22 +29,27 @@ env:
- TEST_PLATFORM="ARMED"
- TEST_PLATFORM="BIGTREE_BTT002"
- TEST_PLATFORM="BIGTREE_SKR_PRO"
- TEST_PLATFORM="STM32F103R_bigtree"
- TEST_PLATFORM="STM32F103RC_bigtree"
- TEST_PLATFORM="jgaurora_a5s_a1"
- TEST_PLATFORM="STM32F103V_longer"
- TEST_PLATFORM="STM32F103VE_longer"
- TEST_PLATFORM="STM32F407VE_black"
# Put lengthy tests last
- TEST_PLATFORM="LPC1768"
- TEST_PLATFORM="LPC1769"
# Non-working environment tests
#- TEST_PLATFORM="at90usb1286_cdc"
#- TEST_PLATFORM="at90usb1286_dfu"
#- TEST_PLATFORM="malyanm200"
#- TEST_PLATFORM="STM32F103CB_malyan"
#- TEST_PLATFORM="mks_robin"
#- TEST_PLATFORM="mks_robin_lite"
#- TEST_PLATFORM="mks_robin_mini"
#- TEST_PLATFORM="mks_robin_nano"
#- TEST_PLATFORM="SAMD51_grandcentral_m4"
#- TEST_PLATFORM="STM32F103R_bigtree"
#- TEST_PLATFORM="STM32F103R_fysetc"
#- TEST_PLATFORM="STM32F103RC_bigtree"
#- TEST_PLATFORM="STM32F103RC_bigtree_USB"
#- TEST_PLATFORM="STM32F103RC_fysetc"
#- TEST_PLATFORM="STM32F4"
#- TEST_PLATFORM="STM32F7"
+19 -23
View File
@@ -1,7 +1,7 @@
#define ABL_BLTOUCH // Replaces RGB LED
//#define ABL_BLTOUCH // Replaces RGB LED
#define GraphicalLCD // Will work next to MKS TFT
#define TMC_2209 // Defaults to TMC2100
#define ABL_UBL // Defaults to Bilinear
//#define ABL_UBL // Defaults to Bilinear
//#define RunoutSensor // Tinymachines Lerdge Sensor
#define RELOCATE_LED // Since the bltouch by default removed the LED, set this if you simply moved them off the hotend
@@ -755,6 +755,11 @@
*/
#define DEFAULT_MAX_FEEDRATE { 300, 300, 50, 70 }
#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2
#if ENABLED(LIMITED_MAX_FR_EDITING)
#define MAX_FEEDRATE_EDIT_VALUES { 600, 600, 100, 150 } // ...or, set your own edit limits
#endif
/**
* Default Max Acceleration (change/s) change = mm/s
* (Maximum start speed for accelerated moves)
@@ -763,6 +768,11 @@
*/
#define DEFAULT_MAX_ACCELERATION { 1500, 1500, 100, 10000 }
#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
#if ENABLED(LIMITED_MAX_ACCEL_EDITING)
#define MAX_ACCEL_EDIT_VALUES { 3000, 3000, 150, 15000 } // ...or, set your own edit limits
#endif
/**
* Default Acceleration (change/s) change = mm/s
* Override with M204
@@ -801,6 +811,11 @@
#define DEFAULT_XJERK 8.0
#define DEFAULT_YJERK 8.0
#define DEFAULT_ZJERK 0.3
//#define LIMITED_JERK_EDITING // Limit edit via M205 or LCD to DEFAULT_aJERK * 2
#if ENABLED(LIMITED_JERK_EDITING)
#define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10 } // ...or, set your own edit limits
#endif
#endif
#define DEFAULT_EJERK 5.0 // May be used by Linear Advance
@@ -963,7 +978,7 @@
* A total of 3 or more adds more slow probes, taking the average.
*/
#define MULTIPLE_PROBING 2
#define EXTRA_PROBING 1
//#define EXTRA_PROBING 1
/**
* Z probes require clearance when deploying, stowing, and moving between
@@ -1255,12 +1270,6 @@
#define GRID_MAX_POINTS_X 5
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
// Set the boundaries for probing (where the probe can reach).
//#define LEFT_PROBE_BED_POSITION MIN_PROBE_EDGE
//#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE - (MIN_PROBE_EDGE))
//#define FRONT_PROBE_BED_POSITION MIN_PROBE_EDGE
//#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - (MIN_PROBE_EDGE))
// Probe along the Y axis, advancing X after each column
//#define PROBE_Y_FIRST
@@ -1314,19 +1323,6 @@
#endif // BED_LEVELING
/**
* Points to probe for all 3-point Leveling procedures.
* Override if the automatically selected points are inadequate.
*/
#if EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL)
//#define PROBE_PT_1_X 50
//#define PROBE_PT_1_Y 250
//#define PROBE_PT_2_X 250
//#define PROBE_PT_2_Y 250
//#define PROBE_PT_3_X 250
//#define PROBE_PT_3_Y 50
#endif
/**
* Add a bed leveling sub-menu for ABL or MBL.
* Include a guided procedure if manual probing is enabled.
@@ -1575,7 +1571,7 @@
#define NOZZLE_CLEAN_TRIANGLES 3
// Specify positions as { X, Y, Z }
#define NOZZLE_CLEAN_START_POINT { 30, 30, (Z_MIN_POS + 1)}
#define NOZZLE_CLEAN_START_POINT { 30, 30, (Z_MIN_POS + 1) }
#define NOZZLE_CLEAN_END_POINT { 100, 60, (Z_MIN_POS + 1) }
// Circular pattern radius
+95 -36
View File
@@ -379,6 +379,7 @@
#define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW
#define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin)
//#define CASE_LIGHT_MAX_PWM 128 // Limit pwm
//#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu
//#define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting.
//#define CASE_LIGHT_USE_NEOPIXEL // Use Neopixel LED as case light, requires NEOPIXEL_LED.
@@ -604,9 +605,7 @@
#endif
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
// Define probe X and Y positions for Z1, Z2 [, Z3]
#define Z_STEPPER_ALIGN_X { 30, 270 }
#define Z_STEPPER_ALIGN_Y { 150, 150 }
// Set number of iterations to align
#define Z_STEPPER_ALIGN_XY { { 30, 150 }, { 270, 150 } }
#define Z_STEPPER_ALIGN_ITERATIONS 3
// Enable to restore leveling setup after operation
#define RESTORE_LEVELING_AFTER_G34
@@ -1209,21 +1208,45 @@
//#define TOUCH_UI_PORTRAIT
//#define TOUCH_UI_MIRRORED
// Enable UTF8 rendering capabilities.
// UTF8 processing and rendering.
// Unsupported characters are shown as '?'.
//#define TOUCH_UI_USE_UTF8
#if ENABLED(TOUCH_UI_USE_UTF8)
// Western accents support. These accented characters use
// combined bitmaps and require relatively little storage.
#define TOUCH_UI_UTF8_WESTERN_CHARSET
#if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
// Additional character groups. These characters require
// full bitmaps and take up considerable storage:
//#define TOUCH_UI_UTF8_SUPERSCRIPTS // ¹ ² ³
//#define TOUCH_UI_UTF8_COPYRIGHT // © ®
//#define TOUCH_UI_UTF8_GERMANIC // ß
//#define TOUCH_UI_UTF8_SCANDINAVIAN // Æ Ð Ø Þ æ ð ø þ
//#define TOUCH_UI_UTF8_PUNCTUATION // « » ¿ ¡
//#define TOUCH_UI_UTF8_CURRENCY // ¢ £ ¤ ¥
//#define TOUCH_UI_UTF8_ORDINALS // º ª
//#define TOUCH_UI_UTF8_MATHEMATICS // ± × ÷
//#define TOUCH_UI_UTF8_FRACTIONS // ¼ ½ ¾
//#define TOUCH_UI_UTF8_SYMBOLS // µ ¶ ¦ § ¬
#endif
#endif
// When labels do not fit buttons, use smaller font
// Use a smaller font when labels don't fit buttons
#define TOUCH_UI_FIT_TEXT
// Runtime language selection (otherwise LCD_LANGUAGE)
//#define TOUCH_UI_LANGUAGE_MENU
// Allow language selection from menu at run-time (otherwise use LCD_LANGUAGE)
//#define LCD_LANGUAGE_1 en
//#define LCD_LANGUAGE_2 fr
//#define LCD_LANGUAGE_3 de
//#define LCD_LANGUAGE_4 es
//#define LCD_LANGUAGE_5 it
// Use a numeric passcode for "Screen lock" keypad.
// (recommended for smaller displays)
//#define TOUCH_UI_PASSCODE
// Output extra debug info for Touch UI events
//#define TOUCH_UI_DEBUG
#endif
//
@@ -1325,6 +1348,42 @@
// @section leveling
/**
* Points to probe for all 3-point Leveling procedures.
* Override if the automatically selected points are inadequate.
*/
#if EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL)
//#define PROBE_PT_1_X 15
//#define PROBE_PT_1_Y 180
//#define PROBE_PT_2_X 15
//#define PROBE_PT_2_Y 20
//#define PROBE_PT_3_X 170
//#define PROBE_PT_3_Y 20
#endif
/**
* Override MIN_PROBE_EDGE for each side of the build plate
* Useful to get probe points to exact positions on targets or
* to allow leveling to avoid plate clamps on only specific
* sides of the bed.
*
* If you are replacing the prior *_PROBE_BED_POSITION options,
* LEFT and FRONT values in most cases will map directly over
* RIGHT and REAR would be the inverse such as
* (X/Y_BED_SIZE - RIGHT/BACK_PROBE_BED_POSITION)
*
* This will allow all positions to match at compilation, however
* should the probe position be modified with M851XY then the
* probe points will follow. This prevents any change from causing
* the probe to be unable to reach any points.
*/
#if PROBE_SELECTED && !IS_KINEMATIC
//#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
//#define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
//#define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
//#define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif
#if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
// Override the mesh area if the automatic (max) area is too large
//#define MESH_MIN_X MESH_INSET
@@ -1755,91 +1814,91 @@
#define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
#define X_MICROSTEPS 16 // 0..256
#define X_RSENSE 0.11
#define X_CHAIN_POS 0 // 0 - Not chained, 1 - MCU MOSI connected, 2 - next in chain, ...
#define X_CHAIN_POS -1 // <=0 : Not chained. 1 : MCU MOSI connected. 2 : Next in chain, ...
#endif
#if AXIS_IS_TMC(X2)
#define X2_CURRENT 800
#define X2_MICROSTEPS 16
#define X2_RSENSE 0.11
#define X2_CHAIN_POS 0
#define X2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Y)
#define Y_CURRENT 800
#define Y_MICROSTEPS 16
#define Y_RSENSE 0.11
#define Y_CHAIN_POS 0
#define Y_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Y2)
#define Y2_CURRENT 800
#define Y2_MICROSTEPS 16
#define Y2_RSENSE 0.11
#define Y2_CHAIN_POS 0
#define Y2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z)
#define Z_CURRENT 800
#define Z_MICROSTEPS 16
#define Z_RSENSE 0.11
#define Z_CHAIN_POS 0
#define Z_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z2)
#define Z2_CURRENT 800
#define Z2_MICROSTEPS 16
#define Z2_RSENSE 0.11
#define Z2_CHAIN_POS 0
#define Z2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z3)
#define Z3_CURRENT 800
#define Z3_MICROSTEPS 16
#define Z3_RSENSE 0.11
#define Z3_CHAIN_POS 0
#define Z3_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E0)
#define E0_CURRENT 800
#define E0_MICROSTEPS 16
#define E0_RSENSE 0.11
#define E0_CHAIN_POS 0
#define E0_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E1)
#define E1_CURRENT 800
#define E1_MICROSTEPS 16
#define E1_RSENSE 0.11
#define E1_CHAIN_POS 0
#define E1_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E2)
#define E2_CURRENT 800
#define E2_MICROSTEPS 16
#define E2_RSENSE 0.11
#define E2_CHAIN_POS 0
#define E2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E3)
#define E3_CURRENT 800
#define E3_MICROSTEPS 16
#define E3_RSENSE 0.11
#define E3_CHAIN_POS 0
#define E3_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E4)
#define E4_CURRENT 800
#define E4_MICROSTEPS 16
#define E4_RSENSE 0.11
#define E4_CHAIN_POS 0
#define E4_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E5)
#define E5_CURRENT 800
#define E5_MICROSTEPS 16
#define E5_RSENSE 0.11
#define E5_CHAIN_POS 0
#define E5_CHAIN_POS -1
#endif
/**
@@ -2079,7 +2138,7 @@
#define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current (VALID: 375 x (1 - 16) - 6A max - rounds down)
#define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down)
#define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper
#define X_CHAIN_POS 0 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI
#define X_CHAIN_POS -1 // Position in SPI chain. (<=0 : Not in chain. 1 : Nearest MOSI)
#endif
#if AXIS_DRIVER_TYPE_X2(L6470)
@@ -2087,7 +2146,7 @@
#define X2_OVERCURRENT 2000
#define X2_STALLCURRENT 1500
#define X2_MAX_VOLTAGE 127
#define X2_CHAIN_POS 0
#define X2_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_Y(L6470)
@@ -2095,7 +2154,7 @@
#define Y_OVERCURRENT 2000
#define Y_STALLCURRENT 1500
#define Y_MAX_VOLTAGE 127
#define Y_CHAIN_POS 0
#define Y_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_Y2(L6470)
@@ -2103,7 +2162,7 @@
#define Y2_OVERCURRENT 2000
#define Y2_STALLCURRENT 1500
#define Y2_MAX_VOLTAGE 127
#define Y2_CHAIN_POS 0
#define Y2_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_Z(L6470)
@@ -2111,7 +2170,7 @@
#define Z_OVERCURRENT 2000
#define Z_STALLCURRENT 1500
#define Z_MAX_VOLTAGE 127
#define Z_CHAIN_POS 0
#define Z_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_Z2(L6470)
@@ -2119,7 +2178,7 @@
#define Z2_OVERCURRENT 2000
#define Z2_STALLCURRENT 1500
#define Z2_MAX_VOLTAGE 127
#define Z2_CHAIN_POS 0
#define Z2_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_Z3(L6470)
@@ -2127,7 +2186,7 @@
#define Z3_OVERCURRENT 2000
#define Z3_STALLCURRENT 1500
#define Z3_MAX_VOLTAGE 127
#define Z3_CHAIN_POS 0
#define Z3_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_E0(L6470)
@@ -2135,7 +2194,7 @@
#define E0_OVERCURRENT 2000
#define E0_STALLCURRENT 1500
#define E0_MAX_VOLTAGE 127
#define E0_CHAIN_POS 0
#define E0_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_E1(L6470)
@@ -2143,7 +2202,7 @@
#define E1_OVERCURRENT 2000
#define E1_STALLCURRENT 1500
#define E1_MAX_VOLTAGE 127
#define E1_CHAIN_POS 0
#define E1_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_E2(L6470)
@@ -2151,7 +2210,7 @@
#define E2_OVERCURRENT 2000
#define E2_STALLCURRENT 1500
#define E2_MAX_VOLTAGE 127
#define E2_CHAIN_POS 0
#define E2_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_E3(L6470)
@@ -2159,7 +2218,7 @@
#define E3_OVERCURRENT 2000
#define E3_STALLCURRENT 1500
#define E3_MAX_VOLTAGE 127
#define E3_CHAIN_POS 0
#define E3_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_E4(L6470)
@@ -2167,7 +2226,7 @@
#define E4_OVERCURRENT 2000
#define E4_STALLCURRENT 1500
#define E4_MAX_VOLTAGE 127
#define E4_CHAIN_POS 0
#define E4_CHAIN_POS -1
#endif
#if AXIS_DRIVER_TYPE_E5(L6470)
@@ -2175,7 +2234,7 @@
#define E5_OVERCURRENT 2000
#define E5_STALLCURRENT 1500
#define E5_MAX_VOLTAGE 127
#define E5_CHAIN_POS 0
#define E5_CHAIN_POS -1
#endif
/**
@@ -2477,13 +2536,13 @@
#define USER_DESC_1 "Setup"
#if (ENABLED(ABL_UBL))
#define USER_GCODE_1 "M190S" CommBedTmp"\nG28\nG34I3\nG29P1\nG29P3R\nG29S1\nG29S0\n G29F0.0\nG29A\nG28\nM109S215\nG1X150Y150\nG1Z0\nM500\nM400\nM77\nM117 Set Z Offset"
#define USER_GCODE_1 "M190S" CommBedTmp"\nG28\nG34\nG29P1\nG29P3R\nG29S1\nG29S0\n G29F0.0\nG29A\nG28\nM109S215\nG1X150Y150\nG1Z0\nM500\nM400\nM77\nM117 Set Z Offset"
#elif ENABLED(ABL_BI)
#define USER_GCODE_1 "M190S" CommBedTmp"\nM104S215\nG34I3\nG28\nG29\nM400\nG28\nM420S1\nM109S215\nG1X100Y100\nG1Z0\nM500\nM400\nM77\nM117 Set Z Offset"
#define USER_GCODE_1 "M190S" CommBedTmp"\nM104S215\nG34\nG28\nG29\nM400\nG28\nM420S1\nM109S215\nG1X100Y100\nG1Z0\nM500\nM400\nM77\nM117 Set Z Offset"
#endif
#define USER_DESC_2 "PID Tune"
#define USER_GCODE_2 "M106 S128 \n M303 C8 S215 E1 U \n M500 \n M117 PID Tune Done"
#define USER_GCODE_2 "M106S128\nM303C8S215E0U\nM500\n M117 PID Tune Done"
#define USER_DESC_3 "Prep for Z Adjust"
#define USER_GCODE_3 "M190 S" CommBedTmp" \n M104 S215 \n G28 \n G29 L1 \n G1 X100 Y 100 \n G1 Z0"
+6
View File
@@ -24,3 +24,9 @@
#include "platforms.h"
#include HAL_PATH(.,HAL.h)
inline void watchdog_refresh() {
#if ENABLED(USE_WATCHDOG)
HAL_watchdog_refresh();
#endif
}
+1 -2
View File
@@ -146,8 +146,7 @@ extern "C" {
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B)
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
UNUSED(frequency);
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
switch (timer_num) {
case STEP_TIMER_NUM:
// waveform generation = 0100 = CTC
+2 -7
View File
@@ -184,15 +184,10 @@ void spiBegin() {
// nop to tune soft SPI timing
#define nop asm volatile ("\tnop\n")
// Set SPI rate
void spiInit(uint8_t spiRate) {
UNUSED(spiRate); // nothing to do
}
void spiInit(uint8_t) { /* do nothing */ }
// Begin SPI transaction, set clock, bit order, data mode
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
UNUSED(spiBeginTransaction); // nothing to do
}
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { /* do nothing */ }
// Soft SPI receive byte
uint8_t spiRec() {
+3 -12
View File
@@ -227,18 +227,9 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin");
void com_print(uint8_t N, uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPGM(" COM");
SERIAL_CHAR(N + '0');
switch (Z) {
case 'A':
SERIAL_ECHOPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6));
break;
case 'B':
SERIAL_ECHOPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4));
break;
case 'C':
SERIAL_ECHOPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2));
break;
}
SERIAL_CHAR('0' + N);
SERIAL_CHAR('A' + Z);
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}
void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - WGM bit layout
+1 -1
View File
@@ -28,4 +28,4 @@ void watchdog_init();
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or AVR will go into emergency procedures.
inline void watchdog_reset() { wdt_reset(); }
inline void HAL_watchdog_refresh() { wdt_reset(); }
+3 -5
View File
@@ -922,8 +922,7 @@ static void ee_Init() {
if (!ee_IsPageClean(grp * PagesPerGroup + page)) {
#ifdef EE_EMU_DEBUG
SERIAL_ECHO_START();
SERIAL_ECHOPAIR("EEPROM Page ",page);
SERIAL_ECHOLNPAIR(" not clean on group ",grp);
SERIAL_ECHOLNPAIR("EEPROM Page ", page, " not clean on group ", grp);
SERIAL_FLUSH();
#endif
ee_PageErase(grp * PagesPerGroup + page);
@@ -944,7 +943,7 @@ static void ee_Init() {
#ifdef EE_EMU_DEBUG
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("EEPROM Active page: ",curPage);
SERIAL_ECHOLNPAIR("EEPROM Active page: ", curPage);
SERIAL_FLUSH();
#endif
@@ -953,8 +952,7 @@ static void ee_Init() {
if (!ee_IsPageClean(curGroup * PagesPerGroup + page)) {
#ifdef EE_EMU_DEBUG
SERIAL_ECHO_START();
SERIAL_ECHOPAIR("EEPROM Page ",page);
SERIAL_ECHOLNPAIR(" not clean on active group ",curGroup);
SERIAL_ECHOLNPAIR("EEPROM Page ", page, " not clean on active group ", curGroup);
SERIAL_FLUSH();
ee_Dump(curGroup * PagesPerGroup + page, getFlashStorage(curGroup * PagesPerGroup + page));
#endif
+1 -1
View File
@@ -87,7 +87,7 @@ extern "C" {
// Return free memory between end of heap (or end bss) and whatever is current
int freeMemory() {
int free_memory, heap_end = (int)_sbrk(0);
return (int)&free_memory - (heap_end ? heap_end : (int)&_ebss);
return (int)&free_memory - (heap_end ?: (int)&_ebss);
}
// ------------------------
+1 -2
View File
@@ -151,13 +151,12 @@
(((uint32_t)(addr) & 0xF0000000) + 0x02000000 + ((uint32_t)(addr)&0xFFFFF)*32 + (bit)*4)
// run at ~8 .. ~10Mhz - Rx version (Tx line not altered)
static uint8_t spiTransferRx0(uint8_t bout) { // using Mode 0
static uint8_t spiTransferRx0(uint8_t) { // using Mode 0
uint32_t bin = 0;
uint32_t work = 0;
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(MISO_PIN))+0x3C, PIN_SHIFT(MISO_PIN)); /* PDSR of port in bitband area */
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SCK_PIN);
UNUSED(bout);
/* The software SPI routine */
__asm__ __volatile__(
+2 -5
View File
@@ -55,12 +55,9 @@ static int pending_char = -1;
#endif
// Public Methods
void MarlinSerialUSB::begin(const long baud_setting) {
UNUSED(baud_setting);
}
void MarlinSerialUSB::begin(const long) {}
void MarlinSerialUSB::end() {
}
void MarlinSerialUSB::end() {}
int MarlinSerialUSB::peek() {
if (pending_char >= 0)
+1 -1
View File
@@ -50,7 +50,7 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
{ TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5]
{ TC0, 1, TC1_IRQn, 0}, // 1
{ TC0, 2, TC2_IRQn, 2}, // 2 - stepper
{ TC1, 0, TC3_IRQn, 0}, // 3
{ TC1, 0, TC3_IRQn, 0}, // 3 - stepper for BOARD_ARCHIM1
{ TC1, 1, TC4_IRQn, 15}, // 4 - temperature
{ TC1, 2, TC5_IRQn, 3}, // 5 - [servo timer3]
{ TC2, 0, TC6_IRQn, 14}, // 6 - tone
+5 -1
View File
@@ -39,7 +39,9 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 2 // index of timer to use for stepper
#endif
#define TEMP_TIMER_NUM 4 // index of timer to use for temperature
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define TONE_TIMER_NUM 6 // index of timer to use for beeper tones
@@ -61,7 +63,9 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR() void TC2_Handler()
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() void TC2_Handler()
#endif
#define HAL_TEMP_TIMER_ISR() void TC4_Handler()
#define HAL_TONE_TIMER_ISR() void TC6_Handler()
+7 -7
View File
@@ -174,11 +174,11 @@ static xSemaphoreHandle ctrl_access_semphr = NULL;
//! LUN descriptor table.
static const struct
{
Ctrl_status (*test_unit_ready)();
Ctrl_status (*test_unit_ready)(void);
Ctrl_status (*read_capacity)(U32 *);
bool (*unload)(bool);
bool (*wr_protect)();
bool (*removal)();
bool (*wr_protect)(void);
bool (*removal)(void);
#if ACCESS_USB == true
Ctrl_status (*usb_read_10)(U32, U16);
Ctrl_status (*usb_write_10)(U32, U16);
@@ -255,7 +255,7 @@ bool g_wr_protect;
#ifdef FREERTOS_USED
bool ctrl_access_init()
bool ctrl_access_init(void)
{
// If the handle to the protecting semaphore is not valid,
if (!ctrl_access_semphr)
@@ -275,7 +275,7 @@ bool ctrl_access_init()
*
* \return \c true if the access was successfully locked, else \c false.
*/
static bool ctrl_access_lock()
static bool ctrl_access_lock(void)
{
// If the semaphore could not be created, there is no backup solution.
if (!ctrl_access_semphr) return false;
@@ -289,7 +289,7 @@ static bool ctrl_access_lock()
#endif // FREERTOS_USED
U8 get_nb_lun()
U8 get_nb_lun(void)
{
#if MEM_USB == ENABLE
# ifndef Lun_usb_get_lun
@@ -310,7 +310,7 @@ U8 get_nb_lun()
}
U8 get_cur_lun()
U8 get_cur_lun(void)
{
return LUN_ID_0;
}
+3 -3
View File
@@ -191,7 +191,7 @@ extern bool g_wr_protect;
*
* \return \c true if the locker was successfully initialized, else \c false.
*/
extern bool ctrl_access_init();
extern bool ctrl_access_init(void);
#endif // FREERTOS_USED
@@ -199,7 +199,7 @@ extern bool ctrl_access_init();
*
* \return Number of LUNs in the system.
*/
extern U8 get_nb_lun();
extern U8 get_nb_lun(void);
/*! \brief Returns the current LUN.
*
@@ -207,7 +207,7 @@ extern U8 get_nb_lun();
*
* \todo Implement.
*/
extern U8 get_cur_lun();
extern U8 get_cur_lun(void);
/*! \brief Tests the memory state and initializes the memory if required.
*
+3 -10
View File
@@ -33,19 +33,12 @@ Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
return CTRL_GOOD;
}
bool sd_mmc_spi_unload(bool unload) {
UNUSED(unload);
return true;
}
bool sd_mmc_spi_unload(bool) { return true; }
bool sd_mmc_spi_wr_protect() {
return false;
}
bool sd_mmc_spi_wr_protect() { return false; }
bool sd_mmc_spi_removal() {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return true;
return false;
return (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted());
}
#if ACCESS_USB == true
+4 -4
View File
@@ -78,7 +78,7 @@
//!
//! @brief This function initializes the hw/sw resources required to drive the SD_MMC_SPI.
//!/
extern void sd_mmc_spi_mem_init();
extern void sd_mmc_spi_mem_init(void);
//!
//! @brief This function tests the state of the SD_MMC memory and sends it to the Host.
@@ -91,7 +91,7 @@ extern void sd_mmc_spi_mem_init();
//! Media not present -> CTRL_NO_PRESENT
//! Media has changed -> CTRL_BUSY
//!/
extern Ctrl_status sd_mmc_spi_test_unit_ready();
extern Ctrl_status sd_mmc_spi_test_unit_ready(void);
//!
//! @brief This function gives the address of the last valid sector.
@@ -124,14 +124,14 @@ extern bool sd_mmc_spi_unload(bool unload);
//!
//! @return false -> the memory is not write-protected (always)
//!/
extern bool sd_mmc_spi_wr_protect();
extern bool sd_mmc_spi_wr_protect(void);
//!
//! @brief This function tells if the memory has been removed or not.
//!
//! @return false -> The memory isn't removed
//!
extern bool sd_mmc_spi_removal();
extern bool sd_mmc_spi_removal(void);
//---- ACCESS DATA FONCTIONS ----
+2 -2
View File
@@ -71,7 +71,7 @@ extern "C" {
* \param pll_id Source of the USB clock.
* \param div Actual clock divisor. Must be superior to 0.
*/
void sysclk_enable_usb()
void sysclk_enable_usb(void)
{
Assert(CONFIG_USBCLK_DIV > 0);
@@ -103,7 +103,7 @@ void sysclk_enable_usb()
*
* \note This implementation does not switch off the PLL, it just turns off the USB clock.
*/
void sysclk_disable_usb()
void sysclk_disable_usb(void)
{
pmc_disable_udpck();
}
+2 -2
View File
@@ -213,8 +213,8 @@ extern "C" {
#endif
extern void sysclk_enable_usb();
extern void sysclk_disable_usb();
extern void sysclk_enable_usb(void);
extern void sysclk_disable_usb(void);
//! @}
+26 -26
View File
@@ -132,14 +132,14 @@ static uint8_t udc_string_product_name[] = USB_DEVICE_PRODUCT_NAME;
* define USB_DEVICE_GET_SERIAL_NAME_LENGTH.
*/
#if defined USB_DEVICE_GET_SERIAL_NAME_POINTER
static const uint8_t *udc_get_string_serial_name()
static const uint8_t *udc_get_string_serial_name(void)
{
return (const uint8_t *)USB_DEVICE_GET_SERIAL_NAME_POINTER;
}
# define USB_DEVICE_SERIAL_NAME_SIZE \
USB_DEVICE_GET_SERIAL_NAME_LENGTH
#elif defined USB_DEVICE_SERIAL_NAME
static const uint8_t *udc_get_string_serial_name()
static const uint8_t *udc_get_string_serial_name(void)
{
return (const uint8_t *)USB_DEVICE_SERIAL_NAME;
}
@@ -164,7 +164,7 @@ static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = {
};
//! @}
usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc()
usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void)
{
return udc_ptr_iface;
}
@@ -174,7 +174,7 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc()
*
* \return address after the last byte of USB Configuration descriptor
*/
static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf()
static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void)
{
return (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *)
udc_ptr_conf->desc +
@@ -360,14 +360,14 @@ static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num)
/*! \brief Start the USB Device stack
*/
void udc_start()
void udc_start(void)
{
udd_enable();
}
/*! \brief Stop the USB Device stack
*/
void udc_stop()
void udc_stop(void)
{
udd_disable();
udc_reset();
@@ -377,7 +377,7 @@ void udc_stop()
* \brief Reset the current configuration of the USB device,
* This routines can be called by UDD when a RESET on the USB line occurs.
*/
void udc_reset()
void udc_reset(void)
{
uint8_t iface_num;
@@ -404,7 +404,7 @@ void udc_reset()
#endif
}
void udc_sof_notify()
void udc_sof_notify(void)
{
uint8_t iface_num;
@@ -424,7 +424,7 @@ void udc_sof_notify()
*
* \return true if success
*/
static bool udc_req_std_dev_get_status()
static bool udc_req_std_dev_get_status(void)
{
if (udd_g_ctrlreq.req.wLength != sizeof(udc_device_status)) {
return false;
@@ -441,7 +441,7 @@ static bool udc_req_std_dev_get_status()
*
* \return true if success
*/
static bool udc_req_std_ep_get_status()
static bool udc_req_std_ep_get_status(void)
{
static le16_t udc_ep_status;
@@ -463,7 +463,7 @@ static bool udc_req_std_ep_get_status()
*
* \return true if success
*/
static bool udc_req_std_dev_clear_feature()
static bool udc_req_std_dev_clear_feature(void)
{
if (udd_g_ctrlreq.req.wLength) {
return false;
@@ -486,7 +486,7 @@ static bool udc_req_std_dev_clear_feature()
*
* \return true if success
*/
static bool udc_req_std_ep_clear_feature()
static bool udc_req_std_ep_clear_feature(void)
{
if (udd_g_ctrlreq.req.wLength) {
return false;
@@ -504,7 +504,7 @@ static bool udc_req_std_ep_clear_feature()
*
* \return true if success
*/
static bool udc_req_std_dev_set_feature()
static bool udc_req_std_dev_set_feature(void)
{
if (udd_g_ctrlreq.req.wLength) {
return false;
@@ -567,7 +567,7 @@ static bool udc_req_std_dev_set_feature()
* \return true if success
*/
#if (0!=USB_DEVICE_MAX_EP)
static bool udc_req_std_ep_set_feature()
static bool udc_req_std_ep_set_feature(void)
{
if (udd_g_ctrlreq.req.wLength) {
return false;
@@ -584,7 +584,7 @@ static bool udc_req_std_ep_set_feature()
* \brief Change the address of device
* Callback called at the end of request set address
*/
static void udc_valid_address()
static void udc_valid_address(void)
{
udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F);
}
@@ -594,7 +594,7 @@ static void udc_valid_address()
*
* \return true if success
*/
static bool udc_req_std_dev_set_address()
static bool udc_req_std_dev_set_address(void)
{
if (udd_g_ctrlreq.req.wLength) {
return false;
@@ -611,7 +611,7 @@ static bool udc_req_std_dev_set_address()
*
* \return true if success
*/
static bool udc_req_std_dev_get_str_desc()
static bool udc_req_std_dev_get_str_desc(void)
{
uint8_t i;
const uint8_t *str;
@@ -670,7 +670,7 @@ static bool udc_req_std_dev_get_str_desc()
*
* \return true if success
*/
static bool udc_req_std_dev_get_descriptor()
static bool udc_req_std_dev_get_descriptor(void)
{
uint8_t conf_num;
@@ -787,7 +787,7 @@ static bool udc_req_std_dev_get_descriptor()
*
* \return true if success
*/
static bool udc_req_std_dev_get_configuration()
static bool udc_req_std_dev_get_configuration(void)
{
if (udd_g_ctrlreq.req.wLength != 1) {
return false;
@@ -802,7 +802,7 @@ static bool udc_req_std_dev_get_configuration()
*
* \return true if success
*/
static bool udc_req_std_dev_set_configuration()
static bool udc_req_std_dev_set_configuration(void)
{
uint8_t iface_num;
@@ -867,7 +867,7 @@ static bool udc_req_std_dev_set_configuration()
*
* \return true if success
*/
static bool udc_req_std_iface_get_setting()
static bool udc_req_std_iface_get_setting(void)
{
uint8_t iface_num;
udi_api_t UDC_DESC_STORAGE *udi_api;
@@ -905,7 +905,7 @@ static bool udc_req_std_iface_get_setting()
*
* \return true if success
*/
static bool udc_req_std_iface_set_setting()
static bool udc_req_std_iface_set_setting(void)
{
uint8_t iface_num, setting_num;
@@ -933,7 +933,7 @@ static bool udc_req_std_iface_set_setting()
*
* \return true if the request is supported
*/
static bool udc_reqstd()
static bool udc_reqstd(void)
{
if (Udd_setup_is_in()) {
// GET Standard Requests
@@ -1027,7 +1027,7 @@ static bool udc_reqstd()
*
* \return true if the request is supported
*/
static bool udc_req_iface()
static bool udc_req_iface(void)
{
uint8_t iface_num;
udi_api_t UDC_DESC_STORAGE *udi_api;
@@ -1062,7 +1062,7 @@ static bool udc_req_iface()
*
* \return true if the request is supported
*/
static bool udc_req_ep()
static bool udc_req_ep(void)
{
uint8_t iface_num;
udi_api_t UDC_DESC_STORAGE *udi_api;
@@ -1101,7 +1101,7 @@ static bool udc_req_ep()
*
* \return true if the request is supported, else the request is stalled by UDD
*/
bool udc_process_setup()
bool udc_process_setup(void)
{
// By default no data (receive/send) and no callbacks registered
udd_g_ctrlreq.payload_size = 0;
+24 -24
View File
@@ -172,18 +172,18 @@ extern "C" {
}
\endcode
*/
static inline bool udc_include_vbus_monitoring()
static inline bool udc_include_vbus_monitoring(void)
{
return udd_include_vbus_monitoring();
}
/*! \brief Start the USB Device stack
*/
void udc_start();
void udc_start(void);
/*! \brief Stop the USB Device stack
*/
void udc_stop();
void udc_stop(void);
/**
* \brief Attach device to the bus when possible
@@ -192,7 +192,7 @@ void udc_stop();
* then it will attach device when an acceptable Vbus
* level from the host is detected.
*/
static inline void udc_attach()
static inline void udc_attach(void)
{
udd_attach();
}
@@ -203,7 +203,7 @@ static inline void udc_attach()
*
* The driver must remove pull-up on USB line D- or D+.
*/
static inline void udc_detach()
static inline void udc_detach(void)
{
udd_detach();
}
@@ -212,7 +212,7 @@ static inline void udc_detach()
/*! \brief The USB driver sends a resume signal called \e "Upstream Resume"
* This is authorized only when the remote wakeup feature is enabled by host.
*/
static inline void udc_remotewakeup()
static inline void udc_remotewakeup(void)
{
udd_send_remotewakeup();
}
@@ -223,7 +223,7 @@ static inline void udc_remotewakeup()
*
* \return pointer on the current interface descriptor.
*/
usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
//@}
@@ -334,7 +334,7 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
*
* Add to application C-file:
* \code
void usb_init()
void usb_init(void)
{
udc_start();
}
@@ -551,23 +551,23 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
#define USB_DEVICE_ATTR \
(USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED)
#define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
extern void my_callback_remotewakeup_enable();
extern void my_callback_remotewakeup_enable(void);
#define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
extern void my_callback_remotewakeup_disable();
extern void my_callback_remotewakeup_disable(void);
\endcode
*
* Add to application C-file:
* \code
void my_callback_remotewakeup_enable()
void my_callback_remotewakeup_enable(void)
{
// Enable application wakeup events (e.g. enable GPIO interrupt)
}
void my_callback_remotewakeup_disable()
void my_callback_remotewakeup_disable(void)
{
// Disable application wakeup events (e.g. disable GPIO interrupt)
}
void my_interrupt_event()
void my_interrupt_event(void)
{
udc_remotewakeup();
}
@@ -580,10 +580,10 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
#define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED) \endcode
* - \code // Define callback called when the host enables the remotewakeup feature
#define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
extern void my_callback_remotewakeup_enable(); \endcode
extern void my_callback_remotewakeup_enable(void); \endcode
* - \code // Define callback called when the host disables the remotewakeup feature
#define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
extern void my_callback_remotewakeup_disable(); \endcode
extern void my_callback_remotewakeup_disable(void); \endcode
* -# Send a remote wakeup (USB upstream):
* - \code udc_remotewakeup(); \endcode
*/
@@ -605,18 +605,18 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
* \code
#define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED)
#define UDC_SUSPEND_EVENT() user_callback_suspend_action()
extern void user_callback_suspend_action()
extern void user_callback_suspend_action(void)
#define UDC_RESUME_EVENT() user_callback_resume_action()
extern void user_callback_resume_action()
extern void user_callback_resume_action(void)
\endcode
*
* Add to application C-file:
* \code
void user_callback_suspend_action()
void user_callback_suspend_action(void)
{
// Disable hardware component to reduce power consumption
}
void user_callback_resume_action()
void user_callback_resume_action(void)
{
// Re-enable hardware component
}
@@ -628,12 +628,12 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
#define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED) \endcode
* - \code // Define callback called when the host suspend the USB line
#define UDC_SUSPEND_EVENT() user_callback_suspend_action()
extern void user_callback_suspend_action(); \endcode
extern void user_callback_suspend_action(void); \endcode
* - \code // Define callback called when the host or device resume the USB line
#define UDC_RESUME_EVENT() user_callback_resume_action()
extern void user_callback_resume_action(); \endcode
extern void user_callback_resume_action(void); \endcode
* -# Reduce power consumption in suspend mode (max. 2.5mA on Vbus):
* - \code void user_callback_suspend_action()
* - \code void user_callback_suspend_action(void)
{
turn_off_components();
} \endcode
@@ -664,7 +664,7 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
* \code
uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
void init_build_usb_serial_number()
void init_build_usb_serial_number(void)
{
serial_number[0] = 'A';
serial_number[1] = 'B';
@@ -683,7 +683,7 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc();
* - \code
uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
void init_build_usb_serial_number()
void init_build_usb_serial_number(void)
{
serial_number[0] = 'A';
serial_number[1] = 'B';
+20 -20
View File
@@ -94,11 +94,11 @@ typedef struct {
uint16_t payload_size;
//! Callback called after reception of ZLP from setup request
void (*callback)();
void (*callback)(void);
//! Callback called when the buffer given (.payload) is full or empty.
//! This one return false to abort data transfer, or true with a new buffer in .payload.
bool (*over_under_run)();
bool (*over_under_run)(void);
} udd_ctrl_request_t;
extern udd_ctrl_request_t udd_g_ctrlreq;
@@ -123,7 +123,7 @@ extern udd_ctrl_request_t udd_g_ctrlreq;
* Registered by routine udd_ep_wait_stall_clear()
* Callback called when endpoint stall is cleared.
*/
typedef void (*udd_callback_halt_cleared_t)();
typedef void (*udd_callback_halt_cleared_t)(void);
/**
* \brief End of transfer callback function type.
@@ -142,17 +142,17 @@ typedef void (*udd_callback_trans_t) (udd_ep_status_t status,
*
* \return true, if the VBUS monitoring is possible.
*/
bool udd_include_vbus_monitoring();
bool udd_include_vbus_monitoring(void);
/**
* \brief Enables the USB Device mode
*/
void udd_enable();
void udd_enable(void);
/**
* \brief Disables the USB Device mode
*/
void udd_disable();
void udd_disable(void);
/**
* \brief Attach device to the bus when possible
@@ -161,14 +161,14 @@ void udd_disable();
* then it will attach device when an acceptable Vbus
* level from the host is detected.
*/
void udd_attach();
void udd_attach(void);
/**
* \brief Detaches the device from the bus
*
* The driver must remove pull-up on USB line D- or D+.
*/
void udd_detach();
void udd_detach(void);
/**
* \brief Test whether the USB Device Controller is running at high
@@ -176,7 +176,7 @@ void udd_detach();
*
* \return \c true if the Device is running at high speed mode, otherwise \c false.
*/
bool udd_is_high_speed();
bool udd_is_high_speed(void);
/**
* \brief Changes the USB address of device
@@ -190,25 +190,25 @@ void udd_set_address(uint8_t address);
*
* \return USB address
*/
uint8_t udd_getaddress();
uint8_t udd_getaddress(void);
/**
* \brief Returns the current start of frame number
*
* \return current start of frame number.
*/
uint16_t udd_get_frame_number();
uint16_t udd_get_frame_number(void);
/**
* \brief Returns the current micro start of frame number
*
* \return current micro start of frame number required in high speed mode.
*/
uint16_t udd_get_micro_frame_number();
uint16_t udd_get_micro_frame_number(void);
/*! \brief The USB driver sends a resume signal called Upstream Resume
*/
void udd_send_remotewakeup();
void udd_send_remotewakeup(void);
/**
* \brief Load setup payload
@@ -346,10 +346,10 @@ void udd_ep_abort(udd_ep_id_t ep);
* The following functions allow the device to jump to a specific test mode required in high speed mode.
*/
//@{
void udd_test_mode_j();
void udd_test_mode_k();
void udd_test_mode_se0_nak();
void udd_test_mode_packet();
void udd_test_mode_j(void);
void udd_test_mode_k(void);
void udd_test_mode_se0_nak(void);
void udd_test_mode_packet(void);
//@}
@@ -370,21 +370,21 @@ void udd_test_mode_packet();
*
* \return \c 1 if the request is accepted, otherwise \c 0.
*/
extern bool udc_process_setup();
extern bool udc_process_setup(void);
/**
* \brief Reset the UDC
*
* The UDC must reset all configuration.
*/
extern void udc_reset();
extern void udc_reset(void);
/**
* \brief To signal that a SOF is occurred
*
* The UDC must send the signal to all UDIs enabled
*/
extern void udc_sof_notify();
extern void udc_sof_notify(void);
//@}
+5 -5
View File
@@ -82,7 +82,7 @@ typedef struct {
*
* \return \c 1 if function was successfully done, otherwise \c 0.
*/
bool (*enable)();
bool (*enable)(void);
/**
* \brief Disable the interface.
@@ -95,7 +95,7 @@ typedef struct {
* - the device is detached from the host (i.e. Vbus is no
* longer present)
*/
void (*disable)();
void (*disable)(void);
/**
* \brief Handle a control request directed at an interface.
@@ -108,7 +108,7 @@ typedef struct {
*
* \return \c 1 if this interface supports the SETUP request, otherwise \c 0.
*/
bool (*setup)();
bool (*setup)(void);
/**
* \brief Returns the current setting of the selected interface.
@@ -117,12 +117,12 @@ typedef struct {
*
* \return alternate setting of selected interface
*/
uint8_t (*getsetting)();
uint8_t (*getsetting)(void);
/**
* \brief To signal that a SOF is occurred
*/
void (*sof_notify)();
void (*sof_notify)(void);
} udi_api_t;
//@}
+28 -28
View File
@@ -84,14 +84,14 @@
*
* @{
*/
bool udi_cdc_comm_enable();
void udi_cdc_comm_disable();
bool udi_cdc_comm_setup();
bool udi_cdc_data_enable();
void udi_cdc_data_disable();
bool udi_cdc_data_setup();
uint8_t udi_cdc_getsetting();
void udi_cdc_data_sof_notify();
bool udi_cdc_comm_enable(void);
void udi_cdc_comm_disable(void);
bool udi_cdc_comm_setup(void);
bool udi_cdc_data_enable(void);
void udi_cdc_data_disable(void);
bool udi_cdc_data_setup(void);
uint8_t udi_cdc_getsetting(void);
void udi_cdc_data_sof_notify(void);
UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm = {
.enable = udi_cdc_comm_enable,
.disable = udi_cdc_comm_disable,
@@ -130,14 +130,14 @@ UDC_DESC_STORAGE udi_api_t udi_api_cdc_data = {
*
* \return port number
*/
static uint8_t udi_cdc_setup_to_port();
static uint8_t udi_cdc_setup_to_port(void);
/**
* \brief Sends line coding to application
*
* Called after SETUP request when line coding data is received.
*/
static void udi_cdc_line_coding_received();
static void udi_cdc_line_coding_received(void);
/**
* \brief Records new state
@@ -267,7 +267,7 @@ static volatile bool udi_cdc_tx_both_buf_to_send[UDI_CDC_PORT_NB];
//@}
bool udi_cdc_comm_enable()
bool udi_cdc_comm_enable(void)
{
uint8_t port;
uint8_t iface_comm_num;
@@ -321,7 +321,7 @@ bool udi_cdc_comm_enable()
return true;
}
bool udi_cdc_data_enable()
bool udi_cdc_data_enable(void)
{
uint8_t port;
@@ -360,13 +360,13 @@ bool udi_cdc_data_enable()
return true;
}
void udi_cdc_comm_disable()
void udi_cdc_comm_disable(void)
{
Assert(udi_cdc_nb_comm_enabled != 0);
udi_cdc_nb_comm_enabled--;
}
void udi_cdc_data_disable()
void udi_cdc_data_disable(void)
{
uint8_t port;
@@ -377,7 +377,7 @@ void udi_cdc_data_disable()
udi_cdc_data_running = false;
}
bool udi_cdc_comm_setup()
bool udi_cdc_comm_setup(void)
{
uint8_t port = udi_cdc_setup_to_port();
@@ -433,17 +433,17 @@ bool udi_cdc_comm_setup()
return false; // request Not supported
}
bool udi_cdc_data_setup()
bool udi_cdc_data_setup(void)
{
return false; // request Not supported
}
uint8_t udi_cdc_getsetting()
uint8_t udi_cdc_getsetting(void)
{
return 0; // CDC don't have multiple alternate setting
}
void udi_cdc_data_sof_notify()
void udi_cdc_data_sof_notify(void)
{
static uint8_t port_notify = 0;
@@ -461,7 +461,7 @@ void udi_cdc_data_sof_notify()
// ------------------------
//------- Internal routines to control serial line
static uint8_t udi_cdc_setup_to_port()
static uint8_t udi_cdc_setup_to_port(void)
{
uint8_t port;
@@ -479,7 +479,7 @@ static uint8_t udi_cdc_setup_to_port()
return port;
}
static void udi_cdc_line_coding_received()
static void udi_cdc_line_coding_received(void)
{
uint8_t port = udi_cdc_setup_to_port();
UNUSED(port);
@@ -797,17 +797,17 @@ void udi_cdc_ctrl_signal_dsr(bool b_set)
udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DSR);
}
void udi_cdc_signal_framing_error()
void udi_cdc_signal_framing_error(void)
{
udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_FRAMING);
}
void udi_cdc_signal_parity_error()
void udi_cdc_signal_parity_error(void)
{
udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_PARITY);
}
void udi_cdc_signal_overrun()
void udi_cdc_signal_overrun(void)
{
udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_OVERRUN);
}
@@ -853,7 +853,7 @@ iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port)
return nb_received;
}
iram_size_t udi_cdc_get_nb_received_data()
iram_size_t udi_cdc_get_nb_received_data(void)
{
return udi_cdc_multi_get_nb_received_data(0);
}
@@ -863,7 +863,7 @@ bool udi_cdc_multi_is_rx_ready(uint8_t port)
return (udi_cdc_multi_get_nb_received_data(port) > 0);
}
bool udi_cdc_is_rx_ready()
bool udi_cdc_is_rx_ready(void)
{
return udi_cdc_multi_is_rx_ready(0);
}
@@ -912,7 +912,7 @@ udi_cdc_getc_process_one_byte:
return rx_data;
}
int udi_cdc_getc()
int udi_cdc_getc(void)
{
return udi_cdc_multi_getc(0);
}
@@ -1041,7 +1041,7 @@ iram_size_t __attribute__((optimize("O0"))) udi_cdc_multi_get_free_tx_buffer(uin
return retval;
}
iram_size_t udi_cdc_get_free_tx_buffer()
iram_size_t udi_cdc_get_free_tx_buffer(void)
{
return udi_cdc_multi_get_free_tx_buffer(0);
}
@@ -1051,7 +1051,7 @@ bool udi_cdc_multi_is_tx_ready(uint8_t port)
return (udi_cdc_multi_get_free_tx_buffer(port) != 0);
}
bool udi_cdc_is_tx_ready()
bool udi_cdc_is_tx_ready(void)
{
return udi_cdc_multi_is_tx_ready(0);
}
+16 -16
View File
@@ -366,38 +366,38 @@ void udi_cdc_ctrl_signal_dsr(bool b_set);
/**
* \brief Notify a framing error
*/
void udi_cdc_signal_framing_error();
void udi_cdc_signal_framing_error(void);
/**
* \brief Notify a parity error
*/
void udi_cdc_signal_parity_error();
void udi_cdc_signal_parity_error(void);
/**
* \brief Notify a overrun
*/
void udi_cdc_signal_overrun();
void udi_cdc_signal_overrun(void);
/**
* \brief Gets the number of byte received
*
* \return the number of data available
*/
iram_size_t udi_cdc_get_nb_received_data();
iram_size_t udi_cdc_get_nb_received_data(void);
/**
* \brief This function checks if a character has been received on the CDC line
*
* \return \c 1 if a byte is ready to be read.
*/
bool udi_cdc_is_rx_ready();
bool udi_cdc_is_rx_ready(void);
/**
* \brief Waits and gets a value on CDC line
*
* \return value read on CDC line
*/
int udi_cdc_getc();
int udi_cdc_getc(void);
/**
* \brief Reads a RAM buffer on CDC line
@@ -425,7 +425,7 @@ iram_size_t udi_cdc_read_no_polling(void* buf, iram_size_t size);
*
* \return the number of free byte in TX buffer
*/
iram_size_t udi_cdc_get_free_tx_buffer();
iram_size_t udi_cdc_get_free_tx_buffer(void);
/**
* \brief This function checks if a new character sent is possible
@@ -433,7 +433,7 @@ iram_size_t udi_cdc_get_free_tx_buffer();
*
* \return \c 1 if a new character can be sent
*/
bool udi_cdc_is_tx_ready();
bool udi_cdc_is_tx_ready(void);
/**
* \brief Puts a byte on CDC line
@@ -611,9 +611,9 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
* Content of conf_usb.h:
* \code
#define UDI_CDC_ENABLE_EXT(port) my_callback_cdc_enable()
extern bool my_callback_cdc_enable();
extern bool my_callback_cdc_enable(void);
#define UDI_CDC_DISABLE_EXT(port) my_callback_cdc_disable()
extern void my_callback_cdc_disable();
extern void my_callback_cdc_disable(void);
#define UDI_CDC_LOW_RATE
#define UDI_CDC_DEFAULT_RATE 115200
@@ -627,17 +627,17 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
* Add to application C-file:
* \code
static bool my_flag_autorize_cdc_transfert = false;
bool my_callback_cdc_enable()
bool my_callback_cdc_enable(void)
{
my_flag_autorize_cdc_transfert = true;
return true;
}
void my_callback_cdc_disable()
void my_callback_cdc_disable(void)
{
my_flag_autorize_cdc_transfert = false;
}
void task()
void task(void)
{
if (my_flag_autorize_cdc_transfert) {
udi_cdc_putc('A');
@@ -652,14 +652,14 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
* - \code #define USB_DEVICE_SERIAL_NAME "12...EF" // Disk SN for CDC \endcode
* \note The USB serial number is mandatory when a CDC interface is used.
* - \code #define UDI_CDC_ENABLE_EXT(port) my_callback_cdc_enable()
extern bool my_callback_cdc_enable(); \endcode
extern bool my_callback_cdc_enable(void); \endcode
* \note After the device enumeration (detecting and identifying USB devices),
* the USB host starts the device configuration. When the USB CDC interface
* from the device is accepted by the host, the USB host enables this interface and the
* UDI_CDC_ENABLE_EXT() callback function is called and return true.
* Thus, when this event is received, the data transfer on CDC interface are authorized.
* - \code #define UDI_CDC_DISABLE_EXT(port) my_callback_cdc_disable()
extern void my_callback_cdc_disable(); \endcode
extern void my_callback_cdc_disable(void); \endcode
* \note When the USB device is unplugged or is reset by the USB host, the USB
* interface is disabled and the UDI_CDC_DISABLE_EXT() callback function
* is called. Thus, the data transfer must be stopped on CDC interface.
@@ -673,7 +673,7 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
* \note Default configuration of communication port at startup.
* -# Send or wait data on CDC line:
* - \code // Waits and gets a value on CDC line
int udi_cdc_getc();
int udi_cdc_getc(void);
// Reads a RAM buffer on CDC line
iram_size_t udi_cdc_read_buf(int* buf, iram_size_t size);
// Puts a byte on CDC line
+49 -49
View File
@@ -71,10 +71,10 @@
*
* @{
*/
bool udi_msc_enable();
void udi_msc_disable();
bool udi_msc_setup();
uint8_t udi_msc_getsetting();
bool udi_msc_enable(void);
void udi_msc_disable(void);
bool udi_msc_setup(void);
uint8_t udi_msc_getsetting(void);
//! Global structure which contains standard UDI API for UDC
UDC_DESC_STORAGE udi_api_t udi_api_msc = {
@@ -151,12 +151,12 @@ volatile bool udi_msc_b_reset_trans = true;
/**
* \brief Stall CBW request
*/
static void udi_msc_cbw_invalid();
static void udi_msc_cbw_invalid(void);
/**
* \brief Stall CSW request
*/
static void udi_msc_csw_invalid();
static void udi_msc_csw_invalid(void);
/**
* \brief Links a callback and buffer on endpoint OUT reception
@@ -165,7 +165,7 @@ static void udi_msc_csw_invalid();
* - enable interface
* - at the end of previous command after sending the CSW
*/
static void udi_msc_cbw_wait();
static void udi_msc_cbw_wait(void);
/**
* \brief Callback called after CBW reception
@@ -228,7 +228,7 @@ static void udi_msc_data_sent(udd_ep_status_t status, iram_size_t nb_sent,
*
* Called at the end of SCSI command
*/
static void udi_msc_csw_process();
static void udi_msc_csw_process(void);
/**
* \brief Sends CSW
@@ -236,7 +236,7 @@ static void udi_msc_csw_process();
* Called by #udi_msc_csw_process()
* or UDD callback when endpoint halt is cleared
*/
void udi_msc_csw_send();
void udi_msc_csw_send(void);
/**
* \brief Callback called after CSW sent
@@ -259,7 +259,7 @@ static void udi_msc_csw_sent(udd_ep_status_t status, iram_size_t nb_sent,
/**
* \brief Reinitialize sense data.
*/
static void udi_msc_clear_sense();
static void udi_msc_clear_sense(void);
/**
* \brief Update sense data with new value to signal a fail
@@ -274,37 +274,37 @@ static void udi_msc_sense_fail(uint8_t sense_key, uint16_t add_sense,
/**
* \brief Update sense data with new value to signal success
*/
static void udi_msc_sense_pass();
static void udi_msc_sense_pass(void);
/**
* \brief Update sense data to signal that memory is not present
*/
static void udi_msc_sense_fail_not_present();
static void udi_msc_sense_fail_not_present(void);
/**
* \brief Update sense data to signal that memory is busy
*/
static void udi_msc_sense_fail_busy_or_change();
static void udi_msc_sense_fail_busy_or_change(void);
/**
* \brief Update sense data to signal a hardware error on memory
*/
static void udi_msc_sense_fail_hardware();
static void udi_msc_sense_fail_hardware(void);
/**
* \brief Update sense data to signal that memory is protected
*/
static void udi_msc_sense_fail_protected();
static void udi_msc_sense_fail_protected(void);
/**
* \brief Update sense data to signal that CDB fields are not valid
*/
static void udi_msc_sense_fail_cdb_invalid();
static void udi_msc_sense_fail_cdb_invalid(void);
/**
* \brief Update sense data to signal that command is not supported
*/
static void udi_msc_sense_command_invalid();
static void udi_msc_sense_command_invalid(void);
//@}
@@ -317,31 +317,31 @@ static void udi_msc_sense_command_invalid();
* \brief Process SPC Request Sense command
* Returns error information about last command
*/
static void udi_msc_spc_requestsense();
static void udi_msc_spc_requestsense(void);
/**
* \brief Process SPC Inquiry command
* Returns information (name,version) about disk
*/
static void udi_msc_spc_inquiry();
static void udi_msc_spc_inquiry(void);
/**
* \brief Checks state of disk
*
* \retval true if disk is ready, otherwise false and updates sense data
*/
static bool udi_msc_spc_testunitready_global();
static bool udi_msc_spc_testunitready_global(void);
/**
* \brief Process test unit ready command
* Returns state of logical unit
*/
static void udi_msc_spc_testunitready();
static void udi_msc_spc_testunitready(void);
/**
* \brief Process prevent allow medium removal command
*/
static void udi_msc_spc_prevent_allow_medium_removal();
static void udi_msc_spc_prevent_allow_medium_removal(void);
/**
* \brief Process mode sense command
@@ -354,12 +354,12 @@ static void udi_msc_spc_mode_sense(bool b_sense10);
/**
* \brief Process start stop command
*/
static void udi_msc_sbc_start_stop();
static void udi_msc_sbc_start_stop(void);
/**
* \brief Process read capacity command
*/
static void udi_msc_sbc_read_capacity();
static void udi_msc_sbc_read_capacity(void);
/**
* \brief Process read10 or write10 command
@@ -373,7 +373,7 @@ static void udi_msc_sbc_trans(bool b_read);
//@}
bool udi_msc_enable()
bool udi_msc_enable(void)
{
uint8_t lun;
udi_msc_b_trans_req = false;
@@ -398,7 +398,7 @@ bool udi_msc_enable()
}
void udi_msc_disable()
void udi_msc_disable(void)
{
udi_msc_b_trans_req = false;
udi_msc_b_ack_trans = true;
@@ -407,7 +407,7 @@ void udi_msc_disable()
}
bool udi_msc_setup()
bool udi_msc_setup(void)
{
if (Udd_setup_is_in()) {
// Requests Interface GET
@@ -451,7 +451,7 @@ bool udi_msc_setup()
return false; // Not supported request
}
uint8_t udi_msc_getsetting()
uint8_t udi_msc_getsetting(void)
{
return 0; // MSC don't have multiple alternate setting
}
@@ -460,7 +460,7 @@ uint8_t udi_msc_getsetting()
// ------------------------
//------- Routines to process CBW packet
static void udi_msc_cbw_invalid()
static void udi_msc_cbw_invalid(void)
{
if (!udi_msc_b_cbw_invalid)
return; // Don't re-stall endpoint if error reseted by setup
@@ -469,7 +469,7 @@ static void udi_msc_cbw_invalid()
udd_ep_wait_stall_clear(UDI_MSC_EP_OUT, udi_msc_cbw_invalid);
}
static void udi_msc_csw_invalid()
static void udi_msc_csw_invalid(void)
{
if (!udi_msc_b_cbw_invalid)
return; // Don't re-stall endpoint if error reseted by setup
@@ -478,7 +478,7 @@ static void udi_msc_csw_invalid()
udd_ep_wait_stall_clear(UDI_MSC_EP_IN, udi_msc_csw_invalid);
}
static void udi_msc_cbw_wait()
static void udi_msc_cbw_wait(void)
{
// Register buffer and callback on OUT endpoint
if (!udd_ep_run(UDI_MSC_EP_OUT, true,
@@ -648,7 +648,7 @@ static void udi_msc_data_sent(udd_ep_status_t status, iram_size_t nb_sent,
// ------------------------
//------- Routines to process CSW packet
static void udi_msc_csw_process()
static void udi_msc_csw_process(void)
{
if (0 != udi_msc_csw.dCSWDataResidue) {
// Residue not NULL
@@ -665,7 +665,7 @@ static void udi_msc_csw_process()
}
void udi_msc_csw_send()
void udi_msc_csw_send(void)
{
// Sends CSW on IN endpoint
if (!udd_ep_run(UDI_MSC_EP_IN, false,
@@ -694,7 +694,7 @@ static void udi_msc_csw_sent(udd_ep_status_t status, iram_size_t nb_sent,
// ------------------------
//------- Routines manage sense data
static void udi_msc_clear_sense()
static void udi_msc_clear_sense(void)
{
memset((uint8_t*)&udi_msc_sense, 0, sizeof(struct scsi_request_sense_data));
udi_msc_sense.valid_reponse_code = SCSI_SENSE_VALID | SCSI_SENSE_CURRENT;
@@ -715,42 +715,42 @@ static void udi_msc_sense_fail(uint8_t sense_key, uint16_t add_sense,
udi_msc_sense.AddSnsCodeQlfr = add_sense;
}
static void udi_msc_sense_pass()
static void udi_msc_sense_pass(void)
{
udi_msc_clear_sense();
udi_msc_csw.bCSWStatus = USB_CSW_STATUS_PASS;
}
static void udi_msc_sense_fail_not_present()
static void udi_msc_sense_fail_not_present(void)
{
udi_msc_sense_fail(SCSI_SK_NOT_READY, SCSI_ASC_MEDIUM_NOT_PRESENT, 0);
}
static void udi_msc_sense_fail_busy_or_change()
static void udi_msc_sense_fail_busy_or_change(void)
{
udi_msc_sense_fail(SCSI_SK_UNIT_ATTENTION,
SCSI_ASC_NOT_READY_TO_READY_CHANGE, 0);
}
static void udi_msc_sense_fail_hardware()
static void udi_msc_sense_fail_hardware(void)
{
udi_msc_sense_fail(SCSI_SK_HARDWARE_ERROR,
SCSI_ASC_NO_ADDITIONAL_SENSE_INFO, 0);
}
static void udi_msc_sense_fail_protected()
static void udi_msc_sense_fail_protected(void)
{
udi_msc_sense_fail(SCSI_SK_DATA_PROTECT, SCSI_ASC_WRITE_PROTECTED, 0);
}
static void udi_msc_sense_fail_cdb_invalid()
static void udi_msc_sense_fail_cdb_invalid(void)
{
udi_msc_sense_fail(SCSI_SK_ILLEGAL_REQUEST,
SCSI_ASC_INVALID_FIELD_IN_CDB, 0);
}
static void udi_msc_sense_command_invalid()
static void udi_msc_sense_command_invalid(void)
{
udi_msc_sense_fail(SCSI_SK_ILLEGAL_REQUEST,
SCSI_ASC_INVALID_COMMAND_OPERATION_CODE, 0);
@@ -760,7 +760,7 @@ static void udi_msc_sense_command_invalid()
// ------------------------
//------- Routines manage SCSI Commands
static void udi_msc_spc_requestsense()
static void udi_msc_spc_requestsense(void)
{
uint8_t length = udi_msc_cbw.CDB[4];
@@ -775,7 +775,7 @@ static void udi_msc_spc_requestsense()
}
static void udi_msc_spc_inquiry()
static void udi_msc_spc_inquiry(void)
{
uint8_t length, i;
UDC_DATA(4)
@@ -836,7 +836,7 @@ static void udi_msc_spc_inquiry()
}
static bool udi_msc_spc_testunitready_global()
static bool udi_msc_spc_testunitready_global(void)
{
switch (mem_test_unit_ready(udi_msc_cbw.bCBWLUN)) {
case CTRL_GOOD:
@@ -856,7 +856,7 @@ static bool udi_msc_spc_testunitready_global()
}
static void udi_msc_spc_testunitready()
static void udi_msc_spc_testunitready(void)
{
if (udi_msc_spc_testunitready_global()) {
// LUN ready, then update sense data with status pass
@@ -944,7 +944,7 @@ static void udi_msc_spc_mode_sense(bool b_sense10)
}
static void udi_msc_spc_prevent_allow_medium_removal()
static void udi_msc_spc_prevent_allow_medium_removal(void)
{
uint8_t prevent = udi_msc_cbw.CDB[4];
if (0 == prevent) {
@@ -956,7 +956,7 @@ static void udi_msc_spc_prevent_allow_medium_removal()
}
static void udi_msc_sbc_start_stop()
static void udi_msc_sbc_start_stop(void)
{
bool start = 0x1 & udi_msc_cbw.CDB[4];
bool loej = 0x2 & udi_msc_cbw.CDB[4];
@@ -968,7 +968,7 @@ static void udi_msc_sbc_start_stop()
}
static void udi_msc_sbc_read_capacity()
static void udi_msc_sbc_read_capacity(void)
{
UDC_BSS(4) static struct sbc_read_capacity10_data udi_msc_capacity;
@@ -1039,7 +1039,7 @@ static void udi_msc_sbc_trans(bool b_read)
}
bool udi_msc_process_trans()
bool udi_msc_process_trans(void)
{
Ctrl_status status;
+10 -10
View File
@@ -148,7 +148,7 @@ typedef struct {
*
* Routine called by the main loop
*/
bool udi_msc_process_trans();
bool udi_msc_process_trans(void);
/**
* \brief Transfers data to/from USB MSC endpoints
@@ -206,26 +206,26 @@ bool udi_msc_trans_block(bool b_read, uint8_t * block, iram_size_t block_size,
#define UDI_MSC_GLOBAL_PRODUCT_VERSION \
'1', '.', '0', '0'
#define UDI_MSC_ENABLE_EXT() my_callback_msc_enable()
extern bool my_callback_msc_enable();
extern bool my_callback_msc_enable(void);
#define UDI_MSC_DISABLE_EXT() my_callback_msc_disable()
extern void my_callback_msc_disable();
extern void my_callback_msc_disable(void);
#include "udi_msc_conf.h" // At the end of conf_usb.h file
\endcode
*
* Add to application C-file:
* \code
static bool my_flag_autorize_msc_transfert = false;
bool my_callback_msc_enable()
bool my_callback_msc_enable(void)
{
my_flag_autorize_msc_transfert = true;
return true;
}
void my_callback_msc_disable()
void my_callback_msc_disable(void)
{
my_flag_autorize_msc_transfert = false;
}
void task()
void task(void)
{
udi_msc_process_trans();
}
@@ -244,7 +244,7 @@ bool udi_msc_trans_block(bool b_read, uint8_t * block, iram_size_t block_size,
* \note The USB MSC interface requires a vendor ID (8 ASCII characters)
* and a product version (4 ASCII characters).
* - \code #define UDI_MSC_ENABLE_EXT() my_callback_msc_enable()
extern bool my_callback_msc_enable(); \endcode
extern bool my_callback_msc_enable(void); \endcode
* \note After the device enumeration (detecting and identifying USB devices),
* the USB host starts the device configuration. When the USB MSC interface
* from the device is accepted by the host, the USB host enables this interface and the
@@ -252,7 +252,7 @@ bool udi_msc_trans_block(bool b_read, uint8_t * block, iram_size_t block_size,
* Thus, when this event is received, the tasks which call
* udi_msc_process_trans() must be enabled.
* - \code #define UDI_MSC_DISABLE_EXT() my_callback_msc_disable()
extern void my_callback_msc_disable(); \endcode
extern void my_callback_msc_disable(void); \endcode
* \note When the USB device is unplugged or is reset by the USB host, the USB
* interface is disabled and the UDI_MSC_DISABLE_EXT() callback function
* is called. Thus, it is recommended to disable the task which is called udi_msc_process_trans().
@@ -260,14 +260,14 @@ bool udi_msc_trans_block(bool b_read, uint8_t * block, iram_size_t block_size,
* which provides the memories interfaces. However, the memory data transfers
* must be done outside USB interrupt routine. This is done in the MSC process
* ("udi_msc_process_trans()") called by main loop:
* - \code * void task() {
* - \code * void task(void) {
udi_msc_process_trans();
} \endcode
* -# The MSC speed depends on task periodicity. To get the best speed
* the notification callback "UDI_MSC_NOTIFY_TRANS_EXT" can be used to wakeup
* this task (Example, through a mutex):
* - \code #define UDI_MSC_NOTIFY_TRANS_EXT() msc_notify_trans()
void msc_notify_trans() {
void msc_notify_trans(void) {
wakeup_my_task();
} \endcode
*
+46 -46
View File
@@ -357,41 +357,41 @@ static uint16_t udd_ctrl_payload_buf_cnt;
*
* Called after a USB line reset or when UDD is enabled
*/
static void udd_reset_ep_ctrl();
static void udd_reset_ep_ctrl(void);
/**
* \brief Reset control endpoint management
*
* Called after a USB line reset or at the end of SETUP request (after ZLP)
*/
static void udd_ctrl_init();
static void udd_ctrl_init(void);
//! \brief Managed reception of SETUP packet on control endpoint
static void udd_ctrl_setup_received();
static void udd_ctrl_setup_received(void);
//! \brief Managed reception of IN packet on control endpoint
static void udd_ctrl_in_sent();
static void udd_ctrl_in_sent(void);
//! \brief Managed reception of OUT packet on control endpoint
static void udd_ctrl_out_received();
static void udd_ctrl_out_received(void);
//! \brief Managed underflow event of IN packet on control endpoint
static void udd_ctrl_underflow();
static void udd_ctrl_underflow(void);
//! \brief Managed overflow event of OUT packet on control endpoint
static void udd_ctrl_overflow();
static void udd_ctrl_overflow(void);
//! \brief Managed stall event of IN/OUT packet on control endpoint
static void udd_ctrl_stall_data();
static void udd_ctrl_stall_data(void);
//! \brief Send a ZLP IN on control endpoint
static void udd_ctrl_send_zlp_in();
static void udd_ctrl_send_zlp_in(void);
//! \brief Send a ZLP OUT on control endpoint
static void udd_ctrl_send_zlp_out();
static void udd_ctrl_send_zlp_out(void);
//! \brief Call callback associated to setup request
static void udd_ctrl_endofrequest();
static void udd_ctrl_endofrequest(void);
/**
@@ -401,7 +401,7 @@ static void udd_ctrl_endofrequest();
*
* \return \c 1 if an event about control endpoint is occured, otherwise \c 0.
*/
static bool udd_ctrl_interrupt();
static bool udd_ctrl_interrupt(void);
//@}
@@ -448,10 +448,10 @@ typedef struct {
static udd_ep_job_t udd_ep_job[USB_DEVICE_MAX_EP];
//! \brief Reset all job table
static void udd_ep_job_table_reset();
static void udd_ep_job_table_reset(void);
//! \brief Abort all endpoint jobs on going
static void udd_ep_job_table_kill();
static void udd_ep_job_table_kill(void);
#ifdef UDD_EP_FIFO_SUPPORTED
/**
@@ -500,7 +500,7 @@ static void udd_ep_finish_job(udd_ep_job_t * ptr_job, bool b_abort, uint8_t ep_n
*
* \return \c 1 if an event about bulk/interrupt/isochronous endpoints has occured, otherwise \c 0.
*/
static bool udd_ep_interrupt();
static bool udd_ep_interrupt(void);
#endif // (0!=USB_DEVICE_MAX_EP)
//@}
@@ -524,8 +524,8 @@ static bool udd_ep_interrupt();
* See Technical reference $3.8.3 Masking interrupt requests in peripheral modules.
*/
#ifdef UHD_ENABLE
void udd_interrupt();
void udd_interrupt()
void udd_interrupt(void);
void udd_interrupt(void)
#else
ISR(UDD_USB_INT_FUN)
#endif
@@ -643,13 +643,13 @@ udd_interrupt_sof_end:
}
bool udd_include_vbus_monitoring()
bool udd_include_vbus_monitoring(void)
{
return true;
}
void udd_enable()
void udd_enable(void)
{
irqflags_t flags;
@@ -736,7 +736,7 @@ void udd_enable()
}
void udd_disable()
void udd_disable(void)
{
irqflags_t flags;
@@ -777,7 +777,7 @@ void udd_disable()
}
void udd_attach()
void udd_attach(void)
{
irqflags_t flags;
flags = cpu_irq_save();
@@ -818,7 +818,7 @@ void udd_attach()
}
void udd_detach()
void udd_detach(void)
{
otg_unfreeze_clock();
@@ -829,7 +829,7 @@ void udd_detach()
}
bool udd_is_high_speed()
bool udd_is_high_speed(void)
{
#ifdef USB_DEVICE_HS_SUPPORT
return !Is_udd_full_speed_mode();
@@ -847,23 +847,23 @@ void udd_set_address(uint8_t address)
}
uint8_t udd_getaddress()
uint8_t udd_getaddress(void)
{
return udd_get_configured_address();
}
uint16_t udd_get_frame_number()
uint16_t udd_get_frame_number(void)
{
return udd_frame_number();
}
uint16_t udd_get_micro_frame_number()
uint16_t udd_get_micro_frame_number(void)
{
return udd_micro_frame_number();
}
void udd_send_remotewakeup()
void udd_send_remotewakeup(void)
{
#ifndef UDD_NO_SLEEP_MGR
if (!udd_b_idle)
@@ -1242,27 +1242,27 @@ bool udd_ep_wait_stall_clear(udd_ep_id_t ep,
#ifdef USB_DEVICE_HS_SUPPORT
void udd_test_mode_j()
void udd_test_mode_j(void)
{
udd_enable_hs_test_mode();
udd_enable_hs_test_mode_j();
}
void udd_test_mode_k()
void udd_test_mode_k(void)
{
udd_enable_hs_test_mode();
udd_enable_hs_test_mode_k();
}
void udd_test_mode_se0_nak()
void udd_test_mode_se0_nak(void)
{
udd_enable_hs_test_mode();
}
void udd_test_mode_packet()
void udd_test_mode_packet(void)
{
uint8_t i;
uint8_t *ptr_dest;
@@ -1310,7 +1310,7 @@ void udd_test_mode_packet()
// ------------------------
//--- INTERNAL ROUTINES TO MANAGED THE CONTROL ENDPOINT
static void udd_reset_ep_ctrl()
static void udd_reset_ep_ctrl(void)
{
irqflags_t flags;
@@ -1334,7 +1334,7 @@ static void udd_reset_ep_ctrl()
cpu_irq_restore(flags);
}
static void udd_ctrl_init()
static void udd_ctrl_init(void)
{
irqflags_t flags;
flags = cpu_irq_save();
@@ -1357,7 +1357,7 @@ static void udd_ctrl_init()
}
static void udd_ctrl_setup_received()
static void udd_ctrl_setup_received(void)
{
irqflags_t flags;
uint8_t i;
@@ -1419,7 +1419,7 @@ static void udd_ctrl_setup_received()
}
static void udd_ctrl_in_sent()
static void udd_ctrl_in_sent(void)
{
static bool b_shortpacket = false;
uint16_t nb_remain;
@@ -1503,7 +1503,7 @@ static void udd_ctrl_in_sent()
}
static void udd_ctrl_out_received()
static void udd_ctrl_out_received(void)
{
irqflags_t flags;
uint8_t i;
@@ -1594,7 +1594,7 @@ static void udd_ctrl_out_received()
}
static void udd_ctrl_underflow()
static void udd_ctrl_underflow(void)
{
if (Is_udd_out_received(0))
return; // Underflow ignored if OUT data is received
@@ -1611,7 +1611,7 @@ static void udd_ctrl_underflow()
}
static void udd_ctrl_overflow()
static void udd_ctrl_overflow(void)
{
if (Is_udd_in_send(0))
return; // Overflow ignored if IN data is received
@@ -1627,7 +1627,7 @@ static void udd_ctrl_overflow()
}
static void udd_ctrl_stall_data()
static void udd_ctrl_stall_data(void)
{
// Stall all packets on IN & OUT control endpoint
udd_ep_control_state = UDD_EPCTRL_STALL_REQ;
@@ -1635,7 +1635,7 @@ static void udd_ctrl_stall_data()
}
static void udd_ctrl_send_zlp_in()
static void udd_ctrl_send_zlp_in(void)
{
irqflags_t flags;
@@ -1653,7 +1653,7 @@ static void udd_ctrl_send_zlp_in()
}
static void udd_ctrl_send_zlp_out()
static void udd_ctrl_send_zlp_out(void)
{
irqflags_t flags;
@@ -1669,7 +1669,7 @@ static void udd_ctrl_send_zlp_out()
}
static void udd_ctrl_endofrequest()
static void udd_ctrl_endofrequest(void)
{
// If a callback is registered then call it
if (udd_g_ctrlreq.callback) {
@@ -1678,7 +1678,7 @@ static void udd_ctrl_endofrequest()
}
static bool udd_ctrl_interrupt()
static bool udd_ctrl_interrupt(void)
{
if (!Is_udd_endpoint_interrupt(0)) {
@@ -1734,7 +1734,7 @@ static bool udd_ctrl_interrupt()
#if (0 != USB_DEVICE_MAX_EP)
static void udd_ep_job_table_reset()
static void udd_ep_job_table_reset(void)
{
uint8_t i;
for (i = 0; i < USB_DEVICE_MAX_EP; i++) {
@@ -1744,7 +1744,7 @@ static void udd_ep_job_table_reset()
}
static void udd_ep_job_table_kill()
static void udd_ep_job_table_kill(void)
{
uint8_t i;
@@ -1970,7 +1970,7 @@ static void udd_ep_out_received(udd_ep_id_t ep)
}
#endif // #ifdef UDD_EP_FIFO_SUPPORTED
static bool udd_ep_interrupt()
static bool udd_ep_interrupt(void)
{
udd_ep_id_t ep;
udd_ep_job_t *ptr_job;
+2 -2
View File
@@ -66,13 +66,13 @@ extern "C" {
*
* \return \c true if the ID pin management has been started, otherwise \c false.
*/
bool otg_dual_enable();
bool otg_dual_enable(void);
/**
* \brief Uninitialize the dual role
* This function is implemented in uotghs_host.c file.
*/
void otg_dual_disable();
void otg_dual_disable(void);
//! @name UOTGHS OTG ID pin management
+9 -9
View File
@@ -56,7 +56,7 @@
static volatile bool main_b_cdc_enable = false;
static volatile bool main_b_dtr_active = false;
void usb_task_idle() {
void usb_task_idle(void) {
#if ENABLED(SDSUPPORT)
// Attend SD card access from the USB MSD -- Prioritize access to improve speed
int delay = 2;
@@ -70,14 +70,14 @@ void usb_task_idle() {
}
#if ENABLED(SDSUPPORT)
bool usb_task_msc_enable() { return ((main_b_msc_enable = true)); }
void usb_task_msc_disable() { main_b_msc_enable = false; }
bool usb_task_msc_isenabled() { return main_b_msc_enable; }
bool usb_task_msc_enable(void) { return ((main_b_msc_enable = true)); }
void usb_task_msc_disable(void) { main_b_msc_enable = false; }
bool usb_task_msc_isenabled(void) { return main_b_msc_enable; }
#endif
bool usb_task_cdc_enable(const uint8_t port) { UNUSED(port); return ((main_b_cdc_enable = true)); }
void usb_task_cdc_disable(const uint8_t port) { UNUSED(port); main_b_cdc_enable = false; main_b_dtr_active = false; }
bool usb_task_cdc_isenabled() { return main_b_cdc_enable; }
bool usb_task_cdc_isenabled(void) { return main_b_cdc_enable; }
/*! \brief Called by CDC interface
* Callback running when CDC device have received data
@@ -121,7 +121,7 @@ void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable) {
}
}
bool usb_task_cdc_dtr_active() { return main_b_dtr_active; }
bool usb_task_cdc_dtr_active(void) { return main_b_dtr_active; }
/// Microsoft WCID descriptor
typedef struct USB_MicrosoftCompatibleDescriptor_Interface {
@@ -202,7 +202,7 @@ static USB_MicrosoftExtendedPropertiesDescriptor microsoft_extended_properties_d
** WCID configuration information
** Hooked into UDC via UDC_GET_EXTRA_STRING #define.
*/
bool usb_task_extra_string() {
bool usb_task_extra_string(void) {
static uint8_t udi_msft_magic[] = "MSFT100\xEE";
static uint8_t udi_cdc_name[] = "CDC interface";
#if ENABLED(SDSUPPORT)
@@ -262,7 +262,7 @@ bool usb_task_extra_string() {
/**************************************************************************************************
** Handle device requests that the ASF stack doesn't
*/
bool usb_task_other_requests() {
bool usb_task_other_requests(void) {
uint8_t* ptr = 0;
uint16_t size = 0;
@@ -297,7 +297,7 @@ bool usb_task_other_requests() {
return true;
}
void usb_task_init() {
void usb_task_init(void) {
uint16_t *ptr;
+10 -10
View File
@@ -58,12 +58,12 @@ extern "C" {
*
* \retval true if MSC startup is ok
*/
bool usb_task_msc_enable();
bool usb_task_msc_enable(void);
/*! \brief Called by MSC interface
* Callback running when USB Host disable MSC interface
*/
void usb_task_msc_disable();
void usb_task_msc_disable(void);
/*! \brief Opens the communication port
* This is called by CDC interface when USB Host enable it.
@@ -84,25 +84,25 @@ void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable);
/*! \brief Check if MSC is enumerated and configured on the PC side
*/
bool usb_task_msc_isenabled();
bool usb_task_msc_isenabled(void);
/*! \brief Check if CDC is enumerated and configured on the PC side
*/
bool usb_task_cdc_isenabled();
bool usb_task_cdc_isenabled(void);
/*! \brief Check if CDC is actually OPEN by an application on the PC side
* assuming DTR signal means a program is listening to messages
*/
bool usb_task_cdc_dtr_active();
bool usb_task_cdc_dtr_active(void);
/*! \brief Called by UDC when USB Host request a extra string different
* of this specified in USB device descriptor
*/
bool usb_task_extra_string();
bool usb_task_extra_string(void);
/*! \brief Called by UDC when USB Host performs unknown requests
*/
bool usb_task_other_requests();
bool usb_task_other_requests(void);
/*! \brief Called by CDC interface
* Callback running when CDC device have received data
@@ -117,15 +117,15 @@ void usb_task_cdc_config(const uint8_t port, usb_cdc_line_coding_t *cfg);
/*! \brief The USB device interrupt
*/
void USBD_ISR();
void USBD_ISR(void);
/*! \brief USB task init
*/
void usb_task_init();
void usb_task_init(void);
/*! \brief USB task idle
*/
void usb_task_idle();
void usb_task_idle(void);
#ifdef __cplusplus
}
+1 -1
View File
@@ -30,4 +30,4 @@ void watchdog_init();
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or AVR will go into emergency procedures.
inline void watchdog_reset() { watchdogReset(); }
inline void HAL_watchdog_refresh() { watchdogReset(); }
+14 -14
View File
@@ -32,25 +32,25 @@
int Servo::channel_next_free = 12;
Servo::Servo() {
this->channel = channel_next_free++;
channel = channel_next_free++;
}
int8_t Servo::attach(const int pin) {
if (this->channel >= CHANNEL_MAX_NUM) return -1;
if (pin > 0) this->pin = pin;
int8_t Servo::attach(const int inPin) {
if (channel >= CHANNEL_MAX_NUM) return -1;
if (pin > 0) pin = inPin;
ledcSetup(this->channel, 50, 16); // channel X, 50 Hz, 16-bit depth
ledcAttachPin(this->pin, this->channel);
ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth
ledcAttachPin(pin, channel);
return true;
}
void Servo::detach() { ledcDetachPin(this->pin); }
void Servo::detach() { ledcDetachPin(pin); }
int Servo::read() { return this->degrees; }
int Servo::read() { return degrees; }
void Servo::write(int inDegrees) {
this->degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE);
int us = map(this->degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE);
int us = map(degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE);
ledcWrite(channel, duty);
}
@@ -58,11 +58,11 @@ void Servo::write(int inDegrees) {
void Servo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->channel]);
if (attach(0) >= 0) {
write(value);
safe_delay(servo_delay[channel]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
+1 -1
View File
@@ -25,4 +25,4 @@
void watchdog_init();
// Reset watchdog.
inline void watchdog_reset() { }
inline void HAL_watchdog_refresh() {}
+5 -1
View File
@@ -78,7 +78,7 @@ extern HalSerial usb_serial;
#define ENABLE_ISRS()
#define DISABLE_ISRS()
inline void HAL_init() { }
inline void HAL_init() {}
// Utility functions
#pragma GCC diagnostic push
@@ -97,6 +97,10 @@ void HAL_adc_enable_channel(int pin);
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result();
// Reset source
inline void HAL_clear_reset_source(void) {}
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
/* ---------------- Delay in cycles */
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
Clock::delayCycles(x);
+1 -1
View File
@@ -29,7 +29,7 @@
// Interrupts
void cli() { } // Disable
void sei() { } // Enable
void sei() { } // Enable
// Time functions
void _delay_ms(const int delay_ms) {
+2 -2
View File
@@ -83,9 +83,9 @@ public:
HalSerial() { host_connected = true; }
void begin(int32_t baud) { }
void begin(int32_t) {}
void end() { }
void end() {}
int peek() {
uint8_t value;
+2 -12
View File
@@ -29,18 +29,8 @@
#include "watchdog.h"
void watchdog_init() {}
void HAL_watchdog_refresh() {}
void HAL_clear_reset_source() {}
uint8_t HAL_get_reset_source() {
return RST_POWER_ON;
}
void watchdog_reset() {}
#else
void HAL_clear_reset_source() {}
uint8_t HAL_get_reset_source() { return RST_POWER_ON; }
#endif // USE_WATCHDOG
#endif
#endif // __PLAT_LINUX__
+1 -3
View File
@@ -24,6 +24,4 @@
#define WDT_TIMEOUT 4000000 // 4 second timeout
void watchdog_init();
void watchdog_reset();
void HAL_clear_reset_source();
uint8_t HAL_get_reset_source();
void HAL_watchdog_refresh();
+17
View File
@@ -26,6 +26,10 @@
#include "../shared/Delay.h"
#include "../../../gcode/parser.h"
#if ENABLED(USE_WATCHDOG)
#include "watchdog.h"
#endif
// U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) {
DELAY_US(val);
@@ -65,4 +69,17 @@ void flashFirmware(int16_t value) {
NVIC_SystemReset();
}
void HAL_clear_reset_source(void) {
#if ENABLED(USE_WATCHDOG)
watchdog_clear_timeout_flag();
#endif
}
uint8_t HAL_get_reset_source(void) {
#if ENABLED(USE_WATCHDOG)
if (watchdog_timed_out()) return RST_WATCHDOG;
#endif
return RST_POWER_ON;
}
#endif // TARGET_LPC1768
+4
View File
@@ -164,3 +164,7 @@ void set_pwm_frequency(const pin_t pin, int f_desired);
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
*/
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
// Reset source
void HAL_clear_reset_source(void);
uint8_t HAL_get_reset_source(void);
+1 -1
View File
@@ -49,7 +49,7 @@ public:
{
}
void end() { }
void end() {}
#if ENABLED(EMERGENCY_PARSER)
bool recv_callback(const char c) override {
+4 -4
View File
@@ -57,11 +57,11 @@ class libServo: public Servo {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(servo_info[this->servoIndex].Pin.nbr) >= 0) { // try to reattach
this->write(value);
safe_delay(servo_delay[this->servoIndex]); // delay to allow servo to reach position
if (attach(servo_info[servoIndex].Pin.nbr) >= 0) { // try to reattach
write(value);
safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
+1 -1
View File
@@ -155,7 +155,7 @@ void HAL_idletask() {
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
// this will not reliably detect delete operations. To be safe we will lock
// the disk if Marlin has it mounted. Unfortuately there is currently no way
// the disk if Marlin has it mounted. Unfortunately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
if (card.isMounted())
+4 -16
View File
@@ -56,28 +56,16 @@ void watchdog_init() {
WDT_Start(WDT_TIMEOUT);
}
void HAL_clear_reset_source() {
WDT_ClrTimeOutFlag();
}
uint8_t HAL_get_reset_source() {
if (TEST(WDT_ReadTimeOutFlag(), 0)) return RST_WATCHDOG;
return RST_POWER_ON;
}
void watchdog_reset() {
void HAL_watchdog_refresh() {
WDT_Feed();
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
TOGGLE(LED_PIN); // heartbeat indicator
#endif
}
#else
void watchdog_init() {}
void watchdog_reset() {}
void HAL_clear_reset_source() {}
uint8_t HAL_get_reset_source() { return RST_POWER_ON; }
// Timeout state
bool watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); }
void watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); }
#endif // USE_WATCHDOG
+4 -3
View File
@@ -24,6 +24,7 @@
#define WDT_TIMEOUT 4000000 // 4 second timeout
void watchdog_init();
void watchdog_reset();
void HAL_clear_reset_source();
uint8_t HAL_get_reset_source();
void HAL_watchdog_refresh();
bool watchdog_timed_out();
void watchdog_clear_timeout_flag();
+1 -1
View File
@@ -414,7 +414,7 @@ extern "C" {
// Return free memory between end of heap (or end bss) and whatever is current
int freeMemory() {
int free_memory, heap_end = (int)_sbrk(0);
return (int)&free_memory - (heap_end ? heap_end : (int)&__bss_end__);
return (int)&free_memory - (heap_end ?: (int)&__bss_end__);
}
// ------------------------
+1 -1
View File
@@ -42,7 +42,7 @@
WDT->INTENCLR.reg = WDT_INTENCLR_EW; // Disable early warning interrupt
WDT->CONFIG.reg = WDT_CONFIG_PER_CYC4096; // Set at least 4s period for chip reset
watchdog_reset();
HAL_watchdog_refresh();
WDT->CTRLA.reg = WDT_CTRLA_ENABLE; // Start watchdog now in normal mode
SYNC(WDT->SYNCBUSY.bit.ENABLE);
+1 -1
View File
@@ -25,7 +25,7 @@ void watchdog_init();
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or SAMD will go into emergency procedures.
inline void watchdog_reset() {
inline void HAL_watchdog_refresh() {
SYNC(WDT->SYNCBUSY.bit.CLEAR); // Test first if previous is 'ongoing' to save time waiting for command execution
WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
}
+5 -6
View File
@@ -104,12 +104,11 @@ extern "C" {
// ADC
// ------------------------
void HAL_adc_start_conversion(const uint8_t adc_pin) {
HAL_adc_result = analogRead(adc_pin);
}
// TODO: Make sure this doesn't cause any delay
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
uint16_t HAL_adc_get_result() {
return HAL_adc_result;
}
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
void flashFirmware(int16_t) { NVIC_SystemReset(); }
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
+3
View File
@@ -198,3 +198,6 @@ uint16_t HAL_adc_get_result();
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
#define PLATFORM_M997_SUPPORT
void flashFirmware(int16_t value);
+9 -9
View File
@@ -31,24 +31,24 @@
uint8_t servoPin[MAX_SERVOS] = { 0 };
int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
if (pin > 0) servoPin[this->servoIndex] = pin;
return Servo::attach(servoPin[this->servoIndex]);
if (servoIndex >= MAX_SERVOS) return -1;
if (pin > 0) servoPin[servoIndex] = pin;
return super::attach(servoPin[servoIndex]);
}
int8_t libServo::attach(const int pin, const int min, const int max) {
if (pin > 0) servoPin[this->servoIndex] = pin;
return Servo::attach(servoPin[this->servoIndex], min, max);
if (pin > 0) servoPin[servoIndex] = pin;
return super::attach(servoPin[servoIndex], min, max);
}
void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->servoIndex]);
if (attach(0) >= 0) {
write(value);
safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
+1
View File
@@ -31,6 +31,7 @@ class libServo : public Servo {
int8_t attach(const int pin, const int min, const int max);
void move(const int value);
private:
typedef Servo super;
uint16_t min_ticks, max_ticks;
uint8_t servoIndex; // index into the channel data for this servo
};
+1 -1
View File
@@ -33,7 +33,7 @@
void watchdog_init() { IWatchdog.begin(4000000); } // 4 sec timeout
void watchdog_reset() {
void HAL_watchdog_refresh() {
IWatchdog.reload();
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
TOGGLE(LED_PIN); // heartbeat indicator
+1 -1
View File
@@ -22,4 +22,4 @@
#pragma once
void watchdog_init();
void watchdog_reset();
void HAL_watchdog_refresh();
+1 -1
View File
@@ -233,7 +233,7 @@ void HAL_idletask() {
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
// this will not reliably detect delete operations. To be safe we will lock
// the disk if Marlin has it mounted. Unfortuately there is currently no way
// the disk if Marlin has it mounted. Unfortunately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
/* copy from lpc1768 framework, should be fixed later for process SHARED_SD_CARD*/
+32 -43
View File
@@ -213,31 +213,31 @@ void SPIClass::setDataSize(uint32_t datasize) {
}
void SPIClass::setDataMode(uint8_t dataMode) {
/*
Notes:
As far as we know the AVR numbers for dataMode match the numbers required by the STM32.
From the AVR doc http://www.atmel.com/images/doc2585.pdf section 2.4
SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge
0 0 0 Falling Rising
1 0 1 Rising Falling
2 1 0 Rising Falling
3 1 1 Falling Rising
On the STM32 it appears to be
bit 1 - CPOL : Clock polarity
(This bit should not be changed when communication is ongoing)
0 : CLK to 0 when idle
1 : CLK to 1 when idle
bit 0 - CPHA : Clock phase
(This bit should not be changed when communication is ongoing)
0 : The first clock transition is the first data capture edge
1 : The second clock transition is the first data capture edge
If someone finds this is not the case or sees a logic error with this let me know ;-)
*/
/**
* Notes:
* As far as we know the AVR numbers for dataMode match the numbers required by the STM32.
* From the AVR doc http://www.atmel.com/images/doc2585.pdf section 2.4
*
* SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge
* 0 0 0 Falling Rising
* 1 0 1 Rising Falling
* 2 1 0 Rising Falling
* 3 1 1 Falling Rising
*
* On the STM32 it appears to be
*
* bit 1 - CPOL : Clock polarity
* (This bit should not be changed when communication is ongoing)
* 0 : CLK to 0 when idle
* 1 : CLK to 1 when idle
*
* bit 0 - CPHA : Clock phase
* (This bit should not be changed when communication is ongoing)
* 0 : The first clock transition is the first data capture edge
* 1 : The second clock transition is the first data capture edge
*
* If someone finds this is not the case or sees a logic error with this let me know ;-)
*/
_currentSetting->dataMode = dataMode;
uint32_t cr1 = _currentSetting->spi_d->regs->CR1 & ~(SPI_CR1_CPOL|SPI_CR1_CPHA);
_currentSetting->spi_d->regs->CR1 = cr1 | (dataMode & (SPI_CR1_CPOL|SPI_CR1_CPHA));
@@ -593,7 +593,7 @@ void SPIClass::detachInterrupt() {
// Should be disableInterrupt()
}
/*
/**
* Pin accessors
*/
@@ -613,25 +613,14 @@ uint8_t SPIClass::nssPin() {
return dev_to_spi_pins(_currentSetting->spi_d)->nss;
}
/*
/**
* Deprecated functions
*/
uint8_t SPIClass::send(uint8_t data) { write(data); return 1; }
uint8_t SPIClass::send(uint8_t *buf, uint32_t len) { write(buf, len); return len; }
uint8_t SPIClass::recv() { return read(); }
uint8_t SPIClass::send(uint8_t data) {
this->write(data);
return 1;
}
uint8_t SPIClass::send(uint8_t *buf, uint32_t len) {
this->write(buf, len);
return len;
}
uint8_t SPIClass::recv() {
return this->read();
}
/*
/**
* DMA call back functions, one per port.
*/
#if BOARD_NR_SPI >= 1
@@ -650,7 +639,7 @@ uint8_t SPIClass::recv() {
}
#endif
/*
/**
* Auxiliary functions
*/
static const spi_pins* dev_to_spi_pins(spi_dev *dev) {
+20 -20
View File
@@ -96,36 +96,36 @@ typedef enum {
class SPISettings {
public:
SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) {
if (__builtin_constant_p(clock))
init_AlwaysInline(clock, bitOrder, dataMode, DATA_SIZE_8BIT);
SPISettings(uint32_t inClock, BitOrder inBitOrder, uint8_t inDataMode) {
if (__builtin_constant_p(inClock))
init_AlwaysInline(inClock, inBitOrder, inDataMode, DATA_SIZE_8BIT);
else
init_MightInline(clock, bitOrder, dataMode, DATA_SIZE_8BIT);
init_MightInline(inClock, inBitOrder, inDataMode, DATA_SIZE_8BIT);
}
SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode, uint32_t dataSize) {
if (__builtin_constant_p(clock))
init_AlwaysInline(clock, bitOrder, dataMode, dataSize);
SPISettings(uint32_t inClock, BitOrder inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
if (__builtin_constant_p(inClock))
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
else
init_MightInline(clock, bitOrder, dataMode, dataSize);
init_MightInline(inClock, inBitOrder, inDataMode, inDataSize);
}
SPISettings(uint32_t clock) {
if (__builtin_constant_p(clock))
init_AlwaysInline(clock, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
SPISettings(uint32_t inClock) {
if (__builtin_constant_p(inClock))
init_AlwaysInline(inClock, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
else
init_MightInline(clock, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
init_MightInline(inClock, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
}
SPISettings() {
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
}
private:
void init_MightInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode, uint32_t dataSize) {
init_AlwaysInline(clock, bitOrder, dataMode, dataSize);
void init_MightInline(uint32_t inClock, BitOrder inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
}
void init_AlwaysInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode, uint32_t dataSize) __attribute__((__always_inline__)) {
this->clock = clock;
this->bitOrder = bitOrder;
this->dataMode = dataMode;
this->dataSize = dataSize;
void init_AlwaysInline(uint32_t inClock, BitOrder inBitOrder, uint8_t inDataMode, uint32_t inDataSize) __attribute__((__always_inline__)) {
clock = inClock;
bitOrder = inBitOrder;
dataMode = inDataMode;
dataSize = inDataSize;
}
uint32_t clock;
uint32_t dataSize;
@@ -339,7 +339,7 @@ public:
* or 1-3 in high density devices.
*/
void setModule(int spi_num) {
_currentSetting=&_settings[spi_num-1];// SPI channels are called 1 2 and 3 but the array is zero indexed
_currentSetting = &_settings[spi_num - 1];// SPI channels are called 1 2 and 3 but the array is zero indexed
}
/* -- The following methods are deprecated --------------------------- */
+42 -45
View File
@@ -56,52 +56,50 @@ uint8_t ServoCount = 0;
#define SERVO_OVERFLOW ((uint16_t)round((double)TAU_CYC / SERVO_PRESCALER))
// Unit conversions
#define US_TO_COMPARE(us) ((uint16_t)map((us), 0, TAU_USEC, 0, SERVO_OVERFLOW))
#define COMPARE_TO_US(c) ((uint32_t)map((c), 0, SERVO_OVERFLOW, 0, TAU_USEC))
#define ANGLE_TO_US(a) ((uint16_t)(map((a), this->minAngle, this->maxAngle, \
SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW)))
#define US_TO_ANGLE(us) ((int16_t)(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, \
this->minAngle, this->maxAngle)))
#define US_TO_COMPARE(us) uint16_t(map((us), 0, TAU_USEC, 0, SERVO_OVERFLOW))
#define COMPARE_TO_US(c) uint32_t(map((c), 0, SERVO_OVERFLOW, 0, TAU_USEC))
#define ANGLE_TO_US(a) uint16_t(map((a), minAngle, maxAngle, SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW))
#define US_TO_ANGLE(us) int16_t(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, minAngle, maxAngle))
void libServo::servoWrite(uint8_t pin, uint16_t duty_cycle) {
void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) {
#ifdef SERVO0_TIMER_NUM
if (this->servoIndex == 0) {
this->pwmSetDuty(duty_cycle);
if (servoIndex == 0) {
pwmSetDuty(duty_cycle);
return;
}
#endif
timer_dev *tdev = PIN_MAP[pin].timer_device;
uint8_t tchan = PIN_MAP[pin].timer_channel;
timer_dev *tdev = PIN_MAP[inPin].timer_device;
uint8_t tchan = PIN_MAP[inPin].timer_channel;
if (tdev) timer_set_compare(tdev, tchan, duty_cycle);
}
libServo::libServo() {
this->servoIndex = ServoCount < MAX_SERVOS ? ServoCount++ : INVALID_SERVO;
servoIndex = ServoCount < MAX_SERVOS ? ServoCount++ : INVALID_SERVO;
}
bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t maxAngle) {
if (this->servoIndex >= MAX_SERVOS) return false;
if (pin >= BOARD_NR_GPIO_PINS) return false;
bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32_t inMaxAngle) {
if (servoIndex >= MAX_SERVOS) return false;
if (inPin >= BOARD_NR_GPIO_PINS) return false;
this->minAngle = minAngle;
this->maxAngle = maxAngle;
this->angle = -1;
minAngle = inMinAngle;
maxAngle = inMaxAngle;
angle = -1;
#ifdef SERVO0_TIMER_NUM
if (this->servoIndex == 0 && this->setupSoftPWM(pin)) {
this->pin = pin; // set attached()
if (servoIndex == 0 && setupSoftPWM(inPin)) {
pin = inPin; // set attached()
return true;
}
#endif
if (!PWM_PIN(pin)) return false;
if (!PWM_PIN(inPin)) return false;
timer_dev *tdev = PIN_MAP[pin].timer_device;
//uint8_t tchan = PIN_MAP[pin].timer_channel;
timer_dev *tdev = PIN_MAP[inPin].timer_device;
//uint8_t tchan = PIN_MAP[inPin].timer_channel;
SET_PWM(pin);
servoWrite(pin, 0);
SET_PWM(inPin);
servoWrite(inPin, 0);
timer_pause(tdev);
timer_set_prescaler(tdev, SERVO_PRESCALER - 1); // prescaler is 1-based
@@ -109,25 +107,24 @@ bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t m
timer_generate_update(tdev);
timer_resume(tdev);
this->pin = pin; // set attached()
pin = inPin; // set attached()
return true;
}
bool libServo::detach() {
if (!this->attached()) return false;
this->angle = -1;
servoWrite(this->pin, 0);
if (!attached()) return false;
angle = -1;
servoWrite(pin, 0);
return true;
}
int32_t libServo::read() const {
if (this->attached()) {
if (attached()) {
#ifdef SERVO0_TIMER_NUM
if (this->servoIndex == 0) return this->angle;
if (servoIndex == 0) return angle;
#endif
timer_dev *tdev = PIN_MAP[this->pin].timer_device;
uint8_t tchan = PIN_MAP[this->pin].timer_channel;
timer_dev *tdev = PIN_MAP[pin].timer_device;
uint8_t tchan = PIN_MAP[pin].timer_channel;
return US_TO_ANGLE(COMPARE_TO_US(timer_get_compare(tdev, tchan)));
}
return 0;
@@ -137,12 +134,12 @@ void libServo::move(const int32_t value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attached()) {
this->angle = constrain(value, this->minAngle, this->maxAngle);
servoWrite(this->pin, US_TO_COMPARE(ANGLE_TO_US(this->angle)));
safe_delay(servo_delay[this->servoIndex]);
if (attached()) {
angle = constrain(value, minAngle, maxAngle);
servoWrite(pin, US_TO_COMPARE(ANGLE_TO_US(angle)));
safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
@@ -169,13 +166,13 @@ void libServo::move(const int32_t value) {
}
}
bool libServo::setupSoftPWM(const int32_t pin) {
bool libServo::setupSoftPWM(const int32_t inPin) {
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
if (!tdev) return false;
#ifdef SERVO0_PWM_OD
OUT_WRITE_OD(pin, 1);
OUT_WRITE_OD(inPin, 1);
#else
OUT_WRITE(pin, 0);
OUT_WRITE(inPin, 0);
#endif
timer_pause(tdev);
@@ -206,9 +203,9 @@ void libServo::move(const int32_t value) {
timer_disable_irq(tdev, 1);
timer_disable_irq(tdev, 2);
#ifdef SERVO0_PWM_OD
OUT_WRITE_OD(this->pin, 1); // off
OUT_WRITE_OD(pin, 1); // off
#else
OUT_WRITE(this->pin, 0);
OUT_WRITE(pin, 0);
#endif
}
}
@@ -221,7 +218,7 @@ void libServo::move(const int32_t value) {
#else
bool libServo::setupSoftPWM(const int32_t pin) { return false; }
bool libServo::setupSoftPWM(const int32_t inPin) { return false; }
void libServo::pwmSetDuty(const uint16_t duty_cycle) {}
void libServo::pauseSoftPWM() {}
+1 -1
View File
@@ -41,7 +41,7 @@ class libServo {
public:
libServo();
bool attach(const int32_t pin, const int32_t minAngle=SERVO_DEFAULT_MIN_ANGLE, const int32_t maxAngle=SERVO_DEFAULT_MAX_ANGLE);
bool attached() const { return this->pin != NOT_ATTACHED; }
bool attached() const { return pin != NOT_ATTACHED; }
bool detach();
void move(const int32_t value);
int32_t read() const;
+1 -1
View File
@@ -33,7 +33,7 @@
#include <libmaple/iwdg.h>
#include "watchdog.h"
void watchdog_reset() {
void HAL_watchdog_refresh() {
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
TOGGLE(LED_PIN); // heartbeat indicator
#endif
+1 -1
View File
@@ -41,4 +41,4 @@ void watchdog_init();
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or STM32F1 will reset.
void watchdog_reset();
void HAL_watchdog_refresh();
+1 -1
View File
@@ -150,7 +150,7 @@ extern uint16_t HAL_adc_result;
// Memory related
#define __bss_end __bss_end__
inline void HAL_init() { }
inline void HAL_init() {}
// Clear reset reason
void HAL_clear_reset_source();
+7 -7
View File
@@ -30,22 +30,22 @@
#include "Servo.h"
int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
return Servo::attach(pin);
if (servoIndex >= MAX_SERVOS) return -1;
return super::attach(pin);
}
int8_t libServo::attach(const int pin, const int min, const int max) {
return Servo::attach(pin, min, max);
return super::attach(pin, min, max);
}
void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->servoIndex]);
if (attach(0) >= 0) {
write(value);
safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
+1
View File
@@ -35,6 +35,7 @@ class libServo : public Servo {
int8_t attach(const int pin, const int min, const int max);
void move(const int value);
private:
typedef Servo super;
uint16_t min_ticks, max_ticks;
uint8_t servoIndex; // index into the channel data for this servo
};
+1 -1
View File
@@ -44,7 +44,7 @@
}
}
void watchdog_reset() {
void HAL_watchdog_refresh() {
/* Refresh IWDG: reload counter */
if (HAL_IWDG_Refresh(&hiwdg) != HAL_OK) {
/* Refresh Error */
+1 -1
View File
@@ -24,4 +24,4 @@
extern IWDG_HandleTypeDef hiwdg;
void watchdog_init();
void watchdog_reset();
void HAL_watchdog_refresh();
+1 -1
View File
@@ -87,7 +87,7 @@ typedef int8_t pin_t;
#undef pgm_read_word
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
inline void HAL_init() { }
inline void HAL_init() {}
// Clear the reset reason
void HAL_clear_reset_source();
+11 -11
View File
@@ -29,25 +29,25 @@
uint8_t servoPin[MAX_SERVOS] = { 0 };
int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
if (pin > 0) servoPin[this->servoIndex] = pin;
return Servo::attach(servoPin[this->servoIndex]);
int8_t libServo::attach(const int inPin) {
if (servoIndex >= MAX_SERVOS) return -1;
if (inPin > 0) servoPin[servoIndex] = inPin;
return super::attach(servoPin[servoIndex]);
}
int8_t libServo::attach(const int pin, const int min, const int max) {
if (pin > 0) servoPin[this->servoIndex] = pin;
return Servo::attach(servoPin[this->servoIndex], min, max);
int8_t libServo::attach(const int inPin, const int inMin, const int inMax) {
if (inPin > 0) servoPin[servoIndex] = inPin;
return super::attach(servoPin[servoIndex], inMin, inMax);
}
void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->servoIndex]);
if (attach(0) >= 0) {
write(value);
safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
+4 -3
View File
@@ -30,7 +30,8 @@ class libServo : public Servo {
int8_t attach(const int pin, const int min, const int max);
void move(const int value);
private:
uint16_t min_ticks;
uint16_t max_ticks;
uint8_t servoIndex; // index into the channel data for this servo
typedef Servo super;
uint16_t min_ticks;
uint16_t max_ticks;
uint8_t servoIndex; // index into the channel data for this servo
};
+1 -1
View File
@@ -27,7 +27,7 @@
void watchdog_init();
inline void watchdog_reset() {
inline void HAL_watchdog_refresh() {
// Watchdog refresh sequence
WDOG_REFRESH = 0xA602;
WDOG_REFRESH = 0xB480;
+1 -1
View File
@@ -93,7 +93,7 @@ typedef int8_t pin_t;
#undef pgm_read_word
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
inline void HAL_init() { }
inline void HAL_init() {}
// Clear reset reason
void HAL_clear_reset_source();
+32 -11
View File
@@ -1,3 +1,24 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
*
*/
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#include "../../inc/MarlinConfig.h"
@@ -8,25 +29,25 @@
uint8_t servoPin[MAX_SERVOS] = { 0 };
int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
if (pin > 0) servoPin[this->servoIndex] = pin;
return Servo::attach(servoPin[this->servoIndex]);
int8_t libServo::attach(const int inPin) {
if (servoIndex >= MAX_SERVOS) return -1;
if (inPin > 0) servoPin[servoIndex] = inPin;
return super::attach(servoPin[servoIndex]);
}
int8_t libServo::attach(const int pin, const int min, const int max) {
if (pin > 0) servoPin[this->servoIndex] = pin;
return Servo::attach(servoPin[this->servoIndex], min, max);
int8_t libServo::attach(const int inPin, const int inMin, const int inMax) {
if (inPin > 0) servoPin[servoIndex] = inPin;
return super::attach(servoPin[servoIndex], inMin, inMax);
}
void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->servoIndex]);
if (attach(0) >= 0) {
write(value);
safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
+4 -3
View File
@@ -30,7 +30,8 @@ class libServo : public Servo {
int8_t attach(const int pin, const int min, const int max);
void move(const int value);
private:
uint16_t min_ticks;
uint16_t max_ticks;
uint8_t servoIndex; // Index into the channel data for this servo
typedef Servo super;
uint16_t min_ticks;
uint16_t max_ticks;
uint8_t servoIndex; // Index into the channel data for this servo
};
+1 -1
View File
@@ -23,7 +23,7 @@
void watchdog_init();
inline void watchdog_reset() {
inline void HAL_watchdog_refresh() {
// Watchdog refresh sequence
WDOG_REFRESH = 0xA602;
WDOG_REFRESH = 0xB480;
+1 -1
View File
@@ -53,7 +53,7 @@
FORCE_INLINE static void DELAY_CYCLES(const uint32_t x) {
const uint32_t endCycles = getCycleCount() + x;
while (PENDING(getCycleCount(), endCycles)) { }
while (PENDING(getCycleCount(), endCycles)) {}
}
#else
+1 -5
View File
@@ -43,11 +43,7 @@ static uint8_t eeprom_device_address = 0x50;
// ------------------------
static void eeprom_init() {
static bool eeprom_initialized = false;
if (!eeprom_initialized) {
Wire.begin();
eeprom_initialized = true;
}
Wire.begin();
}
void eeprom_write_byte(uint8_t *pos, unsigned char value) {
+30 -30
View File
@@ -58,11 +58,11 @@
#include "servo.h"
#include "servo_private.h"
ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures
uint8_t ServoCount = 0; // the total number of attached servos
ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures
uint8_t ServoCount = 0; // the total number of attached servos
#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo
#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo
#define SERVO_MIN(v) (MIN_PULSE_WIDTH - (v) * 4) // minimum value in uS for this servo
#define SERVO_MAX(v) (MAX_PULSE_WIDTH - (v) * 4) // maximum value in uS for this servo
/************ static functions common to all instances ***********************/
@@ -79,54 +79,54 @@ static boolean isTimerActive(timer16_Sequence_t timer) {
Servo::Servo() {
if (ServoCount < MAX_SERVOS) {
this->servoIndex = ServoCount++; // assign a servo index to this instance
servo_info[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009
servoIndex = ServoCount++; // assign a servo index to this instance
servo_info[servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009
}
else
this->servoIndex = INVALID_SERVO; // too many servos
servoIndex = INVALID_SERVO; // too many servos
}
int8_t Servo::attach(const int pin) {
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
int8_t Servo::attach(const int inPin) {
return attach(inPin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
}
int8_t Servo::attach(const int pin, const int min, const int max) {
int8_t Servo::attach(const int inPin, const int inMin, const int inMax) {
if (this->servoIndex >= MAX_SERVOS) return -1;
if (servoIndex >= MAX_SERVOS) return -1;
if (pin > 0) servo_info[this->servoIndex].Pin.nbr = pin;
pinMode(servo_info[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
if (inPin > 0) servo_info[servoIndex].Pin.nbr = inPin;
pinMode(servo_info[servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
// todo min/max check: ABS(min - MIN_PULSE_WIDTH) /4 < 128
this->min = (MIN_PULSE_WIDTH - min) / 4; //resolution of min/max is 4 uS
this->max = (MAX_PULSE_WIDTH - max) / 4;
// TODO: min/max check: ABS(min - MIN_PULSE_WIDTH) / 4 < 128
min = (MIN_PULSE_WIDTH - inMin) / 4; //resolution of min/max is 4 uS
max = (MAX_PULSE_WIDTH - inMax) / 4;
// initialize the timer if it has not already been initialized
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
if (!isTimerActive(timer)) initISR(timer);
servo_info[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive
servo_info[servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive
return this->servoIndex;
return servoIndex;
}
void Servo::detach() {
servo_info[this->servoIndex].Pin.isActive = false;
servo_info[servoIndex].Pin.isActive = false;
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
if (!isTimerActive(timer)) finISR(timer);
}
void Servo::write(int value) {
if (value < MIN_PULSE_WIDTH) // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(), SERVO_MAX());
this->writeMicroseconds(value);
value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(min), SERVO_MAX(max));
writeMicroseconds(value);
}
void Servo::writeMicroseconds(int value) {
// calculate and store the values for the given channel
byte channel = this->servoIndex;
byte channel = servoIndex;
if (channel < MAX_SERVOS) { // ensure channel is valid
// ensure pulse width is valid
value = constrain(value, SERVO_MIN(), SERVO_MAX()) - (TRIM_DURATION);
value = constrain(value, SERVO_MIN(min), SERVO_MAX(max)) - (TRIM_DURATION);
value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
CRITICAL_SECTION_START;
@@ -136,22 +136,22 @@ void Servo::writeMicroseconds(int value) {
}
// return the value as degrees
int Servo::read() { return map(this->readMicroseconds() + 1, SERVO_MIN(), SERVO_MAX(), 0, 180); }
int Servo::read() { return map(readMicroseconds() + 1, SERVO_MIN(min), SERVO_MAX(max), 0, 180); }
int Servo::readMicroseconds() {
return (this->servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servo_info[this->servoIndex].ticks) + (TRIM_DURATION);
return (servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servo_info[servoIndex].ticks) + (TRIM_DURATION);
}
bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
bool Servo::attached() { return servo_info[servoIndex].Pin.isActive; }
void Servo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->servoIndex]);
if (attach(0) >= 0) {
write(value);
safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
detach();
#endif
}
}
+46 -121
View File
@@ -173,10 +173,6 @@
#include "feature/prusa_MMU2/mmu2.h"
#endif
#if ENABLED(EXTENSIBLE_UI)
#include "lcd/extensible_ui/ui_api.h"
#endif
#if HAS_DRIVER(L6470)
#include "libs/L6470/L6470_Marlin.h"
#endif
@@ -279,6 +275,10 @@ void quickstop_stepper() {
sync_plan_position();
}
void enable_e_steppers() {
enable_E0(); enable_E1(); enable_E2(); enable_E3(); enable_E4(); enable_E5();
}
void enable_all_steppers() {
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.power_on();
@@ -286,30 +286,11 @@ void enable_all_steppers() {
enable_X();
enable_Y();
enable_Z();
enable_E0();
enable_E1();
enable_E2();
enable_E3();
enable_E4();
enable_E5();
}
void enable_e_steppers() {
enable_E0();
enable_E1();
enable_E2();
enable_E3();
enable_E4();
enable_E5();
enable_e_steppers();
}
void disable_e_steppers() {
disable_E0();
disable_E1();
disable_E2();
disable_E3();
disable_E4();
disable_E5();
disable_E0(); disable_E1(); disable_E2(); disable_E3(); disable_E4(); disable_E5();
}
void disable_e_stepper(const uint8_t e) {
@@ -330,71 +311,6 @@ void disable_all_steppers() {
disable_e_steppers();
}
#if HAS_FILAMENT_SENSOR
void event_filament_runout() {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
if (did_pause_print) return; // Action already in progress. Purge triggered repeated runout.
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onFilamentRunout(ExtUI::getActiveTool());
#endif
#if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
const char tool = '0'
#if NUM_RUNOUT_SENSORS > 1
+ active_extruder
#endif
;
#endif
//action:out_of_filament
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
host_action_prompt_end();
host_action_prompt_begin(PSTR("FilamentRunout T"), false);
SERIAL_CHAR(tool);
SERIAL_EOL();
host_action_prompt_show();
#endif
const bool run_runout_script = !runout.host_handling;
#if ENABLED(HOST_ACTION_COMMANDS)
if (run_runout_script
&& ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
|| strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|| strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
#endif
)
) {
host_action_paused(false);
}
else {
// Legacy Repetier command for use until newer version supports standard dialog
// To be removed later when pause command also triggers dialog
#ifdef ACTION_ON_FILAMENT_RUNOUT
host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
SERIAL_CHAR(tool);
SERIAL_EOL();
#endif
host_action_pause(false);
}
SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
SERIAL_CHAR(tool);
SERIAL_EOL();
#endif // HOST_ACTION_COMMANDS
if (run_runout_script)
queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
}
#endif // HAS_FILAMENT_SENSOR
#if ENABLED(G29_RETRY_AND_RECOVER)
void event_probe_failure() {
@@ -414,7 +330,7 @@ void disable_all_steppers() {
void event_probe_recover() {
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"));
host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), PSTR("Dismiss"));
#endif
#ifdef ACTION_ON_G29_RECOVER
host_action(PSTR(ACTION_ON_G29_RECOVER));
@@ -426,6 +342,20 @@ void disable_all_steppers() {
#endif
/**
* Printing is active when the print job timer is running
*/
bool printingIsActive() {
return print_job_timer.isRunning() || IS_SD_PRINTING();
}
/**
* Printing is paused according to SD or host indicators
*/
bool printingIsPaused() {
return print_job_timer.isPaused() || IS_SD_PAUSED();
}
/**
* Manage several activities:
* - Check for Filament Runout
@@ -582,10 +512,10 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
}
#endif // !SWITCHING_EXTRUDER
const float olde = current_position[E_AXIS];
current_position[E_AXIS] += EXTRUDER_RUNOUT_EXTRUDE;
planner.buffer_line(current_position, MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED), active_extruder);
current_position[E_AXIS] = olde;
const float olde = current_position.e;
current_position.e += EXTRUDER_RUNOUT_EXTRUDE;
line_to_current_position(MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED));
current_position.e = olde;
planner.set_e_position_mm(olde);
planner.synchronize();
@@ -629,7 +559,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
if (delayed_move_time && ELAPSED(ms, delayed_move_time + 1000UL) && IsRunning()) {
// travel moves have been received so enact them
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
set_destination_from_current();
destination = current_position;
prepare_move_to_destination();
}
#endif
@@ -762,7 +692,7 @@ void kill(PGM_P const lcd_msg/*=nullptr*/, const bool steppers_off/*=false*/) {
SERIAL_ERROR_MSG(MSG_ERR_KILLED);
#if HAS_DISPLAY
ui.kill_screen(lcd_msg ? lcd_msg : PSTR(MSG_KILLED));
ui.kill_screen(lcd_msg ?: PSTR(MSG_KILLED));
#else
UNUSED(lcd_msg);
#endif
@@ -801,29 +731,17 @@ void minkill(const bool steppers_off/*=false*/) {
#if HAS_KILL
// Wait for kill to be released
while (!READ(KILL_PIN)) {
#if ENABLED(USE_WATCHDOG)
watchdog_reset();
#endif
}
while (!READ(KILL_PIN)) watchdog_refresh();
// Wait for kill to be pressed
while (READ(KILL_PIN)) {
#if ENABLED(USE_WATCHDOG)
watchdog_reset();
#endif
}
while (READ(KILL_PIN)) watchdog_refresh();
void (*resetFunc)() = 0; // Declare resetFunc() at address 0
resetFunc(); // Jump to address 0
#else // !HAS_KILL
for (;;) {
#if ENABLED(USE_WATCHDOG)
watchdog_reset();
#endif
} // Wait for reset
for (;;) watchdog_refresh(); // Wait for reset
#endif // !HAS_KILL
}
@@ -962,10 +880,11 @@ void setup() {
SERIAL_EOL();
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
SERIAL_ECHO_START();
SERIAL_ECHOPGM(MSG_CONFIGURATION_VER);
SERIAL_ECHOPGM(STRING_DISTRIBUTION_DATE);
SERIAL_ECHOLNPGM(MSG_AUTHOR STRING_CONFIG_H_AUTHOR);
SERIAL_ECHO_MSG(
MSG_CONFIGURATION_VER
STRING_DISTRIBUTION_DATE
MSG_AUTHOR STRING_CONFIG_H_AUTHOR
);
SERIAL_ECHO_MSG("Compiled: " __DATE__);
#endif
@@ -974,6 +893,12 @@ void setup() {
// UI must be initialized before EEPROM
// (because EEPROM code calls the UI).
// Set up LEDs early
#if HAS_COLOR_LEDS
leds.setup();
#endif
ui.init();
ui.reset_status();
@@ -995,7 +920,7 @@ void setup() {
#if HAS_M206_COMMAND
// Initialize current position based on home_offset
LOOP_XYZ(a) current_position[a] += home_offset[a];
current_position += home_offset;
#endif
// Vital to init stepper/planner equivalent for current_position
@@ -1068,10 +993,6 @@ void setup() {
OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF
#endif
#if HAS_COLOR_LEDS
leds.setup();
#endif
#if HAS_CASE_LIGHT
#if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
@@ -1152,6 +1073,10 @@ void setup() {
card.beginautostart();
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_action_prompt_end();
#endif
#if HAS_TRINAMIC && DISABLED(PS_DEFAULT_OFF)
test_tmc_connection(true, true, true, true);
#endif
+3 -4
View File
@@ -331,6 +331,9 @@ extern bool Running;
inline bool IsRunning() { return Running; }
inline bool IsStopped() { return !Running; }
bool printingIsActive();
bool printingIsPaused();
extern bool wait_for_heatup;
#if HAS_RESUME_CONTINUE
@@ -368,10 +371,6 @@ void protected_pin_err();
inline void suicide() { OUT_WRITE(SUICIDE_PIN, LOW); }
#endif
#if HAS_FILAMENT_SENSOR
void event_filament_runout();
#endif
#if ENABLED(G29_RETRY_AND_RECOVER)
void event_probe_recover();
void event_probe_failure();
+8 -7
View File
@@ -255,9 +255,9 @@
// STM32 ARM Cortex-M3
//
#define BOARD_STM32F103R 4000 // STM32F103R Libmaple-based STM32F1 controller
#define BOARD_STM32F103RE 4000 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_MALYAN_M200 4001 // STM32C8T6 Libmaple-based STM32F1 controller
#define BOARD_STM3R_MINI 4002 // STM32F103R Libmaple-based STM32F1 controller
#define BOARD_STM3R_MINI 4002 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_GTM32_PRO_VB 4003 // STM32F103VET6 controller
#define BOARD_MORPHEUS 4004 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
#define BOARD_CHITU3D 4005 // Chitu3D (STM32F103RET6)
@@ -268,11 +268,12 @@
#define BOARD_BIGTREE_SKR_MINI_V1_1 4010 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
#define BOARD_BIGTREE_SKR_MINI_E3 4011 // BigTreeTech SKR Mini E3 (STM32F103RC)
#define BOARD_BIGTREE_SKR_E3_DIP 4012 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC)
#define BOARD_JGAURORA_A5S_A1 4013 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4014 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4015 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4016 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4017 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
#define BOARD_BTT_SKR_MINI_E3_V1_2 4013 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
#define BOARD_JGAURORA_A5S_A1 4014 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4015 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4016 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4017 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4018 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
//
// ARM Cortex-M4F
-63
View File
@@ -1,63 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Axis indices as enumerated constants
*
* - X_AXIS, Y_AXIS, and Z_AXIS should be used for axes in Cartesian space
* - A_AXIS, B_AXIS, and C_AXIS should be used for Steppers, corresponding to XYZ on Cartesians
* - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics
*/
enum AxisEnum : unsigned char {
X_AXIS = 0,
A_AXIS = 0,
Y_AXIS = 1,
B_AXIS = 1,
Z_AXIS = 2,
C_AXIS = 2,
E_AXIS = 3,
X_HEAD = 4,
Y_HEAD = 5,
Z_HEAD = 6,
E0_AXIS = 3,
E1_AXIS = 4,
E2_AXIS = 5,
E3_AXIS = 6,
E4_AXIS = 7,
E5_AXIS = 8,
ALL_AXES = 0xFE,
NO_AXIS = 0xFF
};
#define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=(S); VAR<=(N); VAR++)
#define LOOP_S_L_N(VAR, S, N) for (uint8_t VAR=(S); VAR<(N); VAR++)
#define LOOP_LE_N(VAR, N) LOOP_S_LE_N(VAR, 0, N)
#define LOOP_L_N(VAR, N) LOOP_S_L_N(VAR, 0, N)
#define LOOP_NA(VAR) LOOP_L_N(VAR, NUM_AXIS)
#define LOOP_XYZ(VAR) LOOP_S_LE_N(VAR, X_AXIS, Z_AXIS)
#define LOOP_XYZE(VAR) LOOP_S_LE_N(VAR, X_AXIS, E_AXIS)
#define LOOP_XYZE_N(VAR) LOOP_S_L_N(VAR, X_AXIS, XYZE_N)
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
#define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS)
#define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N)
+32 -35
View File
@@ -337,36 +337,38 @@
#define MSG_Y2 "Y2"
#define MSG_Z2 "Z2"
#define MSG_Z3 "Z3"
#define MSG_H1 "1"
#define MSG_H2 "2"
#define MSG_H3 "3"
#define MSG_H4 "4"
#define MSG_H5 "5"
#define MSG_H6 "6"
#define MSG_LCD_N0 " 1"
#define MSG_LCD_N1 " 2"
#define MSG_LCD_N2 " 3"
#define MSG_LCD_N3 " 4"
#define MSG_LCD_N4 " 5"
#define MSG_LCD_N5 " 6"
#define MSG_E1 "E1"
#define MSG_E2 "E2"
#define MSG_E3 "E3"
#define MSG_E4 "E4"
#define MSG_E5 "E5"
#define MSG_E6 "E6"
#define MSG_MOVE_E1 "1"
#define MSG_MOVE_E2 "2"
#define MSG_MOVE_E3 "3"
#define MSG_MOVE_E4 "4"
#define MSG_MOVE_E5 "5"
#define MSG_MOVE_E6 "6"
#define MSG_DIAM_E1 " 1"
#define MSG_DIAM_E2 " 2"
#define MSG_DIAM_E3 " 3"
#define MSG_DIAM_E4 " 4"
#define MSG_DIAM_E5 " 5"
#define MSG_DIAM_E6 " 6"
/**
* Tool indexes for LCD display only
*
* By convention the LCD shows "E1" for the first extruder.
* However, internal to Marlin E0/T0 is the first tool, and
* most board silkscreens say "E0." Zero-based labels will
* make these indexes consistent but this defies expectation.
*
*/
#if ENABLED(NUMBER_TOOLS_FROM_0)
#define LCD_STR_N0 "0"
#define LCD_STR_N1 "1"
#define LCD_STR_N2 "2"
#define LCD_STR_N3 "3"
#define LCD_STR_N4 "4"
#define LCD_STR_N5 "5"
#else
#define LCD_STR_N0 "1"
#define LCD_STR_N1 "2"
#define LCD_STR_N2 "3"
#define LCD_STR_N3 "4"
#define LCD_STR_N4 "5"
#define LCD_STR_N5 "6"
#endif
#define LCD_STR_E0 "E" LCD_STR_N0
#define LCD_STR_E1 "E" LCD_STR_N1
#define LCD_STR_E2 "E" LCD_STR_N2
#define LCD_STR_E3 "E" LCD_STR_N3
#define LCD_STR_E4 "E" LCD_STR_N4
#define LCD_STR_E5 "E" LCD_STR_N5
#include INCLUDE_LANGUAGE
@@ -383,8 +385,3 @@
#endif
#include "../lcd/language/language_en.h"
#ifdef CUSTOM_USER_MENU_TITLE
#undef MSG_USER_MENU
#define MSG_USER_MENU CUSTOM_USER_MENU_TITLE
#endif
+54 -46
View File
@@ -21,11 +21,11 @@
*/
#pragma once
#define NUM_AXIS 4
#define ABCE 4
#define XYZE 4
#define ABC 3
#define XYZ 3
#define XY 2
#define _AXIS(A) (A##_AXIS)
@@ -61,6 +61,13 @@
// Nanoseconds per cycle
#define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU)
// Macros to make sprintf_P read from PROGMEM (AVR extension)
#ifdef __AVR__
#define S_FMT "%S"
#else
#define S_FMT "%s"
#endif
// Macros to make a string from a macro
#define STRINGIFY_(M) #M
#define STRINGIFY(M) STRINGIFY_(M)
@@ -198,25 +205,29 @@
}while(0)
// Macros for initializing arrays
#define ARRAY_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P }
#define ARRAY_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N,O }
#define ARRAY_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N }
#define ARRAY_13(A,B,C,D,E,F,G,H,I,J,K,L,M,...) { A,B,C,D,E,F,G,H,I,J,K,L,M }
#define ARRAY_12(A,B,C,D,E,F,G,H,I,J,K,L,...) { A,B,C,D,E,F,G,H,I,J,K,L }
#define ARRAY_11(A,B,C,D,E,F,G,H,I,J,K,...) { A,B,C,D,E,F,G,H,I,J,K }
#define ARRAY_10(A,B,C,D,E,F,G,H,I,J,...) { A,B,C,D,E,F,G,H,I,J }
#define ARRAY_9( A,B,C,D,E,F,G,H,I,...) { A,B,C,D,E,F,G,H,I }
#define ARRAY_8( A,B,C,D,E,F,G,H,...) { A,B,C,D,E,F,G,H }
#define ARRAY_7( A,B,C,D,E,F,G,...) { A,B,C,D,E,F,G }
#define ARRAY_6( A,B,C,D,E,F,...) { A,B,C,D,E,F }
#define ARRAY_5( A,B,C,D,E,...) { A,B,C,D,E }
#define ARRAY_4( A,B,C,D,...) { A,B,C,D }
#define ARRAY_3( A,B,C,...) { A,B,C }
#define ARRAY_2( A,B,...) { A,B }
#define ARRAY_1( A,...) { A }
#define LIST_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P
#define LIST_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
#define LIST_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N
#define LIST_13(A,B,C,D,E,F,G,H,I,J,K,L,M,...) A,B,C,D,E,F,G,H,I,J,K,L,M
#define LIST_12(A,B,C,D,E,F,G,H,I,J,K,L,...) A,B,C,D,E,F,G,H,I,J,K,L
#define LIST_11(A,B,C,D,E,F,G,H,I,J,K,...) A,B,C,D,E,F,G,H,I,J,K
#define LIST_10(A,B,C,D,E,F,G,H,I,J,...) A,B,C,D,E,F,G,H,I,J
#define LIST_9( A,B,C,D,E,F,G,H,I,...) A,B,C,D,E,F,G,H,I
#define LIST_8( A,B,C,D,E,F,G,H,...) A,B,C,D,E,F,G,H
#define LIST_7( A,B,C,D,E,F,G,...) A,B,C,D,E,F,G
#define LIST_6( A,B,C,D,E,F,...) A,B,C,D,E,F
#define LIST_5( A,B,C,D,E,...) A,B,C,D,E
#define LIST_4( A,B,C,D,...) A,B,C,D
#define LIST_3( A,B,C,...) A,B,C
#define LIST_2( A,B,...) A,B
#define LIST_1( A,...) A
#define _ARRAY_N(N,V...) ARRAY_##N(V)
#define ARRAY_N(N,V...) _ARRAY_N(N,V)
#define _LIST_N(N,V...) LIST_##N(V)
#define LIST_N(N,V...) _LIST_N(N,V)
#define ARRAY_N(N,V...) { _LIST_N(N,V) }
#define _JOIN_1(O) (O)
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
// Macros for adding
#define INC_0 1
@@ -244,9 +255,6 @@
#define DECREMENT_(n) DEC_##n
#define DECREMENT(n) DECREMENT_(n)
#define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
#define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
#define NOOP (void(0))
#define CEILING(x,y) (((x) + (y) - 1) / (y))
@@ -285,8 +293,8 @@
#endif
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
#define _NUM_ARGS(_0,_24_,_23,_22,_21,_20,_19,_18,_17,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,N,...) N
#define NUM_ARGS(V...) _NUM_ARGS(0,V,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
#define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
#define NUM_ARGS(V...) _NUM_ARGS(0,V,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
#ifdef __cplusplus
@@ -312,29 +320,29 @@
#else
#define MIN_2(a,b) ((a)<(b)?(a):(b))
#define MIN_3(a,...) MIN_2(a,MIN_2(__VA_ARGS__))
#define MIN_4(a,...) MIN_2(a,MIN_3(__VA_ARGS__))
#define MIN_5(a,...) MIN_2(a,MIN_4(__VA_ARGS__))
#define MIN_6(a,...) MIN_2(a,MIN_5(__VA_ARGS__))
#define MIN_7(a,...) MIN_2(a,MIN_6(__VA_ARGS__))
#define MIN_8(a,...) MIN_2(a,MIN_7(__VA_ARGS__))
#define MIN_9(a,...) MIN_2(a,MIN_8(__VA_ARGS__))
#define MIN_10(a,...) MIN_2(a,MIN_9(__VA_ARGS__))
#define __MIN_N(N, ...) MIN_##N(__VA_ARGS__)
#define _MIN_N(N, ...) __MIN_N(N,__VA_ARGS__)
#define _MIN(...) _MIN_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
#define MIN_3(a,V...) MIN_2(a,MIN_2(V))
#define MIN_4(a,V...) MIN_2(a,MIN_3(V))
#define MIN_5(a,V...) MIN_2(a,MIN_4(V))
#define MIN_6(a,V...) MIN_2(a,MIN_5(V))
#define MIN_7(a,V...) MIN_2(a,MIN_6(V))
#define MIN_8(a,V...) MIN_2(a,MIN_7(V))
#define MIN_9(a,V...) MIN_2(a,MIN_8(V))
#define MIN_10(a,V...) MIN_2(a,MIN_9(V))
#define __MIN_N(N,V...) MIN_##N(V)
#define _MIN_N(N,V...) __MIN_N(N,V)
#define _MIN(V...) _MIN_N(NUM_ARGS(V), V)
#define MAX_2(a,b) ((a)>(b)?(a):(b))
#define MAX_3(a,...) MAX_2(a,MAX_2(__VA_ARGS__))
#define MAX_4(a,...) MAX_2(a,MAX_3(__VA_ARGS__))
#define MAX_5(a,...) MAX_2(a,MAX_4(__VA_ARGS__))
#define MAX_6(a,...) MAX_2(a,MAX_5(__VA_ARGS__))
#define MAX_7(a,...) MAX_2(a,MAX_6(__VA_ARGS__))
#define MAX_8(a,...) MAX_2(a,MAX_7(__VA_ARGS__))
#define MAX_9(a,...) MAX_2(a,MAX_8(__VA_ARGS__))
#define MAX_10(a,...) MAX_2(a,MAX_9(__VA_ARGS__))
#define __MAX_N(N, ...) MAX_##N(__VA_ARGS__)
#define _MAX_N(N, ...) __MAX_N(N,__VA_ARGS__)
#define _MAX(...) _MAX_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
#define MAX_3(a,V...) MAX_2(a,MAX_2(V))
#define MAX_4(a,V...) MAX_2(a,MAX_3(V))
#define MAX_5(a,V...) MAX_2(a,MAX_4(V))
#define MAX_6(a,V...) MAX_2(a,MAX_5(V))
#define MAX_7(a,V...) MAX_2(a,MAX_6(V))
#define MAX_8(a,V...) MAX_2(a,MAX_7(V))
#define MAX_9(a,V...) MAX_2(a,MAX_8(V))
#define MAX_10(a,V...) MAX_2(a,MAX_9(V))
#define __MAX_N(N,V...) MAX_##N(V)
#define _MAX_N(N,V...) __MAX_N(N,V)
#define _MAX(V...) _MAX_N(NUM_ARGS(V), V)
#endif
+1 -6
View File
@@ -22,7 +22,6 @@
#include "serial.h"
#include "language.h"
#include "enum.h"
uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;
@@ -68,12 +67,8 @@ void print_bin(const uint16_t val) {
}
}
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float &x, const float &y, const float &z) {
void print_xyz(const float &x, const float &y, const float &z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
serialprintPGM(prefix);
SERIAL_ECHOPAIR(" " MSG_X, x, " " MSG_Y, y, " " MSG_Z, z);
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
}
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]) {
print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
}
+37 -6
View File
@@ -139,14 +139,41 @@ extern uint8_t marlin_debug_flags;
#define _SELP_21(a,b,V...) do{ _SEP_2(a,b); _SELP_19(V); }while(0)
#define _SELP_22(a,b,V...) do{ _SEP_2(a,b); _SELP_20(V); }while(0)
#define _SELP_23(a,b,V...) do{ _SEP_2(a,b); _SELP_21(V); }while(0)
#define _SELP_24(a,b,V...) do{ _SEP_2(a,b); _SELP_22(V); }while(0)
#define _SELP_24(a,b,V...) do{ _SEP_2(a,b); _SELP_22(V); }while(0) // Use up two, pass the rest up
#define SERIAL_ECHOLNPAIR(V...) _SELP_N(NUM_ARGS(V),V)
// Print up to 20 comma-separated pairs of values
#define __SLST_N(N,V...) _SLST_##N(V)
#define _SLST_N(N,V...) __SLST_N(N,V)
#define _SLST_1(a) SERIAL_ECHO(a)
#define _SLST_2(a,b) do{ SERIAL_ECHO(a); SERIAL_ECHOPAIR(", ",b); }while(0)
#define _SLST_3(a,b,c) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_1(c); }while(0)
#define _SLST_4(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_2(V); }while(0)
#define _SLST_5(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_3(V); }while(0)
#define _SLST_6(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_4(V); }while(0)
#define _SLST_7(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_5(V); }while(0)
#define _SLST_8(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_6(V); }while(0)
#define _SLST_9(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_7(V); }while(0)
#define _SLST_10(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_8(V); }while(0)
#define _SLST_11(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_9(V); }while(0)
#define _SLST_12(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_10(V); }while(0)
#define _SLST_13(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_11(V); }while(0)
#define _SLST_14(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_12(V); }while(0)
#define _SLST_15(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_13(V); }while(0)
#define _SLST_16(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_14(V); }while(0)
#define _SLST_17(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_15(V); }while(0)
#define _SLST_18(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_16(V); }while(0)
#define _SLST_19(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_17(V); }while(0)
#define _SLST_20(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_18(V); }while(0) // Use up two, pass the rest up
#define SERIAL_ECHOLIST(pre,V...) do{ SERIAL_ECHOPGM(pre); _SLST_N(NUM_ARGS(V),V); }while(0)
#define SERIAL_ECHOLIST_N(N,V...) _SLST_N(N,LIST_N(N,V))
#define SERIAL_ECHOPGM(S) (serialprintPGM(PSTR(S)))
#define SERIAL_ECHOLNPGM(S) (serialprintPGM(PSTR(S "\n")))
#define SERIAL_ECHOPAIR_F(S, V...) do{ SERIAL_ECHOPGM(S); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ECHOPAIR_F(S,V...) do{ SERIAL_ECHOPGM(S); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHO_START() serial_echo_start()
@@ -186,7 +213,11 @@ void serial_spaces(uint8_t count);
void print_bin(const uint16_t val);
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float &x, const float &y, const float &z);
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(PSTR(PREFIX), nullptr, V); }while(0)
void print_xyz(const float &x, const float &y, const float &z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);
inline void print_xyz(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
print_xyz(xyz.x, xyz.y, xyz.z, prefix, suffix);
}
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(V, PSTR(PREFIX), nullptr); }while(0)
+486
View File
@@ -0,0 +1,486 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <math.h>
#include <stddef.h>
#include "millis_t.h"
//
// Enumerated axis indices
//
// - X_AXIS, Y_AXIS, and Z_AXIS should be used for axes in Cartesian space
// - A_AXIS, B_AXIS, and C_AXIS should be used for Steppers, corresponding to XYZ on Cartesians
// - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics
//
enum AxisEnum : uint8_t {
X_AXIS = 0, A_AXIS = 0,
Y_AXIS = 1, B_AXIS = 1,
Z_AXIS = 2, C_AXIS = 2,
E_AXIS = 3,
X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 6,
E0_AXIS = 3,
E1_AXIS = 4,
E2_AXIS = 5,
E3_AXIS = 6,
E4_AXIS = 7,
E5_AXIS = 8,
ALL_AXES = 0xFE, NO_AXIS = 0xFF
};
//
// Loop over XYZE axes
//
#define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=(S); VAR<=(N); VAR++)
#define LOOP_S_L_N(VAR, S, N) for (uint8_t VAR=(S); VAR<(N); VAR++)
#define LOOP_LE_N(VAR, N) LOOP_S_LE_N(VAR, 0, N)
#define LOOP_L_N(VAR, N) LOOP_S_L_N(VAR, 0, N)
#define LOOP_XYZ(VAR) LOOP_S_LE_N(VAR, X_AXIS, Z_AXIS)
#define LOOP_XYZE(VAR) LOOP_S_LE_N(VAR, X_AXIS, E_AXIS)
#define LOOP_XYZE_N(VAR) LOOP_S_L_N(VAR, X_AXIS, XYZE_N)
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
#define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS)
#define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N)
//
// Conditional type assignment magic. For example...
//
// typename IF<(MYOPT==12), int, float>::type myvar;
//
template <bool, class L, class R>
struct IF { typedef R type; };
template <class L, class R>
struct IF<true, L, R> { typedef L type; };
//
// feedRate_t is just a humble float
//
typedef float feedRate_t;
// Conversion macros
#define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f)
#define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f)
#define MMS_SCALED(V) ((V) * 0.01f * feedrate_percentage)
//
// Coordinates structures for XY, XYZ, XYZE...
//
// Helpers
#define _RECIP(N) ((N) ? 1.0f / float(N) : 0.0f)
#define _ABS(N) ((N) < 0 ? -(N) : (N))
#define _LS(N) (N = (T)(uint32_t(N) << v))
#define _RS(N) (N = (T)(uint32_t(N) >> v))
#define FI FORCE_INLINE
// Forward declarations
template<typename T> struct XYval;
template<typename T> struct XYZval;
template<typename T> struct XYZEval;
typedef struct XYval<bool> xy_bool_t;
typedef struct XYZval<bool> xyz_bool_t;
typedef struct XYZEval<bool> xyze_bool_t;
typedef struct XYval<char> xy_char_t;
typedef struct XYZval<char> xyz_char_t;
typedef struct XYZEval<char> xyze_char_t;
typedef struct XYval<unsigned char> xy_uchar_t;
typedef struct XYZval<unsigned char> xyz_uchar_t;
typedef struct XYZEval<unsigned char> xyze_uchar_t;
typedef struct XYval<int8_t> xy_int8_t;
typedef struct XYZval<int8_t> xyz_int8_t;
typedef struct XYZEval<int8_t> xyze_int8_t;
typedef struct XYval<uint8_t> xy_uint8_t;
typedef struct XYZval<uint8_t> xyz_uint8_t;
typedef struct XYZEval<uint8_t> xyze_uint8_t;
typedef struct XYval<int16_t> xy_int_t;
typedef struct XYZval<int16_t> xyz_int_t;
typedef struct XYZEval<int16_t> xyze_int_t;
typedef struct XYval<uint16_t> xy_uint_t;
typedef struct XYZval<uint16_t> xyz_uint_t;
typedef struct XYZEval<uint16_t> xyze_uint_t;
typedef struct XYval<int32_t> xy_long_t;
typedef struct XYZval<int32_t> xyz_long_t;
typedef struct XYZEval<int32_t> xyze_long_t;
typedef struct XYval<uint32_t> xy_ulong_t;
typedef struct XYZval<uint32_t> xyz_ulong_t;
typedef struct XYZEval<uint32_t> xyze_ulong_t;
typedef struct XYZval<volatile int32_t> xyz_vlong_t;
typedef struct XYZEval<volatile int32_t> xyze_vlong_t;
typedef struct XYval<float> xy_float_t;
typedef struct XYZval<float> xyz_float_t;
typedef struct XYZEval<float> xyze_float_t;
typedef struct XYval<feedRate_t> xy_feedrate_t;
typedef struct XYZval<feedRate_t> xyz_feedrate_t;
typedef struct XYZEval<feedRate_t> xyze_feedrate_t;
typedef xy_uint8_t xy_byte_t;
typedef xyz_uint8_t xyz_byte_t;
typedef xyze_uint8_t xyze_byte_t;
typedef xyz_long_t abc_long_t;
typedef xyze_long_t abce_long_t;
typedef xyz_ulong_t abc_ulong_t;
typedef xyze_ulong_t abce_ulong_t;
typedef xy_float_t xy_pos_t;
typedef xyz_float_t xyz_pos_t;
typedef xyze_float_t xyze_pos_t;
typedef xy_float_t ab_float_t;
typedef xyz_float_t abc_float_t;
typedef xyze_float_t abce_float_t;
typedef ab_float_t ab_pos_t;
typedef abc_float_t abc_pos_t;
typedef abce_float_t abce_pos_t;
// External conversion methods
void toLogical(xy_pos_t &raw);
void toLogical(xyz_pos_t &raw);
void toLogical(xyze_pos_t &raw);
void toNative(xy_pos_t &raw);
void toNative(xyz_pos_t &raw);
void toNative(xyze_pos_t &raw);
//
// XY coordinates, counters, etc.
//
template<typename T>
struct XYval {
union {
struct { T x, y; };
struct { T a, b; };
T pos[2];
};
FI void set(const T px) { x = px; }
FI void set(const T px, const T py) { x = px; y = py; }
FI void reset() { x = y = 0; }
FI T magnitude() const { return (T)sqrtf(x*x + y*y); }
FI operator T* () { return pos; }
FI operator bool() { return x || y; }
FI XYval<T> copy() const { return *this; }
FI XYval<T> ABS() const { return { T(_ABS(x)), T(_ABS(y)) }; }
FI XYval<int16_t> asInt() { return { int16_t(x), int16_t(y) }; }
FI XYval<int16_t> asInt() const { return { int16_t(x), int16_t(y) }; }
FI XYval<int32_t> asLong() { return { int32_t(x), int32_t(y) }; }
FI XYval<int32_t> asLong() const { return { int32_t(x), int32_t(y) }; }
FI XYval<float> asFloat() { return { float(x), float(y) }; }
FI XYval<float> asFloat() const { return { float(x), float(y) }; }
FI XYval<float> reciprocal() const { return { _RECIP(x), _RECIP(y) }; }
FI XYval<float> asLogical() const { XYval<float> o = asFloat(); toLogical(o); return o; }
FI XYval<float> asNative() const { XYval<float> o = asFloat(); toNative(o); return o; }
FI operator XYZval<T>() { return { x, y }; }
FI operator XYZval<T>() const { return { x, y }; }
FI operator XYZEval<T>() { return { x, y }; }
FI operator XYZEval<T>() const { return { x, y }; }
FI T& operator[](const int i) { return pos[i]; }
FI const T& operator[](const int i) const { return pos[i]; }
FI XYval<T>& operator= (const T v) { set(v, v ); return *this; }
FI XYval<T>& operator= (const XYZval<T> &rs) { set(rs.x, rs.y); return *this; }
FI XYval<T>& operator= (const XYZEval<T> &rs) { set(rs.x, rs.y); return *this; }
FI XYval<T> operator+ (const XYval<T> &rs) const { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYval<T> operator+ (const XYval<T> &rs) { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYval<T> operator- (const XYval<T> &rs) const { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYval<T> operator- (const XYval<T> &rs) { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYval<T> operator* (const XYval<T> &rs) const { XYval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYval<T> operator* (const XYval<T> &rs) { XYval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYval<T> operator/ (const XYval<T> &rs) const { XYval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYval<T> operator/ (const XYval<T> &rs) { XYval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYval<T> operator+ (const XYZval<T> &rs) const { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYval<T> operator+ (const XYZval<T> &rs) { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYval<T> operator- (const XYZval<T> &rs) const { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYval<T> operator- (const XYZval<T> &rs) { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYval<T> operator* (const XYZval<T> &rs) const { XYval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYval<T> operator* (const XYZval<T> &rs) { XYval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYval<T> operator/ (const XYZval<T> &rs) const { XYval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYval<T> operator/ (const XYZval<T> &rs) { XYval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYval<T> operator+ (const XYZEval<T> &rs) const { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYval<T> operator+ (const XYZEval<T> &rs) { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYval<T> operator- (const XYZEval<T> &rs) const { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYval<T> operator- (const XYZEval<T> &rs) { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYval<T> operator* (const XYZEval<T> &rs) const { XYval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYval<T> operator* (const XYZEval<T> &rs) { XYval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYval<T> operator/ (const XYZEval<T> &rs) const { XYval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYval<T> operator/ (const XYZEval<T> &rs) { XYval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYval<T> operator* (const float &v) const { XYval<T> ls = *this; ls.x *= v; ls.y *= v; return ls; }
FI XYval<T> operator* (const float &v) { XYval<T> ls = *this; ls.x *= v; ls.y *= v; return ls; }
FI XYval<T> operator* (const int &v) const { XYval<T> ls = *this; ls.x *= v; ls.y *= v; return ls; }
FI XYval<T> operator* (const int &v) { XYval<T> ls = *this; ls.x *= v; ls.y *= v; return ls; }
FI XYval<T> operator/ (const float &v) const { XYval<T> ls = *this; ls.x /= v; ls.y /= v; return ls; }
FI XYval<T> operator/ (const float &v) { XYval<T> ls = *this; ls.x /= v; ls.y /= v; return ls; }
FI XYval<T> operator/ (const int &v) const { XYval<T> ls = *this; ls.x /= v; ls.y /= v; return ls; }
FI XYval<T> operator/ (const int &v) { XYval<T> ls = *this; ls.x /= v; ls.y /= v; return ls; }
FI XYval<T> operator>>(const int &v) const { XYval<T> ls = *this; _RS(ls.x); _RS(ls.y); return ls; }
FI XYval<T> operator>>(const int &v) { XYval<T> ls = *this; _RS(ls.x); _RS(ls.y); return ls; }
FI XYval<T> operator<<(const int &v) const { XYval<T> ls = *this; _LS(ls.x); _LS(ls.y); return ls; }
FI XYval<T> operator<<(const int &v) { XYval<T> ls = *this; _LS(ls.x); _LS(ls.y); return ls; }
FI XYval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
FI XYval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
FI XYval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
FI XYval<T>& operator+=(const XYZval<T> &rs) { x += rs.x; y += rs.y; return *this; }
FI XYval<T>& operator-=(const XYZval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
FI XYval<T>& operator*=(const XYZval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
FI XYval<T>& operator+=(const XYZEval<T> &rs) { x += rs.x; y += rs.y; return *this; }
FI XYval<T>& operator-=(const XYZEval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
FI XYval<T>& operator*=(const XYZEval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
FI XYval<T>& operator*=(const float &v) { x *= v; y *= v; return *this; }
FI XYval<T>& operator*=(const int &v) { x *= v; y *= v; return *this; }
FI XYval<T>& operator>>=(const int &v) { _RS(x); _RS(y); return *this; }
FI XYval<T>& operator<<=(const int &v) { _LS(x); _LS(y); return *this; }
FI bool operator==(const XYval<T> &rs) { return x == rs.x && y == rs.y; }
FI bool operator==(const XYZval<T> &rs) { return x == rs.x && y == rs.y; }
FI bool operator==(const XYZEval<T> &rs) { return x == rs.x && y == rs.y; }
FI bool operator==(const XYval<T> &rs) const { return x == rs.x && y == rs.y; }
FI bool operator==(const XYZval<T> &rs) const { return x == rs.x && y == rs.y; }
FI bool operator==(const XYZEval<T> &rs) const { return x == rs.x && y == rs.y; }
FI bool operator!=(const XYval<T> &rs) { return !operator==(rs); }
FI bool operator!=(const XYZval<T> &rs) { return !operator==(rs); }
FI bool operator!=(const XYZEval<T> &rs) { return !operator==(rs); }
FI bool operator!=(const XYval<T> &rs) const { return !operator==(rs); }
FI bool operator!=(const XYZval<T> &rs) const { return !operator==(rs); }
FI bool operator!=(const XYZEval<T> &rs) const { return !operator==(rs); }
FI XYval<T> operator-() { XYval<T> o = *this; o.x = -x; o.y = -y; return o; }
FI const XYval<T> operator-() const { XYval<T> o = *this; o.x = -x; o.y = -y; return o; }
};
//
// XYZ coordinates, counters, etc.
//
template<typename T>
struct XYZval {
union {
struct { T x, y, z; };
struct { T a, b, c; };
T pos[3];
};
FI void set(const T px) { x = px; }
FI void set(const T px, const T py) { x = px; y = py; }
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; }
FI void reset() { x = y = z = 0; }
FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z); }
FI operator T* () { return pos; }
FI operator bool() { return z || x || y; }
FI XYZval<T> copy() const { XYZval<T> o = *this; return o; }
FI XYZval<T> ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)) }; }
FI XYZval<int16_t> asInt() { return { int16_t(x), int16_t(y), int16_t(z) }; }
FI XYZval<int16_t> asInt() const { return { int16_t(x), int16_t(y), int16_t(z) }; }
FI XYZval<int32_t> asLong() { return { int32_t(x), int32_t(y), int32_t(z) }; }
FI XYZval<int32_t> asLong() const { return { int32_t(x), int32_t(y), int32_t(z) }; }
FI XYZval<float> asFloat() { return { float(x), float(y), float(z) }; }
FI XYZval<float> asFloat() const { return { float(x), float(y), float(z) }; }
FI XYZval<float> reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z) }; }
FI XYZval<float> asLogical() const { XYZval<float> o = asFloat(); toLogical(o); return o; }
FI XYZval<float> asNative() const { XYZval<float> o = asFloat(); toNative(o); return o; }
FI operator XYval<T>&() { return *(XYval<T>*)this; }
FI operator const XYval<T>&() const { return *(const XYval<T>*)this; }
FI operator XYZEval<T>() const { return { x, y, z }; }
FI T& operator[](const int i) { return pos[i]; }
FI const T& operator[](const int i) const { return pos[i]; }
FI XYZval<T>& operator= (const T v) { set(v, v, v ); return *this; }
FI XYZval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y ); return *this; }
FI XYZval<T>& operator= (const XYZEval<T> &rs) { set(rs.x, rs.y, rs.z); return *this; }
FI XYZval<T> operator+ (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYZval<T> operator+ (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYZval<T> operator- (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYZval<T> operator- (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYZval<T> operator* (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYZval<T> operator* (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYZval<T> operator/ (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYZval<T> operator/ (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYZval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
FI XYZval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
FI XYZval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
FI XYZval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
FI XYZval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
FI XYZval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
FI XYZval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
FI XYZval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
FI XYZval<T> operator+ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
FI XYZval<T> operator+ (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
FI XYZval<T> operator- (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
FI XYZval<T> operator- (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
FI XYZval<T> operator* (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
FI XYZval<T> operator* (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
FI XYZval<T> operator/ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
FI XYZval<T> operator/ (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
FI XYZval<T> operator* (const float &v) const { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= z; return ls; }
FI XYZval<T> operator* (const float &v) { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= z; return ls; }
FI XYZval<T> operator* (const int &v) const { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= z; return ls; }
FI XYZval<T> operator* (const int &v) { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= z; return ls; }
FI XYZval<T> operator/ (const float &v) const { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= z; return ls; }
FI XYZval<T> operator/ (const float &v) { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= z; return ls; }
FI XYZval<T> operator/ (const int &v) const { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= z; return ls; }
FI XYZval<T> operator/ (const int &v) { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= z; return ls; }
FI XYZval<T> operator>>(const int &v) const { XYZval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; }
FI XYZval<T> operator>>(const int &v) { XYZval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; }
FI XYZval<T> operator<<(const int &v) const { XYZval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; }
FI XYZval<T> operator<<(const int &v) { XYZval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; }
FI XYZval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
FI XYZval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
FI XYZval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
FI XYZval<T>& operator/=(const XYval<T> &rs) { x /= rs.x; y /= rs.y; return *this; }
FI XYZval<T>& operator+=(const XYZval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; }
FI XYZval<T>& operator-=(const XYZval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; }
FI XYZval<T>& operator*=(const XYZval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; }
FI XYZval<T>& operator/=(const XYZval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; }
FI XYZval<T>& operator+=(const XYZEval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; }
FI XYZval<T>& operator-=(const XYZEval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; }
FI XYZval<T>& operator*=(const XYZEval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; }
FI XYZval<T>& operator/=(const XYZEval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; }
FI XYZval<T>& operator*=(const float &v) { x *= v; y *= v; z *= v; return *this; }
FI XYZval<T>& operator*=(const int &v) { x *= v; y *= v; z *= v; return *this; }
FI XYZval<T>& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); return *this; }
FI XYZval<T>& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); return *this; }
FI bool operator==(const XYZEval<T> &rs) { return x == rs.x && y == rs.y && z == rs.z; }
FI bool operator!=(const XYZEval<T> &rs) { return !operator==(rs); }
FI bool operator==(const XYZEval<T> &rs) const { return x == rs.x && y == rs.y && z == rs.z; }
FI bool operator!=(const XYZEval<T> &rs) const { return !operator==(rs); }
FI XYZval<T> operator-() { XYZval<T> o = *this; o.x = -x; o.y = -y; o.z = -z; return o; }
FI const XYZval<T> operator-() const { XYZval<T> o = *this; o.x = -x; o.y = -y; o.z = -z; return o; }
};
//
// XYZE coordinates, counters, etc.
//
template<typename T>
struct XYZEval {
union {
struct{ T x, y, z, e; };
struct{ T a, b, c; };
T pos[4];
};
FI void reset() { x = y = z = e = 0; }
FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z + e*e); }
FI operator T* () { return pos; }
FI operator bool() { return e || z || x || y; }
FI void set(const T px) { x = px; }
FI void set(const T px, const T py) { x = px; y = py; }
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
FI void set(const T px, const T py, const T pz, const T pe) { x = px; y = py; z = pz; e = pe; }
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; }
FI void set(const XYZval<T> pxyz) { x = pxyz.x; y = pxyz.y; z = pxyz.z; }
FI void set(const XYval<T> pxy, const T pz, const T pe) { x = pxy.x; y = pxy.y; z = pz; e = pe; }
FI void set(const XYval<T> pxy, const XYval<T> pze) { x = pxy.x; y = pxy.y; z = pze.z; e = pze.e; }
FI void set(const XYZval<T> pxyz, const T pe) { x = pxyz.x; y = pxyz.y; z = pxyz.z; e = pe; }
FI XYZEval<T> copy() const { return *this; }
FI XYZEval<T> ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(e)) }; }
FI XYZEval<int16_t> asInt() { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; }
FI XYZEval<int16_t> asInt() const { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; }
FI XYZEval<int32_t> asLong() const { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; }
FI XYZEval<int32_t> asLong() { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; }
FI XYZEval<float> asFloat() { return { float(x), float(y), float(z), float(e) }; }
FI XYZEval<float> asFloat() const { return { float(x), float(y), float(z), float(e) }; }
FI XYZEval<float> reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(e) }; }
FI XYZEval<float> asLogical() const { XYZEval<float> o = asFloat(); toLogical(o); return o; }
FI XYZEval<float> asNative() const { XYZEval<float> o = asFloat(); toNative(o); return o; }
FI operator XYval<T>&() { return *(XYval<T>*)this; }
FI operator const XYval<T>&() const { return *(const XYval<T>*)this; }
FI operator XYZval<T>&() { return *(XYZval<T>*)this; }
FI operator const XYZval<T>&() const { return *(const XYZval<T>*)this; }
FI T& operator[](const int i) { return pos[i]; }
FI const T& operator[](const int i) const { return pos[i]; }
FI XYZEval<T>& operator= (const T v) { set(v, v, v, v); return *this; }
FI XYZEval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y); return *this; }
FI XYZEval<T>& operator= (const XYZval<T> &rs) { set(rs.x, rs.y, rs.z); return *this; }
FI XYZEval<T> operator+ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYZEval<T> operator+ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
FI XYZEval<T> operator- (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYZEval<T> operator- (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
FI XYZEval<T> operator* (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYZEval<T> operator* (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
FI XYZEval<T> operator/ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYZEval<T> operator/ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
FI XYZEval<T> operator+ (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
FI XYZEval<T> operator+ (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
FI XYZEval<T> operator- (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
FI XYZEval<T> operator- (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
FI XYZEval<T> operator* (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
FI XYZEval<T> operator* (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
FI XYZEval<T> operator/ (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
FI XYZEval<T> operator/ (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
FI XYZEval<T> operator+ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; }
FI XYZEval<T> operator+ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; }
FI XYZEval<T> operator- (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; }
FI XYZEval<T> operator- (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; }
FI XYZEval<T> operator* (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; }
FI XYZEval<T> operator* (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; }
FI XYZEval<T> operator/ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; }
FI XYZEval<T> operator/ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; }
FI XYZEval<T> operator* (const float &v) const { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
FI XYZEval<T> operator* (const float &v) { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
FI XYZEval<T> operator* (const int &v) const { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
FI XYZEval<T> operator* (const int &v) { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
FI XYZEval<T> operator/ (const float &v) const { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
FI XYZEval<T> operator/ (const float &v) { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
FI XYZEval<T> operator/ (const int &v) const { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
FI XYZEval<T> operator/ (const int &v) { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
FI XYZEval<T> operator>>(const int &v) const { XYZEval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; }
FI XYZEval<T> operator>>(const int &v) { XYZEval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; }
FI XYZEval<T> operator<<(const int &v) const { XYZEval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; }
FI XYZEval<T> operator<<(const int &v) { XYZEval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; }
FI XYZEval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
FI XYZEval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
FI XYZEval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
FI XYZEval<T>& operator/=(const XYval<T> &rs) { x /= rs.x; y /= rs.y; return *this; }
FI XYZEval<T>& operator+=(const XYZval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; }
FI XYZEval<T>& operator-=(const XYZval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; }
FI XYZEval<T>& operator*=(const XYZval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; }
FI XYZEval<T>& operator/=(const XYZval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; }
FI XYZEval<T>& operator+=(const XYZEval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; e += rs.e; return *this; }
FI XYZEval<T>& operator-=(const XYZEval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; e -= rs.e; return *this; }
FI XYZEval<T>& operator*=(const XYZEval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; e *= rs.e; return *this; }
FI XYZEval<T>& operator/=(const XYZEval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; e /= rs.e; return *this; }
FI XYZEval<T>& operator*=(const T &v) { x *= v; y *= v; z *= v; e *= v; return *this; }
FI XYZEval<T>& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); _RS(e); return *this; }
FI XYZEval<T>& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); _LS(e); return *this; }
FI bool operator==(const XYZval<T> &rs) { return x == rs.x && y == rs.y && z == rs.z; }
FI bool operator!=(const XYZval<T> &rs) { return !operator==(rs); }
FI bool operator==(const XYZval<T> &rs) const { return x == rs.x && y == rs.y && z == rs.z; }
FI bool operator!=(const XYZval<T> &rs) const { return !operator==(rs); }
FI XYZEval<T> operator-() { return { -x, -y, -z, -e }; }
FI const XYZEval<T> operator-() const { return { -x, -y, -z, -e }; }
};
#undef _RECIP
#undef _ABS
#undef _LS
#undef _RS
#undef FI
const xyze_char_t axis_codes { 'X', 'Y', 'Z', 'E' };
+20 -30
View File
@@ -79,36 +79,36 @@ void safe_delay(millis_t ms) {
);
#if HAS_BED_PROBE
SERIAL_ECHOPAIR("Probe Offset X:", zprobe_offset[X_AXIS], " Y:", zprobe_offset[Y_AXIS], " Z:", zprobe_offset[Z_AXIS]);
if (zprobe_offset[X_AXIS] > 0)
SERIAL_ECHOPAIR("Probe Offset X", probe_offset.x, " Y", probe_offset.y, " Z", probe_offset.z);
if (probe_offset.x > 0)
SERIAL_ECHOPGM(" (Right");
else if (zprobe_offset[X_AXIS] < 0)
else if (probe_offset.x < 0)
SERIAL_ECHOPGM(" (Left");
else if (zprobe_offset[Y_AXIS] != 0)
else if (probe_offset.y != 0)
SERIAL_ECHOPGM(" (Middle");
else
SERIAL_ECHOPGM(" (Aligned With");
if (zprobe_offset[Y_AXIS] > 0) {
if (probe_offset.y > 0) {
#if IS_SCARA
SERIAL_ECHOPGM("-Distal");
#else
SERIAL_ECHOPGM("-Back");
#endif
}
else if (zprobe_offset[Y_AXIS] < 0) {
else if (probe_offset.y < 0) {
#if IS_SCARA
SERIAL_ECHOPGM("-Proximal");
#else
SERIAL_ECHOPGM("-Front");
#endif
}
else if (zprobe_offset[X_AXIS] != 0)
else if (probe_offset.x != 0)
SERIAL_ECHOPGM("-Center");
if (zprobe_offset[Z_AXIS] < 0)
if (probe_offset.z < 0)
SERIAL_ECHOPGM(" & Below");
else if (zprobe_offset[Z_AXIS] > 0)
else if (probe_offset.z > 0)
SERIAL_ECHOPGM(" & Above");
else
SERIAL_ECHOPGM(" & Same Z as");
@@ -134,24 +134,18 @@ void safe_delay(millis_t ms) {
SERIAL_ECHOLNPAIR("Z Fade: ", planner.z_fade_height);
#endif
#if ABL_PLANAR
const float diff[XYZ] = {
planner.get_axis_position_mm(X_AXIS) - current_position[X_AXIS],
planner.get_axis_position_mm(Y_AXIS) - current_position[Y_AXIS],
planner.get_axis_position_mm(Z_AXIS) - current_position[Z_AXIS]
};
SERIAL_ECHOPGM("ABL Adjustment X");
if (diff[X_AXIS] > 0) SERIAL_CHAR('+');
SERIAL_ECHO(diff[X_AXIS]);
SERIAL_ECHOPGM(" Y");
if (diff[Y_AXIS] > 0) SERIAL_CHAR('+');
SERIAL_ECHO(diff[Y_AXIS]);
SERIAL_ECHOPGM(" Z");
if (diff[Z_AXIS] > 0) SERIAL_CHAR('+');
SERIAL_ECHO(diff[Z_AXIS]);
LOOP_XYZ(a) {
float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
SERIAL_CHAR(' ');
SERIAL_CHAR('X' + char(a));
if (v > 0) SERIAL_CHAR('+');
SERIAL_ECHO(v);
}
#else
#if ENABLED(AUTO_BED_LEVELING_UBL)
SERIAL_ECHOPGM("UBL Adjustment Z");
const float rz = ubl.get_z_correction(current_position[X_AXIS], current_position[Y_AXIS]);
const float rz = ubl.get_z_correction(current_position);
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
SERIAL_ECHOPGM("ABL Adjustment Z");
const float rz = bilinear_z_offset(current_position);
@@ -159,7 +153,7 @@ void safe_delay(millis_t ms) {
SERIAL_ECHO(ftostr43sign(rz, '+'));
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
if (planner.z_fade_height) {
SERIAL_ECHOPAIR(" (", ftostr43sign(rz * planner.fade_scaling_factor_for_z(current_position[Z_AXIS]), '+'));
SERIAL_ECHOPAIR(" (", ftostr43sign(rz * planner.fade_scaling_factor_for_z(current_position.z), '+'));
SERIAL_CHAR(')');
}
#endif
@@ -175,15 +169,11 @@ void safe_delay(millis_t ms) {
SERIAL_ECHOPGM("Mesh Bed Leveling");
if (planner.leveling_active) {
SERIAL_ECHOLNPGM(" (enabled)");
SERIAL_ECHOPAIR("MBL Adjustment Z", ftostr43sign(mbl.get_z(current_position[X_AXIS], current_position[Y_AXIS]
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, 1.0
#endif
), '+'));
SERIAL_ECHOPAIR("MBL Adjustment Z", ftostr43sign(mbl.get_z(current_position), '+'));
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
if (planner.z_fade_height) {
SERIAL_ECHOPAIR(" (", ftostr43sign(
mbl.get_z(current_position[X_AXIS], current_position[Y_AXIS], planner.fade_scaling_factor_for_z(current_position[Z_AXIS])), '+'
mbl.get_z(current_position, planner.fade_scaling_factor_for_z(current_position.z)), '+'
));
SERIAL_CHAR(')');
}
+21 -7
View File
@@ -22,8 +22,7 @@
#pragma once
#include "../inc/MarlinConfigPre.h"
constexpr char axis_codes[XYZE] = { 'X', 'Y', 'Z', 'E' };
#include "../core/types.h"
// Delay that ensures heaters and watchdog are kept alive
void safe_delay(millis_t ms);
@@ -37,10 +36,25 @@ inline void serial_delay(const millis_t ms) {
#endif
}
// 16x16 bit arrays
FORCE_INLINE void bitmap_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
FORCE_INLINE void bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
FORCE_INLINE bool is_bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
#if GRID_MAX_POINTS_X && GRID_MAX_POINTS_Y
// 16x16 bit arrays
template <int W, int H>
struct FlagBits {
typename IF<(W>8), uint16_t, uint8_t>::type bits[H];
void fill() { memset(bits, 0xFF, sizeof(bits)); }
void reset() { memset(bits, 0x00, sizeof(bits)); }
void unmark(const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
void mark(const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
bool marked(const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
inline void unmark(const xy_int8_t &xy) { unmark(xy.y, xy.x); }
inline void mark(const xy_int8_t &xy) { mark(xy.y, xy.x); }
inline bool marked(const xy_int8_t &xy) { return marked(xy.y, xy.x); }
};
typedef FlagBits<GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y> MeshFlags;
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
void log_machine_info();
@@ -59,7 +73,7 @@ public:
inline void restore() { ref_ = val_; }
};
#define REMEMBER(N,X, ...) const restorer<typeof(X)> restorer_##N(X, ##__VA_ARGS__)
#define REMEMBER(N,X,V...) const restorer<typeof(X)> restorer_##N(X, ##V)
#define RESTORE(N) restorer_##N.restore()
// Converts from an uint8_t in the range of 0-255 to an uint8_t
+20 -25
View File
@@ -326,25 +326,23 @@ bool I2CPositionEncoder::test_axis() {
//only works on XYZ cartesian machines for the time being
if (!(encoderAxis == X_AXIS || encoderAxis == Y_AXIS || encoderAxis == Z_AXIS)) return false;
float startCoord[NUM_AXIS] = { 0 }, endCoord[NUM_AXIS] = { 0 };
const float startPosition = soft_endstop[encoderAxis].min + 10,
endPosition = soft_endstop[encoderAxis].max - 10,
feedrate = FLOOR(MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY));
const float startPosition = soft_endstop.min[encoderAxis] + 10,
endPosition = soft_endstop.max[encoderAxis] - 10;
const feedRate_t fr_mm_s = FLOOR(MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY));
ec = false;
LOOP_XYZ(i) {
startCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
endCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
xyze_pos_t startCoord, endCoord;
LOOP_XYZ(a) {
startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
}
startCoord[encoderAxis] = startPosition;
endCoord[encoderAxis] = endPosition;
planner.synchronize();
planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
planner.get_axis_position_mm(E_AXIS), feedrate, 0);
startCoord.e = planner.get_axis_position_mm(E_AXIS);
planner.buffer_line(startCoord, fr_mm_s, 0);
planner.synchronize();
// if the module isn't currently trusted, wait until it is (or until it should be if things are working)
@@ -355,8 +353,8 @@ bool I2CPositionEncoder::test_axis() {
}
if (trusted) { // if trusted, commence test
planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
planner.get_axis_position_mm(E_AXIS), feedrate, 0);
endCoord.e = planner.get_axis_position_mm(E_AXIS);
planner.buffer_line(endCoord, fr_mm_s, 0);
planner.synchronize();
}
@@ -376,44 +374,41 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
float old_steps_mm, new_steps_mm,
startDistance, endDistance,
travelDistance, travelledDistance, total = 0,
startCoord[NUM_AXIS] = { 0 }, endCoord[NUM_AXIS] = { 0 };
float feedrate;
travelDistance, travelledDistance, total = 0;
int32_t startCount, stopCount;
feedrate = MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY);
const feedRate_t fr_mm_s = MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY);
bool oldec = ec;
ec = false;
startDistance = 20;
endDistance = soft_endstop[encoderAxis].max - 20;
endDistance = soft_endstop.max[encoderAxis] - 20;
travelDistance = endDistance - startDistance;
xyze_pos_t startCoord, endCoord;
LOOP_XYZ(a) {
startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
}
startCoord[encoderAxis] = startDistance;
endCoord[encoderAxis] = endDistance;
planner.synchronize();
LOOP_L_N(i, iter) {
planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
planner.get_axis_position_mm(E_AXIS), feedrate, 0);
startCoord.e = planner.get_axis_position_mm(E_AXIS);
planner.buffer_line(startCoord, fr_mm_s, 0);
planner.synchronize();
delay(250);
startCount = get_position();
//do_blocking_move_to(endCoord[X_AXIS],endCoord[Y_AXIS],endCoord[Z_AXIS]);
//do_blocking_move_to(endCoord);
planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
planner.get_axis_position_mm(E_AXIS), feedrate, 0);
endCoord.e = planner.get_axis_position_mm(E_AXIS);
planner.buffer_line(endCoord, fr_mm_s, 0);
planner.synchronize();
//Read encoder distance
-2
View File
@@ -93,8 +93,6 @@
#define LOOP_PE(VAR) LOOP_L_N(VAR, I2CPE_ENCODER_CNT)
#define CHECK_IDX() do{ if (!WITHIN(idx, 0, I2CPE_ENCODER_CNT - 1)) return; }while(0)
extern const char axis_codes[XYZE];
typedef union {
volatile int32_t val = 0;
uint8_t bval[4];
+1 -1
View File
@@ -75,7 +75,7 @@ class Max7219 {
public:
static uint8_t led_line[MAX7219_LINES];
Max7219() { }
Max7219() {}
static void init();
static void register_setup();
+6 -11
View File
@@ -36,13 +36,10 @@
Babystep babystep;
volatile int16_t Babystep::steps[BS_TODO_AXIS(Z_AXIS) + 1];
#if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)
int16_t Babystep::accum;
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
#endif
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
#endif
int16_t Babystep::accum;
void Babystep::step_axis(const AxisEnum axis) {
const int16_t curTodo = steps[BS_TODO_AXIS(axis)]; // get rid of volatile for performance
@@ -75,11 +72,9 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
if (!CAN_BABYSTEP(axis)) return;
#if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)
accum += distance; // Count up babysteps for the UI
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
axis_total[BS_TOTAL_AXIS(axis)] += distance;
#endif
accum += distance; // Count up babysteps for the UI
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
axis_total[BS_TOTAL_AXIS(axis)] += distance;
#endif
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
+11 -16
View File
@@ -29,7 +29,7 @@
#define BS_TODO_AXIS(A) 0
#endif
#if (HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)) && ENABLED(BABYSTEP_DISPLAY_TOTAL)
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
#if ENABLED(BABYSTEP_XY)
#define BS_TOTAL_AXIS(A) A
#else
@@ -40,22 +40,17 @@
class Babystep {
public:
static volatile int16_t steps[BS_TODO_AXIS(Z_AXIS) + 1];
static int16_t accum; // Total babysteps in current edit
#if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)
static int16_t accum; // Total babysteps in current edit
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28
static inline void reset_total(const AxisEnum axis) {
if (true
#if ENABLED(BABYSTEP_XY)
&& axis == Z_AXIS
#endif
) axis_total[BS_TOTAL_AXIS(axis)] = 0;
}
#endif
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28
static inline void reset_total(const AxisEnum axis) {
if (true
#if ENABLED(BABYSTEP_XY)
&& axis == Z_AXIS
#endif
) axis_total[BS_TOTAL_AXIS(axis)] = 0;
}
#endif
static void add_steps(const AxisEnum axis, const int16_t distance);
+12 -12
View File
@@ -31,9 +31,9 @@
#ifdef BACKLASH_DISTANCE_MM
#if ENABLED(BACKLASH_GCODE)
float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
xyz_float_t Backlash::distance_mm = BACKLASH_DISTANCE_MM;
#else
const float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
const xyz_float_t Backlash::distance_mm = BACKLASH_DISTANCE_MM;
#endif
#endif
@@ -45,8 +45,8 @@
#endif
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
float Backlash::measured_mm[XYZ] = { 0 };
uint8_t Backlash::measured_count[XYZ] = { 0 };
xyz_float_t Backlash::measured_mm{0};
xyz_uint8_t Backlash::measured_count{0};
#endif
Backlash backlash;
@@ -80,12 +80,12 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
// Residual error carried forward across multiple segments, so correction can be applied
// to segments where there is no direction change.
static int32_t residual_error[XYZ] = { 0 };
static xyz_long_t residual_error{0};
#else
// No direction change, no correction.
if (!changed_dir) return;
// No leftover residual error from segment to segment
int32_t residual_error[XYZ] = { 0 };
xyz_long_t residual_error{0};
#endif
const float f_corr = float(correction) / 255.0f;
@@ -131,15 +131,15 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
// Measure Z backlash by raising nozzle in increments until probe deactivates
void Backlash::measure_with_probe() {
if (measured_count[Z_AXIS] == 255) return;
if (measured_count.z == 255) return;
float start_height = current_position[Z_AXIS];
while (current_position[Z_AXIS] < (start_height + BACKLASH_MEASUREMENT_LIMIT) && TEST_PROBE_PIN)
do_blocking_move_to_z(current_position[Z_AXIS] + BACKLASH_MEASUREMENT_RESOLUTION, MMM_TO_MMS(BACKLASH_MEASUREMENT_FEEDRATE));
const float start_height = current_position.z;
while (current_position.z < (start_height + BACKLASH_MEASUREMENT_LIMIT) && TEST_PROBE_PIN)
do_blocking_move_to_z(current_position.z + BACKLASH_MEASUREMENT_RESOLUTION, MMM_TO_MMS(BACKLASH_MEASUREMENT_FEEDRATE));
// The backlash from all probe points is averaged, so count the number of measurements
measured_mm[Z_AXIS] += current_position[Z_AXIS] - start_height;
measured_count[Z_AXIS]++;
measured_mm.z += current_position.z - start_height;
measured_count.z++;
}
#endif
+4 -4
View File
@@ -29,7 +29,7 @@ constexpr uint8_t all_on = 0xFF, all_off = 0x00;
class Backlash {
public:
#if ENABLED(BACKLASH_GCODE)
static float distance_mm[XYZ];
static xyz_float_t distance_mm;
static uint8_t correction;
#ifdef BACKLASH_SMOOTHING_MM
static float smoothing_mm;
@@ -39,7 +39,7 @@ public:
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
#else
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
static const float distance_mm[XYZ];
static const xyz_float_t distance_mm;
#ifdef BACKLASH_SMOOTHING_MM
static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
#endif
@@ -47,8 +47,8 @@ public:
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
private:
static float measured_mm[XYZ];
static uint8_t measured_count[XYZ];
static xyz_float_t measured_mm;
static xyz_uint8_t measured_count;
public:
static void measure_with_probe();
#endif
+83 -89
View File
@@ -35,9 +35,9 @@
#include "../../../lcd/extensible_ui/ui_api.h"
#endif
int bilinear_grid_spacing[2], bilinear_start[2];
float bilinear_grid_factor[2],
z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
xy_int_t bilinear_grid_spacing, bilinear_start;
xy_float_t bilinear_grid_factor;
bed_mesh_t z_values;
/**
* Extrapolate a single point from its neighbors
@@ -153,8 +153,8 @@ void print_bilinear_leveling_grid() {
#define ABL_TEMP_POINTS_X (GRID_MAX_POINTS_X + 2)
#define ABL_TEMP_POINTS_Y (GRID_MAX_POINTS_Y + 2)
float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y];
int bilinear_grid_spacing_virt[2] = { 0 };
float bilinear_grid_factor_virt[2] = { 0 };
xy_int_t bilinear_grid_spacing_virt;
xy_float_t bilinear_grid_factor_virt;
void print_bilinear_leveling_grid_virt() {
SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:");
@@ -207,7 +207,7 @@ void print_bilinear_leveling_grid() {
+ p[i] * (2 - 5 * sq(t) + 3 * t * sq(t))
+ p[i+1] * t * (1 + 4 * t - 3 * sq(t))
- p[i+2] * sq(t) * (1 - t)
) * 0.5;
) * 0.5f;
}
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const float &tx, const float &ty) {
@@ -222,10 +222,8 @@ void print_bilinear_leveling_grid() {
}
void bed_level_virt_interpolate() {
bilinear_grid_spacing_virt[X_AXIS] = bilinear_grid_spacing[X_AXIS] / (BILINEAR_SUBDIVISIONS);
bilinear_grid_spacing_virt[Y_AXIS] = bilinear_grid_spacing[Y_AXIS] / (BILINEAR_SUBDIVISIONS);
bilinear_grid_factor_virt[X_AXIS] = RECIPROCAL(bilinear_grid_spacing_virt[X_AXIS]);
bilinear_grid_factor_virt[Y_AXIS] = RECIPROCAL(bilinear_grid_spacing_virt[Y_AXIS]);
bilinear_grid_spacing_virt = bilinear_grid_spacing / (BILINEAR_SUBDIVISIONS);
bilinear_grid_factor_virt = bilinear_grid_spacing_virt.reciprocal();
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t ty = 0; ty < BILINEAR_SUBDIVISIONS; ty++)
@@ -245,40 +243,38 @@ void print_bilinear_leveling_grid() {
// Refresh after other values have been updated
void refresh_bed_level() {
bilinear_grid_factor[X_AXIS] = RECIPROCAL(bilinear_grid_spacing[X_AXIS]);
bilinear_grid_factor[Y_AXIS] = RECIPROCAL(bilinear_grid_spacing[Y_AXIS]);
bilinear_grid_factor = bilinear_grid_spacing.reciprocal();
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
bed_level_virt_interpolate();
#endif
}
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
#define ABL_BG_SPACING(A) bilinear_grid_spacing_virt[A]
#define ABL_BG_FACTOR(A) bilinear_grid_factor_virt[A]
#define ABL_BG_SPACING(A) bilinear_grid_spacing_virt.A
#define ABL_BG_FACTOR(A) bilinear_grid_factor_virt.A
#define ABL_BG_POINTS_X ABL_GRID_POINTS_VIRT_X
#define ABL_BG_POINTS_Y ABL_GRID_POINTS_VIRT_Y
#define ABL_BG_GRID(X,Y) z_values_virt[X][Y]
#else
#define ABL_BG_SPACING(A) bilinear_grid_spacing[A]
#define ABL_BG_FACTOR(A) bilinear_grid_factor[A]
#define ABL_BG_SPACING(A) bilinear_grid_spacing.A
#define ABL_BG_FACTOR(A) bilinear_grid_factor.A
#define ABL_BG_POINTS_X GRID_MAX_POINTS_X
#define ABL_BG_POINTS_Y GRID_MAX_POINTS_Y
#define ABL_BG_GRID(X,Y) z_values[X][Y]
#endif
// Get the Z adjustment for non-linear bed leveling
float bilinear_z_offset(const float raw[XYZ]) {
float bilinear_z_offset(const xy_pos_t &raw) {
static float z1, d2, z3, d4, L, D, ratio_x, ratio_y,
last_x = -999.999, last_y = -999.999;
static float z1, d2, z3, d4, L, D;
static xy_pos_t prev { -999.999, -999.999 }, ratio;
// Whole units for the grid line indices. Constrained within bounds.
static int8_t gridx, gridy, nextx, nexty,
last_gridx = -99, last_gridy = -99;
static xy_int8_t thisg, nextg, lastg { -99, -99 };
// XY relative to the probed area
const float rx = raw[X_AXIS] - bilinear_start[X_AXIS],
ry = raw[Y_AXIS] - bilinear_start[Y_AXIS];
xy_pos_t rel = raw - bilinear_start.asFloat();
#if ENABLED(EXTRAPOLATE_BEYOND_GRID)
#define FAR_EDGE_OR_BOX 2 // Keep using the last grid box
@@ -286,63 +282,62 @@ float bilinear_z_offset(const float raw[XYZ]) {
#define FAR_EDGE_OR_BOX 1 // Just use the grid far edge
#endif
if (last_x != rx) {
last_x = rx;
ratio_x = rx * ABL_BG_FACTOR(X_AXIS);
const float gx = constrain(FLOOR(ratio_x), 0, ABL_BG_POINTS_X - (FAR_EDGE_OR_BOX));
ratio_x -= gx; // Subtract whole to get the ratio within the grid box
if (prev.x != rel.x) {
prev.x = rel.x;
ratio.x = rel.x * ABL_BG_FACTOR(x);
const float gx = constrain(FLOOR(ratio.x), 0, ABL_BG_POINTS_X - (FAR_EDGE_OR_BOX));
ratio.x -= gx; // Subtract whole to get the ratio within the grid box
#if DISABLED(EXTRAPOLATE_BEYOND_GRID)
// Beyond the grid maintain height at grid edges
NOLESS(ratio_x, 0); // Never < 0.0. (> 1.0 is ok when nextx==gridx.)
NOLESS(ratio.x, 0); // Never <0 (>1 is ok when nextg.x==thisg.x)
#endif
gridx = gx;
nextx = _MIN(gridx + 1, ABL_BG_POINTS_X - 1);
thisg.x = gx;
nextg.x = _MIN(thisg.x + 1, ABL_BG_POINTS_X - 1);
}
if (last_y != ry || last_gridx != gridx) {
if (prev.y != rel.y || lastg.x != thisg.x) {
if (last_y != ry) {
last_y = ry;
ratio_y = ry * ABL_BG_FACTOR(Y_AXIS);
const float gy = constrain(FLOOR(ratio_y), 0, ABL_BG_POINTS_Y - (FAR_EDGE_OR_BOX));
ratio_y -= gy;
if (prev.y != rel.y) {
prev.y = rel.y;
ratio.y = rel.y * ABL_BG_FACTOR(y);
const float gy = constrain(FLOOR(ratio.y), 0, ABL_BG_POINTS_Y - (FAR_EDGE_OR_BOX));
ratio.y -= gy;
#if DISABLED(EXTRAPOLATE_BEYOND_GRID)
// Beyond the grid maintain height at grid edges
NOLESS(ratio_y, 0); // Never < 0.0. (> 1.0 is ok when nexty==gridy.)
NOLESS(ratio.y, 0); // Never < 0.0. (> 1.0 is ok when nextg.y==thisg.y.)
#endif
gridy = gy;
nexty = _MIN(gridy + 1, ABL_BG_POINTS_Y - 1);
thisg.y = gy;
nextg.y = _MIN(thisg.y + 1, ABL_BG_POINTS_Y - 1);
}
if (last_gridx != gridx || last_gridy != gridy) {
last_gridx = gridx;
last_gridy = gridy;
if (lastg != thisg) {
lastg = thisg;
// Z at the box corners
z1 = ABL_BG_GRID(gridx, gridy); // left-front
d2 = ABL_BG_GRID(gridx, nexty) - z1; // left-back (delta)
z3 = ABL_BG_GRID(nextx, gridy); // right-front
d4 = ABL_BG_GRID(nextx, nexty) - z3; // right-back (delta)
z1 = ABL_BG_GRID(thisg.x, thisg.y); // left-front
d2 = ABL_BG_GRID(thisg.x, nextg.y) - z1; // left-back (delta)
z3 = ABL_BG_GRID(nextg.x, thisg.y); // right-front
d4 = ABL_BG_GRID(nextg.x, nextg.y) - z3; // right-back (delta)
}
// Bilinear interpolate. Needed since ry or gridx has changed.
L = z1 + d2 * ratio_y; // Linear interp. LF -> LB
const float R = z3 + d4 * ratio_y; // Linear interp. RF -> RB
// Bilinear interpolate. Needed since rel.y or thisg.x has changed.
L = z1 + d2 * ratio.y; // Linear interp. LF -> LB
const float R = z3 + d4 * ratio.y; // Linear interp. RF -> RB
D = R - L;
}
const float offset = L + ratio_x * D; // the offset almost always changes
const float offset = L + ratio.x * D; // the offset almost always changes
/*
static float last_offset = 0;
if (ABS(last_offset - offset) > 0.2) {
SERIAL_ECHOLNPAIR("Sudden Shift at x=", rx, " / ", bilinear_grid_spacing[X_AXIS], " -> gridx=", gridx);
SERIAL_ECHOLNPAIR(" y=", ry, " / ", bilinear_grid_spacing[Y_AXIS], " -> gridy=", gridy);
SERIAL_ECHOLNPAIR(" ratio_x=", ratio_x, " ratio_y=", ratio_y);
SERIAL_ECHOLNPAIR("Sudden Shift at x=", rel.x, " / ", bilinear_grid_spacing.x, " -> thisg.x=", thisg.x);
SERIAL_ECHOLNPAIR(" y=", rel.y, " / ", bilinear_grid_spacing.y, " -> thisg.y=", thisg.y);
SERIAL_ECHOLNPAIR(" ratio.x=", ratio.x, " ratio.y=", ratio.y);
SERIAL_ECHOLNPAIR(" z1=", z1, " z2=", z2, " z3=", z3, " z4=", z4);
SERIAL_ECHOLNPAIR(" L=", L, " R=", R, " offset=", offset);
}
@@ -354,71 +349,70 @@ float bilinear_z_offset(const float raw[XYZ]) {
#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
#define CELL_INDEX(A,V) ((V - bilinear_start[_AXIS(A)]) * ABL_BG_FACTOR(_AXIS(A)))
#define CELL_INDEX(A,V) ((V - bilinear_start.A) * ABL_BG_FACTOR(A))
/**
* Prepare a bilinear-leveled linear move on Cartesian,
* splitting the move where it crosses grid borders.
*/
void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits, uint16_t y_splits) {
void bilinear_line_to_destination(const feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) {
// Get current and destination cells for this line
int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
cx2 = CELL_INDEX(X, destination[X_AXIS]),
cy2 = CELL_INDEX(Y, destination[Y_AXIS]);
LIMIT(cx1, 0, ABL_BG_POINTS_X - 2);
LIMIT(cy1, 0, ABL_BG_POINTS_Y - 2);
LIMIT(cx2, 0, ABL_BG_POINTS_X - 2);
LIMIT(cy2, 0, ABL_BG_POINTS_Y - 2);
xy_int_t c1 { CELL_INDEX(x, current_position.x), CELL_INDEX(y, current_position.y) },
c2 { CELL_INDEX(x, destination.x), CELL_INDEX(y, destination.y) };
LIMIT(c1.x, 0, ABL_BG_POINTS_X - 2);
LIMIT(c1.y, 0, ABL_BG_POINTS_Y - 2);
LIMIT(c2.x, 0, ABL_BG_POINTS_X - 2);
LIMIT(c2.y, 0, ABL_BG_POINTS_Y - 2);
// Start and end in the same cell? No split needed.
if (cx1 == cx2 && cy1 == cy2) {
buffer_line_to_destination(fr_mm_s);
set_current_from_destination();
if (c1 == c2) {
current_position = destination;
line_to_current_position(scaled_fr_mm_s);
return;
}
#define LINE_SEGMENT_END(A) (current_position[_AXIS(A)] + (destination[_AXIS(A)] - current_position[_AXIS(A)]) * normalized_dist)
#define LINE_SEGMENT_END(A) (current_position.A + (destination.A - current_position.A) * normalized_dist)
float normalized_dist, end[XYZE];
const int8_t gcx = _MAX(cx1, cx2), gcy = _MAX(cy1, cy2);
float normalized_dist;
xyze_pos_t end;
const xy_int8_t gc { _MAX(c1.x, c2.x), _MAX(c1.y, c2.y) };
// Crosses on the X and not already split on this X?
// The x_splits flags are insurance against rounding errors.
if (cx2 != cx1 && TEST(x_splits, gcx)) {
if (c2.x != c1.x && TEST(x_splits, gc.x)) {
// Split on the X grid line
CBI(x_splits, gcx);
COPY(end, destination);
destination[X_AXIS] = bilinear_start[X_AXIS] + ABL_BG_SPACING(X_AXIS) * gcx;
normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
destination[Y_AXIS] = LINE_SEGMENT_END(Y);
CBI(x_splits, gc.x);
end = destination;
destination.x = bilinear_start.x + ABL_BG_SPACING(x) * gc.x;
normalized_dist = (destination.x - current_position.x) / (end.x - current_position.x);
destination.y = LINE_SEGMENT_END(y);
}
// Crosses on the Y and not already split on this Y?
else if (cy2 != cy1 && TEST(y_splits, gcy)) {
else if (c2.y != c1.y && TEST(y_splits, gc.y)) {
// Split on the Y grid line
CBI(y_splits, gcy);
COPY(end, destination);
destination[Y_AXIS] = bilinear_start[Y_AXIS] + ABL_BG_SPACING(Y_AXIS) * gcy;
normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
destination[X_AXIS] = LINE_SEGMENT_END(X);
CBI(y_splits, gc.y);
end = destination;
destination.y = bilinear_start.y + ABL_BG_SPACING(y) * gc.y;
normalized_dist = (destination.y - current_position.y) / (end.y - current_position.y);
destination.x = LINE_SEGMENT_END(x);
}
else {
// Must already have been split on these border(s)
// This should be a rare case.
buffer_line_to_destination(fr_mm_s);
set_current_from_destination();
current_position = destination;
line_to_current_position(scaled_fr_mm_s);
return;
}
destination[Z_AXIS] = LINE_SEGMENT_END(Z);
destination[E_AXIS] = LINE_SEGMENT_END(E);
destination.z = LINE_SEGMENT_END(z);
destination.e = LINE_SEGMENT_END(e);
// Do the split and look for more borders
bilinear_line_to_destination(fr_mm_s, x_splits, y_splits);
bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits);
// Restore destination from stack
COPY(destination, end);
bilinear_line_to_destination(fr_mm_s, x_splits, y_splits);
destination = end;
bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits);
}
#endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES
+7 -7
View File
@@ -23,10 +23,10 @@
#include "../../../inc/MarlinConfigPre.h"
extern int bilinear_grid_spacing[2], bilinear_start[2];
extern float bilinear_grid_factor[2],
z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
float bilinear_z_offset(const float raw[XYZ]);
extern xy_int_t bilinear_grid_spacing, bilinear_start;
extern xy_float_t bilinear_grid_factor;
extern bed_mesh_t z_values;
float bilinear_z_offset(const xy_pos_t &raw);
void extrapolate_unprobed_bed_level();
void print_bilinear_leveling_grid();
@@ -37,9 +37,9 @@ void refresh_bed_level();
#endif
#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF);
void bilinear_line_to_destination(const feedRate_t &scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF);
#endif
#define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS])
#define _GET_MESH_Y(J) (bilinear_start[Y_AXIS] + (J) * bilinear_grid_spacing[Y_AXIS])
#define _GET_MESH_X(I) float(bilinear_start.x + (I) * bilinear_grid_spacing.x)
#define _GET_MESH_Y(J) float(bilinear_start.y + (J) * bilinear_grid_spacing.y)
#define Z_VALUES_ARR z_values

Some files were not shown because too many files have changed in this diff Show More