Skip to content

Commit

Permalink
Merge branch 'bugfix-2.0.x' of https://github.com/MarlinFirmware/Marlin
Browse files Browse the repository at this point in the history
… into bugfix-2.0.x
  • Loading branch information
crysxd committed Sep 15, 2020
2 parents 838b150 + 0b7d69d commit 0a84e0b
Show file tree
Hide file tree
Showing 49 changed files with 523 additions and 425 deletions.
102 changes: 53 additions & 49 deletions Marlin/src/HAL/LPC1768/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
* Some of the LCD interfaces/adapters result in the LCD SPI and the SD card
* SPI sharing pins. The SCK, MOSI & MISO pins can NOT be set/cleared with
* WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
* active. If any of these pins are shared then the software SPI must be used.
* active. If any of these pins are shared then the software SPI must be used.
*
* A more sophisticated hardware SPI can be found at the following link. This
* implementation has not been fully debugged.
* A more sophisticated hardware SPI can be found at the following link.
* This implementation has not been fully debugged.
* https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
*/

Expand Down Expand Up @@ -170,69 +170,74 @@ static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) {
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
}

// Retain the pin init state of the SPI, to avoid init more than once,
// even if more instances of SPIClass exist
static bool spiInitialised[BOARD_NR_SPI] = { false };

SPIClass::SPIClass(uint8_t device) {
// Init things specific to each SPI device
// clock divider setup is a bit of hack, and needs to be improved at a later date.

PINSEL_CFG_Type PinCfg; // data structure to hold init values
#if BOARD_NR_SPI >= 1
_settings[0].spi_d = LPC_SSP0;
_settings[0].dataMode = SPI_MODE0;
_settings[0].dataSize = DATA_SIZE_8BIT;
_settings[0].clock = SPI_CLOCK_MAX;
// _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_SCK_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_SCK_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI1_SCK_PIN);

PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MISO_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MISO_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_INPUT(BOARD_SPI1_MISO_PIN);

PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MOSI_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MOSI_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI1_MOSI_PIN);
//_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
#endif

#if BOARD_NR_SPI >= 2
_settings[1].spi_d = LPC_SSP1;
_settings[1].dataMode = SPI_MODE0;
_settings[1].dataSize = DATA_SIZE_8BIT;
_settings[1].clock = SPI_CLOCK_MAX;
// _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
//_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
#endif

setModule(device);

// Init the GPDMA controller
// TODO: call once in the constructor? or each time?
GPDMA_Init();
}

void SPIClass::begin() {
// Init the SPI pins in the first begin call
if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) ||
(_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false)) {
pin_t sck, miso, mosi;
if (_currentSetting->spi_d == LPC_SSP0) {
sck = BOARD_SPI1_SCK_PIN;
miso = BOARD_SPI1_MISO_PIN;
mosi = BOARD_SPI1_MOSI_PIN;
spiInitialised[0] = true;
}
else if (_currentSetting->spi_d == LPC_SSP1) {
sck = BOARD_SPI2_SCK_PIN;
miso = BOARD_SPI2_MISO_PIN;
mosi = BOARD_SPI2_MOSI_PIN;
spiInitialised[1] = true;
}
PINSEL_CFG_Type PinCfg; // data structure to hold init values
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_SCK_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_SCK_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(sck);
PinCfg.Portnum = LPC176x::pin_port(sck);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI2_SCK_PIN);
SET_OUTPUT(sck);

PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MISO_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MISO_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(miso);
PinCfg.Portnum = LPC176x::pin_port(miso);
PINSEL_ConfigPin(&PinCfg);
SET_INPUT(BOARD_SPI2_MISO_PIN);
SET_INPUT(miso);

PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MOSI_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MOSI_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(mosi);
PinCfg.Portnum = LPC176x::pin_port(mosi);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI2_MOSI_PIN);
#endif

setModule(device);

/* Initialize GPDMA controller */
//TODO: call once in the constructor? or each time?
GPDMA_Init();
}
SET_OUTPUT(mosi);
}

void SPIClass::begin() {
updateSettings();
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
}
Expand All @@ -246,16 +251,15 @@ void SPIClass::beginTransaction(const SPISettings &cfg) {
}

