From 6d9aaca0828cab5abf0541394ebe60f04d01c989 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilenko Date: Fri, 29 Mar 2019 20:40:24 +0300 Subject: [PATCH] Fix compilation error for MKS Robin (#13506) --- Marlin/src/HAL/HAL_STM32F1/HAL.h | 4 ++++ .../src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp | 18 +++++++++++++++--- .../HAL_STM32F1/u8g_com_stm32duino_fsmc.cpp | 4 ++-- Marlin/src/lcd/dogm/HAL_LCD_com_defines.h | 2 +- .../share/PlatformIO/scripts/mks_robin.py | 4 +++- platformio.ini | 1 + 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.h b/Marlin/src/HAL/HAL_STM32F1/HAL.h index 6839ba2e66..66c4cba59e 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.h @@ -130,6 +130,10 @@ void HAL_init(); #define analogInputToDigitalPin(p) (p) #endif +#ifndef digitalPinHasPWM + #define digitalPinHasPWM(P) (PIN_MAP[P].timer_device != NULL) +#endif + #define CRITICAL_SECTION_START uint32_t primask = __get_primask(); (void)__iCliRetVal() #define CRITICAL_SECTION_END if (!primask) (void)__iSeiRetVal() #define ISRS_ENABLED() (!__get_primask()) diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp b/Marlin/src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp index bb5f2e1a84..d7aa3ccd20 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp +++ b/Marlin/src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp @@ -21,7 +21,7 @@ * */ -#if defined(__STM32F1__) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)) +#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)) #include "HAL_sdio_STM32F1.h" @@ -76,7 +76,7 @@ bool SDIO_Init(void) { return true; } -bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) { +bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) { if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false; if (blockAddress >= SdCard.LogBlockNbr) return false; if ((0x03 & (uint32_t)data)) return false; // misaligned data @@ -100,6 +100,12 @@ bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) { dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL); + if (SDIO->STA & SDIO_STA_RXDAVL) { + while (SDIO->STA & SDIO_STA_RXDAVL) (void) SDIO->FIFO; + SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); + return false; + } + if (SDIO_GET_FLAG(SDIO_STA_TRX_ERROR_FLAGS)) { SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); return false; @@ -108,6 +114,12 @@ bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) { return true; } +bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) { + uint32_t retries = 3; + while (retries--) if (SDIO_ReadBlock_DMA(blockAddress, data)) return true; + return false; +} + bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) { if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false; if (blockAddress >= SdCard.LogBlockNbr) return false; @@ -264,4 +276,4 @@ bool SDIO_GetCmdResp7(void) { return true; } -#endif // __STM32F1__ && (STM32_HIGH_DENSITY || STM32_XL_DENSITY) +#endif // ARDUINO_ARCH_STM32F1 && (STM32_HIGH_DENSITY || STM32_XL_DENSITY) diff --git a/Marlin/src/HAL/HAL_STM32F1/u8g_com_stm32duino_fsmc.cpp b/Marlin/src/HAL/HAL_STM32F1/u8g_com_stm32duino_fsmc.cpp index 8645a785ed..1d2153d208 100644 --- a/Marlin/src/HAL/HAL_STM32F1/u8g_com_stm32duino_fsmc.cpp +++ b/Marlin/src/HAL/HAL_STM32F1/u8g_com_stm32duino_fsmc.cpp @@ -26,7 +26,7 @@ * Communication interface for FSMC */ -#if (defined(STM32F1) || defined(STM32F1xx)) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)) +#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)) #include "../../inc/MarlinConfig.h" @@ -267,4 +267,4 @@ uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) { #endif // HAS_GRAPHICAL_LCD -#endif // (STM32F1 || STM32F1xx) && (STM32_HIGH_DENSITY || STM32_XL_DENSITY) +#endif // ARDUINO_ARCH_STM32F1 && (STM32_HIGH_DENSITY || STM32_XL_DENSITY) diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index 190d63f736..0785cb79a6 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -47,7 +47,7 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); #define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn - #if defined(STM32F1) || defined(STM32F1xx) + #if defined(ARDUINO_ARCH_STM32F1) uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); #define U8G_COM_HAL_FSMC_FN u8g_com_stm32duino_fsmc_fn #else diff --git a/buildroot/share/PlatformIO/scripts/mks_robin.py b/buildroot/share/PlatformIO/scripts/mks_robin.py index e4109635c8..742f4cd173 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin.py @@ -1,7 +1,9 @@ Import("env") # Relocate firmware from 0x08000000 to 0x08007000 -env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728)) +for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + env['CPPDEFINES'].remove(define) env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin.ld") diff --git a/platformio.ini b/platformio.ini index 6ca0fe7125..b474361ce9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -308,6 +308,7 @@ board = genericSTM32F103ZE extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin.py build_flags = !python Marlin/src/HAL/HAL_STM32F1/STM32F1_flag_script.py ${common.build_flags} + -DSTM32_XL_DENSITY src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} lib_ignore = c1921b4