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
33
34
35
36
40
41
42
45
46
47
50
51
60
61
64
65
66
68
69
71
72
75
76
77
78
79
80
81
82
85
86
87
90
91
93
94
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
115
116
117
118
119
120
121
122
123
124
125
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
163
164
167
168
169
172
173
176
182
183
184
185
188
189
192
193
194
195
196
199
200
203
204
205
206
207
208
211
212
215
216
217
218
219
220
221
222
223
224
225
226
229
230
233
234
235
237
240
241
242
243
244
245
246
249
250
251
254
255
258
259
260
261
262
263
264
267
268
271
272
273
274
275
276
277
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
300
301
304
305
309
310
316
317
318
319
320
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
407
408
409
412
413
416
417
418
419
420
421
422
423
424
427
428
429
432
433
434
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
468
469
472
473
474
475
476
477
478
479
480
481
484
485
488
489
490
491
492
493
496
497
500
501
502
503
506
507
510
511
514
515
518
519
522
523
526
527
530
531
534
535
536
539
540
543
544
547
548
551
552
553
556
557
560
561
564
565
568
569
570
571
574
576
577
579
580
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
606
607
608
609
610
611
612
613
614
617
620
623
624
627
628
629
630
633
634
635
636
637
638
/* ... */
#ifndef STM32F4xx_HAL_DMA2D_H
#define STM32F4xx_HAL_DMA2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f4xx_hal_def.h"
/* ... */
#if defined (DMA2D)
/* ... */
/* ... */
#define MAX_DMA2D_LAYER 2U
/* ... */
typedef struct
{
uint32_t *pCLUT;
uint32_t CLUTColorMode;
/* ... */
uint32_t Size;
/* ... */
...} DMA2D_CLUTCfgTypeDef;
/* ... */
typedef struct
{
uint32_t Mode;
/* ... */
uint32_t ColorMode;
/* ... */
uint32_t OutputOffset;
/* ... */
...} DMA2D_InitTypeDef;
/* ... */
typedef struct
{
uint32_t InputOffset;
/* ... */
uint32_t InputColorMode;
/* ... */
uint32_t AlphaMode;
/* ... */
uint32_t InputAlpha;
/* ... */
...} DMA2D_LayerCfgTypeDef;
/* ... */
typedef enum
{
HAL_DMA2D_STATE_RESET = 0x00U,
HAL_DMA2D_STATE_READY = 0x01U,
HAL_DMA2D_STATE_BUSY = 0x02U,
HAL_DMA2D_STATE_TIMEOUT = 0x03U,
HAL_DMA2D_STATE_ERROR = 0x04U,
HAL_DMA2D_STATE_SUSPEND = 0x05U
...} HAL_DMA2D_StateTypeDef;
/* ... */
typedef struct __DMA2D_HandleTypeDef
{
DMA2D_TypeDef *Instance;
DMA2D_InitTypeDef Init;
void (* XferCpltCallback)(struct __DMA2D_HandleTypeDef *hdma2d);
void (* XferErrorCallback)(struct __DMA2D_HandleTypeDef *hdma2d);
#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
void (* LineEventCallback)(struct __DMA2D_HandleTypeDef *hdma2d);
void (* CLUTLoadingCpltCallback)(struct __DMA2D_HandleTypeDef *hdma2d);
void (* MspInitCallback)(struct __DMA2D_HandleTypeDef *hdma2d);
void (* MspDeInitCallback)(struct __DMA2D_HandleTypeDef *hdma2d);
/* ... */
#endif
DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER];
HAL_LockTypeDef Lock;
__IO HAL_DMA2D_StateTypeDef State;
__IO uint32_t ErrorCode;
...} DMA2D_HandleTypeDef;
#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
/* ... */
typedef void (*pDMA2D_CallbackTypeDef)(DMA2D_HandleTypeDef *hdma2d); /* ... */
#endif
/* ... */
Exported types
/* ... */
/* ... */
#define HAL_DMA2D_ERROR_NONE 0x00000000U
#define HAL_DMA2D_ERROR_TE 0x00000001U
#define HAL_DMA2D_ERROR_CE 0x00000002U
#define HAL_DMA2D_ERROR_CAE 0x00000004U
#define HAL_DMA2D_ERROR_TIMEOUT 0x00000020U
5 defines#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
#define HAL_DMA2D_ERROR_INVALID_CALLBACK 0x00000040U
#endif
/* ... */
/* ... */
#define DMA2D_M2M 0x00000000U
#define DMA2D_M2M_PFC DMA2D_CR_MODE_0
#define DMA2D_M2M_BLEND DMA2D_CR_MODE_1
#define DMA2D_R2M DMA2D_CR_MODE
/* ... */
/* ... */
#define DMA2D_OUTPUT_ARGB8888 0x00000000U
#define DMA2D_OUTPUT_RGB888 DMA2D_OPFCCR_CM_0
#define DMA2D_OUTPUT_RGB565 DMA2D_OPFCCR_CM_1
#define DMA2D_OUTPUT_ARGB1555 (DMA2D_OPFCCR_CM_0|DMA2D_OPFCCR_CM_1)
#define DMA2D_OUTPUT_ARGB4444 DMA2D_OPFCCR_CM_2
/* ... */
/* ... */
#define DMA2D_INPUT_ARGB8888 0x00000000U
#define DMA2D_INPUT_RGB888 0x00000001U
#define DMA2D_INPUT_RGB565 0x00000002U
#define DMA2D_INPUT_ARGB1555 0x00000003U
#define DMA2D_INPUT_ARGB4444 0x00000004U
#define DMA2D_INPUT_L8 0x00000005U
#define DMA2D_INPUT_AL44 0x00000006U
#define DMA2D_INPUT_AL88 0x00000007U
#define DMA2D_INPUT_L4 0x00000008U
#define DMA2D_INPUT_A8 0x00000009U
#define DMA2D_INPUT_A4 0x0000000AU
/* ... */
/* ... */
#define DMA2D_NO_MODIF_ALPHA 0x00000000U
#define DMA2D_REPLACE_ALPHA 0x00000001U
#define DMA2D_COMBINE_ALPHA 0x00000002U
/* ... */
/* ... */
/* ... */
#define DMA2D_CCM_ARGB8888 0x00000000U
#define DMA2D_CCM_RGB888 0x00000001U
/* ... */
/* ... */
#define DMA2D_IT_CE DMA2D_CR_CEIE
#define DMA2D_IT_CTC DMA2D_CR_CTCIE
#define DMA2D_IT_CAE DMA2D_CR_CAEIE
#define DMA2D_IT_TW DMA2D_CR_TWIE
#define DMA2D_IT_TC DMA2D_CR_TCIE
#define DMA2D_IT_TE DMA2D_CR_TEIE
/* ... */
/* ... */
#define DMA2D_FLAG_CE DMA2D_ISR_CEIF
#define DMA2D_FLAG_CTC DMA2D_ISR_CTCIF
#define DMA2D_FLAG_CAE DMA2D_ISR_CAEIF
#define DMA2D_FLAG_TW DMA2D_ISR_TWIF
#define DMA2D_FLAG_TC DMA2D_ISR_TCIF
#define DMA2D_FLAG_TE DMA2D_ISR_TEIF
37 defines
/* ... */
#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
/* ... */
typedef enum
{
HAL_DMA2D_MSPINIT_CB_ID = 0x00U,
HAL_DMA2D_MSPDEINIT_CB_ID = 0x01U,
HAL_DMA2D_TRANSFERCOMPLETE_CB_ID = 0x02U,
HAL_DMA2D_TRANSFERERROR_CB_ID = 0x03U,
HAL_DMA2D_LINEEVENT_CB_ID = 0x04U,
HAL_DMA2D_CLUTLOADINGCPLT_CB_ID = 0x05U,
...} HAL_DMA2D_CallbackIDTypeDef;/* ... */
#endif
/* ... */
Exported constants
/* ... */
/* ... */
#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
#define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) do{ \
(__HANDLE__)->State = HAL_DMA2D_STATE_RESET;\
(__HANDLE__)->MspInitCallback = NULL; \
(__HANDLE__)->MspDeInitCallback = NULL; \
...}while(0)...
/* ... */#else
#define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA2D_STATE_RESET)
#endif
/* ... */
#define __HAL_DMA2D_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA2D_CR_START)
/* ... */
#define __HAL_DMA2D_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__))
/* ... */
#define __HAL_DMA2D_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->IFCR = (__FLAG__))
/* ... */
#define __HAL_DMA2D_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
/* ... */
#define __HAL_DMA2D_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
/* ... */
#define __HAL_DMA2D_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__))
6 defines
/* ... */
Exported macros
/* ... */
/* ... */
HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d);
HAL_StatusTypeDef HAL_DMA2D_DeInit(DMA2D_HandleTypeDef *hdma2d);
void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d);
void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef *hdma2d);
#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
HAL_StatusTypeDef HAL_DMA2D_RegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID,
pDMA2D_CallbackTypeDef pCallback);
HAL_StatusTypeDef HAL_DMA2D_UnRegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID);/* ... */
#endif
/* ... */
/* ... */
HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
uint32_t Height);
HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2,
uint32_t DstAddress, uint32_t Width, uint32_t Height);
HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
uint32_t Height);
HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2,
uint32_t DstAddress, uint32_t Width, uint32_t Height);
HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d);
HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d);
HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d);
HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg,
uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg,
uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Abort(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Suspend(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Resume(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout);
void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d);
void HAL_DMA2D_LineEventCallback(DMA2D_HandleTypeDef *hdma2d);
void HAL_DMA2D_CLUTLoadingCpltCallback(DMA2D_HandleTypeDef *hdma2d);
/* ... */
/* ... */
HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line);
HAL_StatusTypeDef HAL_DMA2D_EnableDeadTime(DMA2D_HandleTypeDef *hdma2d);
HAL_StatusTypeDef HAL_DMA2D_DisableDeadTime(DMA2D_HandleTypeDef *hdma2d);
HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime(DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime);
/* ... */
/* ... */
HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d);
uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d);
/* ... */
/* ... */
Exported functions
/* ... */
/* ... */
#define DMA2D_LINE_WATERMARK_MAX DMA2D_LWR_LW
/* ... */
/* ... */
#define DMA2D_COLOR_VALUE 0x000000FFU
/* ... */
/* ... */
#define DMA2D_MAX_LAYER 2U
/* ... */
/* ... */
#define DMA2D_BACKGROUND_LAYER 0x00000000U
#define DMA2D_FOREGROUND_LAYER 0x00000001U
/* ... */
/* ... */
#define DMA2D_OFFSET DMA2D_FGOR_LO
/* ... */
/* ... */
#define DMA2D_PIXEL (DMA2D_NLR_PL >> 16U)
#define DMA2D_LINE DMA2D_NLR_NL
/* ... */
/* ... */
#define DMA2D_CLUT_SIZE (DMA2D_FGPFCCR_CS >> 8U)
/* ... */
/* ... */
/* ... */
#define IS_DMA2D_LAYER(LAYER) (((LAYER) == DMA2D_BACKGROUND_LAYER)\
|| ((LAYER) == DMA2D_FOREGROUND_LAYER))...
#define IS_DMA2D_MODE(MODE) (((MODE) == DMA2D_M2M) || ((MODE) == DMA2D_M2M_PFC) || \
((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M))...
#define IS_DMA2D_CMODE(MODE_ARGB) (((MODE_ARGB) == DMA2D_OUTPUT_ARGB8888) || \
((MODE_ARGB) == DMA2D_OUTPUT_RGB888) || \
((MODE_ARGB) == DMA2D_OUTPUT_RGB565) || \
((MODE_ARGB) == DMA2D_OUTPUT_ARGB1555) || \
((MODE_ARGB) == DMA2D_OUTPUT_ARGB4444))...
#define IS_DMA2D_COLOR(COLOR) ((COLOR) <= DMA2D_COLOR_VALUE)
#define IS_DMA2D_LINE(LINE) ((LINE) <= DMA2D_LINE)
#define IS_DMA2D_PIXEL(PIXEL) ((PIXEL) <= DMA2D_PIXEL)
#define IS_DMA2D_OFFSET(OOFFSET) ((OOFFSET) <= DMA2D_OFFSET)
#define IS_DMA2D_INPUT_COLOR_MODE(INPUT_CM) (((INPUT_CM) == DMA2D_INPUT_ARGB8888) || \
((INPUT_CM) == DMA2D_INPUT_RGB888) || \
((INPUT_CM) == DMA2D_INPUT_RGB565) || \
((INPUT_CM) == DMA2D_INPUT_ARGB1555) || \
((INPUT_CM) == DMA2D_INPUT_ARGB4444) || \
((INPUT_CM) == DMA2D_INPUT_L8) || \
((INPUT_CM) == DMA2D_INPUT_AL44) || \
((INPUT_CM) == DMA2D_INPUT_AL88) || \
((INPUT_CM) == DMA2D_INPUT_L4) || \
((INPUT_CM) == DMA2D_INPUT_A8) || \
((INPUT_CM) == DMA2D_INPUT_A4))...
#define IS_DMA2D_ALPHA_MODE(AlphaMode) (((AlphaMode) == DMA2D_NO_MODIF_ALPHA) || \
((AlphaMode) == DMA2D_REPLACE_ALPHA) || \
((AlphaMode) == DMA2D_COMBINE_ALPHA))...
#define IS_DMA2D_CLUT_CM(CLUT_CM) (((CLUT_CM) == DMA2D_CCM_ARGB8888) || ((CLUT_CM) == DMA2D_CCM_RGB888))
#define IS_DMA2D_CLUT_SIZE(CLUT_SIZE) ((CLUT_SIZE) <= DMA2D_CLUT_SIZE)
#define IS_DMA2D_LINEWATERMARK(LineWatermark) ((LineWatermark) <= DMA2D_LINE_WATERMARK_MAX)
#define IS_DMA2D_IT(IT) (((IT) == DMA2D_IT_CTC) || ((IT) == DMA2D_IT_CAE) || \
((IT) == DMA2D_IT_TW) || ((IT) == DMA2D_IT_TC) || \
((IT) == DMA2D_IT_TE) || ((IT) == DMA2D_IT_CE))...
#define IS_DMA2D_GET_FLAG(FLAG) (((FLAG) == DMA2D_FLAG_CTC) || ((FLAG) == DMA2D_FLAG_CAE) || \
((FLAG) == DMA2D_FLAG_TW) || ((FLAG) == DMA2D_FLAG_TC) || \
((FLAG) == DMA2D_FLAG_TE) || ((FLAG) == DMA2D_FLAG_CE))...
23 defines
/* ... */
/* ... */
/* ... */
#endif
/* ... */
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif