1
0

drv_st7796.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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-05-23 Chushicheng the first version.
  9. */
  10. #ifndef DRV_ST7796_H__
  11. #define DRV_ST7796_H__
  12. #include <rtdevice.h>
  13. #define LCD_DEVICE_NAME "st7796"
  14. typedef enum
  15. {
  16. ST7796_DIR_0 = 0x08U,
  17. ST7796_DIR_90 = 0x68U,
  18. ST7796_DIR_180 = 0xC8U,
  19. ST7796_DIR_270 = 0xA8U,
  20. } st7796_direction_t;
  21. typedef enum
  22. {
  23. ST7796_RGB444 = 3,
  24. ST7796_RGB565 = 5,
  25. ST7796_RGB666 = 6,
  26. ST7796_RGB888 = 7
  27. } st7796_pixfmt_t;
  28. typedef struct
  29. {
  30. rt_err_t (*reset_cb)(void *handle);
  31. rt_err_t (*backlight_cb)(void *handle, rt_uint8_t on);
  32. rt_err_t (*write_cmd_cb)(void *handle, rt_uint8_t *cmd, rt_uint8_t len);
  33. rt_err_t (*write_data_cb)(void *handle, void *data, rt_uint32_t len);
  34. } st7796_cb_t;
  35. typedef struct
  36. {
  37. st7796_direction_t direction;
  38. st7796_pixfmt_t pix_fmt;
  39. rt_uint8_t inversion;
  40. rt_uint8_t bgr_mode;
  41. uint8_t mirrored;
  42. } st7796_config_t;
  43. typedef struct
  44. {
  45. void *user_data;
  46. st7796_cb_t cb;
  47. st7796_config_t config;
  48. } st7796_lcd_t;
  49. typedef struct
  50. {
  51. struct rt_device parent;
  52. st7796_lcd_t st7796;
  53. struct rt_spi_device *spi_dev;
  54. } st7796_t;
  55. void lcd_load(rt_uint16_t x_start, rt_uint16_t x_end, rt_uint16_t y_start, rt_uint16_t y_end, void *data);
  56. int drv_st7796_init(void);
  57. #endif /* DRV_ST7796_H__ */