From 8fd6562eaa184806ae381e65b97e113b947c4403 Mon Sep 17 00:00:00 2001 From: digant73 Date: Mon, 19 Feb 2024 17:10:38 +0100 Subject: [PATCH] Minor cleanup --- README.md | 14 ++++---- TFT/src/User/API/HW_Init.c | 8 ++--- TFT/src/User/API/Mainboard_FlowControl.c | 2 +- TFT/src/User/Hal/HD44780.c | 6 ++-- TFT/src/User/Hal/Knob_LED.c | 2 +- TFT/src/User/Hal/buzzer.c | 8 ++--- TFT/src/User/Hal/gd32f30x/lcd.c | 4 +-- TFT/src/User/Hal/gd32f30x/lcd.h | 34 +++++++++--------- TFT/src/User/Hal/gd32f30x/uart.c | 4 +-- TFT/src/User/Hal/gd32f30x/uart.h | 10 +++--- TFT/src/User/Variants/pin_GD_TFT35_V3_0.h | 2 +- TFT/src/User/Variants/pin_GD_TFT43_V3_0.h | 2 +- ...T28_V1_2-4.h => pin_MKS_GD_TFT28_V1_2_4.h} | 22 ++++++------ TFT/src/User/Variants/pin_MKS_TFT32_V1_3.h | 2 +- TFT/src/User/Variants/pin_MKS_TFT32_V1_4.h | 4 +-- TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h | 4 +-- TFT/src/User/Variants/pin_TFT24_V1_1.h | 4 +-- TFT/src/User/Variants/pin_TFT28_V1_0.h | 2 +- TFT/src/User/Variants/pin_TFT28_V3_0.h | 2 +- TFT/src/User/Variants/pin_TFT35_V1_0.h | 4 +-- TFT/src/User/Variants/pin_TFT35_V1_2.h | 2 +- TFT/src/User/Variants/pin_TFT35_V2_0.h | 4 +-- TFT/src/User/Variants/pin_TFT35_V3_0.h | 2 +- TFT/src/User/Variants/pin_TFT43_V3_0.h | 2 +- TFT/src/User/Variants/pin_TFT70_V3_0.h | 4 +-- TFT/src/User/Variants/pin_Template.h | 2 +- TFT/src/User/Variants/variants.h | 4 +-- TFT/src/User/main.c | 5 ++- TFT/src/User/os_timer.c | 4 +-- buildroot/ldscripts/gd32f30xxC_0x7000_iap.ld | 18 +++++----- platformio.ini | 36 +++++++++++-------- 31 files changed, 116 insertions(+), 107 deletions(-) rename TFT/src/User/Variants/{pin_MKS_GD_TFT28_V1_2-4.h => pin_MKS_GD_TFT28_V1_2_4.h} (77%) diff --git a/README.md b/README.md index d726ac08e8..9756a81389 100644 --- a/README.md +++ b/README.md @@ -90,9 +90,9 @@ Only the TFTs listed below are currently supported. Trying to install the firmwa MKS_TFT32L_V3.0 MKS_TFT35_V1.0 -**MKS TFT with GigaDevice MCUs** +**MKS GD TFT** - MKS_GD_TFT28_V1_2_4 + MKS_GD_TFT28_V1.2-4 (V1.2 and V1.4) **WARNING:** BTT does not officially provide MKS TFT hardware support. MKS TFT is maintained by open source contributors and BTT does not bear any risk of MKS TFT hardware using this firmware. @@ -255,11 +255,12 @@ For **MKS TFTs**: 1. The firmwares use the naming convention `MKS_TFT*_V*.*.*.x.bin` 2. Any binary file for an MKS firmware (e.g. `MKS_TFT28_V4.0.27.x.bin`) **MUST** be renamed to `MKSTFT*.bin` (e.g. `MKSTFT28.bin`, `MKSTFT35.bin` etc.) in order it can be recognized and installed by the TFT -For MKS TFTs **GigaDevice MCUs** (like the newest version of Genious Pro): +For **MKS GD TFTs**: -1. rename the right binary (e.g. `MKS_GD_TFT28_V1_2_4.27.x.bin`) in `mkstft28evo.bin` -2. create an empty `mkstft28.bin` file -3. create two empty directories `mks_font` and `mks_pic` +For MKS TFT28 mounting GD32 MCU (GigaDevice MCU) (like the newest version of Genious Pro), you need to: +1. Rename the right binary (e.g. `MKS_GD_TFT28_V1_2_4.27.x.bin`) to `MKSTFT28EVO.bin` +2. Create an empty file named `MKSTFT28.bin` +3. Create two empty directories named `MKS_FONT` and `MKS_PIC` For example, for BTT TFT35 V3 select: @@ -489,6 +490,7 @@ Please, see [Customization Guides](https://github.com/bigtreetech/BIGTREETECH-To ;MKS_TFT32_V1_4_NOBL ;MKS_TFT32L_V3_0 ;MKS_TFT35_V1_0 + ;MKS_GD_TFT28_V1_2_4 [platformio] diff --git a/TFT/src/User/API/HW_Init.c b/TFT/src/User/API/HW_Init.c index f7c649af74..45b4ceb953 100644 --- a/TFT/src/User/API/HW_Init.c +++ b/TFT/src/User/API/HW_Init.c @@ -7,7 +7,7 @@ void HW_GetClocksFreq(CLOCKS *clk) { - #if defined GD32F2XX || defined GD32F3XX + #if defined(GD32F2XX) || defined(GD32F3XX) RCU_GetClocksFreq(&clk->rccClocks); #else RCC_GetClocksFreq(&clk->rccClocks); @@ -28,7 +28,7 @@ void HW_Init(void) { HW_GetClocksFreq(&mcuClocks); - #if defined GD32F2XX || defined GD32F3XX + #if defined(GD32F2XX) || defined(GD32F3XX) nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2); #else NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); @@ -45,10 +45,10 @@ void HW_Init(void) #endif #if defined(MKS_TFT) && !defined(MKS_TFT35_V1_0) // not used by MKS_TFT35_V1_0 - #if defined (GD32F3XX) + #ifdef GD32F3XX rcu_periph_clock_enable(RCU_AF); gpio_pin_remap_config(GPIO_USART1_REMAP, ENABLE); - #else + #else // if STM32F RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE); #endif diff --git a/TFT/src/User/API/Mainboard_FlowControl.c b/TFT/src/User/API/Mainboard_FlowControl.c index c48a50fb48..a0bf154435 100644 --- a/TFT/src/User/API/Mainboard_FlowControl.c +++ b/TFT/src/User/API/Mainboard_FlowControl.c @@ -76,7 +76,7 @@ void loopBackEnd(void) if (infoMachineSettings.onboardSD == ENABLED) loopPrintFromOnboard(); - // Buzzer handling + // buzzer handling #ifdef BUZZER_PIN loopBuzzer(); #endif diff --git a/TFT/src/User/Hal/HD44780.c b/TFT/src/User/Hal/HD44780.c index 933decb9c5..f0708bed38 100644 --- a/TFT/src/User/Hal/HD44780.c +++ b/TFT/src/User/Hal/HD44780.c @@ -8,7 +8,7 @@ CIRCULAR_QUEUE *HD44780_queue = NULL; void HD44780_DeConfig(void) { -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) nvic_irq_disable(EXTI10_15_IRQn); #else NVIC_InitTypeDef NVIC_InitStructure; @@ -49,7 +49,7 @@ void HD44780_Config(CIRCULAR_QUEUE *queue) GPIO_InitSet(LCD_D4, MGPIO_MODE_IPD, 0); GPIO_InitSet(LCD_RS, MGPIO_MODE_IPD, 0); -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) gpio_exti_source_select(GPIO_EVENT_PORT_GPIOB, GPIO_EVENT_PIN_15); exti_init(EXTI_15, EXTI_INTERRUPT, EXTI_TRIG_RISING); @@ -86,7 +86,7 @@ void HD44780_Config(CIRCULAR_QUEUE *queue) bool HD44780_writeData(void) { bool dataWritten = false; -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) if ((GPIO_ISTAT(GPIOB) & (1 << 15)) != 0) { uint8_t temp = ((GPIO_ISTAT(LCD_D7_PORT) & GPIO_PIN_6) >> 3 ) + // D7 diff --git a/TFT/src/User/Hal/Knob_LED.c b/TFT/src/User/Hal/Knob_LED.c index 1a81778135..bf3c37d921 100644 --- a/TFT/src/User/Hal/Knob_LED.c +++ b/TFT/src/User/Hal/Knob_LED.c @@ -10,7 +10,7 @@ uint32_t frameTimeStamp = 0; // Frame unit need > 280us for WS2812 #define NEOPIXEL_T0H_US 0.35 // Neopixel code 0 high level hold time in us #define NEOPIXEL_T1H_US 2.15 // Neopixel code 1 high level hold time in us -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) #define NEOPIXEL_TIMER_CLOCK_ENABLE() rcu_periph_clock_enable(RCU_TIMER5) #define NEOPIXEL_TIMER_CNT() TIMER_CNT(TIMER5) #define NEOPIXEL_TIMER_PSC() TIMER_PSC(TIMER5) diff --git a/TFT/src/User/Hal/buzzer.c b/TFT/src/User/Hal/buzzer.c index 61c8f3a1b0..f1a670e2da 100644 --- a/TFT/src/User/Hal/buzzer.c +++ b/TFT/src/User/Hal/buzzer.c @@ -21,7 +21,7 @@ volatile uint32_t toggles = 0; void TIM3_Config(void) { -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) nvic_irq_enable(TIMER2_IRQn, 1U, 0U); rcu_periph_clock_enable(RCU_TIMER2); @@ -46,7 +46,7 @@ void TIM3_Config(void) #endif } -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) void TIMER2_IRQHandler(void) { if ((TIMER_INTF(TIMER2) & TIMER_INTF_UPIF) != 0) // update interrupt flag @@ -108,7 +108,7 @@ void Buzzer_TurnOn(const uint16_t frequency, const uint16_t duration) void tone(const uint16_t frequency, const uint16_t duration) { if (frequency == 0 || duration == 0) return; -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) nvic_irq_disable(TIMER2_IRQn); toggles = 2 * (frequency * duration / 1000); // must have an even value @@ -147,7 +147,7 @@ void loopBuzzer(void) else if (OS_GetTimeMs() > buzzerEndTime && toggles == 0) { buzzerEndTime = 0; - #if defined GD32F2XX || defined GD32F3XX + #if defined(GD32F2XX) || defined(GD32F3XX) TIMER_CTL0(TIMER2) &= ~TIMER_CTL0_CEN; #else TIM3->CR1 &= ~TIM_CR1_CEN; // stop timer (for safety) diff --git a/TFT/src/User/Hal/gd32f30x/lcd.c b/TFT/src/User/Hal/gd32f30x/lcd.c index 8a84e71670..ee5649c7c2 100644 --- a/TFT/src/User/Hal/gd32f30x/lcd.c +++ b/TFT/src/User/Hal/gd32f30x/lcd.c @@ -59,8 +59,8 @@ void LCD_GPIO_Config(void) void LCD_EXMC_Config(void) { - exmc_norsram_parameter_struct EXMC_NORSRAMInitStructure; - exmc_norsram_timing_parameter_struct readWriteTiming,writeTiming; ; + exmc_norsram_parameter_struct EXMC_NORSRAMInitStructure; + exmc_norsram_timing_parameter_struct readWriteTiming,writeTiming; /* EXMC configuration */ readWriteTiming.asyn_address_setuptime = 1U; diff --git a/TFT/src/User/Hal/gd32f30x/lcd.h b/TFT/src/User/Hal/gd32f30x/lcd.h index 0e4d80f968..c64acd856c 100644 --- a/TFT/src/User/Hal/gd32f30x/lcd.h +++ b/TFT/src/User/Hal/gd32f30x/lcd.h @@ -20,25 +20,25 @@ #else #if defined(MKS_TFT) - /* - #define LCD_WR PB14 - #define LCD_RS PD13 - #define LCD_CS PC8 - #define LCD_RD PD15 - */ - // GPIO_SetLevel - #define LCD_CS_SET gpio_bit_set(GPIOC, GPIO_PIN_8 ) // Chip Select Port PC8 //片选端口 - #define LCD_RS_SET gpio_bit_set(GPIOD, GPIO_PIN_13) // Data / command PD13 //数据/命令 - #define LCD_WR_SET gpio_bit_set(GPIOB, GPIO_PIN_14) // Write data PB14 //写数据 - #define LCD_RD_SET gpio_bit_set(GPIOD, GPIO_PIN_15) // Read data PD15 //读数据 - - #define LCD_CS_CLR gpio_bit_reset(GPIOC, GPIO_PIN_8) // Chip select port PC8 //片选端口 - #define LCD_RS_CLR gpio_bit_reset(GPIOD, GPIO_PIN_13) // Data / command PD13 //数据/命令 - #define LCD_WR_CLR gpio_bit_reset(GPIOB, GPIO_PIN_14) // Write data PB14 //写数据 - #define LCD_RD_CLR gpio_bit_reset(GPIOD, GPIO_PIN_15) // Read data PD15 //读数据 + /* + #define LCD_WR PB14 + #define LCD_RS PD13 + #define LCD_CS PC8 + #define LCD_RD PD15 + */ + // GPIO_SetLevel + #define LCD_CS_SET gpio_bit_set(GPIOC, GPIO_PIN_8 ) // Chip Select Port PC8 //片选端口 + #define LCD_RS_SET gpio_bit_set(GPIOD, GPIO_PIN_13) // Data / command PD13 //数据/命令 + #define LCD_WR_SET gpio_bit_set(GPIOB, GPIO_PIN_14) // Write data PB14 //写数据 + #define LCD_RD_SET gpio_bit_set(GPIOD, GPIO_PIN_15) // Read data PD15 //读数据 + + #define LCD_CS_CLR gpio_bit_reset(GPIOC, GPIO_PIN_8) // Chip select port PC8 //片选端口 + #define LCD_RS_CLR gpio_bit_reset(GPIOD, GPIO_PIN_13) // Data / command PD13 //数据/命令 + #define LCD_WR_CLR gpio_bit_reset(GPIOB, GPIO_PIN_14) // Write data PB14 //写数据 + #define LCD_RD_CLR gpio_bit_reset(GPIOD, GPIO_PIN_15) // Read data PD15 //读数据 #define DATAOUT(x) do{gpio_port_write(GPIOE, x);}while(0) // Data output //数据输出 - #define DATAIN() gpio_input_port_get(GPIOE) // Data input //数据输入 + #define DATAIN() gpio_input_port_get(GPIOE) // Data input //数据输入 #else #error "don't support LCD-GPIO yet" #endif diff --git a/TFT/src/User/Hal/gd32f30x/uart.c b/TFT/src/User/Hal/gd32f30x/uart.c index 366799db6c..a52feac4fe 100644 --- a/TFT/src/User/Hal/gd32f30x/uart.c +++ b/TFT/src/User/Hal/gd32f30x/uart.c @@ -78,7 +78,7 @@ void UART_GPIO_DeInit(uint8_t port) GPIO_InitSet(uart_rx[port], MGPIO_MODE_IPN, 0); } -void UART_Protocol_Init(uint8_t port,uint32_t baud) +void UART_Protocol_Init(uint8_t port, uint32_t baud) { rcu_periph_clock_enable(rcu_uart_en[port]); // Enable clock @@ -96,7 +96,7 @@ void UART_Protocol_Init(uint8_t port,uint32_t baud) void UART_IRQ_Init(uint8_t port, uint16_t usart_it, bool idle_interrupt) { - uint32_t IRQ_Channel[_UART_CNT] = {USART0_IRQn, USART1_IRQn, USART2_IRQn, UART3_IRQn, UART4_IRQn }; + uint32_t IRQ_Channel[_UART_CNT] = {USART0_IRQn, USART1_IRQn, USART2_IRQn, UART3_IRQn, UART4_IRQn}; nvic_irq_enable(IRQ_Channel[port], 0U, 0U); if (idle_interrupt) // enable or disable serial line IDLE interrupt diff --git a/TFT/src/User/Hal/gd32f30x/uart.h b/TFT/src/User/Hal/gd32f30x/uart.h index e312f10ae4..8617f44811 100644 --- a/TFT/src/User/Hal/gd32f30x/uart.h +++ b/TFT/src/User/Hal/gd32f30x/uart.h @@ -4,11 +4,11 @@ #include #include -#define _USART1 0 // USART0 -#define _USART2 1 // USART1 -#define _USART3 2 // USART2 -#define _UART4 3 // UART3 -#define _UART5 4 // UART4 +#define _USART1 0 // USART0 +#define _USART2 1 // USART1 +#define _USART3 2 // USART2 +#define _UART4 3 // UART3 +#define _UART5 4 // UART4 #define _USART6 5 #define _UART_CNT 6 diff --git a/TFT/src/User/Variants/pin_GD_TFT35_V3_0.h b/TFT/src/User/Variants/pin_GD_TFT35_V3_0.h index fae81c57c7..ddfcd586d0 100644 --- a/TFT/src/User/Variants/pin_GD_TFT35_V3_0.h +++ b/TFT/src/User/Variants/pin_GD_TFT35_V3_0.h @@ -1,7 +1,7 @@ #ifndef _PIN_GD_TFT35_V3_0_H_ // modify to actual filename !!! #define _PIN_GD_TFT35_V3_0_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "gd32f20x.h" diff --git a/TFT/src/User/Variants/pin_GD_TFT43_V3_0.h b/TFT/src/User/Variants/pin_GD_TFT43_V3_0.h index 20766bcf15..2e775021ed 100644 --- a/TFT/src/User/Variants/pin_GD_TFT43_V3_0.h +++ b/TFT/src/User/Variants/pin_GD_TFT43_V3_0.h @@ -22,7 +22,7 @@ #endif // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER SSD1963 #define TFTLCD_DRIVER_SPEED 0x10 // SSD1963 needs slower speed diff --git a/TFT/src/User/Variants/pin_MKS_GD_TFT28_V1_2-4.h b/TFT/src/User/Variants/pin_MKS_GD_TFT28_V1_2_4.h similarity index 77% rename from TFT/src/User/Variants/pin_MKS_GD_TFT28_V1_2-4.h rename to TFT/src/User/Variants/pin_MKS_GD_TFT28_V1_2_4.h index 97706234fd..d1d176723b 100644 --- a/TFT/src/User/Variants/pin_MKS_GD_TFT28_V1_2-4.h +++ b/TFT/src/User/Variants/pin_MKS_GD_TFT28_V1_2_4.h @@ -1,7 +1,7 @@ -#ifndef _PIN_MKS_GD_TFT28_V1_24_H_ // modify to actual filename !!! -#define _PIN_MKS_GD_TFT28_V1_24_H_ // modify to actual filename !!! +#ifndef _PIN_MKS_GD_TFT28_V1_2_4_H_ // modify to actual filename !!! +#define _PIN_MKS_GD_TFT28_V1_2_4_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "gd32f30x.h" @@ -14,14 +14,7 @@ // Hardware version config #ifndef HARDWARE_VERSION - #define HARDWARE_VERSION "GD_TFT28_V4.0" -#endif - -// USB Disk support -#ifndef USB_FLASH_DRIVE_SUPPORT - #define USB_FLASH_DRIVE_SUPPORT - #define USE_USB_FS - #define USE_USB_OTG_FS + #define HARDWARE_VERSION "GD_TFT28_V1.2-4" #endif // SERIAL_PORT: communicating with host (Marlin, RRF etc...) @@ -37,6 +30,13 @@ #define SERIAL_PORT_4 _UART4 #endif +// USB Disk support +#ifndef USB_FLASH_DRIVE_SUPPORT + #define USB_FLASH_DRIVE_SUPPORT + #define USE_USB_FS + #define USE_USB_OTG_FS +#endif + #include "pin_MKS_TFT32_V1_4.h" #endif diff --git a/TFT/src/User/Variants/pin_MKS_TFT32_V1_3.h b/TFT/src/User/Variants/pin_MKS_TFT32_V1_3.h index 1856f9e6a0..f42844ec44 100644 --- a/TFT/src/User/Variants/pin_MKS_TFT32_V1_3.h +++ b/TFT/src/User/Variants/pin_MKS_TFT32_V1_3.h @@ -11,7 +11,7 @@ #endif // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER ILI9325 #endif diff --git a/TFT/src/User/Variants/pin_MKS_TFT32_V1_4.h b/TFT/src/User/Variants/pin_MKS_TFT32_V1_4.h index 7cb637f435..c3a75d0338 100644 --- a/TFT/src/User/Variants/pin_MKS_TFT32_V1_4.h +++ b/TFT/src/User/Variants/pin_MKS_TFT32_V1_4.h @@ -55,7 +55,7 @@ #define W25Qxx_CS_PIN PB9 // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER HX8558 #endif @@ -209,7 +209,7 @@ #endif // LCD Encoder pins + Marlin mode -#ifdef ST7920_EMULATOR +#if defined(ST7920_EMULATOR) && !defined(GD32F3XX) // Free JTAG (PB3/PB4) for SPI3 and free SWDIO, PA13, PA14 for encoder pins #define DISABLE_DEBUG() RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); \ GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE) diff --git a/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h b/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h index 6076080a5a..fc3174ae79 100644 --- a/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h +++ b/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h @@ -1,7 +1,7 @@ #ifndef _PIN_TFT35_V1_0_H_ // modify to actual filename !!! #define _PIN_TFT35_V1_0_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "stm32f4xx.h" @@ -59,7 +59,7 @@ #define W25Qxx_CS_PIN PB9 // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER (ILI9488 | NT35310) #define TFTLCD_DRIVER_SPEED 0x03 // testing, was 0x10 diff --git a/TFT/src/User/Variants/pin_TFT24_V1_1.h b/TFT/src/User/Variants/pin_TFT24_V1_1.h index 279f614f0d..28aefe5711 100644 --- a/TFT/src/User/Variants/pin_TFT24_V1_1.h +++ b/TFT/src/User/Variants/pin_TFT24_V1_1.h @@ -1,7 +1,7 @@ #ifndef _PIN_TFT24_V1_1_H_ // modify to actual filename !!! #define _PIN_TFT24_V1_1_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "stm32f10x.h" @@ -60,7 +60,7 @@ #define W25Qxx_CS_PIN PD2 // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER ILI9341 #define TFTLCD_DRIVER_SPEED 0x03 diff --git a/TFT/src/User/Variants/pin_TFT28_V1_0.h b/TFT/src/User/Variants/pin_TFT28_V1_0.h index 1d5d6962c1..1b4bf9cf1f 100644 --- a/TFT/src/User/Variants/pin_TFT28_V1_0.h +++ b/TFT/src/User/Variants/pin_TFT28_V1_0.h @@ -22,7 +22,7 @@ #endif // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER ILI9341 #define TFTLCD_DRIVER_SPEED 0x03 diff --git a/TFT/src/User/Variants/pin_TFT28_V3_0.h b/TFT/src/User/Variants/pin_TFT28_V3_0.h index 461962f953..c2081ea27f 100644 --- a/TFT/src/User/Variants/pin_TFT28_V3_0.h +++ b/TFT/src/User/Variants/pin_TFT28_V3_0.h @@ -22,7 +22,7 @@ #endif // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER ST7789 #define TFTLCD_DRIVER_SPEED 0x05 diff --git a/TFT/src/User/Variants/pin_TFT35_V1_0.h b/TFT/src/User/Variants/pin_TFT35_V1_0.h index f678d6ed0e..2385563e9e 100644 --- a/TFT/src/User/Variants/pin_TFT35_V1_0.h +++ b/TFT/src/User/Variants/pin_TFT35_V1_0.h @@ -1,7 +1,7 @@ #ifndef _PIN_TFT35_V1_0_H_ // modify to actual filename !!! #define _PIN_TFT35_V1_0_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "stm32f10x.h" @@ -55,7 +55,7 @@ #define W25Qxx_CS_PIN PA4 // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER RM68042 #define TFTLCD_DRIVER_SPEED 0x03 diff --git a/TFT/src/User/Variants/pin_TFT35_V1_2.h b/TFT/src/User/Variants/pin_TFT35_V1_2.h index 9d7c096889..205d79e2a7 100644 --- a/TFT/src/User/Variants/pin_TFT35_V1_2.h +++ b/TFT/src/User/Variants/pin_TFT35_V1_2.h @@ -7,7 +7,7 @@ #endif // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER ILI9488 #define TFTLCD_DRIVER_SPEED 0x03 diff --git a/TFT/src/User/Variants/pin_TFT35_V2_0.h b/TFT/src/User/Variants/pin_TFT35_V2_0.h index 0f8a668c3e..b58fcc1421 100644 --- a/TFT/src/User/Variants/pin_TFT35_V2_0.h +++ b/TFT/src/User/Variants/pin_TFT35_V2_0.h @@ -1,7 +1,7 @@ #ifndef _PIN_TFT35_V2_0_H_ // modify to actual filename !!! #define _PIN_TFT35_V2_0_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "stm32f10x.h" @@ -60,7 +60,7 @@ #define W25Qxx_CS_PIN PA4 // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER (ILI9488 | NT35310) #define TFTLCD_DRIVER_SPEED 0x03 diff --git a/TFT/src/User/Variants/pin_TFT35_V3_0.h b/TFT/src/User/Variants/pin_TFT35_V3_0.h index 025a1d2cc0..34d38310c9 100644 --- a/TFT/src/User/Variants/pin_TFT35_V3_0.h +++ b/TFT/src/User/Variants/pin_TFT35_V3_0.h @@ -1,7 +1,7 @@ #ifndef _PIN_TFT35_V3_0_H_ // modify to actual filename !!! #define _PIN_TFT35_V3_0_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "stm32f2xx.h" diff --git a/TFT/src/User/Variants/pin_TFT43_V3_0.h b/TFT/src/User/Variants/pin_TFT43_V3_0.h index 7f04c776dc..464758ece3 100644 --- a/TFT/src/User/Variants/pin_TFT43_V3_0.h +++ b/TFT/src/User/Variants/pin_TFT43_V3_0.h @@ -22,7 +22,7 @@ #endif // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER SSD1963 #define TFTLCD_DRIVER_SPEED 0x10 // SSD1963 needs slower speed diff --git a/TFT/src/User/Variants/pin_TFT70_V3_0.h b/TFT/src/User/Variants/pin_TFT70_V3_0.h index c8b2bd4140..ed50be0cb6 100644 --- a/TFT/src/User/Variants/pin_TFT70_V3_0.h +++ b/TFT/src/User/Variants/pin_TFT70_V3_0.h @@ -1,7 +1,7 @@ #ifndef _PIN_TFT70_V3_0_H_ // modify to actual filename !!! #define _PIN_TFT70_V3_0_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE #include "stm32f4xx.h" @@ -57,7 +57,7 @@ #define W25Qxx_CS_PIN PB6 // LCD interface -// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558] +// Supported LCD drivers: [ST7789, SSD1963, RM68042, NT35310, ILI9488, ILI9341, ILI9325, HX8558, ST7796S] #ifndef TFTLCD_DRIVER #define TFTLCD_DRIVER SSD1963 #define TFTLCD_DRIVER_SPEED 0x10 // SSD1963 needs slower speed diff --git a/TFT/src/User/Variants/pin_Template.h b/TFT/src/User/Variants/pin_Template.h index a4f95ed102..31909464d4 100644 --- a/TFT/src/User/Variants/pin_Template.h +++ b/TFT/src/User/Variants/pin_Template.h @@ -1,7 +1,7 @@ #ifndef _PIN_TEMPLATE_H_ // modify to actual filename !!! #define _PIN_TEMPLATE_H_ // modify to actual filename !!! -// MCU type (STM32F10x, STM32F2xx, STM32F4xx, gd32f20x, gd32f30x) +// MCU type (STM32F10x, STM32F2xx, STM32F4xx, GD32F20x, GD32F30x) #ifndef MCU_TYPE #define MCU_TYPE //#include "stm32fxxx.h" diff --git a/TFT/src/User/Variants/variants.h b/TFT/src/User/Variants/variants.h index aaea8629a8..03c0fd1e11 100644 --- a/TFT/src/User/Variants/variants.h +++ b/TFT/src/User/Variants/variants.h @@ -71,8 +71,8 @@ #include "pin_MKS_TFT32L_V3_0.h" #elif defined(MKS_TFT35_V1_0) #include "pin_MKS_TFT35_V1_0.h" -#elif defined(MKS_GD_TFT28_V1_24) - #include "pin_MKS_GD_TFT28_V1_2-4.h" +#elif defined(MKS_GD_TFT28_V1_2_4) + #include "pin_MKS_GD_TFT28_V1_2_4.h" #endif #define LCD_ENCODER_SUPPORT (defined(LCD_ENCA_PIN) && defined(LCD_ENCB_PIN) && defined(LCD_BTN_PIN)) diff --git a/TFT/src/User/main.c b/TFT/src/User/main.c index 1e397debb7..ba527da091 100644 --- a/TFT/src/User/main.c +++ b/TFT/src/User/main.c @@ -3,9 +3,8 @@ int main(void) { - #if defined GD32F3XX - // Required due to enabling interrupt after vector table relocation - __enable_irq(); + #ifdef GD32F3XX + __enable_irq(); // required due to enabling interrupt after vector table relocation #endif SystemClockInit(); // it depends on "variants.h" included in "includes.h" diff --git a/TFT/src/User/os_timer.c b/TFT/src/User/os_timer.c index 6a60b4125b..1cab6a753f 100644 --- a/TFT/src/User/os_timer.c +++ b/TFT/src/User/os_timer.c @@ -5,7 +5,7 @@ OS_COUNTER os_counter = {0, 0}; void OS_InitTimerMs(void) { -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) nvic_irq_enable(TIMER6_IRQn, 2U, 0U); rcu_periph_clock_enable(RCU_TIMER6); @@ -32,7 +32,7 @@ void OS_InitTimerMs(void) #endif } -#if defined GD32F2XX || defined GD32F3XX +#if defined(GD32F2XX) || defined(GD32F3XX) void TIMER6_IRQHandler(void) { if ((TIMER_INTF(TIMER6) & TIMER_INTF_UPIF) != 0) diff --git a/buildroot/ldscripts/gd32f30xxC_0x7000_iap.ld b/buildroot/ldscripts/gd32f30xxC_0x7000_iap.ld index 9ddb3ffbc3..5df00e5b2a 100644 --- a/buildroot/ldscripts/gd32f30xxC_0x7000_iap.ld +++ b/buildroot/ldscripts/gd32f30xxC_0x7000_iap.ld @@ -9,8 +9,8 @@ ENTRY(Reset_Handler) /* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x5000; /* required amount of heap */ -_Min_Stack_Size = 0x2000; /* required amount of stack */ +_Min_Heap_Size = 0x5000; /* required amount of heap */ +_Min_Stack_Size = 0x2000; /* required amount of stack */ /* Specify the memory areas */ MEMORY @@ -54,12 +54,12 @@ SECTIONS } >FLASH - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH .ARM.attributes : { *(.ARM.attributes) } > FLASH @@ -79,8 +79,8 @@ SECTIONS .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(.fini_array*)) KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) PROVIDE_HIDDEN (__fini_array_end = .); } >FLASH @@ -145,3 +145,5 @@ SECTIONS libgcc.a ( * ) } } + + diff --git a/platformio.ini b/platformio.ini index 0b4ce88f36..390364f0b5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -39,13 +39,14 @@ ;MKS_TFT32_V1_4_NOBL ;MKS_TFT32L_V3_0 ;MKS_TFT35_V1_0 + ;MKS_GD_TFT28_V1_2_4 [platformio] src_dir = TFT boards_dir = buildroot/boards ;Build only Target - BIGTREE_TFT35_V3_0 -default_envs = MKS_GD_TFT28_V1_2_4 +default_envs = BIGTREE_TFT35_V3_0 ;Build all Targets ;default_envs = BIGTREE_TFT24_V1_1, BIGTREE_TFT28_V1_0, BIGTREE_TFT28_V3_0, BIGTREE_TFT35_V1_0, BIGTREE_TFT35_V1_1, BIGTREE_TFT35_V1_2, BIGTREE_TFT35_V2_0, BIGTREE_TFT35_V3_0, BIGTREE_TFT35_E3_V3_0, BIGTREE_TFT35_B1_V3_0, BIGTREE_TFT43_V3_0, BIGTREE_TFT50_V3_0, BIGTREE_TFT70_V3_0, BIGTREE_GD_TFT24_V1_1, BIGTREE_GD_TFT35_V2_0, BIGTREE_GD_TFT35_V3_0, BIGTREE_GD_TFT35_E3_V3_0, BIGTREE_GD_TFT35_B1_V3_0, BIGTREE_GD_TFT43_V3_0, BIGTREE_GD_TFT50_V3_0, BIGTREE_GD_TFT70_V3_0, MKS_TFT28_V3_0, MKS_TFT28_V4_0, MKS_TFT28_NEW_GENIUS, MKS_TFT32_V1_3, MKS_TFT32_V1_4, MKS_TFT32_V1_4_NOBL, MKS_TFT32L_V3_0, MKS_TFT35_V1_0, MKS_GD_TFT28_V1_2_4 @@ -147,9 +148,10 @@ build_flags = ${common.build_flags} -ITFT/src/User/Hal/STM32_USB_OTG_Driver/inc [gd32f30x] -default_src_filter = ${common.default_src_filter} + + + - + + -build_flags = ${common.build_flags} +default_src_filter = ${common.default_src_filter} + + + + + + + +build_flags = ${common.build_flags} -ITFT/src/Libraries/cmsis/Core-CM4 -ITFT/src/Libraries/cmsis/gd32f30x -ITFT/src/Libraries/fwlib/gd32f30x @@ -687,27 +689,31 @@ build_flags = ${stm32f4xx.build_flags} ${base64_png.build_flags} -DMKS_TFT35_V1_0= -DMKS_TFT= -# GigaDevice versions + # -# MKS GD TFT28 V4.0 +# MKS GD32 Series. Maintained by open source contributors +# + +# +# MKS GD TFT28 V1.2-4 # [env:MKS_GD_TFT28_V1_2_4] -extends = common_gd32 -board = GD32F305VC_0x7000 -build_src_filter = ${gd32f30x.default_src_filter} ${base64_png.default_src_filter} +extends = common_gd32 +board = GD32F305VC_0x7000 upload_protocol = stlink debug_tool = stlink -extra_scripts = ${common.extra_scripts} - buildroot/scripts/gd32f30xxC_0x7000_iap.py -build_flags = ${gd32f30x.build_flags} ${base64_png.build_flags} +build_src_filter = ${gd32f30x.default_src_filter} ${base64_png.default_src_filter} +extra_scripts = ${common.extra_scripts} + buildroot/scripts/gd32f30xxC_0x7000_iap.py +build_flags = ${gd32f30x.build_flags} ${base64_png.build_flags} -DGD32F3XX= -DHXTAL_VALUE=25000000ul -DVECT_TAB_FLASH=0x08007000 -DRAM_SIZE=64 ; Available RAM size in kbytes - ; -DBINARY_FILENAME="mkstft28evo" ; To override the default binary filename provided by -DHARDWARE - ; -DBINARY_DIRECTORY="mkstft28evo" ; To override the default release directory +; -DBINARY_FILENAME="MKSTFT28EVO" ; To override the default binary filename provided by -DHARDWARE +; -DBINARY_DIRECTORY="Copy to SD Card - MKS" ; To override the default release directory -DHARDWARE="MKS_GD_TFT28_V1_2_4" -DHARDWARE_SHORT="M28GDV2" - -DMKS_GD_TFT28_V1_24= + -DMKS_GD_TFT28_V1_2_4= -DMKS_TFT=