lcd.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-10-14 spaceman first version
  9. */
  10. #include <board.h>
  11. // #define XSIZE_PHYS 800
  12. // #define YSIZE_PHYS 480
  13. // extern __align(256) rt_uint32_t LTDC_Buf[XSIZE_PHYS*YSIZE_PHYS];
  14. #define LCD_SPI_CS(a) \
  15. if (a) \
  16. GPIOB->BSRR = GPIO_Pin_11; \
  17. else \
  18. GPIOB->BRR = GPIO_Pin_11;
  19. #define SPI_DCLK(a) \
  20. if (a) \
  21. GPIOB->BSRR = GPIO_Pin_9; \
  22. else \
  23. GPIOB->BRR = GPIO_Pin_9;
  24. #define SPI_SDA(a) \
  25. if (a) \
  26. GPIOB->BSRR = GPIO_Pin_0; \
  27. else \
  28. GPIOB->BRR = GPIO_Pin_0;
  29. #define LCD_RST(a) \
  30. if (a) \
  31. GPIOD->BSRR = GPIO_Pin_6; \
  32. else \
  33. GPIOD->BRR = GPIO_Pin_6;
  34. #define Set_Rst GPIOD->BSRR = GPIO_Pin_6
  35. #define Clr_Rst GPIOD->BRR = GPIO_Pin_6
  36. #define Lcd_Light_ON GPIOD->BSRR = GPIO_Pin_8 //PD8为高电平 背光打开
  37. #define Lcd_Light_OFF GPIOD->BRR = GPIO_Pin_8 //PD8为低电平 背光关闭
  38. //************* 24位色(1600万色)定义 *************//
  39. #define White 0xFFFFFF
  40. #define Black 0x000000
  41. #define Blue 0xFF0000
  42. #define Blue2 0xFF3F3F
  43. #define Red 0x0000FF
  44. #define Magenta 0xFF00FF
  45. #define Green 0x00FF00
  46. #define Cyan 0xFFFF00
  47. #define Yellow 0x00FFFF
  48. //************* 16位色定义 *************//
  49. //#define White 0xFFFF
  50. //#define Black 0x0000
  51. //#define Blue 0x001F
  52. //#define Blue2 0x051F
  53. //#define Red 0xF800
  54. //#define Magenta 0xF81F
  55. //#define Green 0x07E0
  56. //#define Cyan 0x7FFF
  57. //#define Yellow 0xFFE0
  58. void LCD_Initial(rt_uint32_t LTDC_Buf1, rt_uint32_t LTDC_Buf2); //LCD初始化函数
  59. // volatile void LCD_delay(volatile int time);
  60. // void WriteComm(unsigned char CMD);
  61. // void WriteData(rt_uint32_t dat);
  62. // void LCD_WR_REG(rt_uint16_t Index,rt_uint16_t CongfigTemp);
  63. // void Lcd_ColorBox(rt_uint16_t xStart,rt_uint16_t yStart,rt_uint16_t xLong,rt_uint16_t yLong,rt_uint32_t Color);
  64. //void SPILCD_DrawLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short color);
  65. //void SPILCD_ShowChar(unsigned short x,unsigned short y,unsigned char num, unsigned int fColor, unsigned int bColor,unsigned char flag) ;
  66. // void LCD_PutString(unsigned short x, unsigned short y, char *s, unsigned int fColor, unsigned int bColor,unsigned char flag);
  67. // void LCD_Fill_Pic(rt_uint16_t x, rt_uint16_t y,rt_uint16_t pic_H, rt_uint16_t pic_V, rt_uint32_t* pic);