uint8_t SPIClass::transfer(const uint16_t b) {
/* send and receive a single byte */
// Send and receive a single byte
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
SSP_SendData(_currentSetting->spi_d, b);
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
return SSP_ReceiveData(_currentSetting->spi_d);
}

uint16_t SPIClass::transfer16(const uint16_t data) {
return (transfer((data >> 8) & 0xFF) << 8)
| (transfer(data & 0xFF) & 0xFF);
return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF);
}

void SPIClass::end() {
Expand Down Expand Up @@ -294,23 +298,23 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
// Enable dma on SPI
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);

// only increase memory if minc is true
// Only increase memory if minc is true
GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);

// Setup channel with given parameter
GPDMA_Setup(&GPDMACfg);

// enabled dma
// Enable DMA
GPDMA_ChannelCmd(0, ENABLE);

// wait data transfer
// Wait for data transfer
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }

// clear err and int
// Clear err and int
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);

// dma disable
// Disable DMA
GPDMA_ChannelCmd(0, DISABLE);

waitSpiTxEnd(_currentSetting->spi_d);
Expand Down
12 changes: 4 additions & 8 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,18 +977,14 @@ void setup() {
SERIAL_CHAR(' ');
SERIAL_ECHOLNPGM(SHORT_BUILD_VERSION);
SERIAL_EOL();

#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
SERIAL_ECHO_MSG(
STR_CONFIGURATION_VER
STRING_DISTRIBUTION_DATE
STR_AUTHOR STRING_CONFIG_H_AUTHOR
" Last Updated: " STRING_DISTRIBUTION_DATE
" | Author: " STRING_CONFIG_H_AUTHOR
);
SERIAL_ECHO_MSG("Compiled: " __DATE__);
#endif

SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE));
SERIAL_ECHO_MSG("Compiled: " __DATE__);
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE));

// Set up LEDs early
#if HAS_COLOR_LEDS
Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
#define STR_BROWNOUT_RESET " Brown out Reset"
#define STR_WATCHDOG_RESET " Watchdog Reset"
#define STR_SOFTWARE_RESET " Software Reset"
#define STR_AUTHOR " | Author: "
#define STR_CONFIGURATION_VER " Last Updated: "
#define STR_FREE_MEMORY " Free Memory: "
#define STR_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
#define STR_OK "ok"
Expand All @@ -127,7 +125,6 @@
#define STR_INVALID_E_STEPPER "Invalid E stepper"
#define STR_E_STEPPER_NOT_SPECIFIED "E stepper not specified"
#define STR_INVALID_SOLENOID "Invalid solenoid"
#define STR_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
#define STR_COUNT_X " Count X:"
#define STR_COUNT_A " Count A:"
#define STR_WATCHDOG_FIRED "Watchdog timeout. Reset required."
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
// Start the heater idle timers
const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);

HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);

#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
Expand All @@ -503,7 +503,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep

// If the nozzle has timed out...
if (!nozzle_timed_out)
HOTEND_LOOP() nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out;
HOTEND_LOOP() nozzle_timed_out |= thermalManager.heater_idle[e].timed_out;

// Wait for the user to press the button to re-heat the nozzle, then
// re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
Expand Down Expand Up @@ -533,7 +533,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
// Start the heater idle timers
const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);

HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished.")));
wait_for_user = true;
Expand Down Expand Up @@ -588,7 +588,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
// Re-enable the heaters if they timed out
bool nozzle_timed_out = false;
HOTEND_LOOP() {
nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out;
nozzle_timed_out |= thermalManager.heater_idle[e].timed_out;
thermalManager.reset_hotend_idle_timer(e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ void GcodeSuite::M871() {
}

/**
* M872: Wait for probe temperature sensor to reach a target
* M192: Wait for probe temperature sensor to reach a target
*
* Select only one of these flags:
* R - Wait for heating or cooling
* S - Wait only for heating
*/
void GcodeSuite::M872() {
void GcodeSuite::M192() {
if (DEBUGGING(DRYRUN)) return;

const bool no_wait_for_cooling = parser.seenval('S');
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
#endif

#if ENABLED(PROBE_TEMP_COMPENSATION)
case 192: M192(); break; // M192: Wait for probe temp
case 871: M871(); break; // M871: Print/reset/clear first layer temperature offset values
case 872: M872(); break; // M872: Wait for probe temp
#endif

#if ENABLED(LIN_ADVANCE)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
* M868 - Report or set position encoder module error correction threshold.
* M869 - Report position encoder module error.
* M871 - Print/reset/clear first layer temperature offset values. (Requires PROBE_TEMP_COMPENSATION)
* M872 - Wait for probe temp (Requires PROBE_TEMP_COMPENSATION)
* M192 - Wait for probe temp (Requires PROBE_TEMP_COMPENSATION)
* M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER)
* M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE)
* M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470)
Expand Down Expand Up @@ -822,8 +822,8 @@ class GcodeSuite {
#endif

#if ENABLED(PROBE_TEMP_COMPENSATION)
static void M192();
static void M871();
static void M872();
#endif

TERN_(LIN_ADVANCE, static void M900());
Expand Down
12 changes: 10 additions & 2 deletions Marlin/src/gcode/host/M115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@
* the capability is not present.
*/
void GcodeSuite::M115() {

SERIAL_ECHOLNPGM(STR_M115_REPORT);
SERIAL_ECHOLNPGM(
"FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") "
"SOURCE_CODE_URL:" SOURCE_CODE_URL " "
"PROTOCOL_VERSION:" PROTOCOL_VERSION " "
"MACHINE_TYPE:" MACHINE_NAME " "
"EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " "
#ifdef MACHINE_UUID
"UUID:" MACHINE_UUID
#endif
);

#if ENABLED(EXTENDED_CAPABILITIES_REPORT)

Expand Down
9 changes: 9 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@
#undef SHOW_TEMP_ADC_VALUES
#endif

#if TEMP_SENSOR_BED == 0
#undef THERMAL_PROTECTION_BED
#undef THERMAL_PROTECTION_BED_PERIOD
#endif

#if TEMP_SENSOR_CHAMBER == 0
#undef THERMAL_PROTECTION_CHAMBER
#endif

#if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || BOTH(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS))
#define HAS_MIXER_SYNC_CHANNEL 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2020-09-14"
#define STRING_DISTRIBUTION_DATE "2020-09-15"
#endif

/**
Expand Down
28 changes: 4 additions & 24 deletions Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const

FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
#if HAS_HEATED_BED
const bool isBed = heater_id < 0;
const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0);
const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)),
t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
#else
Expand All @@ -536,14 +536,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr
#if !HEATER_IDLE_HANDLER
UNUSED(blink);
#else
const bool is_idle = (
#if HAS_HEATED_BED
isBed ? thermalManager.bed_idle.timed_out :
#endif
thermalManager.hotend_idle[heater_id].timed_out
);

if (!blink && is_idle) {
if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) {
lcd_put_wchar(' ');
if (t2 >= 10) lcd_put_wchar(' ');
if (t2 >= 100) lcd_put_wchar(' ');
Expand All @@ -560,27 +553,14 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr
}

FORCE_INLINE void _draw_bed_status(const bool blink) {
_draw_heater_status(H_BED, (
#if HAS_LEVELING
planner.leveling_active && blink ? '_' :
#endif
LCD_STR_BEDTEMP[0]
),
blink
);
_draw_heater_status(H_BED, TERN0(HAS_LEVELING, blink && planner.leveling_active) ? '_' : LCD_STR_BEDTEMP[0], blink);
}

#if HAS_PRINT_PROGRESS

FORCE_INLINE void _draw_print_progress() {
const uint8_t progress = ui.get_progress_percent();
lcd_put_u8str_P(PSTR(
#if ENABLED(SDSUPPORT)
"SD"
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY)
"P:"
#endif
));
lcd_put_u8str_P(PSTR(TERN(SDSUPPORT, "SD", "P:")));
if (progress)
lcd_put_u8str(ui8tostr3rj(progress));
else
Expand Down
Loading

0 comments on commit 0a84e0b

Please sign in to comment.