1 /**
2 ******************************************************************************
3 * @file stm32u5xx_hal_gpu2d.c
4 * @author MCD Application Team
5 * @brief GPU2D HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the GPU2D peripheral:
8 * + Initialization and de-initialization functions
9 * + IO operation functions
10 * + Peripheral State and Errors functions
11 ******************************************************************************
12 * @attention
13 *
14 * Copyright (c) 2022 STMicroelectronics.
15 * All rights reserved.
16 *
17 * This software is licensed under terms that can be found in the LICENSE file
18 * in the root directory of this software component.
19 * If no LICENSE file comes with this software, it is provided AS-IS.
20 *
21 ******************************************************************************
22 @verbatim
23 ==============================================================================
24 ##### How to use this driver #####
25 ==============================================================================
26 [..]
27 (#) Peripheral control is exclusively done by the accompanying middleware library.
28
29 *** Interrupt mode IO operation ***
30 ===================================
31 [..]
32 (#) Configure the GPU2D hardware to perform graphics operation using the Third Party MW
33 Library APIs.
34 (#) Submit command List to the hardware.
35 (#) Wait indefinitely for the completion of submitted Command List by GPU2D hardware.
36 (#) Use HAL_GPU2D_IRQHandler() called under GPU2D_IRQHandler() interrupt subroutine.
37 (#) At the end of Command List execution HAL_GPU2D_IRQHandler() function is executed
38 and user can add his own function by customization of function pointer
39 (#) CommandListCpltCallback (member of GPU2D handle structure) to notify the upper level
40 about the completion of Command List execution.
41
42 (#) Callback HAL_GPU2D_CommandListCpltCallback is invoked when the GPU2D hardware executes
43 the programmed command list (Command List execution completion).
44
45 (++) This callback is called when the compilation defines USE_HAL_GPU2D_REGISTER_CALLBACKS
46 is set to 0 or not defined.
47
48 (++) This callback should be implemented in the application side. It should notify
49 the upper level that the programmed command list is completed.
50
51 (#) To control the GPU2D state, use the following function: HAL_GPU2D_GetState().
52
53 (#) To read the GPU2D error code, use the following function: HAL_GPU2D_GetError().
54
55 *** GPU2D HAL driver macros list ***
56 =============================================
57 [..]
58 Below the list of most used macros in GPU2D HAL driver :
59
60 (+) __HAL_GPU2D_RESET_HANDLE_STATE: Reset GPU2D handle state.
61 (+) __HAL_GPU2D_GET_FLAG: Get the GPU2D pending flags.
62 (+) __HAL_GPU2D_CLEAR_FLAG: Clear the GPU2D pending flags.
63 (+) __HAL_GPU2D_GET_IT_SOURCE: Check whether the specified GPU2D interrupt is enabled or not.
64
65 *** Callback registration ***
66 ===================================
67 [..]
68 (#) The compilation define USE_HAL_GPU2D_REGISTER_CALLBACKS when set to 1
69 allows the user to configure dynamically the driver callbacks.
70 Use function @ref HAL_GPU2D_RegisterCallback() to register a user callback.
71
72 (#) Function @ref HAL_GPU2D_RegisterCallback() allows to register following callbacks:
73 (+) CommandListCpltCallback : callback for Command List completion.
74 (+) MspInitCallback : GPU2D MspInit.
75 (+) MspDeInitCallback : GPU2D MspDeInit.
76 This function takes as parameters the HAL peripheral handle, the Callback ID
77 and a pointer to the user callback function.
78
79 (#) Use function @ref HAL_GPU2D_UnRegisterCallback() to reset a callback to the default
80 weak (surcharged) function.
81 @ref HAL_GPU2D_UnRegisterCallback() takes as parameters the HAL peripheral handle,
82 and the Callback ID.
83 This function allows to reset following callbacks:
84 (+) CommandListCpltCallback : callback for Command List completion.
85 (+) MspInitCallback : GPU2D MspInit.
86 (+) MspDeInitCallback : GPU2D MspDeInit.
87
88 Callbacks can be registered/unregistered in READY state only.
89 Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
90 in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
91 during the Init/DeInit.
92 In that case first register the MspInit/MspDeInit user callbacks
93 using @ref HAL_GPU2D_RegisterCallback before calling @ref HAL_GPU2D_DeInit
94 or @ref HAL_GPU2D_Init function.
95
96 When The compilation define USE_HAL_GPU2D_REGISTER_CALLBACKS is set to 0 or
97 not defined, the callback registering feature is not available
98 and weak (surcharged) callbacks are used.
99
100 [..]
101 (@) You can refer to the GPU2D HAL driver header file for more useful macros
102
103 @endverbatim
104 */
105
106 /* Includes ------------------------------------------------------------------*/
107 #include "stm32u5xx_hal.h"
108
109 #ifdef HAL_GPU2D_MODULE_ENABLED
110 #if defined (GPU2D)
111
112 /** @addtogroup STM32U5xx_HAL_Driver
113 * @{
114 */
115
116 /** @defgroup GPU2D GPU2D
117 * @brief GPU2D HAL module driver
118 * @{
119 */
120
121 /* Private types -------------------------------------------------------------*/
122 /* Private define ------------------------------------------------------------*/
123 /* Private variables ---------------------------------------------------------*/
124 /* Private constants ---------------------------------------------------------*/
125 /* Private macro -------------------------------------------------------------*/
126 /** @defgroup GPU2D_Private_Macros GPU2D Private Macros
127 * @{
128 */
129
130 /** @defgroup GPU2D_Write_Read Common write and read registers Macros
131 * @{
132 */
133
134 /**
135 * @brief Write a value in GPU2D register
136 * @param __INSTANCE__ GPU2D Instance
137 * @param __REG__ Register to be written
138 * @param __VALUE__ Value to be written in the register
139 * @retval None
140 */
141 #define GPU2D_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(*(__IO uint32_t *)(__INSTANCE__\
142 + __REG__), __VALUE__)
143
144 /**
145 * @brief Read a value in GPU2D register
146 * @param __INSTANCE__ GPU2D Instance
147 * @param __REG__ Register to be read
148 * @retval Register value
149 */
150 #define GPU2D_ReadReg(__INSTANCE__, __REG__) READ_REG(*(__IO uint32_t *)(__INSTANCE__ + __REG__))
151 /**
152 * @}
153 */
154
155 /**
156 * @}
157 */
158
159 /* Private function prototypes -----------------------------------------------*/
160 /* Private functions ---------------------------------------------------------*/
161 /* Exported functions --------------------------------------------------------*/
162 /** @defgroup GPU2D_Exported_Functions GPU2D Exported Functions
163 * @{
164 */
165
166 /** @defgroup GPU2D_Exported_Functions_Group1 Initialization and de-initialization functions
167 * @brief Initialization and Configuration functions
168 *
169 @verbatim
170 ===============================================================================
171 ##### Initialization and Configuration functions #####
172 ===============================================================================
173 [..] This section provides functions allowing to:
174 (+) Initialize and configure the GPU2D
175 (+) De-initialize the GPU2D
176
177 @endverbatim
178 * @{
179 */
180
181 /**
182 * @brief Initialize the GPU2D according to the specified
183 * parameters in the GPU2D_InitTypeDef and create the associated handle.
184 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
185 * the configuration information for the GPU2D.
186 * @retval HAL status
187 */
HAL_GPU2D_Init(GPU2D_HandleTypeDef * hgpu2d)188 HAL_StatusTypeDef HAL_GPU2D_Init(GPU2D_HandleTypeDef *hgpu2d)
189 {
190 /* Check the GPU2D handle validity */
191 if (hgpu2d == NULL)
192 {
193 return HAL_ERROR;
194 }
195
196 /* Check the parameters */
197 assert_param(IS_GPU2D_ALL_INSTANCE(hgpu2d->Instance));
198
199 if (hgpu2d->State == HAL_GPU2D_STATE_RESET)
200 {
201 #if (USE_HAL_GPU2D_REGISTER_CALLBACKS == 1)
202 /* Reset Callback pointers in HAL_GPU2D_STATE_RESET only */
203 hgpu2d->CommandListCpltCallback = HAL_GPU2D_CommandListCpltCallback;
204 if (hgpu2d->MspInitCallback == NULL)
205 {
206 hgpu2d->MspInitCallback = HAL_GPU2D_MspInit;
207 }
208
209 /* Init the low level hardware */
210 hgpu2d->MspInitCallback(hgpu2d);
211 #else /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 0 */
212 /* Init the low level hardware */
213 HAL_GPU2D_MspInit(hgpu2d);
214 #endif /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 1 */
215
216 /* Allocate lock resource and initialize it */
217 hgpu2d->Lock = HAL_UNLOCKED;
218 }
219
220 /* Process locked */
221 __HAL_LOCK(hgpu2d);
222
223 #if (USE_HAL_GPU2D_REGISTER_CALLBACKS == 1)
224 /* Reset the CommandListCpltCallback handler */
225 hgpu2d->CommandListCpltCallback = NULL;
226 #endif /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 1 */
227
228 /* Update error code */
229 hgpu2d->ErrorCode = HAL_GPU2D_ERROR_NONE;
230
231 /* Initialize the GPU2D state*/
232 hgpu2d->State = HAL_GPU2D_STATE_READY;
233
234 /* Release Lock */
235 __HAL_UNLOCK(hgpu2d);
236
237 return HAL_OK;
238 }
239
240 /**
241 * @brief Deinitializes the GPU2D peripheral registers to their default reset
242 * values.
243 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
244 * the configuration information for the GPU2D.
245 * @retval None
246 */
HAL_GPU2D_DeInit(GPU2D_HandleTypeDef * hgpu2d)247 HAL_StatusTypeDef HAL_GPU2D_DeInit(GPU2D_HandleTypeDef *hgpu2d)
248 {
249 /* Check the GPU2D handle validity */
250 if (hgpu2d == NULL)
251 {
252 return HAL_ERROR;
253 }
254
255 /* Check the parameters */
256 assert_param(IS_GPU2D_ALL_INSTANCE(hgpu2d->Instance));
257
258 /* Process locked */
259 __HAL_LOCK(hgpu2d);
260
261 if (hgpu2d->State == HAL_GPU2D_STATE_READY)
262 {
263 #if (USE_HAL_GPU2D_REGISTER_CALLBACKS == 1)
264 if (hgpu2d->MspDeInitCallback == NULL)
265 {
266 hgpu2d->MspDeInitCallback = HAL_GPU2D_MspDeInit;
267 }
268
269 /* DeInit the low level hardware */
270 hgpu2d->MspDeInitCallback(hgpu2d);
271 #else /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 0 */
272 /* Carry on with de-initialization of low level hardware */
273 HAL_GPU2D_MspDeInit(hgpu2d);
274 #endif /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 1 */
275 }
276
277 #if (USE_HAL_GPU2D_REGISTER_CALLBACKS == 1)
278 /* Reset the CommandListCpltCallback handler */
279 hgpu2d->CommandListCpltCallback = NULL;
280 #endif /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 1 */
281
282 /* Update error code */
283 hgpu2d->ErrorCode = HAL_GPU2D_ERROR_NONE;
284
285 /* Reset the GPU2D state*/
286 hgpu2d->State = HAL_GPU2D_STATE_RESET;
287
288 /* Release Lock */
289 __HAL_UNLOCK(hgpu2d);
290
291 return HAL_OK;
292 }
293
294 /**
295 * @brief Initializes the GPU2D MSP.
296 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
297 * the configuration information for the GPU2D.
298 * @retval None
299 */
HAL_GPU2D_MspInit(GPU2D_HandleTypeDef * hgpu2d)300 __weak void HAL_GPU2D_MspInit(GPU2D_HandleTypeDef *hgpu2d)
301 {
302 /* Prevent unused argument(s) compilation warning */
303 UNUSED(hgpu2d);
304
305 /* NOTE : This function should not be modified; when the callback is needed,
306 the HAL_GPU2D_MspInit can be implemented in the user file.
307 */
308 }
309
310 /**
311 * @brief DeInitializes the GPU2D MSP.
312 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
313 * the configuration information for the GPU2D.
314 * @retval None
315 */
HAL_GPU2D_MspDeInit(GPU2D_HandleTypeDef * hgpu2d)316 __weak void HAL_GPU2D_MspDeInit(GPU2D_HandleTypeDef *hgpu2d)
317 {
318 /* Prevent unused argument(s) compilation warning */
319 UNUSED(hgpu2d);
320
321 /* NOTE : This function should not be modified; when the callback is needed,
322 the HAL_GPU2D_MspDeInit can be implemented in the user file.
323 */
324 }
325
326 #if (USE_HAL_GPU2D_REGISTER_CALLBACKS == 1)
327 /**
328 * @brief Register a User GPU2D callback
329 * To be used instead of the weak (surcharged) predefined callback
330 * @param hgpu2d GPU2D handle
331 * @param CallbackID ID of the callback to be registered
332 * This parameter can be one of the following values:
333 * @arg @ref HAL_GPU2D_MSPINIT_CB_ID GPU2D MspInit callback ID
334 * @arg @ref HAL_GPU2D_MSPDEINIT_CB_ID GPU2D MspDeInit callback ID
335 * @param pCallback pointer to the callback function
336 * @note Weak predefined callback is defined for HAL_GPU2D_MSPINIT_CB_ID and HAL_GPU2D_MSPDEINIT_CB_ID
337 * @retval HAL status
338 */
HAL_GPU2D_RegisterCallback(GPU2D_HandleTypeDef * hgpu2d,HAL_GPU2D_CallbackIDTypeDef CallbackID,pGPU2D_CallbackTypeDef pCallback)339 HAL_StatusTypeDef HAL_GPU2D_RegisterCallback(GPU2D_HandleTypeDef *hgpu2d, HAL_GPU2D_CallbackIDTypeDef CallbackID,
340 pGPU2D_CallbackTypeDef pCallback)
341 {
342 HAL_StatusTypeDef status = HAL_OK;
343
344 /* Check the GPU2D handle validity */
345 if (hgpu2d == NULL)
346 {
347 return HAL_ERROR;
348 }
349
350 /* Process locked */
351 __HAL_LOCK(hgpu2d);
352
353 /* Check the pCallback parameter is valid or not */
354 if (pCallback == NULL)
355 {
356 /* Update the error code */
357 hgpu2d->ErrorCode |= HAL_GPU2D_ERROR_INVALID_CALLBACK;
358 status = HAL_ERROR;
359 }
360 else
361 {
362 if ((hgpu2d->State == HAL_GPU2D_STATE_READY)
363 || (hgpu2d->State == HAL_GPU2D_STATE_RESET))
364 {
365 switch (CallbackID)
366 {
367 case HAL_GPU2D_MSPINIT_CB_ID:
368 hgpu2d->MspInitCallback = pCallback;
369 break;
370
371 case HAL_GPU2D_MSPDEINIT_CB_ID:
372 hgpu2d->MspDeInitCallback = pCallback;
373 break;
374
375 default :
376 /* Update the error code */
377 hgpu2d->ErrorCode |= HAL_GPU2D_ERROR_INVALID_CALLBACK;
378 status = HAL_ERROR;
379 break;
380 }
381 }
382 else
383 {
384 status = HAL_ERROR;
385 }
386 }
387
388 /* Release lock */
389 __HAL_UNLOCK(hgpu2d);
390
391 return status;
392 }
393
394 /**
395 * @brief Unregister a GPU2D callback
396 * GPU2D Callback is redirected to the weak (surcharged) predefined callback
397 * @param hgpu2d GPU2D handle
398 * @param CallbackID ID of the callback to be unregistered
399 * This parameter can be one of the following values:
400 * @arg @ref HAL_GPU2D_MSPINIT_CB_ID GPU2D MspInit callback ID
401 * @arg @ref HAL_GPU2D_MSPDEINIT_CB_ID GPU2D MspDeInit callback ID
402 * @note Callback pointers will be set to legacy weak predefined callbacks for HAL_GPU2D_MSPINIT_CB_ID and
403 * HAL_GPU2D_MSPDEINIT_CB_ID
404 * @retval status
405 */
HAL_GPU2D_UnRegisterCallback(GPU2D_HandleTypeDef * hgpu2d,HAL_GPU2D_CallbackIDTypeDef CallbackID)406 HAL_StatusTypeDef HAL_GPU2D_UnRegisterCallback(GPU2D_HandleTypeDef *hgpu2d, HAL_GPU2D_CallbackIDTypeDef CallbackID)
407 {
408 HAL_StatusTypeDef status = HAL_OK;
409
410 /* Check the GPU2D handle validity */
411 if (hgpu2d == NULL)
412 {
413 return HAL_ERROR;
414 }
415
416 /* Process locked */
417 __HAL_LOCK(hgpu2d);
418
419 if ((HAL_GPU2D_STATE_READY == hgpu2d->State)
420 || (HAL_GPU2D_STATE_RESET == hgpu2d->State))
421 {
422 switch (CallbackID)
423 {
424 case HAL_GPU2D_MSPINIT_CB_ID:
425 hgpu2d->MspInitCallback = HAL_GPU2D_MspInit; /* Legacy weak Msp Init */
426 break;
427
428 case HAL_GPU2D_MSPDEINIT_CB_ID:
429 hgpu2d->MspDeInitCallback = HAL_GPU2D_MspDeInit; /* Legacy weak Msp DeInit */
430 break;
431
432 default :
433 /* Update the error code */
434 hgpu2d->ErrorCode |= HAL_GPU2D_ERROR_INVALID_CALLBACK;
435 status = HAL_ERROR;
436 break;
437 }
438 }
439 else
440 {
441 status = HAL_ERROR;
442 }
443
444 /* Release lock */
445 __HAL_UNLOCK(hgpu2d);
446
447 return status;
448 }
449
450 /**
451 * @brief Register GPU2D Command List Complete Callback
452 * To be used instead of the weak (surcharged) predefined callback
453 * @param hgpu2d GPU2D handle
454 * @param pCallback pointer to the Command List Complete Callback function
455 * @note Weak predefined callback is defined for Command List Complete
456 * @retval status
457 */
HAL_GPU2D_RegisterCommandListCpltCallback(GPU2D_HandleTypeDef * hgpu2d,pGPU2D_CommandListCpltCallbackTypeDef pCallback)458 HAL_StatusTypeDef HAL_GPU2D_RegisterCommandListCpltCallback(GPU2D_HandleTypeDef *hgpu2d,
459 pGPU2D_CommandListCpltCallbackTypeDef pCallback)
460 {
461 HAL_StatusTypeDef status = HAL_OK;
462
463 /* Check the GPU2D handle validity */
464 if (hgpu2d == NULL)
465 {
466 return HAL_ERROR;
467 }
468
469 /* Process locked */
470 __HAL_LOCK(hgpu2d);
471
472 /* Check the CallbackID is valid or not */
473 if (pCallback == NULL)
474 {
475 /* Update the error code */
476 hgpu2d->ErrorCode |= HAL_GPU2D_ERROR_INVALID_CALLBACK;
477 status = HAL_ERROR;
478 }
479 else
480 {
481 if ((HAL_GPU2D_STATE_READY == hgpu2d->State)
482 || (HAL_GPU2D_STATE_RESET == hgpu2d->State))
483 {
484 hgpu2d->CommandListCpltCallback = pCallback;
485 }
486 else
487 {
488 status = HAL_ERROR;
489 }
490 }
491
492 /* Release lock */
493 __HAL_UNLOCK(hgpu2d);
494
495 return status;
496 }
497
498 /**
499 * @brief Unregister a GPU2D Command List Complete Callback
500 * GPU2D Command List Complete Callback is redirected to the weak (surcharged) predefined callback
501 * @param hgpu2d GPU2D handle
502 * @note Callback pointer will be invalidate (NULL value)
503 * @retval status
504 */
HAL_GPU2D_UnRegisterCommandListCpltCallback(GPU2D_HandleTypeDef * hgpu2d)505 HAL_StatusTypeDef HAL_GPU2D_UnRegisterCommandListCpltCallback(GPU2D_HandleTypeDef *hgpu2d)
506 {
507 HAL_StatusTypeDef status = HAL_OK;
508
509 /* Check the GPU2D handle validity */
510 if (hgpu2d == NULL)
511 {
512 return HAL_ERROR;
513 }
514
515 /* Process locked */
516 __HAL_LOCK(hgpu2d);
517
518 if ((hgpu2d->State == HAL_GPU2D_STATE_READY)
519 || (hgpu2d->State == HAL_GPU2D_STATE_RESET))
520 {
521 hgpu2d->CommandListCpltCallback = NULL; /* Invalidate the Callback pointer */
522 }
523 else
524 {
525 status = HAL_ERROR;
526 }
527
528 /* Release Lock */
529 __HAL_UNLOCK(hgpu2d);
530
531 return status;
532 }
533 #endif /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 1 */
534
535 /**
536 * @}
537 */
538
539
540 /** @defgroup GPU2D_Exported_Functions_Group2 IO operation functions
541 * @brief IO operation functions
542 *
543 @verbatim
544 ===============================================================================
545 ##### IO operation functions #####
546 ===============================================================================
547 [..] This section provides functions allowing to:
548 (+) Read GPU2D Register value.
549 (+) Write a value to GPU2D Register.
550 (+) handle GPU2D interrupt request.
551 (+) Command List Complete Transfer Complete callback.
552
553
554 @endverbatim
555 * @{
556 */
557
558 /**
559 * @brief Read GPU2D Register. Helper function for the higher-level library.
560 * @param hgpu2d Pointer to a GPU2D_HandleTypeDef structure that contains
561 * the configuration information for the GPU2D.
562 * @param offset The register offset from GPU2D base address to read.
563 * @retval Register value
564 */
HAL_GPU2D_ReadRegister(GPU2D_HandleTypeDef * hgpu2d,uint32_t offset)565 uint32_t HAL_GPU2D_ReadRegister(GPU2D_HandleTypeDef *hgpu2d, uint32_t offset)
566 {
567 uint32_t value;
568
569 /* Check the GPU2D handle validity */
570 assert_param(hgpu2d != NULL);
571
572 /* Check the parameters */
573 assert_param(IS_GPU2D_ALL_INSTANCE(hgpu2d->Instance));
574 assert_param(IS_GPU2D_OFFSET(offset));
575
576 /* No locking is required since reading a register is an atomic operation
577 * and doesn't incur a state change in hal_gpu2d. */
578 value = GPU2D_ReadReg(hgpu2d->Instance, offset);
579
580 return value;
581 }
582
583 /**
584 * @brief Write a value to GPU2D Register. Helper function for the higher-level library.
585 * @param hgpu2d Pointer to a GPU2D_HandleTypeDef structure that contains
586 * the configuration information for the GPU2D.
587 * @param offset The register offset from GPU2D base address to write.
588 * @param value The value to be written to provided register.
589 * @retval HAL status
590 */
HAL_GPU2D_WriteRegister(GPU2D_HandleTypeDef * hgpu2d,uint32_t offset,uint32_t value)591 HAL_StatusTypeDef HAL_GPU2D_WriteRegister(GPU2D_HandleTypeDef *hgpu2d, uint32_t offset, uint32_t value)
592 {
593 /* Check the GPU2D handle validity */
594 assert_param(hgpu2d != NULL);
595
596 /* Check the parameters */
597 assert_param(IS_GPU2D_ALL_INSTANCE(hgpu2d->Instance));
598 assert_param(IS_GPU2D_OFFSET(offset));
599
600 /* No locking is required since writing a register is an atomic operation
601 * and doesn't incur a state change in hal_gpu2d. */
602 GPU2D_WriteReg(hgpu2d->Instance, offset, value);
603
604 return HAL_OK;
605 }
606
607 /**
608 * @brief Handle GPU2D interrupt request.
609 * @param hgpu2d Pointer to a GPU2D_HandleTypeDef structure that contains
610 * the configuration information for the GPU2D.
611 * @retval None
612 */
HAL_GPU2D_IRQHandler(GPU2D_HandleTypeDef * hgpu2d)613 void HAL_GPU2D_IRQHandler(GPU2D_HandleTypeDef *hgpu2d)
614 {
615 uint32_t isr_flags = GPU2D_ReadReg(hgpu2d->Instance, GPU2D_ITCTRL);
616
617 /* Command List Complete Interrupt management */
618 if ((isr_flags & GPU2D_FLAG_CLC) != 0U)
619 {
620 uint32_t last_cl_id;
621
622 /* Clear the completion flag */
623 __HAL_GPU2D_CLEAR_FLAG(hgpu2d, GPU2D_FLAG_CLC);
624
625 last_cl_id = GPU2D_ReadReg(hgpu2d->Instance, GPU2D_CLID);
626
627 /* Command List Complete Callback */
628 #if (USE_HAL_GPU2D_REGISTER_CALLBACKS == 1)
629 if (hgpu2d->CommandListCpltCallback != NULL)
630 {
631 hgpu2d->CommandListCpltCallback(hgpu2d, last_cl_id);
632 }
633 #else /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 0 */
634 HAL_GPU2D_CommandListCpltCallback(hgpu2d, last_cl_id);
635 #endif /* USE_HAL_GPU2D_REGISTER_CALLBACKS = 1 */
636 }
637 }
638
639 /**
640 * @brief Handle GPU2D Error interrupt request.
641 * @param hgpu2d Pointer to a GPU2D_HandleTypeDef structure that contains
642 * the configuration information for the GPU2D.
643 * @retval None
644 */
HAL_GPU2D_ER_IRQHandler(GPU2D_HandleTypeDef * hgpu2d)645 void HAL_GPU2D_ER_IRQHandler(GPU2D_HandleTypeDef *hgpu2d)
646 {
647 HAL_GPU2D_ErrorCallback(hgpu2d);
648 }
649
650 /**
651 * @brief Command List Complete callback.
652 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
653 * the configuration information for the GPU2D.
654 * @param CmdListID Command list ID that got completed.
655 * @retval None
656 */
HAL_GPU2D_CommandListCpltCallback(GPU2D_HandleTypeDef * hgpu2d,uint32_t CmdListID)657 __weak void HAL_GPU2D_CommandListCpltCallback(GPU2D_HandleTypeDef *hgpu2d, uint32_t CmdListID)
658 {
659 /* Prevent unused argument(s) compilation warning */
660 UNUSED(hgpu2d);
661 UNUSED(CmdListID);
662
663 /* NOTE : This function should not be modified; when the callback is needed,
664 the HAL_GPU2D_CommandListCpltCallback can be implemented in the user file.
665 */
666 }
667
668 /**
669 * @brief Error handler callback.
670 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
671 * the configuration information for the GPU2D.
672 * @retval None
673 */
HAL_GPU2D_ErrorCallback(GPU2D_HandleTypeDef * hgpu2d)674 __weak void HAL_GPU2D_ErrorCallback(GPU2D_HandleTypeDef *hgpu2d)
675 {
676 /* Prevent unused argument(s) compilation warning */
677 UNUSED(hgpu2d);
678
679 /* NOTE : This function should not be modified; when the callback is needed,
680 the HAL_GPU2D_ErrorCallback can be implemented in the user file.
681 The default implementation stops the execution as an error is considered
682 fatal and non recoverable.
683 */
684
685 for (;;)
686 {
687 /* infinite loop */
688 }
689 }
690
691 /**
692 * @}
693 */
694
695
696 /** @defgroup GPU2D_Exported_Functions_Group3 Peripheral State and Error functions
697 * @brief Peripheral State functions
698 *
699 @verbatim
700 ===============================================================================
701 ##### Peripheral State and Errors functions #####
702 ===============================================================================
703 [..]
704 This subsection provides functions allowing to:
705 (+) Get the GPU2D state
706 (+) Get the GPU2D error code
707
708 @endverbatim
709 * @{
710 */
711
712 /**
713 * @brief Return the GPU2D state
714 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
715 * the configuration information for the GPU2D.
716 * @retval GPU2D state
717 */
HAL_GPU2D_GetState(GPU2D_HandleTypeDef const * const hgpu2d)718 HAL_GPU2D_StateTypeDef HAL_GPU2D_GetState(GPU2D_HandleTypeDef const *const hgpu2d)
719 {
720 return hgpu2d->State;
721 }
722
723 /**
724 * @brief Return the GPU2D error code
725 * @param hgpu2d pointer to a GPU2D_HandleTypeDef structure that contains
726 * the configuration information for GPU2D.
727 * @retval GPU2D Error Code
728 */
HAL_GPU2D_GetError(GPU2D_HandleTypeDef const * const hgpu2d)729 uint32_t HAL_GPU2D_GetError(GPU2D_HandleTypeDef const *const hgpu2d)
730 {
731 return hgpu2d->ErrorCode;
732 }
733
734 /**
735 * @}
736 */
737
738 /**
739 * @}
740 */
741
742 /**
743 * @}
744 */
745
746 /**
747 * @}
748 */
749 #endif /* GPU2D */
750 #endif /* HAL_GPU2D_MODULE_ENABLED */
751