-
Notifications
You must be signed in to change notification settings - Fork 8
/
dgus_reg.h
355 lines (323 loc) · 8.39 KB
/
dgus_reg.h
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#pragma once
/**
* @file dgus_reg.h
* @author Barry Carter
* @date 01 Jan 2021
* @brief DGUS II LCD Driver. Register and cointrol definitions
*
*/
#define member_size(type, member) sizeof(((type *)0)->member) /**< Get the member size of a struct */
#define SWP16(pt) (pt>>8) | (pt<<8) /**< Swap XY bytes to be YX */
#define SWP32(i) ((i&0xff000000)>>24)| ((i&0xff0000)>>8) | ((i&0xff00)<<8) | ((i&0xff)<<24) /**< Swap all bytes in a u32 to be le order */
/* Base addresses and hard coded vars */
#define PIC_SET_PAGE_BASE ((unsigned long)0x5A010000) /**< Base address of the page change */
#define DGUS_RESET ((unsigned long)0x55AA5AA5) /**< Magic reset command for the T5 */
#define DGUS_RESET_HARD ((unsigned long)0x55AA5A5A) /**< Magic reset command for the T5 and all onboard periphs */
/* Command addresses. A REG is 8bit, VAR cmd typically 16 */
/**
* @brief Addresses of the command and variables
*/
enum command {
DGUS_CMD_REG_W = 0x80,
DGUS_CMD_REG_R,
DGUS_CMD_VAR_W,
DGUS_CMD_VAR_R,
DGUS_CMD_CURVE_W
};
#define DGUS_RETURN uint8_t /**< Defines the return status of a function */
/**
* @brief DGUS_RETURN Response to an async request such as dgus_request_var()
*/
#define DGUS_OK 0 /**< Everything was fine */
#define DGUS_TIMEOUT 1 /**< Timed out waiting for OK */
#define DGUS_ERROR 2 /**< Unspecified serious error */
#define DGUS_CURVE_BUFFER_FULL 10 /**< Cannot append any more data to this buffer */
#define DGUS_CURVE_CHANNEL_NOT_FOUND 11 /**< The Curve channel 0-7 was not initialised or found */
/**
* @brief Layout of the VAR register
*
*/
enum dgus_cmd_reg { // word sized registers
DeviceId = 0x00,
SystemReset = 0x04,
OsUpdateCmd = 0x06,
NorFlashRWCmd = 0x08,
Reserved0C = 0x0C,
Ver = 0x0F,
Rtc = 0x10,
PicPage = 0x14,
GuiStatus = 0x15,
TpStatus = 0x16,
Reserved1A = 0x1A,
Vcc = 0x30,
Led = 0x31,
Adc01 = 0x32,
Reserved34 = 0x34,
FolderName = 0x7C, // Max 8 chars like "DWIN_SET"
SystemConfig = 0x80,
LedConfig = 0x82,
PicSetPage = 0x84,
Pwm0Set = 0x86,
Reserved88 = 0x88,
Pwm0Out = 0x92,
Reserved93 = 0x93,
RTCSet = 0x9C,
MusicPlaySet = 0xA0,
BmpDownloadNotSupported = 0xA2,
JpegDownload = 0xA6,
NANDFlashRWCmd = 0xAA,
TouchControl = 0xB0,
SimTouchControl = 0xD4,
PointerOverlay = 0xD8,
ReservedDC = 0xDC,
CrcMemoryCheck = 0xE0,
ReservedE2 = 0xE2,
MusicStreaming = 0xF0,
PaintingInterface = 0xF4,
DcsBusData = 0x100,
Undefined200 = 0x200,
Curve = 0x300,
Reserved380 = 0x380,
};
/**
* @brief The position of the control in x,y from the top left of the display
*
* @return typedef struct
*/
typedef struct __attribute__((packed)) dgus_control_position {
uint16_t x;
uint16_t y;
} dgus_control_position; /**< xy position of control */
/**
* @brief position and size of the control
*
* @return typedef struct
*/
typedef struct __attribute__((packed)) dgus_control_size {
uint16_t x_top;
uint16_t y_top;
uint16_t x_bottom;
uint16_t y_bottom;
} dgus_control_size; /**< xy position and size of control */
/* Control specific structures */
typedef struct __attribute__((packed)) var_icon {
uint16_t vp;
uint16_t x;
uint16_t y;
uint16_t v_min;
uint16_t v_max;
uint16_t icon_min;
uint16_t icon_max;
uint8_t icon_lib;
uint8_t mode;
uint8_t layer_mode;
uint8_t icon_gamma;
uint8_t pic_gamma;
uint8_t filter_set;
} var_icon; /**< Icon Data */
typedef struct __attribute__((packed)) animation_icon {
uint16_t vp;
uint16_t x;
uint16_t y;
uint16_t reset_icon;
uint16_t v_stop;
uint16_t v_start;
uint16_t icon_stop;
uint16_t icon_start;
uint16_t icon_end;
uint8_t icon_lib;
uint8_t mode;
uint8_t layer_mode;
uint8_t icon_gamma;
uint8_t pic_gamma;
uint8_t time;
uint8_t display_mode;
uint8_t filter_set;
} animation_icon; /**< Animation Icon Data */
typedef struct __attribute__((packed)) slider_display {
uint16_t vp;
uint16_t v_begin;
uint16_t v_end;
uint16_t x_begin;
uint16_t x_end;
uint16_t icon_id;
uint16_t y;
uint8_t x_adj;
uint8_t mode;
uint8_t icon_lib;
uint8_t icon_mode;
uint8_t vp_data_mode;
uint8_t layer_mode;
uint8_t icon_gamma;
uint8_t pic_gamma;
uint8_t filter_set;
} slider_display; /**< Slider Data */
typedef struct __attribute__((packed)) artistic_var {
uint16_t vp;
uint16_t x;
uint16_t y;
uint16_t icon_0;
uint8_t icon_lib;
uint8_t icon_mode;
uint8_t integer_digits;
uint8_t decimal_digits;
uint8_t vp_mode;
uint8_t alignment;
uint8_t layer_mode;
uint8_t icon_gamma;
uint8_t pic_gamma;
uint8_t filter_set;
} artistic_var; /**< Artistic Data */
typedef struct __attribute__((packed)) image_animation {
uint16_t zero;
uint16_t pic_begin;
uint16_t pic_end;
uint8_t frame_time;
uint8_t icl_Lib_id;
uint8_t pic_end_exp;
uint8_t reserved[16];
} image_animation; /**< Image Animation Data */
typedef struct __attribute__((packed)) icon_rotation {
uint16_t vp;
uint16_t icon_id;
uint16_t icon_xc;
uint16_t icon_yc;
uint16_t xc;
uint16_t yc;
uint16_t v_begin;
uint16_t v_end;
uint16_t al_begin;
uint16_t al_end;
uint8_t vp_mode;
uint8_t lib_id;
uint8_t mode;
} icon_rotation; /**< Icon Rotation Data */
typedef struct __attribute__((packed)) bit_var_icon {
uint16_t vp;
uint16_t vp_aux;
uint8_t display_mode;
uint8_t move_mode;
uint8_t icon_mode;
uint8_t icon_lib;
uint16_t icon_0_s;
uint16_t icon_0_e;
uint16_t icon_1_s;
uint16_t icon_1_e;
uint16_t x;
uint16_t y;
uint16_t dismove;
uint16_t reserved;
} bit_var_icon; /**< Bit Var Icon Data */
typedef struct __attribute__((packed)) data_var {
uint16_t vp;
uint16_t x;
uint16_t y;
uint16_t colour;
uint8_t lib_id;
uint8_t font_width;
uint8_t alignment;
uint8_t integer_digits;
uint8_t decimal_digits;
uint8_t vp_mode;
uint8_t len_unit;
uint8_t string_unit[];
} data_var; /**< Data Var Data */
typedef struct __attribute__((packed)) rtc_display_digital {
uint16_t zero;
uint16_t x;
uint16_t y;
uint16_t colour;
uint8_t lib_id;
uint8_t font_width;
uint8_t string_code[]; // max 15
} rtc_display_digital; /**< RTC Data */
typedef struct __attribute__((packed)) rtc_display_analogue {
uint16_t one; // literally 0x0001
uint16_t x;
uint16_t y;
uint16_t icon_hour;
uint32_t icon_hour_central;
uint16_t icon_minute;
uint32_t icon_minute_central;
uint16_t icon_second;
uint32_t icon_second_central;
uint8_t lib_id;
uint8_t reserved;
} rtc_display_analogue; /**< RTC Display Data */
typedef struct __attribute__((packed)) hex_data {
uint16_t vp;
uint16_t x;
uint16_t y;
uint8_t mode;
uint8_t lib_id;
uint8_t font_x;
uint8_t string_code[]; // max 15
} hex_data; /**< Hex Data */
typedef struct __attribute__((packed)) roll_text {
uint16_t vp;
uint8_t rolling_mode;
uint8_t rolling_distance_px;
uint8_t adjust_mode;
uint8_t reserved_00;
uint16_t colour;
uint16_t x_start;
uint16_t y_start;
uint16_t x_end;
uint16_t y_end;
uint8_t font_0_id;
uint8_t font_1_id;
uint8_t font_x_dots;
uint8_t font_y_dots;
uint8_t encode_mode;
uint8_t text_distance_px;
uint32_t reserved;
} roll_text; /**< Rolling Text Data */
typedef struct __attribute__((packed)) data_window {
uint16_t vp;
uint8_t v_min;
uint8_t v_max;
uint8_t integer_digits;
uint8_t decimal_digits;
uint8_t data_num;
uint8_t mode;
uint16_t x;
uint16_t y;
uint16_t adjust_step;
uint8_t font_x_dots;
uint8_t font_y_dots;
uint16_t colour;
uint8_t font_x_dots1;
uint8_t font_y_dots1;
uint16_t colour1;
uint16_t reserved;
} data_window; /**< Window Data */
typedef struct __attribute__((packed)) basic_graphic {
uint16_t vp;
uint8_t area[8];
uint8_t dashed_line_enable;
uint8_t dash_set[4];
uint8_t pixel_scale[13];
} basic_graphic; /**< Graphic Data */
typedef struct __attribute__((packed)) zone_rolling {
uint16_t x_start;
uint16_t y_start;
uint16_t x_end;
uint16_t y_end;
uint16_t distance_move;
uint16_t mode_move;
} zone_rolling; /**< Zone Data */
typedef struct __attribute__((packed)) qr_code {
uint16_t vp;
uint16_t x;
uint16_t y;
uint16_t unit_pixels;
uint8_t fix_mode;
uint8_t reserved_0;
} qr_code; /**< QR Data */
typedef struct __attribute__((packed)) area_brightness {
uint16_t vp;
uint16_t x_start;
uint16_t y_start;
uint16_t x_end;
uint16_t y_end;
} area_brightness; /**< Area Brightness Data */