Skip to content

Commit 7393285

Browse files
committed
SDIO retry, hsd clock, etc.
1 parent e0ae072 commit 7393285

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

Marlin/src/HAL/STM32/sdio.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
286286

287287
go_to_transfer_speed();
288288

289+
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_ENABLE;
290+
hsd.Init.ClockDiv = 8;
291+
289292
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined
290293
retry_Cnt = retryCnt;
291294
for (;;) {
@@ -433,7 +436,10 @@ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
433436
#else
434437

435438
uint8_t retries = SDIO_READ_RETRIES;
436-
while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true;
439+
while (retries--) {
440+
if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true;
441+
delay(10);
442+
}
437443
return false;
438444

439445
#endif

Marlin/src/feature/stepper_driver_safety.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void stepper_driver_backward_check() {
4343
SET_INPUT(AXIS##_ENABLE_PIN); \
4444
OUT_WRITE(AXIS##_STEP_PIN, false); \
4545
delay(20); \
46-
if (READ(AXIS##_ENABLE_PIN) == false) { \
46+
if (READ(AXIS##_ENABLE_PIN) == LOW) { \
4747
SBI(axis_plug_backward, BIT); \
4848
stepper_driver_backward_error(F(STRINGIFY(AXIS))); \
4949
} \

Marlin/src/gcode/config/M220.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@
3636
* R : Flag to restore the last-saved factor
3737
*/
3838
void GcodeSuite::M220() {
39+
if (!parser.seen_any()) {
40+
SERIAL_ECHOLNPGM("FR:", feedrate_percentage, "%");
41+
return;
42+
}
3943

4044
static int16_t backup_feedrate_percentage = 100;
41-
if (parser.seen('B')) backup_feedrate_percentage = feedrate_percentage;
42-
if (parser.seen('R')) feedrate_percentage = backup_feedrate_percentage;
43-
45+
const int16_t now_feedrate_perc = feedrate_percentage;
46+
if (parser.seen_test('R')) feedrate_percentage = backup_feedrate_percentage;
47+
if (parser.seen_test('B')) backup_feedrate_percentage = now_feedrate_perc;
4448
if (parser.seenval('S')) feedrate_percentage = parser.value_int();
4549

46-
if (!parser.seen_any()) {
47-
SERIAL_ECHOPGM("FR:", feedrate_percentage);
48-
SERIAL_CHAR('%');
49-
SERIAL_EOL();
50-
}
5150
}

Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@
6565
* multiple serial ports are available.
6666
* For example Serial3.
6767
*/
68-
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
69-
#define USB_HOST_SERIAL MYSERIAL1
70-
#endif
71-
7268
#ifndef USB_HOST_SERIAL
73-
#define USB_HOST_SERIAL Serial
69+
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
70+
#define USB_HOST_SERIAL MYSERIAL1
71+
#else
72+
#define USB_HOST_SERIAL Serial
73+
#endif
7474
#endif
7575

7676
////////////////////////////////////////////////////////////////////////////////

docs/Serial.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ The following macros are defined (in `serial.h`) to output data to the serial po
6464
| `SERIAL_ECHOLNPGM_P` | Same as `SERIAL_ECHOPGM_P` | Do `SERIAL_ECHOPGM_P`, adding a newline | `SERIAL_ECHOLNPGM_P(PSTR("Alice"), 78);` | `alice78\n` |
6565
| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST(F("Key "), 1, 2, 3);` | `Key 1, 2, 3` |
6666
| `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` |
67-
| `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` |
67+
| `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLNPGM` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` |
6868
| `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` |
69-
| `SERIAL_ERROR_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full error line | `SERIAL_ERROR_MSG("Not found");` | `Error:Not found` |
69+
| `SERIAL_ERROR_MSG` | Same as `SERIAL_ECHOLNPGM` | Print a full error line | `SERIAL_ERROR_MSG("Not found");` | `Error:Not found` |
7070
| `SERIAL_ECHO_SP` | Number of spaces | Print one or more spaces | `SERIAL_ECHO_SP(3)` | ` ` |
7171
| `SERIAL_EOL` | None | Print an end of line | `SERIAL_EOL();` | `\n` |
7272
| `SERIAL_OUT` | `SERIAL_OUT(myMethod)` | Call a custom serial method | `SERIAL_OUT(msgDone);` | ... |

0 commit comments

Comments
 (0)