Skip to content

Commit

Permalink
TMC serial multiplexer, FYSETC AIO-II (MarlinFirmware#18080)
Browse files Browse the repository at this point in the history
  • Loading branch information
GerogeFu authored and HairingX committed Jun 16, 2021
1 parent dd1a7b0 commit 7e0882d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 42 deletions.
4 changes: 4 additions & 0 deletions Marlin/src/feature/tmc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
TMCMarlin(Stream * SerialPort, const float RS, const uint8_t) :
TMC2208Stepper(SerialPort, RS)
{}
TMCMarlin(Stream * SerialPort, const float RS, uint8_t addr, const uint16_t mul_pin1, const uint16_t mul_pin2) :
TMC2208Stepper(SerialPort, RS, addr, mul_pin1, mul_pin2)
{}
TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t, const bool has_rx=true) :
TMC2208Stepper(RX, TX, RS, has_rx)
{}

uint16_t rms_current() { return TMC2208Stepper::rms_current(); }
inline void rms_current(const uint16_t mA) {
this->val_mA = mA;
Expand Down
6 changes: 5 additions & 1 deletion Marlin/src/module/stepper/trinamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#define __TMC_SPI_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_CS_PIN, float(ST##_RSENSE), ST##_CHAIN_POS)
#endif

#define TMC_UART_HW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(&ST##_HARDWARE_SERIAL, float(ST##_RSENSE), ST##_SLAVE_ADDRESS)
#if ENABLED(TMC_SERIAL_MULTIPLEXER)
#define TMC_UART_HW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(&ST##_HARDWARE_SERIAL, float(ST##_RSENSE), ST##_SLAVE_ADDRESS, SERIAL_MUL_PIN1, SERIAL_MUL_PIN2)
#else
#define TMC_UART_HW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(&ST##_HARDWARE_SERIAL, float(ST##_RSENSE), ST##_SLAVE_ADDRESS)
#endif
#define TMC_UART_SW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_SERIAL_RX_PIN, ST##_SERIAL_TX_PIN, float(ST##_RSENSE), ST##_SLAVE_ADDRESS, ST##_SERIAL_RX_PIN > -1)

#define _TMC_SPI_DEFINE(IC, ST, AI) __TMC_SPI_DEFINE(IC, ST, TMC_##ST##_LABEL, AI)
Expand Down
44 changes: 22 additions & 22 deletions Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#define DISABLE_JTAG

#define pins_v2_20190128 // geo-f:add for new pins define
#define pins_v2_20190128 // new pins define

// Ignore temp readings during development.
//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000
Expand Down Expand Up @@ -84,32 +84,32 @@
#define E0_DIR_PIN PC14
#define E0_ENABLE_PIN PC13

#if HAS_TMC220x

/**
* TMC2208/TMC2209 stepper drivers
*/

//
// Hardware serial with switch
//
#define X_HARDWARE_SERIAL Serial1
#define Y_HARDWARE_SERIAL Serial1
#define Z_HARDWARE_SERIAL Serial1
#define E0_HARDWARE_SERIAL Serial1
#define TMC_SERIAL_MULTIPLEXER
#define SERIAL_MUL_PIN1 PB13
#define SERIAL_MUL_PIN2 PB12

#endif

//
// Stepper current PWM
//

// X:PA2 Y:PA3 Z:PB12 E:PB13 // changed for test
//#define MOTOR_CURRENT_PWM_XY_PIN PA3
//#define MOTOR_CURRENT_PWM_Z_PIN PA2 // PB12
//#define MOTOR_CURRENT_PWM_XY_PIN PB6
//#define MOTOR_CURRENT_PWM_Z_PIN PB7 // PB12
//#define MOTOR_CURRENT_PWM_E_PIN -1 // PB13
// Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range
#ifndef MOTOR_CURRENT_PWM_RANGE
#define MOTOR_CURRENT_PWM_RANGE 1500 // geo-f:old 2000
#define MOTOR_CURRENT_PWM_RANGE 1500 // origin:2000
#endif
#define DEFAULT_PWM_MOTOR_CURRENT {500, 500, 400} // geo-f:old 1300 1300 1250

// 采用 SDIO PCB从左到右数
// 1:PC10 - SDIO_D2
// 2:PC11 - SDIO_D3
// 3:PD2 - SDIO_CMD
// 4:VCC
// 5:PC12 - SDIO_CK
// 6:VDD
// 7:PC8 - SDIO_D0
// 8:PC9 - SDIO_D1
// 9:PA15 - SD_DETECT_PIN
#define DEFAULT_PWM_MOTOR_CURRENT { 500, 500, 400 } // origin: {1300,1300,1250}

//
// Heaters / Fans
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void CardReader::manage_media() {
if (stat) { // Media Inserted
safe_delay(500); // Some boards need a delay to get settled
mount(); // Try to mount the media
#if MB(FYSETC_CHEETAH)
#if MB(FYSETC_CHEETAH, FYSETC_AIO_II)
reset_stepper_drivers(); // Workaround for Cheetah bug
#endif
if (!isMounted()) stat = 0; // Not mounted?
Expand Down
22 changes: 4 additions & 18 deletions buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from os.path import expandvars
Import("env", "projenv")

# Relocate firmware from 0x08000000 to 0x08002000
# Relocate firmware from 0x08000000 to 0x08010000
# for define in env['CPPDEFINES']:
# if define[0] == "VECT_TAB_ADDR":
# env['CPPDEFINES'].remove(define)
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))

Expand All @@ -14,14 +17,6 @@
"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
]), "Building $TARGET"))

# please keep $SOURCE variable, it will be replaced with a path to firmware

# Generic
#env.Replace(
# UPLOADER="serial_upload.bat"
# UPLOADCMD="$UPLOADER stm32loader.py $SOURCE"
#)

# In-line command with arguments
UPLOAD_TOOL="stm32flash"
platform = env.PioPlatform()
Expand All @@ -32,12 +27,3 @@
UPLOADER=UPLOAD_TOOL,
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
)

# Python callback
#def on_upload(source, target, env):
# print source, target
# firmware_path = str(source[0])
# # do something
# env.Execute(".\serial_upload.bat")

#env.Replace(UPLOADCMD=on_upload)

0 comments on commit 7e0882d

Please sign in to comment.