Skip to content

Commit

Permalink
Fix and optimize MightyBoard (MarlinFirmware#20493)
Browse files Browse the repository at this point in the history
  • Loading branch information
grauerfuchs authored and thinkyhead committed Apr 29, 2021
1 parent bd0ab8a commit 6f40f6e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@
/**
* I2C-based DIGIPOTs (e.g., Azteeg X3 Pro)
*/
//#define DIGIPOT_MCP4018 // Requires https://github.com/stawel/SlowSoftI2CMaster
//#define DIGIPOT_MCP4018 // Requires https://github.com/felias-fogg/SlowSoftI2CMaster
//#define DIGIPOT_MCP4451
#if EITHER(DIGIPOT_MCP4018, DIGIPOT_MCP4451)
#define DIGIPOT_I2C_NUM_CHANNELS 8 // 5DPRINT:4 AZTEEG_X3_PRO:8 MKS_SBASE:5 MIGHTYBOARD_REVE:5
Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/feature/digipot/digipot_mcp4018.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "digipot.h"

#include <Stream.h>
#include <SlowSoftI2CMaster.h> // https://github.com/stawel/SlowSoftI2CMaster
#include <SlowSoftI2CMaster.h> // https://github.com/felias-fogg/SlowSoftI2CMaster

// Settings for the I2C based DIGIPOT (MCP4018) based on WT150

Expand All @@ -46,21 +46,21 @@ static byte current_to_wiper(const float current) {
}

static SlowSoftI2CMaster pots[DIGIPOT_I2C_NUM_CHANNELS] = {
SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_X, DIGIPOTS_I2C_SCL)
SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_X, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 1
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_Y, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_Y, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 2
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_Z, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_Z, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 3
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E0, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E0, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 4
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E1, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E1, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 5
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E2, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E2, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 6
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E3, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E3, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#if DIGIPOT_I2C_NUM_CHANNELS > 7
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E4, DIGIPOTS_I2C_SCL)
, SlowSoftI2CMaster(DIGIPOTS_I2C_SDA_E4, DIGIPOTS_I2C_SCL, ENABLED(DIGIPOT_ENABLE_I2C_PULLUPS))
#endif
#endif
#endif
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
#ifndef DIGIPOT_I2C_ADDRESS_A
#define DIGIPOT_I2C_ADDRESS_A 0x2F // unshifted slave address (5E <- 2F << 1)
#endif
#define DIGIPOT_ENABLE_I2C_PULLUPS // MightyBoard doesn't have hardware I2C pin pull-ups.

//
// Temperature Sensors
Expand Down
32 changes: 19 additions & 13 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ board = megaatmega2560
[env:mega2560ext]
platform = atmelavr
extends = env:mega2560
board = megaatmega2560
board_build.variant = megaextendedpins
extra_scripts = ${common.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
Expand All @@ -471,24 +470,31 @@ extends = common_avr8
board = megaatmega1280

#
# MightyBoard ATmega2560 (MegaCore 100 pin boards variants)
# MightyBoard AVR with extended pins
#
[mega_extended_optimized]
extends = common_avr8
board_build.variant = megaextendedpins
extra_scripts = ${common.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
upload_speed = 57600
build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues

#
# MightyBoard ATmega1280
#
[env:MightyBoard1280]
platform = atmelavr
extends = common_avr8
board = ATmega1280
upload_speed = 57600
platform = atmelavr
extends = mega_extended_optimized
board = megaatmega1280

#
# MightyBoard ATmega2560 (MegaCore 100 pin boards variants)
# MightyBoard ATmega2560
#
[env:MightyBoard2560]
platform = atmelavr
extends = common_avr8
board = ATmega2560
upload_protocol = wiring
upload_speed = 57600
board_upload.maximum_size = 253952
platform = atmelavr
extends = mega_extended_optimized
board = megaatmega2560

#
# RAMBo
Expand Down

0 comments on commit 6f40f6e

Please sign in to comment.