~ruther/stm32h747i-disco-usb-image-viewer

ref: 68abb4c6d986c3d7f3f04aa5c6610190960c1104 stm32h747i-disco-usb-image-viewer/firmware/include/display.h -rw-r--r-- 3.1 KiB
68abb4c6 — Rutherther chore: tidy up rust code 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <stm32h747xx.h>
#include <stdint.h>
#include <stdbool.h>

#ifndef DISPLAY_H
#define DISPLAY_H

typedef enum {
  DSI_VIDEO_NON_BURST_PULSES = 0,
  DSI_VIDEO_NON_BURST_EVENTS = 1,
  DSI_VIDEO_BURST = 2,
} dsi_video_mode_t;

typedef struct {
  uint16_t active_width;
  uint16_t active_height;
  uint16_t h_back_porch;
  uint16_t h_front_porch;
  uint16_t v_back_porch;
  uint16_t v_front_porch;

  // ?
  /* uint16_t h_sync_lane_byte_cycles; */

  uint16_t h_sync;
  uint16_t v_sync;
  bool h_sync_pol;
  bool v_sync_pol;
  bool not_data_enable_pol;
  bool pixel_clock_pol;

  dsi_video_mode_t video_mode;

  uint8_t channel;
} display_config_t;

typedef enum {
  CODING_16_BIT_1 = 0,
  CODING_16_BIT_2 = 1,
  CODING_16_BIT_3 = 2,
  CODING_18_BIT_1 = 3,
  CODING_18_BIT_2 = 4,
  CODING_24_BIT = 5,
} dsi_color_coding_t;

typedef enum {
  LTDC_ARGB8888 = 0,
  LTDC_RGB888 = 1,
  LTDC_RGB565 = 2,
  LTDC_ARGB1555 = 3,
  LTDC_ARGB4444 = 4,
  LTDC_L8 = 5,
  LTDC_AL44 = 6,
  LTDC_AL88 = 7,
} ltdc_layer_pixel_format_t;

typedef struct {
  uint8_t channel;
  bool color_loosely_packed;
  dsi_color_coding_t color_coding;
  dsi_color_coding_t wrapper_color_coding;
  uint8_t lp_size;
  uint8_t vlp_size;
} dsi_config_t;

typedef enum {
  DSI_MODE_ADAPTED_COMMAND,
  DSI_MODE_VIDEO,
} dsi_mode_t;

typedef struct {
  uint8_t divn;
  uint8_t idf;
  uint8_t odf;
  uint8_t eckdiv;
} dsi_pll_config_t;

typedef struct {
  bool crc_reception_enable;
  bool ecc_reception_enable;
  bool bta_enable;
  bool eotp_reception_enable;
  bool eotp_transmission_enable;
} dsi_flow_config_t;

typedef struct {
  uint8_t data_lanes;
  bool auto_clock_lane_control;
  uint8_t clock_control;

  uint8_t clock_hs2lp;
  uint8_t clock_lp2hs;

  uint8_t data_hs2lp;
  uint8_t data_lp2hs;
  uint8_t max_read_time;

  uint8_t stop_wait_time;

  uint8_t unit_interval;
} dsi_phy_config_t;


typedef struct {
  DSI_TypeDef* dsi;
  LTDC_TypeDef* ltdc;
  LTDC_Layer_TypeDef* layer;
  display_config_t config;
} display_t;

void display_init(display_t *display, DSI_TypeDef *dsi, LTDC_TypeDef* ltdc, LTDC_Layer_TypeDef* layer, display_config_t display_config);
void display_start(display_t* display);

void display_setup(display_t *display, uint32_t dsi_khz, uint32_t ltdc_khz,
                   dsi_mode_t mode,
                   dsi_pll_config_t pll, dsi_phy_config_t phy,
                   dsi_flow_config_t flow, dsi_config_t dsi_config);

void display_command_mode(display_t* display);
void display_video_mode(display_t* display);

void display_dsi_short_write(display_t* display, uint8_t lsb, uint8_t msb, uint8_t discriminant);
void display_dsi_long_write(display_t* display, uint8_t cmd, uint8_t* data, uint16_t len, uint8_t discriminant);
void display_dsi_read(display_t* display, uint8_t* buffer);

void display_set_command_mode_transmission_kind(display_t* display, bool low_power);

// Layer calls
void display_layer_setup(display_t *display, void* buffer, ltdc_layer_pixel_format_t pixel_format);
void display_set_framebuffer(display_t* display, void* buffer);
void display_refresh(display_t* display);
void display_reload(display_t *display);

#endif // DISPLAY_H
Do not follow this link