Skip to content

Commit

Permalink
Update base branch (#8)
Browse files Browse the repository at this point in the history
* [cron] Bump distribution date (2020-12-31)

* SPI and pins cleanup

* [cron] Bump distribution date (2021-01-01)

* Prefix SD SPI pins (SCK, MISO, MOSI, SS) (MarlinFirmware#20606)

Co-authored-by: Scott Lahteine <[email protected]>

* Fix PARKING_EXTRUDER homing with solenoid (MarlinFirmware#20473)

* Fix CHAMBER_FAN_MODE 0 build (MarlinFirmware#20621)

* [cron] Bump distribution date (2021-01-02)

* Fix UBL mesh edit delta moves (MarlinFirmware#20620)

Co-authored-by: Scott Lahteine <[email protected]>

* Fix //action prefix (MarlinFirmware#20600)

* Assisted Tramming improvements (MarlinFirmware#20298)

* Check for misplaced configs on build (MarlinFirmware#20599)

Co-authored-by: Scott Lahteine <[email protected]>

* Fix a comment (MarlinFirmware#20629)

* Document, adjust some homing code

* Improved bootscreen animation

* [cron] Bump distribution date (2021-01-03)

* Homing code followup (MarlinFirmware#20632)

Patching a87e519

* Animated boot followup

* Add ALL_AXES manual move for UBL mesh editing

Co-Authored-By: Jason Smith <[email protected]>

MarlinFirmware#20620

* Creality 4.2.10 board (MarlinFirmware#20647)

* Update Italian language (MarlinFirmware#20663)

* [cron] Bump distribution date (2021-01-04)

* Fix thermal error protection, reporting (MarlinFirmware#20655)

* Rename FTDI EVE screen data structs

* Fix SD SPI Speed override, FTDI mesh edit (MarlinFirmware#20657)

Co-authored-by: Scott Lahteine <[email protected]>

* Fix IDEX reboot on travel after G28 X (MarlinFirmware#20654)

* Fix delayed_move_time elapsed test

* Move duplication_e_mask

Co-authored-by: thinkyhead <[email protected]>
Co-authored-by: Scott Lahteine <[email protected]>
Co-authored-by: Victor Oliveira <[email protected]>
Co-authored-by: zeleps <[email protected]>
Co-authored-by: Jason Smith <[email protected]>
Co-authored-by: ellensp <[email protected]>
Co-authored-by: qwewer0 <[email protected]>
Co-authored-by: Giuliano Zaro <[email protected]>
Co-authored-by: Marcio T <[email protected]>
Co-authored-by: InsanityAutomation <[email protected]>
  • Loading branch information
11 people authored Jan 4, 2021
1 parent 6b8c18b commit 47f020d
Show file tree
Hide file tree
Showing 172 changed files with 1,467 additions and 1,499 deletions.
10 changes: 0 additions & 10 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1825,16 +1825,6 @@
*/
#define SDSUPPORT

/**
* SD CARD: SPI SPEED
*
* Enable one of the following items for a slower SPI transfer speed.
* This may be required to resolve "volume init" errors.
*/
//#define SPI_SPEED SPI_HALF_SPEED
//#define SPI_SPEED SPI_QUARTER_SPEED
//#define SPI_SPEED SPI_EIGHTH_SPEED

/**
* SD CARD: ENABLE CRC
*
Expand Down
14 changes: 12 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@
#define RESTORE_LEVELING_AFTER_G35 // Enable to restore leveling setup after operation
//#define REPORT_TRAMMING_MM // Report Z deviation (mm) for each point relative to the first
//#define ASSISTED_TRAMMING_MENU_ITEM // Add a menu item to run G35 Assisted Tramming (MarlinUI)
//#define ASSISTED_TRAMMING_WIZARD // Make the menu item open a Tramming Wizard sub-menu
//#define ASSISTED_TRAMMING_WIZARD // Add a Tramming Wizard to the LCD menu
//#define ASSISTED_TRAMMING_WAIT_POSITION { X_CENTER, Y_CENTER, 30 } // Move the nozzle out of the way for adjustment
/**
Expand Down Expand Up @@ -1182,6 +1182,16 @@
#endif

#if ENABLED(SDSUPPORT)
/**
* SD Card SPI Speed
* May be required to resolve "volume init" errors.
*
* Enable and set to SPI_HALF_SPEED, SPI_QUARTER_SPEED, or SPI_EIGHTH_SPEED
* otherwise full speed will be applied.
*
* :['SPI_HALF_SPEED', 'SPI_QUARTER_SPEED', 'SPI_EIGHTH_SPEED']
*/
//#define SD_SPI_SPEED SPI_HALF_SPEED

// The standard SD detect circuit reads LOW when media is inserted and HIGH when empty.
// Enable this option and set to HIGH if your SD cards are incorrectly detected.
Expand Down
28 changes: 14 additions & 14 deletions Marlin/src/HAL/AVR/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
#include "../../inc/MarlinConfig.h"

void spiBegin() {
OUT_WRITE(SS_PIN, HIGH);
SET_OUTPUT(SCK_PIN);
SET_INPUT(MISO_PIN);
SET_OUTPUT(MOSI_PIN);
OUT_WRITE(SD_SS_PIN, HIGH);
SET_OUTPUT(SD_SCK_PIN);
SET_INPUT(SD_MISO_PIN);
SET_OUTPUT(SD_MOSI_PIN);

#if DISABLED(SOFTWARE_SPI)
// SS must be in output mode even it is not chip select
//SET_OUTPUT(SS_PIN);
//SET_OUTPUT(SD_SS_PIN);
// set SS high - may be chip select for another SPI device
//#if SET_SPI_SS_HIGH
//WRITE(SS_PIN, HIGH);
//WRITE(SD_SS_PIN, HIGH);
//#endif
// set a default rate
spiInit(1);
Expand Down Expand Up @@ -195,19 +195,19 @@ void spiBegin() {
// no interrupts during byte receive - about 8µs
cli();
// output pin high - like sending 0xFF
WRITE(MOSI_PIN, HIGH);
WRITE(SD_MOSI_PIN, HIGH);

LOOP_L_N(i, 8) {
WRITE(SCK_PIN, HIGH);
WRITE(SD_SCK_PIN, HIGH);

nop; // adjust so SCK is nice
nop;

data <<= 1;

if (READ(MISO_PIN)) data |= 1;
if (READ(SD_MISO_PIN)) data |= 1;

WRITE(SCK_PIN, LOW);
WRITE(SD_SCK_PIN, LOW);
}

sei();
Expand All @@ -225,18 +225,18 @@ void spiBegin() {
// no interrupts during byte send - about 8µs
cli();
LOOP_L_N(i, 8) {
WRITE(SCK_PIN, LOW);
WRITE(MOSI_PIN, data & 0x80);
WRITE(SD_SCK_PIN, LOW);
WRITE(SD_MOSI_PIN, data & 0x80);
data <<= 1;
WRITE(SCK_PIN, HIGH);
WRITE(SD_SCK_PIN, HIGH);
}

nop; // hold SCK high for a few ns
nop;
nop;
nop;

WRITE(SCK_PIN, LOW);
WRITE(SD_SCK_PIN, LOW);

sei();
}
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/HAL/AVR/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
#define AVR_SS_PIN 16
#endif

#ifndef SCK_PIN
#define SCK_PIN AVR_SCK_PIN
#ifndef SD_SCK_PIN
#define SD_SCK_PIN AVR_SCK_PIN
#endif
#ifndef MISO_PIN
#define MISO_PIN AVR_MISO_PIN
#ifndef SD_MISO_PIN
#define SD_MISO_PIN AVR_MISO_PIN
#endif
#ifndef MOSI_PIN
#define MOSI_PIN AVR_MOSI_PIN
#ifndef SD_MOSI_PIN
#define SD_MOSI_PIN AVR_MOSI_PIN
#endif
#ifndef SS_PIN
#define SS_PIN AVR_SS_PIN
#ifndef SD_SS_PIN
#define SD_SS_PIN AVR_SS_PIN
#endif
88 changes: 44 additions & 44 deletions Marlin/src/HAL/DUE/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@

// run at ~8 .. ~10Mhz - Tx version (Rx data discarded)
static uint8_t spiTransferTx0(uint8_t bout) { // using Mode 0
uint32_t MOSI_PORT_PLUS30 = ((uint32_t) PORT(MOSI_PIN)) + 0x30; /* SODR of port */
uint32_t MOSI_MASK = PIN_MASK(MOSI_PIN);
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SCK_PIN);
uint32_t MOSI_PORT_PLUS30 = ((uint32_t) PORT(SD_MOSI_PIN)) + 0x30; /* SODR of port */
uint32_t MOSI_MASK = PIN_MASK(SD_MOSI_PIN);
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SD_SCK_PIN);
uint32_t idx = 0;

/* Negate bout, as the assembler requires a negated value */
Expand Down Expand Up @@ -154,9 +154,9 @@
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);
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(SD_MISO_PIN))+0x3C, PIN_SHIFT(SD_MISO_PIN)); /* PDSR of port in bitband area */
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SD_SCK_PIN);

/* The software SPI routine */
__asm__ __volatile__(
Expand Down Expand Up @@ -225,15 +225,15 @@
static uint8_t spiTransfer1(uint8_t b) { // using Mode 0
int bits = 8;
do {
WRITE(MOSI_PIN, b & 0x80);
WRITE(SD_MOSI_PIN, b & 0x80);
b <<= 1; // little setup time

WRITE(SCK_PIN, HIGH);
WRITE(SD_SCK_PIN, HIGH);
DELAY_NS(125); // 10 cycles @ 84mhz

b |= (READ(MISO_PIN) != 0);
b |= (READ(SD_MISO_PIN) != 0);

WRITE(SCK_PIN, LOW);
WRITE(SD_SCK_PIN, LOW);
DELAY_NS(125); // 10 cycles @ 84mhz
} while (--bits);
return b;
Expand All @@ -245,15 +245,15 @@
static uint8_t spiTransferX(uint8_t b) { // using Mode 0
int bits = 8;
do {
WRITE(MOSI_PIN, b & 0x80);
WRITE(SD_MOSI_PIN, b & 0x80);
b <<= 1; // little setup time

WRITE(SCK_PIN, HIGH);
WRITE(SD_SCK_PIN, HIGH);
__delay_4cycles(spiDelayCyclesX4);

b |= (READ(MISO_PIN) != 0);
b |= (READ(SD_MISO_PIN) != 0);

WRITE(SCK_PIN, LOW);
WRITE(SD_SCK_PIN, LOW);
__delay_4cycles(spiDelayCyclesX4);
} while (--bits);
return b;
Expand All @@ -271,10 +271,10 @@

// Block transfers run at ~8 .. ~10Mhz - Tx version (Rx data discarded)
static void spiTxBlock0(const uint8_t* ptr, uint32_t todo) {
uint32_t MOSI_PORT_PLUS30 = ((uint32_t) PORT(MOSI_PIN)) + 0x30; /* SODR of port */
uint32_t MOSI_MASK = PIN_MASK(MOSI_PIN);
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SCK_PIN);
uint32_t MOSI_PORT_PLUS30 = ((uint32_t) PORT(SD_MOSI_PIN)) + 0x30; /* SODR of port */
uint32_t MOSI_MASK = PIN_MASK(SD_MOSI_PIN);
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SD_SCK_PIN);
uint32_t work = 0;
uint32_t txval = 0;

Expand Down Expand Up @@ -352,9 +352,9 @@
static void spiRxBlock0(uint8_t* ptr, uint32_t todo) {
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);
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(SD_MISO_PIN))+0x3C, PIN_SHIFT(SD_MISO_PIN)); /* PDSR of port in bitband area */
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SD_SCK_PIN);

/* The software SPI routine */
__asm__ __volatile__(
Expand Down Expand Up @@ -442,22 +442,22 @@
static pfnSpiRxBlock spiRxBlock = (pfnSpiRxBlock)spiRxBlockX;

#if MB(ALLIGATOR)
#define _SS_WRITE(S) WRITE(SS_PIN, S)
#define _SS_WRITE(S) WRITE(SD_SS_PIN, S)
#else
#define _SS_WRITE(S) NOOP
#endif

void spiBegin() {
SET_OUTPUT(SS_PIN);
SET_OUTPUT(SD_SS_PIN);
_SS_WRITE(HIGH);
SET_OUTPUT(SCK_PIN);
SET_INPUT(MISO_PIN);
SET_OUTPUT(MOSI_PIN);
SET_OUTPUT(SD_SCK_PIN);
SET_INPUT(SD_MISO_PIN);
SET_OUTPUT(SD_MOSI_PIN);
}

uint8_t spiRec() {
_SS_WRITE(LOW);
WRITE(MOSI_PIN, HIGH); // Output 1s 1
WRITE(SD_MOSI_PIN, HIGH); // Output 1s 1
uint8_t b = spiTransferRx(0xFF);
_SS_WRITE(HIGH);
return b;
Expand All @@ -466,7 +466,7 @@
void spiRead(uint8_t* buf, uint16_t nbyte) {
if (nbyte) {
_SS_WRITE(LOW);
WRITE(MOSI_PIN, HIGH); // Output 1s 1
WRITE(SD_MOSI_PIN, HIGH); // Output 1s 1
spiRxBlock(buf, nbyte);
_SS_WRITE(HIGH);
}
Expand Down Expand Up @@ -519,8 +519,8 @@
}

_SS_WRITE(HIGH);
WRITE(MOSI_PIN, HIGH);
WRITE(SCK_PIN, LOW);
WRITE(SD_MOSI_PIN, HIGH);
WRITE(SD_SCK_PIN, LOW);
}

/** Begin SPI transaction, set clock, bit order, data mode */
Expand Down Expand Up @@ -575,20 +575,20 @@

// Configure SPI pins
PIO_Configure(
g_APinDescription[SCK_PIN].pPort,
g_APinDescription[SCK_PIN].ulPinType,
g_APinDescription[SCK_PIN].ulPin,
g_APinDescription[SCK_PIN].ulPinConfiguration);
g_APinDescription[SD_SCK_PIN].pPort,
g_APinDescription[SD_SCK_PIN].ulPinType,
g_APinDescription[SD_SCK_PIN].ulPin,
g_APinDescription[SD_SCK_PIN].ulPinConfiguration);
PIO_Configure(
g_APinDescription[MOSI_PIN].pPort,
g_APinDescription[MOSI_PIN].ulPinType,
g_APinDescription[MOSI_PIN].ulPin,
g_APinDescription[MOSI_PIN].ulPinConfiguration);
g_APinDescription[SD_MOSI_PIN].pPort,
g_APinDescription[SD_MOSI_PIN].ulPinType,
g_APinDescription[SD_MOSI_PIN].ulPin,
g_APinDescription[SD_MOSI_PIN].ulPinConfiguration);
PIO_Configure(
g_APinDescription[MISO_PIN].pPort,
g_APinDescription[MISO_PIN].ulPinType,
g_APinDescription[MISO_PIN].ulPin,
g_APinDescription[MISO_PIN].ulPinConfiguration);
g_APinDescription[SD_MISO_PIN].pPort,
g_APinDescription[SD_MISO_PIN].ulPinType,
g_APinDescription[SD_MISO_PIN].ulPin,
g_APinDescription[SD_MISO_PIN].ulPinConfiguration);

// set master mode, peripheral select, fault detection
SPI_Configure(SPI0, ID_SPI0, SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_MR_PS);
Expand All @@ -606,7 +606,7 @@
WRITE(SPI_EEPROM1_CS, HIGH);
WRITE(SPI_EEPROM2_CS, HIGH);
WRITE(SPI_FLASH_CS, HIGH);
WRITE(SS_PIN, HIGH);
WRITE(SD_SS_PIN, HIGH);

OUT_WRITE(SDSS, LOW);

Expand Down
15 changes: 5 additions & 10 deletions Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@

#include "../../../MarlinCore.h"

void spiBegin();
void spiInit(uint8_t spiRate);
void spiSend(uint8_t b);
void spiSend(const uint8_t* buf, size_t n);
#ifndef LCD_SPI_SPEED
#define LCD_SPI_SPEED SPI_QUARTER_SPEED
#endif

#include "../../shared/Marduino.h"
#include "../../shared/HAL_SPI.h"
#include "../fastio.h"

void u8g_SetPIOutput_DUE_hw_spi(u8g_t *u8g, uint8_t pin_index) {
Expand Down Expand Up @@ -100,11 +99,7 @@ uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va

spiBegin();

#ifndef SPI_SPEED
#define SPI_SPEED SPI_FULL_SPEED // use same SPI speed as SD card
#endif
spiInit(2);

spiInit(LCD_SPI_SPEED);
break;

case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@

#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)

#undef SPI_SPEED
#define SPI_SPEED 2 // About 2 MHz

#include "u8g_com_HAL_DUE_sw_spi_shared.h"

#include "../../shared/Marduino.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* Usually the hardware SPI pins are only available to the LCD. This makes the DUE hard SPI used at the same time
* as the TMC2130 soft SPI the most common setup.
*/
#define _IS_HW_SPI(P) (defined(TMC_SW_##P) && (TMC_SW_##P == MOSI_PIN || TMC_SW_##P == MISO_PIN || TMC_SW_##P == SCK_PIN))
#define _IS_HW_SPI(P) (defined(TMC_SW_##P) && (TMC_SW_##P == SD_MOSI_PIN || TMC_SW_##P == SD_MISO_PIN || TMC_SW_##P == SD_SCK_PIN))

#if ENABLED(SDSUPPORT) && HAS_DRIVER(TMC2130)
#if ENABLED(TMC_USE_SW_SPI)
Expand Down
Loading

0 comments on commit 47f020d

Please sign in to comment.