From 64a6e372aecb5ed618a0437597b15e8982911d25 Mon Sep 17 00:00:00 2001 From: acevest Date: Mon, 18 May 2020 02:34:31 +0800 Subject: [PATCH] add support for LilyGO T-Display-GD32V board --- .../BSP/Hardware/lcd/lcd.c | 579 ++++++++++++++++++ .../BSP/Hardware/lcd/lcd.h | 102 +++ .../BSP/Hardware/lcd/lcdfont.h | 246 ++++++++ .../BSP/Inc/mcu_init.h | 18 + .../BSP/Inc/usart.h | 10 + .../BSP/Src/gd32vf103_it.c | 11 + .../BSP/Src/mcu_init.c | 19 + .../BSP/Src/usart.c | 28 + board/LILYGO_TTGO_T_Display_GD32V/README.md | 13 + .../TOS_CONFIG/tos_config.h | 60 ++ .../eclipse/lcd/.cproject | 440 +++++++++++++ .../eclipse/lcd/.gitignore | 1 + .../eclipse/lcd/.project | 99 +++ .../eclipse/lcd/gd32vf103_libopt.h | 61 ++ .../eclipse/lcd/link.lds | 175 ++++++ .../eclipse/lcd/main.c | 150 +++++ .../openocd_sipeed_rv_debugger.cfg | 39 ++ 17 files changed, 2051 insertions(+) create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.c create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.h create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcdfont.h create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/mcu_init.h create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/usart.h create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/gd32vf103_it.c create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/mcu_init.c create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/usart.c create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/README.md create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/TOS_CONFIG/tos_config.h create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.cproject create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.gitignore create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.project create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/gd32vf103_libopt.h create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/link.lds create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/main.c create mode 100644 board/LILYGO_TTGO_T_Display_GD32V/openocd_sipeed_rv_debugger.cfg diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.c b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.c new file mode 100644 index 00000000..0b918cd7 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.c @@ -0,0 +1,579 @@ +#include "lcd.h" +#include "lcdfont.h" + +#define ST7789_SLPOUT 0x11 +#define ST7789_NORON 0x13 +#define ST7789_MADCTL 0x36 // Memory data access control +#define TFT_MAD_RGB 0x08 +#define ST7789_COLMOD 0x3A +#define ST7789_PORCTRL 0xB2 // Porch control +#define ST7789_GCTRL 0xB7 // Gate control +#define ST7789_VCOMS 0xBB // VCOMS setting +#define ST7789_LCMCTRL 0xC0 // LCM control +#define ST7789_VDVVRHEN 0xC2 // VDV and VRH command enable +#define ST7789_VRHS 0xC3 // VRH set +#define ST7789_VDVSET 0xC4 // VDV setting +#define ST7789_FRCTR2 0xC6 // FR Control 2 +#define ST7789_PWCTRL1 0xD0 // Power control 1 +#define ST7789_PVGAMCTRL 0xE0 // Positive voltage gamma control +#define ST7789_NVGAMCTRL 0xE1 // Negative voltage gamma control +#define ST7789_INVON 0x21 +#define ST7789_CASET 0x2A +#define ST7789_RASET 0x2B +#define ST7789_RAMWR 0x2C +#define ST7789_DISPOFF 0x28 +#define ST7789_DISPON 0x29 + +uint16_t bgcolor = BLACK; //背景色 +uint8_t max_width = 0; +uint8_t max_height= 0; +lcd_display_mode_t display_mode = LCD_DISPMODE_VERTICAL; + +void LCD_Writ_Bus(uint8_t dat) +{ +#if USE_HARDWARE_SPI + LCD_CS_Clr(); + + while(RESET == spi_i2s_flag_get(SPI0, SPI_FLAG_TBE)); + spi_i2s_data_transmit(SPI0, dat); + while(RESET == spi_i2s_flag_get(SPI0, SPI_FLAG_RBNE)); + spi_i2s_data_receive(SPI0); + + LCD_CS_Set(); +#endif + +#if USE_HARDWARE_DMA_SPI + spi_dma_enable(SPI0, SPI_DMA_TRANSMIT); +#endif + +#if USE_SOFTWARE_SPI + uint8_t i; + LCD_CS_Clr(); + for(i=0;i<8;i++) + { + LCD_SCLK_Clr(); + if(dat&0x80) + LCD_SDIN_Set(); + else + LCD_SDIN_Clr(); + LCD_SCLK_Set(); + dat<<=1; + } + LCD_CS_Set(); +#endif +} + + +void LCD_WR_DATA8(uint8_t dat) +{ + LCD_DC_Set(); + LCD_Writ_Bus(dat); +} + + +void LCD_WR_DATA(uint16_t dat) +{ + LCD_DC_Set(); + LCD_Writ_Bus(dat>>8); + LCD_Writ_Bus(dat); +} + + +void LCD_WR_REG(uint8_t dat) +{ + LCD_DC_Clr(); + LCD_Writ_Bus(dat); +} + + +void LCD_Address_Set(uint16_t x,uint16_t y,uint16_t width,uint16_t height) +{ + if(width == 0 || height == 0) { + return ; + } + + if(display_mode == LCD_DISPMODE_HORIZONTAL) { + x += 40; + y += 53; + } + + if(display_mode == LCD_DISPMODE_HORIZONTAL_MIRROR) { + x += 40; + y += 52; + } + + if(display_mode == LCD_DISPMODE_VERTICAL) { + x += 52; + y += 40; + } + if(display_mode == LCD_DISPMODE_VERTICAL_MIRROR) { + x += 53; + y += 40; + } + + // column + LCD_WR_REG(0x2a); + LCD_WR_DATA(x); + LCD_WR_DATA(x+width-1); + + // row + LCD_WR_REG(0x2b); + LCD_WR_DATA(y); + LCD_WR_DATA(y+height-1); + + // store + LCD_WR_REG(0x2c); +} + +#if USE_HARDWARE_DMA_SPI +void dma_config(void) +{ + dma_parameter_struct dma_init_struct; + + /* SPI0 transmit dma config:DMA0,DMA_CH2 */ + dma_deinit(DMA0, DMA_CH2); + dma_struct_para_init(&dma_init_struct); + + dma_init_struct.periph_addr = (uint32_t)&SPI_DATA(SPI0); + dma_init_struct.memory_addr = (uint32_t)image; + dma_init_struct.direction = DMA_MEMORY_TO_PERIPHERAL; + dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT; + dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT; + dma_init_struct.priority = DMA_PRIORITY_LOW; + dma_init_struct.number = ((max_width)*(max_height)*2); + dma_init_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE; + dma_init_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE; + dma_init(DMA0, DMA_CH2, &dma_init_struct); + /* configure DMA mode */ + dma_circulation_disable(DMA0, DMA_CH2); + dma_memory_to_memory_disable(DMA0, DMA_CH2); +} +#endif + +#if USE_HARDWARE_SPI +void spi_config(void) +{ + spi_parameter_struct spi_init_struct; + /* deinitilize SPI and the parameters */ + LCD_CS_Set(); + spi_struct_para_init(&spi_init_struct); + + /* SPI0 parameter config */ + spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX; + spi_init_struct.device_mode = SPI_MASTER; + spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT; + spi_init_struct.clock_polarity_phase = SPI_CK_PL_HIGH_PH_2EDGE; + spi_init_struct.nss = SPI_NSS_SOFT; + spi_init_struct.prescale = SPI_PSC_8; + spi_init_struct.endian = SPI_ENDIAN_MSB; + spi_init(SPI0, &spi_init_struct); + + spi_crc_polynomial_set(SPI0,7); + spi_enable(SPI0); +} +#endif + +void delay_1ms(uint32_t count) +{ + uint64_t start_mtime, delta_mtime; + + /* don't start measuruing until we see an mtime tick */ + uint64_t tmp = get_timer_value(); + + do{ + start_mtime = get_timer_value(); + }while(start_mtime == tmp); + + do{ + delta_mtime = get_timer_value() - start_mtime; + }while(delta_mtime <(SystemCoreClock/4000.0 *count)); +} + + +void LCD_On() { + LCD_WR_REG(0x29); +} + +lcd_display_mode_t lcd_display_mode = LCD_DISPMODE_HORIZONTAL; +lcd_display_mode_t LCD_GetDisplayMode() { + return lcd_display_mode; +} + + +void LCD_SetDisplayMode(lcd_display_mode_t m) { + lcd_display_mode = m; + uint8_t d = 0x00; + const uint8_t M = 240; + const uint8_t N = 135; + switch(m) { + case LCD_DISPMODE_HORIZONTAL: + d = 0x60; + max_width = M; + max_height = N; + break; + case LCD_DISPMODE_HORIZONTAL_MIRROR: + d = 0xA0; + max_width = M; + max_height = N; + break; + case LCD_DISPMODE_VERTICAL: + d = 0x00; + max_width = N; + max_height = M; + break; + case LCD_DISPMODE_VERTICAL_MIRROR: + d = 0xC0; + max_width = N; + max_height = M; + break; + default: + return; + }; + + LCD_WR_REG(0x36); + LCD_WR_DATA8(d | 0x08); + display_mode = m; +} + + +void LCD_Init(void) +{ + rcu_periph_clock_enable(RCU_GPIOA); + rcu_periph_clock_enable(RCU_GPIOB); + +#if USE_HARDWARE_SPI + rcu_periph_clock_enable(RCU_AF); + rcu_periph_clock_enable(RCU_SPI0); + /* SPI0 GPIO config: NSS/PA4, SCK/PA5, MOSI/PA7 */ + gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_5 | GPIO_PIN_7); + gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_2 | GPIO_PIN_10); + gpio_bit_set(GPIOB, GPIO_PIN_10); + + spi_config(); +#endif + +#if USE_HARDWARE_DMA_SPI + rcu_periph_clock_enable(RCU_DMA0); + rcu_periph_clock_enable(RCU_SPI0); + + /* SPI0 GPIO config: NSS/PA4, SCK/PA5, MOSI/PA7 */ + gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7); + /* SPI0 GPIO config: MISO/PA6 */ + gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_6); + + dma_config(); + + dma_channel_enable(DMA0,DMA_CH2); +#endif + +#if USE_SOFTWARE_SPI + gpio_init(GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_5 | GPIO_PIN_7); + gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_2); + + gpio_bit_reset(GPIOA, GPIO_PIN_5 | GPIO_PIN_7); + gpio_bit_reset(GPIOB, GPIO_PIN_2); +#endif + + gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0 | GPIO_PIN_1); + gpio_bit_reset(GPIOB, GPIO_PIN_0 | GPIO_PIN_1); + + LCD_RST_Clr(); + delay_1ms(200); + LCD_RST_Set(); + delay_1ms(20); + + LCD_WR_REG(ST7789_SLPOUT); + delay_1ms(100); + + LCD_WR_REG(ST7789_NORON); // Normal display mode on + + // display inversion on + LCD_WR_REG(0x21); + + LCD_WR_REG(ST7789_MADCTL); + //LCD_WR_DATA8(0x00); + LCD_WR_DATA8(TFT_MAD_RGB); + + // JLX240 display datasheet + LCD_WR_REG(0xB6); + LCD_WR_DATA8(0x0A); + LCD_WR_DATA8(0x82); + + LCD_WR_REG(ST7789_COLMOD); + LCD_WR_DATA8(0x55); + delay_1ms(10); + + //--------------------------------ST7789V Frame rate setting----------------------------------// + LCD_WR_REG(ST7789_PORCTRL); + LCD_WR_DATA8(0x0c); + LCD_WR_DATA8(0x0c); + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x33); + LCD_WR_DATA8(0x33); + + LCD_WR_REG(ST7789_GCTRL); // Voltages: VGH / VGL + LCD_WR_DATA8(0x35); + + + //---------------------------------ST7789V Power setting--------------------------------------// + LCD_WR_REG(ST7789_VCOMS); + LCD_WR_DATA8(0x28); // JLX240 display datasheet + + LCD_WR_REG(ST7789_LCMCTRL); + LCD_WR_DATA8(0x0C); + + LCD_WR_REG(ST7789_VDVVRHEN); + LCD_WR_DATA8(0x01); + LCD_WR_DATA8(0xFF); + + LCD_WR_REG(ST7789_VRHS); // voltage VRHS + LCD_WR_DATA8(0x10); + + LCD_WR_REG(ST7789_VDVSET); + LCD_WR_DATA8(0x20); + + LCD_WR_REG(ST7789_FRCTR2); + LCD_WR_DATA8(0x0f); + + LCD_WR_REG(ST7789_PWCTRL1); + LCD_WR_DATA8(0xa4); + LCD_WR_DATA8(0xa1); + + + //--------------------------------ST7789V gamma setting---------------------------------------// + LCD_WR_REG(ST7789_PVGAMCTRL); + LCD_WR_DATA8(0xd0); + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x02); + LCD_WR_DATA8(0x07); + LCD_WR_DATA8(0x0a); + LCD_WR_DATA8(0x28); + LCD_WR_DATA8(0x32); + LCD_WR_DATA8(0x44); + LCD_WR_DATA8(0x42); + LCD_WR_DATA8(0x06); + LCD_WR_DATA8(0x0e); + LCD_WR_DATA8(0x12); + LCD_WR_DATA8(0x14); + LCD_WR_DATA8(0x17); + + LCD_WR_REG(ST7789_NVGAMCTRL); + LCD_WR_DATA8(0xd0); + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x02); + LCD_WR_DATA8(0x07); + LCD_WR_DATA8(0x0a); + LCD_WR_DATA8(0x28); + LCD_WR_DATA8(0x31); + LCD_WR_DATA8(0x54); + LCD_WR_DATA8(0x47); + LCD_WR_DATA8(0x0e); + LCD_WR_DATA8(0x1c); + LCD_WR_DATA8(0x17); + LCD_WR_DATA8(0x1b); + LCD_WR_DATA8(0x1e); + + LCD_WR_REG(ST7789_INVON); + + LCD_WR_REG(ST7789_CASET); // Column address set + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0xE5); // 239 + + LCD_WR_REG(ST7789_RASET); // Row address set + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x00); + LCD_WR_DATA8(0x01); + LCD_WR_DATA8(0x3F); // 319 + + LCD_WR_REG(ST7789_LCMCTRL); + LCD_WR_DATA8(0x0C); + + LCD_SetDisplayMode(LCD_DISPMODE_HORIZONTAL); + + LCD_On(); +} + + + +void LCD_Clear(uint16_t Color) +{ + bgcolor = Color; + LCD_Address_Set(0, 0, max_width, max_height); + for(uint16_t i=0; i= 0 ? n : -n; +} + +void LCD_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) +{ + int16_t dx = x2 - x1; + int16_t dy = y2 - y1; + int16_t ux = ((dx > 0) << 1) - 1;//x的增量方向,取或-1 + int16_t uy = ((dy > 0) << 1) - 1;//y的增量方向,取或-1 + int16_t x = x1, y = y1, eps;//eps为累加误差 + + eps = 0;dx = abs(dx); dy = abs(dy); + if (dx > dy) { + for (x = x1; x != x2; x += ux) { + LCD_DrawPoint(x, y, color); + eps += dy; + if ((eps << 1) >= dx) { + y += uy; eps -= dx; + } + } + } else { + for (y = y1; y != y2; y += uy) { + LCD_DrawPoint(x, y, color); + eps += dx; + if ((eps << 1) >= dy) { + x += ux; eps -= dy; + } + } + } +} + +void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint16_t color) +{ + LCD_DrawLine(x1,y1,x2,y1,color); + LCD_DrawLine(x1,y1,x1,y2,color); + LCD_DrawLine(x1,y2,x2,y2,color); + LCD_DrawLine(x2,y1,x2,y2,color); +} + + +void LCD_DrawCircle(uint16_t x0,uint16_t y0,uint8_t r,uint16_t color) +{ + int a,b; + a=0;b=r; + while(a<=b) + { + LCD_DrawPoint(x0-b,y0-a,color); //3 + LCD_DrawPoint(x0+b,y0-a,color); //0 + LCD_DrawPoint(x0-a,y0+b,color); //1 + LCD_DrawPoint(x0-a,y0-b,color); //2 + LCD_DrawPoint(x0+b,y0+a,color); //4 + LCD_DrawPoint(x0+a,y0-b,color); //5 + LCD_DrawPoint(x0+a,y0+b,color); //6 + LCD_DrawPoint(x0-b,y0+a,color); //7 + a++; + if((a*a+b*b)>(r*r))//判断要画的点是否过远 + { + b--; + } + } +} + + +void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t chr, uint16_t color) +{ + if(x > max_width || y > max_height) { + return; + } + + const uint8_t *p = F8X16 + (chr - ' ')*16; + + LCD_Address_Set(x, y, 8, 16); //设置光标位置 + + for(uint8_t i=0; i<8; i++) { + for(uint8_t j=0; j<8; j++) { + LCD_WR_DATA((p[0+j] & (1< 0); + + for(uint8_t i=0; pos < max_len; i++, pos++) { + LCD_ShowChar(x+i*8, y, buf[pos], color); + } +} diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.h b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.h new file mode 100644 index 00000000..0cb560ac --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcd.h @@ -0,0 +1,102 @@ +#ifndef __LCD_H +#define __LCD_H + +#include "stdlib.h" +#include "gd32vf103_gpio.h" + +typedef enum { + LCD_DISPMODE_HORIZONTAL, + LCD_DISPMODE_HORIZONTAL_MIRROR, + LCD_DISPMODE_VERTICAL, + LCD_DISPMODE_VERTICAL_MIRROR +} lcd_display_mode_t; + +#define USE_HARDWARE_SPI 1 +//#define USE_HARDWARE_DMA_SPI 1 +//#define USE_SOFTWARE_SPI 1 + + +#if USE_HARDWARE_SPI +#define LCD_SCLK_Clr() +#define LCD_SCLK_Set() +#define LCD_SDIN_Clr() +#define LCD_SDIN_Set() +#define LCD_CS_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_2) //CS PB2 +#define LCD_CS_Set() gpio_bit_set( GPIOB, GPIO_PIN_2) +#define OLED_RST_Clr() gpio_bit_reset(GPIOB,GPIO_PIN_1) +#define OLED_RST_Set() gpio_bit_set(GPIOB,GPIO_PIN_1) +#define OLED_BLK_Set() +#endif + + +#if USE_HARDWARE_DMA_SPI +#define LCD_SCLK_Clr() +#define LCD_SCLK_Set() +#define LCD_SDIN_Clr() +#define LCD_SDIN_Set() +#define LCD_CS_Clr() +#define LCD_CS_Set() +#endif + + +#if USE_SOFTWARE_SPI +#define LCD_SCLK_Clr() gpio_bit_reset( GPIOA, GPIO_PIN_5) //CLK PA5 +#define LCD_SCLK_Set() gpio_bit_set( GPIOA, GPIO_PIN_5) +#define LCD_SDIN_Clr() gpio_bit_reset( GPIOA, GPIO_PIN_7) //DIN PA7 +#define LCD_SDIN_Set() gpio_bit_set( GPIOA, GPIO_PIN_7) +#define LCD_CS_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_2) //CS PB2 +#define LCD_CS_Set() gpio_bit_set( GPIOB, GPIO_PIN_2) +#endif + +#define LCD_RST_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_1) //RES PB1 +#define LCD_RST_Set() gpio_bit_set( GPIOB, GPIO_PIN_1) +#define LCD_DC_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_0) //DC PB0 +#define LCD_DC_Set() gpio_bit_set( GPIOB, GPIO_PIN_0) + + +void LCD_Writ_Bus(uint8_t dat); +void LCD_WR_DATA8(uint8_t dat); +void LCD_WR_DATA(uint16_t dat); +void LCD_WR_REG(uint8_t dat); + +void LCD_Init(void); +void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2,uint16_t y2); +void LCD_SetDisplayMode(lcd_display_mode_t m); +lcd_display_mode_t LCD_GetDisplayMode(); + +void LCD_Clear(uint16_t Color); +void LCD_ClearRect(uint16_t Color, uint16_t x, uint16_t y, uint16_t width, uint16_t height); +void LCD_ShowChinese(uint16_t x,uint16_t y,uint8_t index,uint16_t color); +void LCD_ShowChineseWithFonts(uint16_t x,uint16_t y, const char fonts[][16], uint8_t index,uint16_t color); +void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color); +void LCD_Fill(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint16_t color); +void LCD_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); +void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint16_t color); +void LCD_DrawCircle(uint16_t x0,uint16_t y0,uint8_t r,uint16_t color); +void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t ch,uint16_t color); +void LCD_ShowString(uint16_t x,uint16_t y,const uint8_t *p,uint16_t color); +void LCD_ShowNum(uint16_t x,uint16_t y,uint16_t num,uint16_t color); + +#define WHITE 0xFFFF +#define BLACK 0x0000 +#define BLUE 0x001F +#define BRED 0XF81F +#define GRED 0XFFE0 +#define GBLUE 0X07FF +#define RED 0xF800 +#define MAGENTA 0xF81F +#define GREEN 0x07E0 +#define CYAN 0x7FFF +#define YELLOW 0xFFE0 +#define BROWN 0XBC40 +#define BRRED 0XFC07 +#define GRAY 0X8430 +#define DARKBLUE 0x01CF +#define LIGHTBLUE 0x7D7C +#define GRAYBLUE 0x5458 +#define LIGHTGREEN 0x841F +#define LGRAY 0xC618 +#define LGRAYBLUE 0xA651 +#define LBBLUE 0x2B12 + +#endif diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcdfont.h b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcdfont.h new file mode 100644 index 00000000..1414457d --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Hardware/lcd/lcdfont.h @@ -0,0 +1,246 @@ +#ifndef __LCD_FONT_H +#define __LCD_FONT_H + +const unsigned char F6x8[][6] = +{ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp +0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// ! +0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// " +0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// # +0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $ +0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// % +0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// & +0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// ' +0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// ( +0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// ) +0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// * +0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// + +0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// , +0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// - +0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// . +0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// / +0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 +0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 +0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2 +0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 +0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 +0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5 +0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 +0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7 +0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8 +0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 +0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// : +0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ; +0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// < +0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// = +0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// > +0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ? +0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @ +0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A +0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B +0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C +0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D +0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E +0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F +0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G +0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H +0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I +0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J +0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K +0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L +0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M +0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N +0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O +0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P +0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q +0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R +0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S +0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T +0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U +0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V +0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W +0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X +0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y +0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z +0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [ +0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55 +0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ] +0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^ +0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _ +0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// ' +0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a +0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b +0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c +0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d +0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e +0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f +0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g +0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h +0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i +0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j +0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k +0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l +0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m +0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n +0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o +0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p +0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q +0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r +0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s +0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t +0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u +0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v +0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w +0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x +0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y +0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z +0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines +}; + +const unsigned char F8X16[]= +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0 + 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1 + 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2 + 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3 + 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4 + 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5 + 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6 + 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7 + 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8 + 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9 + 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10 + 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14 + 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15 + 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16 + 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17 + 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18 + 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19 + 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20 + 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21 + 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22 + 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23 + 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24 + 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25 + 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26 + 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27 + 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28 + 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29 + 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30 + 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31 + 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32 + 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33 + 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34 + 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35 + 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36 + 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37 + 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38 + 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39 + 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40 + 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41 + 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42 + 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43 + 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44 + 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45 + 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46 + 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47 + 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48 + 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49 + 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50 + 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51 + 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52 + 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53 + 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54 + 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55 + 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56 + 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57 + 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58 + 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59 + 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60 + 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61 + 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63 + 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65 + 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66 + 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67 + 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69 + 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70 + 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71 + 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72 + 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73 + 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74 + 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75 + 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76 + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77 + 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79 + 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80 + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81 + 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82 + 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83 + 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84 + 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85 + 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86 + 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87 + 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88 + 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89 + 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90 + 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91 + 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92 + 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93 + 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94 +}; + + +//[数据排列]:从左到右从上到下 [取模方式]:纵向8点下高位 [正负反色]:否 +const char Hzk[][16]={ +{0x00,0xFE,0x22,0x22,0xFE,0x28,0xA9,0x6E,0x28,0x3F,0x28,0x6C,0xAB,0x28,0x20,0x00}, +{0x80,0x7F,0x02,0x82,0xFF,0x01,0x20,0x2D,0x29,0x29,0x29,0x4F,0x88,0x79,0x01,0x00},/*"腾",0*/ +/* (16 X 16 , 宋体 )*/ +{0x40,0x40,0x42,0xCC,0x00,0x82,0x82,0xFE,0x82,0x82,0x02,0xFE,0x00,0x00,0x00,0x00}, +{0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0xFF,0x00,0x00,0x00,0x0F,0x30,0x40,0xF8,0x00},/*"讯",1*/ +/* (16 X 16 , 宋体 )*/ +{0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00}, +{0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00},/*"物",2*/ +/* (16 X 16 , 宋体 )*/ +{0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0x10,0x11,0x16,0xF0,0x14,0x13,0x10,0x00,0x00}, +{0x10,0x1F,0x08,0x08,0xFF,0x04,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x00},/*"联",3*/ +/* (16 X 16 , 宋体 )*/ +{0x00,0xFE,0x02,0x22,0x42,0x82,0x72,0x02,0x22,0x42,0x82,0x72,0x02,0xFE,0x00,0x00}, +{0x00,0xFF,0x10,0x08,0x06,0x01,0x0E,0x10,0x08,0x06,0x01,0x4E,0x80,0x7F,0x00,0x00},/*"网",4*/ +/* (16 X 16 , 宋体 )*/ +{0x00,0x80,0x60,0xF8,0x07,0x00,0xFE,0x52,0x52,0x52,0x52,0x52,0xFE,0x00,0x00,0x00}, +{0x01,0x00,0x00,0xFF,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x29,0x4F,0x88,0x08,0x00},/*"俱",3*/ +/* (16 X 16 , 宋体 )*/ +{0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00}, +{0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00},/*"乐",4*/ +/* (16 X 16 , 宋体 )*/ +{0x40,0x44,0x54,0x65,0x46,0x44,0x64,0x54,0x44,0x40,0xFE,0x02,0x22,0xDA,0x06,0x00}, +{0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x00},/*"部",5*/ +/* (16 X 16 , 宋体 )*/ +{0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00}, +{0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00},/*"温",5*/ +/* (16 X 16 , 宋体 )*/ +{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00}, +{0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},/*"度",6*/ +/* (16 X 16 , 宋体 )*/ +{0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00}, +{0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00},/*"湿",7*/ +/* (16 X 16 , 宋体 )*/ +{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00}, +{0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},/*"度",8*/ +/* (16 X 16 , 宋体 )*/ +{0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F,0x40,0xC0,0x50,0x48,0x46,0x40,0x40,0x00}, +{0x80,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00},/*"光",9*/ +/* (16 X 16 , 宋体 )*/ +{0x02,0xE2,0x22,0x22,0x3E,0x00,0x80,0x9E,0x92,0x92,0xF2,0x92,0x92,0x9E,0x80,0x00}, +{0x00,0x43,0x82,0x42,0x3E,0x40,0x47,0x44,0x44,0x44,0x7F,0x44,0x44,0x54,0xE7,0x00},/*"强",10*/ +/* (16 X 16 , 宋体 )*/ +}; + +#endif diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/mcu_init.h b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/mcu_init.h new file mode 100644 index 00000000..45cc8711 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/mcu_init.h @@ -0,0 +1,18 @@ +#ifndef __MCU_INIT_H +#define __MCU_INIT_H + +#include "gd32vf103.h" +#include "usart.h" + + +#define LEDR_GPIO_PORT GPIOC +#define LEDG_GPIO_PORT GPIOA +#define LEDB_GPIO_PORT GPIOA + +#define LEDR_PIN GPIO_PIN_13 +#define LEDG_PIN GPIO_PIN_1 +#define LEDB_PIN GPIO_PIN_2 + +void board_init(); + +#endif //__MCU_INIT_H diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/usart.h b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/usart.h new file mode 100644 index 00000000..bb5f1594 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Inc/usart.h @@ -0,0 +1,10 @@ +#ifndef __USART_H +#define __USART_H + +#define USART0_GPIO_TX_PIN GPIO_PIN_9 +#define USART0_GPIO_RX_PIN GPIO_PIN_10 +#define USART0_GPIO_PORT GPIOA + +void usart0_init(int baud); + +#endif // __USART_H diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/gd32vf103_it.c b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/gd32vf103_it.c new file mode 100644 index 00000000..953c2f64 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/gd32vf103_it.c @@ -0,0 +1,11 @@ +#include "tos_k.h" + +// systick handler +void eclic_mtip_handler() { + port_systick_config((uint32_t)k_cpu_cycle_per_tick); + if (tos_knl_is_running()) { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } +} diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/mcu_init.c b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/mcu_init.c new file mode 100644 index 00000000..149da2f5 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/mcu_init.c @@ -0,0 +1,19 @@ +#include "mcu_init.h" +#include "lcd.h" +void board_init() { + + SystemInit(); + rcu_periph_clock_enable(RCU_GPIOA); + rcu_periph_clock_enable(RCU_GPIOC); + + gpio_init(LEDR_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LEDR_PIN); + gpio_init(LEDG_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LEDG_PIN); + gpio_init(LEDB_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LEDB_PIN); + + gpio_bit_set(LEDR_GPIO_PORT, LEDR_PIN); + gpio_bit_set(LEDG_GPIO_PORT, LEDG_PIN); + gpio_bit_set(LEDB_GPIO_PORT, LEDB_PIN); + + LCD_Init(); // init LCD + LCD_Clear(BLACK); +} diff --git a/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/usart.c b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/usart.c new file mode 100644 index 00000000..9d6c0d6f --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/BSP/Src/usart.c @@ -0,0 +1,28 @@ +#include "gd32vf103.h" +#include "usart.h" +void usart0_init(int baud) +{ + /* enable GPIO clock */ + rcu_periph_clock_enable(RCU_GPIOA); + + /* enable USART0 clock */ + rcu_periph_clock_enable(RCU_USART0); + + /* connect port to USART0_Tx */ + gpio_init(USART0_GPIO_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, USART0_GPIO_TX_PIN); + + /* connect port to USART0_Rx */ + gpio_init(USART0_GPIO_PORT, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, USART0_GPIO_RX_PIN); + + /* USART0 configure */ + usart_deinit(USART0); + usart_baudrate_set(USART0, baud); + usart_word_length_set(USART0, USART_WL_8BIT); + usart_stop_bit_set(USART0, USART_STB_1BIT); + usart_parity_config(USART0, USART_PM_NONE); + usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE); + usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE); + usart_receive_config(USART0, USART_RECEIVE_ENABLE); + usart_transmit_config(USART0, USART_TRANSMIT_ENABLE); + usart_enable(USART0); +} diff --git a/board/LILYGO_TTGO_T_Display_GD32V/README.md b/board/LILYGO_TTGO_T_Display_GD32V/README.md new file mode 100644 index 00000000..aaddbd62 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/README.md @@ -0,0 +1,13 @@ +#使用openocd调试 + +需要编译特定的openocd + + +```git clone https://github.com/riscv-mcu/riscv-openocd.git``` + +如果用的是Sipeed USB-JTAG/TTL RISC-V Debugger,需要在编译的时候enable ftdi + +``` +./configure --enable-cmsis-dap --enable-ftdi +``` + diff --git a/board/LILYGO_TTGO_T_Display_GD32V/TOS_CONFIG/tos_config.h b/board/LILYGO_TTGO_T_Display_GD32V/TOS_CONFIG/tos_config.h new file mode 100644 index 00000000..fae07e78 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/TOS_CONFIG/tos_config.h @@ -0,0 +1,60 @@ +#ifndef INC_TOS_CONFIG_H_ +#define INC_TOS_CONFIG_H_ + +#include "gd32vf103.h" +#include "stddef.h" + +// 配置TencentOS tiny默认支持的最大优先级数量 +#define TOS_CFG_TASK_PRIO_MAX 10u + +// 配置TencentOS tiny的内核是否开启时间片轮转 +#define TOS_CFG_ROUND_ROBIN_EN 0u + +// 配置TencentOS tiny是否校验指针合法 +#define TOS_CFG_OBJECT_VERIFY_EN 0u + +#define TOS_CFG_TASK_DYNAMIC_CREATE_EN 0u + +// TencentOS tiny 事件模块功能宏 +#define TOS_CFG_EVENT_EN 1u + +// 配置TencentOS tiny是否开启动态内存模块 +#define TOS_CFG_MMHEAP_EN 1u + +// 配置TencentOS tiny动态内存池大小 +#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 8192 + +// 配置TencentOS tiny是否开启互斥锁模块 +#define TOS_CFG_MUTEX_EN 1u + +// 配置TencentOS tiny是否开启软件定时器模块 +#define TOS_CFG_TIMER_EN 0u + +// 配置TencentOS tiny是否开启信号量模块 +#define TOS_CFG_SEM_EN 1u + +#define TOS_CFG_CPU_SYSTICK_PRIO 0xF + +// 配置TencentOS tiny空闲任务栈大小 +#define TOS_CFG_IDLE_TASK_STK_SIZE 512u + +// 配置TencentOS tiny中断栈大小 +#define TOS_CFG_IRQ_STK_SIZE 128u + +// 配置TencentOS tiny的tick频率 +#define TOS_CFG_CPU_TICK_PER_SECOND 1000u + +// 配置TencentOS tiny CPU频率 +// 除4的原因是,Bumblebee内核通过core_clk_aon四分频来更新mtime寄存器 +// 具体信息参见《Bumblebee内核简明数据手册》 +#define TOS_CFG_CPU_CLOCK (SystemCoreClock/4) + +// 配置是否将TIMER配置成函数模式 +#define TOS_CFG_TIMER_AS_PROC 1u + +#define TOS_CFG_VFS_EN 1u + +#define TOS_CFG_MMBLK_EN 1u + + +#endif /* INC_TOS_CONFIG_H_ */ diff --git a/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.cproject b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.cproject new file mode 100644 index 00000000..2200d35a --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.cproject @@ -0,0 +1,440 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.gitignore b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.gitignore new file mode 100644 index 00000000..3df573fe --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.project b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.project new file mode 100644 index 00000000..4ce2ab69 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/.project @@ -0,0 +1,99 @@ + + + lcd + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Application + 2 + virtual:/virtual + + + GD32VF103_Firmware_Library + 2 + $%7BPARENT-4-PROJECT_LOC%7D/platform/vendor_bsp/gd/GD32VF103_Firmware_Library + + + TencentOS_tiny + 2 + virtual:/virtual + + + Application/Hardware + 2 + $%7BPARENT-2-PROJECT_LOC%7D/BSP/Hardware + + + Application/Inc + 2 + $%7BPARENT-2-PROJECT_LOC%7D/BSP/Inc + + + Application/Src + 2 + $%7BPARENT-2-PROJECT_LOC%7D/BSP/Src + + + Application/tos_config.h + 1 + $%7BPARENT-2-PROJECT_LOC%7D/TOS_CONFIG/tos_config.h + + + TencentOS_tiny/arch + 2 + virtual:/virtual + + + TencentOS_tiny/kernel + 2 + $%7BPARENT-4-PROJECT_LOC%7D/kernel + + + TencentOS_tiny/arch/risc-v + 2 + virtual:/virtual + + + TencentOS_tiny/arch/risc-v/bumblebee + 2 + TOP_DIR/arch/risc-v/bumblebee/gcc + + + TencentOS_tiny/arch/risc-v/common + 2 + $%7BPARENT-4-PROJECT_LOC%7D/arch/risc-v/common + + + TencentOS_tiny/arch/risc-v/rv32i + 2 + TOP_DIR/arch/risc-v/rv32i/gcc + + + + + TOP_DIR + $%7BPARENT-4-PROJECT_LOC%7D + + + diff --git a/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/gd32vf103_libopt.h b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/gd32vf103_libopt.h new file mode 100644 index 00000000..c07eaa8c --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/gd32vf103_libopt.h @@ -0,0 +1,61 @@ +/*! + \file gd32vf103_libopt.h + \brief library optional for gd32vf103 + + \version 2019-6-5, V1.0.0, demo for GD32VF103 +*/ + +/* + Copyright (c) 2019, GigaDevice Semiconductor Inc. + + Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. +*/ + +#ifndef GD32VF103_LIBOPT_H +#define GD32VF103_LIBOPT_H + +#include "gd32vf103_adc.h" +#include "gd32vf103_bkp.h" +#include "gd32vf103_can.h" +#include "gd32vf103_crc.h" +#include "gd32vf103_dac.h" +#include "gd32vf103_dma.h" +#include "gd32vf103_eclic.h" +#include "gd32vf103_exmc.h" +#include "gd32vf103_exti.h" +#include "gd32vf103_fmc.h" +#include "gd32vf103_gpio.h" +#include "gd32vf103_i2c.h" +#include "gd32vf103_fwdgt.h" +#include "gd32vf103_dbg.h" +#include "gd32vf103_pmu.h" +#include "gd32vf103_rcu.h" +#include "gd32vf103_rtc.h" +#include "gd32vf103_spi.h" +#include "gd32vf103_timer.h" +#include "gd32vf103_usart.h" +#include "gd32vf103_wwdgt.h" +#include "n200_func.h" + +#endif /* GD32VF103_LIBOPT_H */ diff --git a/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/link.lds b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/link.lds new file mode 100644 index 00000000..1c32e640 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/link.lds @@ -0,0 +1,175 @@ +OUTPUT_ARCH( "riscv" ) + +ENTRY( _start ) + +MEMORY +{ + /* Run in FLASH */ + flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 128k + ram (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 32K + + /* Run in RAM */ +/* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 24k + ram (wxa!ri) : ORIGIN = 0x20006000, LENGTH = 8K +*/ +} + + +SECTIONS +{ + __stack_size = DEFINED(__stack_size) ? __stack_size : 2K; + + + .init : + { + KEEP (*(SORT_NONE(.init))) + } >flash AT>flash + + .ilalign : + { + . = ALIGN(4); + PROVIDE( _ilm_lma = . ); + } >flash AT>flash + + .ialign : + { + PROVIDE( _ilm = . ); + } >flash AT>flash + + .text : + { + *(.rodata .rodata.*) + *(.text.unlikely .text.unlikely.*) + *(.text.startup .text.startup.*) + *(.text .text.*) + *(.gnu.linkonce.t.*) + } >flash AT>flash + + .fini : + { + KEEP (*(SORT_NONE(.fini))) + } >flash AT>flash + + . = ALIGN(4); + + PROVIDE (__etext = .); + PROVIDE (_etext = .);/*0x80022c8*/ + PROVIDE (etext = .);/*0x80022c8*/ + PROVIDE( _eilm = . ); + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >flash AT>flash + + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) + PROVIDE_HIDDEN (__init_array_end = .); + } >flash AT>flash + + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >flash AT>flash + + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } >flash AT>flash + + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } >flash AT>flash + + . = ALIGN(4); + PROVIDE( _eilm = . ); + + .lalign : + { + . = ALIGN(4); + PROVIDE( _data_lma = . ); + } >flash AT>flash + + .dalign : + { + . = ALIGN(4); + PROVIDE( _data = . ); + } >ram AT>flash + + + .data : + { + *(.rdata) + + *(.gnu.linkonce.r.*) + *(.data .data.*) + *(.gnu.linkonce.d.*) + . = ALIGN(8); + PROVIDE( __global_pointer$ = . + 0x800); + *(.sdata .sdata.*) + *(.gnu.linkonce.s.*) + . = ALIGN(8); + *(.srodata.cst16) + *(.srodata.cst8) + *(.srodata.cst4) + *(.srodata.cst2) + *(.srodata .srodata.*) + } >ram AT>flash + + . = ALIGN(4); + PROVIDE( _edata = . ); + PROVIDE( edata = . ); + + PROVIDE( _fbss = . ); /*0X200052A0 0X200002A0*/ + PROVIDE( __bss_start = . ); + .bss : + { + *(.sbss*) + *(.gnu.linkonce.sb.*) + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + } >ram AT>ram + + . = ALIGN(8); + PROVIDE( _end = . ); /*0X2000,0340*/ + PROVIDE( end = . ); + + .stack ORIGIN(ram) + LENGTH(ram) - __stack_size : + { + PROVIDE( _heap_end = . ); + . = __stack_size; + PROVIDE( _sp = . ); + } >ram AT>ram +} diff --git a/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/main.c b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/main.c new file mode 100644 index 00000000..de8ef040 --- /dev/null +++ b/board/LILYGO_TTGO_T_Display_GD32V/eclipse/lcd/main.c @@ -0,0 +1,150 @@ +#include "mcu_init.h" +#include "tos_k.h" +#include "lcd.h" + +#define TASK_SIZE 2048 + +k_task_t task1_handle; +k_task_t task2_handle; +k_task_t lcd_handle; + +uint8_t task1_stk[TASK_SIZE]; +uint8_t task2_stk[TASK_SIZE]; +uint8_t lcd_stk[TASK_SIZE/2]; + +int share = 0xCBA7F9; +k_sem_t sem; + +typedef struct { + int port; + int pin; +} Led_t; + +Led_t leds[] = { + { LEDR_GPIO_PORT, LEDR_PIN }, + { LEDG_GPIO_PORT, LEDG_PIN }, + { LEDB_GPIO_PORT, LEDB_PIN } +}; + + +void task1(void *arg) +{ + int task_cnt1 = 0; + while (1) { + printf("hello world from %s cnt: %d\n", __func__, task_cnt1++); + tos_sem_pend(&sem, ~0U); + + for(int i=0; i