lcd_ili9341.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-02-23 Rbb666 First version
  9. */
  10. #ifndef __LCD_ILI9341_H__
  11. #define __LCD_ILI9341_H__
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. #include "hal_data.h"
  17. #include <stdint.h>
  18. #include <rtthread.h>
  19. typedef struct
  20. {
  21. uint16_t width; /* LCD width */
  22. uint16_t height; /* LCD high */
  23. uint32_t id; /* LCD ID */
  24. uint8_t dir; /* 0:Vertical | 1:Vertical */
  25. uint16_t wramcmd; /* gram cmd */
  26. uint16_t setxcmd; /* set x cmd */
  27. uint16_t setycmd; /* set y cmd */
  28. } _lcd_dev;
  29. /* LCD param */
  30. extern _lcd_dev lcddev;
  31. #define USE_HORIZONTAL 0 /* 0-0째|1-90째|2-180째|-270째 */
  32. /* lcd size */
  33. #define LCD_W 240
  34. #define LCD_H 320
  35. #define WHITE 0xFFFF
  36. #define BLACK 0x0000
  37. #define BLUE 0x001F
  38. #define BRED 0XF81F
  39. #define GRED 0XFFE0
  40. #define GBLUE 0X07FF
  41. #define RED 0xF800
  42. #define MAGENTA 0xF81F
  43. #define GREEN 0x07E0
  44. #define CYAN 0x7FFF
  45. #define YELLOW 0xFFE0
  46. #define BROWN 0XBC40
  47. #define BRRED 0XFC07
  48. #define GRAY 0X8430
  49. #define LCD_DC_PIN BSP_IO_PORT_04_PIN_13
  50. #define LCD_RES_PIN BSP_IO_PORT_04_PIN_14
  51. #define LCD_CS_PIN BSP_IO_PORT_04_PIN_05
  52. #define LCD_DC_CLR rt_pin_write(LCD_DC_PIN, PIN_LOW)
  53. #define LCD_DC_SET rt_pin_write(LCD_DC_PIN, PIN_HIGH)
  54. #define LCD_RES_CLR rt_pin_write(LCD_RES_PIN, PIN_LOW)
  55. #define LCD_RES_SET rt_pin_write(LCD_RES_PIN, PIN_HIGH)
  56. #define DELAY rt_thread_mdelay
  57. void LCD_RESET(void);
  58. void LCD_WR_REG(uint8_t reg);
  59. void LCD_WR_DATA(uint8_t data);
  60. void LCD_WriteReg(uint8_t reg, uint16_t regdata);
  61. void LCD_WriteRAM_Prepare(void);
  62. void LCD_WriteData_16Bit(uint16_t Data);
  63. void LCD_direction(uint8_t direction);
  64. void LCD_SetWindows(uint16_t xStar, uint16_t yStar, uint16_t xEnd, uint16_t yEnd);
  65. void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos);
  66. void LCD_Clear(uint16_t Color);
  67. void LCD_Fill(uint16_t xsta, uint16_t ysta, uint16_t xend, uint16_t yend, uint16_t color);
  68. void lcd_fill_array_spi(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, void *pcolor);
  69. void LCD_Init(void);
  70. rt_err_t spi_lcd_init(void);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif