diff --git a/Marlin/src/HAL/GD32_MFL/MinSerial.cpp b/Marlin/src/HAL/GD32_MFL/MinSerial.cpp index d5e8147798..2cc79c8853 100644 --- a/Marlin/src/HAL/GD32_MFL/MinSerial.cpp +++ b/Marlin/src/HAL/GD32_MFL/MinSerial.cpp @@ -95,7 +95,7 @@ static void MinSerialBegin() { volatile uint32_t ICER[32]; }; NVICMin *nvicBase = (NVICMin*)0xE000E100; - + SBI32(nvicBase->ICER[nvicIndex >> 5], nvicIndex & 0x1F); // We require memory barriers to properly disable interrupts diff --git a/Marlin/src/HAL/GD32_MFL/SDCard.h b/Marlin/src/HAL/GD32_MFL/SDCard.h index b14063b69f..467482a605 100644 --- a/Marlin/src/HAL/GD32_MFL/SDCard.h +++ b/Marlin/src/HAL/GD32_MFL/SDCard.h @@ -160,12 +160,12 @@ private: info->csd.device_size = (static_cast(csd_bytes[6] & 0x03U) << 10U) | (static_cast(csd_bytes[7]) << 2U) | (static_cast((csd_bytes[8] & 0xC0U) >> 6U)); - info->csd.device_size_multiplier = static_cast((csd_bytes[9] & 0x03U) << 1U | + info->csd.device_size_multiplier = static_cast((csd_bytes[9] & 0x03U) << 1U | (csd_bytes[10] & 0x80U) >> 7U); info->block_size = static_cast(1 << info->csd.read_block_length); - info->capacity = static_cast((info->csd.device_size + 1U) * - (1U << (info->csd.device_size_multiplier + 2U)) * + info->capacity = static_cast((info->csd.device_size + 1U) * + (1U << (info->csd.device_size_multiplier + 2U)) * info->block_size); } @@ -175,15 +175,15 @@ private: static_cast(csd_bytes[9]); info->block_size = BLOCK_SIZE; - info->capacity = static_cast((info->csd.device_size + 1U) * + info->capacity = static_cast((info->csd.device_size + 1U) * BLOCK_SIZE * KILOBYTE); } void process_common_csd_tail(Card_Info* info, const uint8_t* csd_bytes) { - info->csd.sector_size = static_cast(((csd_bytes[9] & 0x3FU) << 1U) | + info->csd.sector_size = static_cast(((csd_bytes[9] & 0x3FU) << 1U) | (csd_bytes[10] & 0x80U) >> 7U); info->csd.speed_factor = static_cast((csd_bytes[11] & 0x1CU) >> 2U); - info->csd.write_block_length = static_cast(((csd_bytes[11] & 0x03U) << 2U) | + info->csd.write_block_length = static_cast(((csd_bytes[11] & 0x03U) << 2U) | ((csd_bytes[12] & 0xC0U) >> 6U)); info->csd.checksum = static_cast((csd_bytes[15] & 0xFEU) >> 1U); } diff --git a/Marlin/src/HAL/GD32_MFL/timers.cpp b/Marlin/src/HAL/GD32_MFL/timers.cpp index bdcf5ed0ed..5b2c2de7ef 100644 --- a/Marlin/src/HAL/GD32_MFL/timers.cpp +++ b/Marlin/src/HAL/GD32_MFL/timers.cpp @@ -97,10 +97,10 @@ uint32_t GetStepperTimerClkFreq() { /** * @brief Starts a hardware timer - * + * * If the timer is not already initialized, this function will initialize it with the given frequency. * The timer is started immediately after initialization - * + * * @param timer The timer base index to start * @param frequency The frequency at which the timer should run * @return None @@ -137,7 +137,7 @@ void HAL_timer_start(const uint8_t timer_number, const uint32_t frequency) { /** * @brief Enables the interrupt for the specified timer - * + * * @param handle The timer handle for which to enable the interrupt * @return None */ @@ -154,7 +154,7 @@ void HAL_timer_enable_interrupt(const uint8_t timer_number) { /** * @brief Disables the interrupt for the specified timer - * + * * @param handle The timer handle for which to disable the interrupt * @return None */ @@ -168,7 +168,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_number) { /** * @brief Checks if the interrupt is enabled for the specified timer - * + * * @param handle The timer handle to check * @return True if the interrupt is enabled, false otherwise */ diff --git a/Marlin/src/HAL/GD32_MFL/timers.h b/Marlin/src/HAL/GD32_MFL/timers.h index 539f599a16..0eb6bd563a 100644 --- a/Marlin/src/HAL/GD32_MFL/timers.h +++ b/Marlin/src/HAL/GD32_MFL/timers.h @@ -123,8 +123,8 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_number) GeneralTimer& timer = (timer_number == MF_TIMER_STEP) ? Step_Timer : Temp_Timer; - return (timer_number == MF_TIMER_STEP || timer_number == MF_TIMER_TEMP) - ? timer.getCounter(TimerFormat::TICK) + return (timer_number == MF_TIMER_STEP || timer_number == MF_TIMER_TEMP) + ? timer.getCounter(TimerFormat::TICK) : 0U; }