Skip to content

Commit

Permalink
SDIO retry, hsd clock, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 7, 2023
1 parent c03f815 commit 864b379
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
8 changes: 7 additions & 1 deletion Marlin/src/HAL/STM32/sdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {

go_to_transfer_speed();

hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_ENABLE;
hsd.Init.ClockDiv = 8;

#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined
retry_Cnt = retryCnt;
for (;;) {
Expand Down Expand Up @@ -433,7 +436,10 @@ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
#else

uint8_t retries = SDIO_READ_RETRIES;
while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true;
while (retries--) {
if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true;
delay(10);
}
return false;

#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/stepper_driver_safety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void stepper_driver_backward_check() {
SET_INPUT(AXIS##_ENABLE_PIN); \
OUT_WRITE(AXIS##_STEP_PIN, false); \
delay(20); \
if (READ(AXIS##_ENABLE_PIN) == false) { \
if (READ(AXIS##_ENABLE_PIN) == LOW) { \
SBI(axis_plug_backward, BIT); \
stepper_driver_backward_error(F(STRINGIFY(AXIS))); \
} \
Expand Down
15 changes: 7 additions & 8 deletions Marlin/src/gcode/config/M220.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@
* R : Flag to restore the last-saved factor
*/
void GcodeSuite::M220() {
if (!parser.seen_any()) {
SERIAL_ECHOLNPGM("FR:", feedrate_percentage, "%");
return;
}

static int16_t backup_feedrate_percentage = 100;
if (parser.seen('B')) backup_feedrate_percentage = feedrate_percentage;
if (parser.seen('R')) feedrate_percentage = backup_feedrate_percentage;

const int16_t now_feedrate_perc = feedrate_percentage;
if (parser.seen_test('R')) feedrate_percentage = backup_feedrate_percentage;
if (parser.seen_test('B')) backup_feedrate_percentage = now_feedrate_perc;
if (parser.seenval('S')) feedrate_percentage = parser.value_int();

if (!parser.seen_any()) {
SERIAL_ECHOPGM("FR:", feedrate_percentage);
SERIAL_CHAR('%');
SERIAL_EOL();
}
}
10 changes: 5 additions & 5 deletions Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
* multiple serial ports are available.
* For example Serial3.
*/
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
#define USB_HOST_SERIAL MYSERIAL1
#endif

#ifndef USB_HOST_SERIAL
#define USB_HOST_SERIAL Serial
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
#define USB_HOST_SERIAL MYSERIAL1
#else
#define USB_HOST_SERIAL Serial
#endif
#endif

////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions docs/Serial.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ The following macros are defined (in `serial.h`) to output data to the serial po
| `SERIAL_ECHOLNPGM_P` | Same as `SERIAL_ECHOPGM_P` | Do `SERIAL_ECHOPGM_P`, adding a newline | `SERIAL_ECHOLNPGM_P(PSTR("Alice"), 78);` | `alice78\n` |
| `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` |
| `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` |
| `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` |
| `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLNPGM` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` |
| `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` |
| `SERIAL_ERROR_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full error line | `SERIAL_ERROR_MSG("Not found");` | `Error:Not found` |
| `SERIAL_ERROR_MSG` | Same as `SERIAL_ECHOLNPGM` | Print a full error line | `SERIAL_ERROR_MSG("Not found");` | `Error:Not found` |
| `SERIAL_ECHO_SP` | Number of spaces | Print one or more spaces | `SERIAL_ECHO_SP(3)` | ` ` |
| `SERIAL_EOL` | None | Print an end of line | `SERIAL_EOL();` | `\n` |
| `SERIAL_OUT` | `SERIAL_OUT(myMethod)` | Call a custom serial method | `SERIAL_OUT(msgDone);` | ... |
Expand Down

0 comments on commit 864b379

Please sign in to comment.