SDIO retry, hsd clock, etc.

This commit is contained in:
Scott Lahteine 2023-01-20 21:17:13 -06:00
parent e0ae072f5a
commit 7393285560
5 changed files with 22 additions and 17 deletions

View file

@ -286,6 +286,9 @@ void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
go_to_transfer_speed(); 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 #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined
retry_Cnt = retryCnt; retry_Cnt = retryCnt;
for (;;) { for (;;) {
@ -433,7 +436,10 @@ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
#else #else
uint8_t retries = SDIO_READ_RETRIES; 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; return false;
#endif #endif

View file

@ -43,7 +43,7 @@ void stepper_driver_backward_check() {
SET_INPUT(AXIS##_ENABLE_PIN); \ SET_INPUT(AXIS##_ENABLE_PIN); \
OUT_WRITE(AXIS##_STEP_PIN, false); \ OUT_WRITE(AXIS##_STEP_PIN, false); \
delay(20); \ delay(20); \
if (READ(AXIS##_ENABLE_PIN) == false) { \ if (READ(AXIS##_ENABLE_PIN) == LOW) { \
SBI(axis_plug_backward, BIT); \ SBI(axis_plug_backward, BIT); \
stepper_driver_backward_error(F(STRINGIFY(AXIS))); \ stepper_driver_backward_error(F(STRINGIFY(AXIS))); \
} \ } \

View file

@ -36,16 +36,15 @@
* R : Flag to restore the last-saved factor * R : Flag to restore the last-saved factor
*/ */
void GcodeSuite::M220() { void GcodeSuite::M220() {
if (!parser.seen_any()) {
SERIAL_ECHOLNPGM("FR:", feedrate_percentage, "%");
return;
}
static int16_t backup_feedrate_percentage = 100; static int16_t backup_feedrate_percentage = 100;
if (parser.seen('B')) backup_feedrate_percentage = feedrate_percentage; const int16_t now_feedrate_perc = feedrate_percentage;
if (parser.seen('R')) feedrate_percentage = backup_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.seenval('S')) feedrate_percentage = parser.value_int();
if (!parser.seen_any()) {
SERIAL_ECHOPGM("FR:", feedrate_percentage);
SERIAL_CHAR('%');
SERIAL_EOL();
}
} }

View file

@ -65,12 +65,12 @@
* multiple serial ports are available. * multiple serial ports are available.
* For example Serial3. * For example Serial3.
*/ */
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
#define USB_HOST_SERIAL MYSERIAL1
#endif
#ifndef USB_HOST_SERIAL #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 #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -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_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_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_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_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_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_EOL` | None | Print an end of line | `SERIAL_EOL();` | `\n` |
| `SERIAL_OUT` | `SERIAL_OUT(myMethod)` | Call a custom serial method | `SERIAL_OUT(msgDone);` | ... | | `SERIAL_OUT` | `SERIAL_OUT(myMethod)` | Call a custom serial method | `SERIAL_OUT(msgDone);` | ... |