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