STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_gfxmmu.c
Go to the documentation of this file.
1 
122 /* Includes ------------------------------------------------------------------*/
123 #include "stm32l4xx_hal.h"
124 
128 #ifdef HAL_GFXMMU_MODULE_ENABLED
129 #if defined(GFXMMU)
130 
135 /* Private typedef -----------------------------------------------------------*/
136 /* Private define ------------------------------------------------------------*/
137 #define GFXMMU_LUTXL_FVB_OFFSET 8U
138 #define GFXMMU_LUTXL_LVB_OFFSET 16U
139 #define GFXMMU_CR_ITS_MASK 0x1FU
140 /* Private macro -------------------------------------------------------------*/
141 /* Private variables ---------------------------------------------------------*/
142 /* Private function prototypes -----------------------------------------------*/
143 /* Exported functions --------------------------------------------------------*/
168 HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu)
169 {
170  HAL_StatusTypeDef status = HAL_OK;
171 
172  /* Check GFXMMU handle */
173  if(hgfxmmu == NULL)
174  {
175  status = HAL_ERROR;
176  }
177  else
178  {
179  /* Check parameters */
180  assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
181  assert_param(IS_GFXMMU_BLOCKS_PER_LINE(hgfxmmu->Init.BlocksPerLine));
182  assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf0Address));
183  assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf1Address));
184  assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf2Address));
185  assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf3Address));
186  assert_param(IS_FUNCTIONAL_STATE(hgfxmmu->Init.Interrupts.Activation));
187 
188 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
189  /* Reset callback pointers to the weak predefined callbacks */
190  hgfxmmu->ErrorCallback = HAL_GFXMMU_ErrorCallback;
191 
192  /* Call GFXMMU MSP init function */
193  if(hgfxmmu->MspInitCallback == NULL)
194  {
195  hgfxmmu->MspInitCallback = HAL_GFXMMU_MspInit;
196  }
197  hgfxmmu->MspInitCallback(hgfxmmu);
198 #else
199  /* Call GFXMMU MSP init function */
200  HAL_GFXMMU_MspInit(hgfxmmu);
201 #endif
202 
203  /* Configure blocks per line and interrupts parameters on GFXMMU_CR register */
204  hgfxmmu->Instance->CR &= ~(GFXMMU_CR_B0OIE | GFXMMU_CR_B1OIE | GFXMMU_CR_B2OIE | GFXMMU_CR_B3OIE |
205  GFXMMU_CR_AMEIE | GFXMMU_CR_192BM);
206  hgfxmmu->Instance->CR |= (hgfxmmu->Init.BlocksPerLine);
207  if(hgfxmmu->Init.Interrupts.Activation == ENABLE)
208  {
209  assert_param(IS_GFXMMU_INTERRUPTS(hgfxmmu->Init.Interrupts.UsedInterrupts));
210  hgfxmmu->Instance->CR |= hgfxmmu->Init.Interrupts.UsedInterrupts;
211  }
212 
213  /* Configure default value on GFXMMU_DVR register */
214  hgfxmmu->Instance->DVR = hgfxmmu->Init.DefaultValue;
215 
216  /* Configure physical buffer adresses on GFXMMU_BxCR registers */
217  hgfxmmu->Instance->B0CR = hgfxmmu->Init.Buffers.Buf0Address;
218  hgfxmmu->Instance->B1CR = hgfxmmu->Init.Buffers.Buf1Address;
219  hgfxmmu->Instance->B2CR = hgfxmmu->Init.Buffers.Buf2Address;
220  hgfxmmu->Instance->B3CR = hgfxmmu->Init.Buffers.Buf3Address;
221 
222  /* Reset GFXMMU error code */
223  hgfxmmu->ErrorCode = GFXMMU_ERROR_NONE;
224 
225  /* Set GFXMMU to ready state */
226  hgfxmmu->State = HAL_GFXMMU_STATE_READY;
227  }
228  /* Return function status */
229  return status;
230 }
231 
237 HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu)
238 {
239  HAL_StatusTypeDef status = HAL_OK;
240 
241  /* Check GFXMMU handle */
242  if(hgfxmmu == NULL)
243  {
244  status = HAL_ERROR;
245  }
246  else
247  {
248  /* Check parameters */
249  assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
250 
251  /* Disable all interrupts on GFXMMU_CR register */
252  hgfxmmu->Instance->CR &= ~(GFXMMU_CR_B0OIE | GFXMMU_CR_B1OIE | GFXMMU_CR_B2OIE | GFXMMU_CR_B3OIE |
253  GFXMMU_CR_AMEIE);
254 
255  /* Call GFXMMU MSP de-init function */
256 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
257  if(hgfxmmu->MspDeInitCallback == NULL)
258  {
259  hgfxmmu->MspDeInitCallback = HAL_GFXMMU_MspDeInit;
260  }
261  hgfxmmu->MspDeInitCallback(hgfxmmu);
262 #else
263  HAL_GFXMMU_MspDeInit(hgfxmmu);
264 #endif
265 
266  /* Set GFXMMU to reset state */
267  hgfxmmu->State = HAL_GFXMMU_STATE_RESET;
268  }
269  /* Return function status */
270  return status;
271 }
272 
279 {
280  /* Prevent unused argument(s) compilation warning */
281  UNUSED(hgfxmmu);
282 
283  /* NOTE : This function should not be modified, when the function is needed,
284  the HAL_GFXMMU_MspInit could be implemented in the user file.
285  */
286 }
287 
294 {
295  /* Prevent unused argument(s) compilation warning */
296  UNUSED(hgfxmmu);
297 
298  /* NOTE : This function should not be modified, when the function is needed,
299  the HAL_GFXMMU_MspDeInit could be implemented in the user file.
300  */
301 }
302 
303 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
304 
317  HAL_GFXMMU_CallbackIDTypeDef CallbackID,
318  pGFXMMU_CallbackTypeDef pCallback)
319 {
320  HAL_StatusTypeDef status = HAL_OK;
321 
322  if(pCallback == NULL)
323  {
324  /* update the error code */
325  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
326  /* update return status */
327  status = HAL_ERROR;
328  }
329  else
330  {
331  if(HAL_GFXMMU_STATE_READY == hgfxmmu->State)
332  {
333  switch (CallbackID)
334  {
336  hgfxmmu->ErrorCallback = pCallback;
337  break;
339  hgfxmmu->MspInitCallback = pCallback;
340  break;
342  hgfxmmu->MspDeInitCallback = pCallback;
343  break;
344  default :
345  /* update the error code */
346  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
347  /* update return status */
348  status = HAL_ERROR;
349  break;
350  }
351  }
352  else if(HAL_GFXMMU_STATE_RESET == hgfxmmu->State)
353  {
354  switch (CallbackID)
355  {
357  hgfxmmu->MspInitCallback = pCallback;
358  break;
360  hgfxmmu->MspDeInitCallback = pCallback;
361  break;
362  default :
363  /* update the error code */
364  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
365  /* update return status */
366  status = HAL_ERROR;
367  break;
368  }
369  }
370  else
371  {
372  /* update the error code */
373  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
374  /* update return status */
375  status = HAL_ERROR;
376  }
377  }
378  return status;
379 }
380 
393  HAL_GFXMMU_CallbackIDTypeDef CallbackID)
394 {
395  HAL_StatusTypeDef status = HAL_OK;
396 
397  if(HAL_GFXMMU_STATE_READY == hgfxmmu->State)
398  {
399  switch (CallbackID)
400  {
402  hgfxmmu->ErrorCallback = HAL_GFXMMU_ErrorCallback;
403  break;
405  hgfxmmu->MspInitCallback = HAL_GFXMMU_MspInit;
406  break;
408  hgfxmmu->MspDeInitCallback = HAL_GFXMMU_MspDeInit;
409  break;
410  default :
411  /* update the error code */
412  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
413  /* update return status */
414  status = HAL_ERROR;
415  break;
416  }
417  }
418  else if(HAL_GFXMMU_STATE_RESET == hgfxmmu->State)
419  {
420  switch (CallbackID)
421  {
423  hgfxmmu->MspInitCallback = HAL_GFXMMU_MspInit;
424  break;
426  hgfxmmu->MspDeInitCallback = HAL_GFXMMU_MspDeInit;
427  break;
428  default :
429  /* update the error code */
430  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
431  /* update return status */
432  status = HAL_ERROR;
433  break;
434  }
435  }
436  else
437  {
438  /* update the error code */
439  hgfxmmu->ErrorCode |= GFXMMU_ERROR_INVALID_CALLBACK;
440  /* update return status */
441  status = HAL_ERROR;
442  }
443  return status;
444 }
445 #endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */
446 
476 HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
477  uint32_t FirstLine,
478  uint32_t LinesNumber,
479  uint32_t Address)
480 {
481  HAL_StatusTypeDef status = HAL_OK;
482 
483  /* Check parameters */
484  assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
485  assert_param(IS_GFXMMU_LUT_LINE(FirstLine));
486  assert_param(IS_GFXMMU_LUT_LINES_NUMBER(LinesNumber));
487 
488  /* Check GFXMMU state and coherent parameters */
489  if((hgfxmmu->State != HAL_GFXMMU_STATE_READY) || ((FirstLine + LinesNumber) > 1024U))
490  {
491  status = HAL_ERROR;
492  }
493  else
494  {
495  uint32_t current_address, current_line, lutxl_address, lutxh_address;
496 
497  /* Initialize local variables */
498  current_address = Address;
499  current_line = 0U;
500  lutxl_address = (uint32_t) &(hgfxmmu->Instance->LUT[2U * FirstLine]);
501  lutxh_address = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * FirstLine) + 1U]);
502 
503  /* Copy LUT from flash to look up RAM */
504  while(current_line < LinesNumber)
505  {
506  *((uint32_t *)lutxl_address) = *((uint32_t *)current_address);
507  current_address += 4U;
508  *((uint32_t *)lutxh_address) = *((uint32_t *)current_address);
509  current_address += 4U;
510  lutxl_address += 8U;
511  lutxh_address += 8U;
512  current_line++;
513  }
514  }
515  /* Return function status */
516  return status;
517 }
518 
529  uint32_t FirstLine,
530  uint32_t LinesNumber)
531 {
532  HAL_StatusTypeDef status = HAL_OK;
533 
534  /* Check parameters */
535  assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
536  assert_param(IS_GFXMMU_LUT_LINE(FirstLine));
537  assert_param(IS_GFXMMU_LUT_LINES_NUMBER(LinesNumber));
538 
539  /* Check GFXMMU state and coherent parameters */
540  if((hgfxmmu->State != HAL_GFXMMU_STATE_READY) || ((FirstLine + LinesNumber) > 1024U))
541  {
542  status = HAL_ERROR;
543  }
544  else
545  {
546  uint32_t current_line, lutxl_address, lutxh_address;
547 
548  /* Initialize local variables */
549  current_line = 0U;
550  lutxl_address = (uint32_t) &(hgfxmmu->Instance->LUT[2U * FirstLine]);
551  lutxh_address = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * FirstLine) + 1U]);
552 
553  /* Disable LUT lines */
554  while(current_line < LinesNumber)
555  {
556  *((uint32_t *)lutxl_address) = 0U;
557  *((uint32_t *)lutxh_address) = 0U;
558  lutxl_address += 8U;
559  lutxh_address += 8U;
560  current_line++;
561  }
562  }
563  /* Return function status */
564  return status;
565 }
566 
574 {
575  HAL_StatusTypeDef status = HAL_OK;
576 
577  /* Check parameters */
578  assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
579  assert_param(IS_GFXMMU_LUT_LINE(lutLine->LineNumber));
580  assert_param(IS_GFXMMU_LUT_LINE_STATUS(lutLine->LineStatus));
581  assert_param(IS_GFXMMU_LUT_BLOCK(lutLine->FirstVisibleBlock));
582  assert_param(IS_GFXMMU_LUT_BLOCK(lutLine->LastVisibleBlock));
583  assert_param(IS_GFXMMU_LUT_LINE_OFFSET(lutLine->LineOffset));
584 
585  /* Check GFXMMU state */
586  if(hgfxmmu->State != HAL_GFXMMU_STATE_READY)
587  {
588  status = HAL_ERROR;
589  }
590  else
591  {
592  uint32_t lutxl_address, lutxh_address;
593 
594  /* Initialize local variables */
595  lutxl_address = (uint32_t) &(hgfxmmu->Instance->LUT[2U * lutLine->LineNumber]);
596  lutxh_address = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * lutLine->LineNumber) + 1U]);
597 
598  /* Configure LUT line */
599  if(lutLine->LineStatus == GFXMMU_LUT_LINE_ENABLE)
600  {
601  /* Enable and configure LUT line */
602  *((uint32_t *)lutxl_address) = (lutLine->LineStatus |
603  (lutLine->FirstVisibleBlock << GFXMMU_LUTXL_FVB_OFFSET) |
604  (lutLine->LastVisibleBlock << GFXMMU_LUTXL_LVB_OFFSET));
605  *((uint32_t *)lutxh_address) = (uint32_t) lutLine->LineOffset;
606  }
607  else
608  {
609  /* Disable LUT line */
610  *((uint32_t *)lutxl_address) = 0U;
611  *((uint32_t *)lutxh_address) = 0U;
612  }
613  }
614  /* Return function status */
615  return status;
616 }
617 
625 {
626  HAL_StatusTypeDef status = HAL_OK;
627 
628  /* Check parameters */
629  assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
630  assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf0Address));
631  assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf1Address));
632  assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf2Address));
633  assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf3Address));
634 
635  /* Check GFXMMU state */
636  if(hgfxmmu->State != HAL_GFXMMU_STATE_READY)
637  {
638  status = HAL_ERROR;
639  }
640  else
641  {
642  /* Modify physical buffer adresses on GFXMMU_BxCR registers */
643  hgfxmmu->Instance->B0CR = Buffers->Buf0Address;
644  hgfxmmu->Instance->B1CR = Buffers->Buf1Address;
645  hgfxmmu->Instance->B2CR = Buffers->Buf2Address;
646  hgfxmmu->Instance->B3CR = Buffers->Buf3Address;
647  }
648  /* Return function status */
649  return status;
650 }
651 
658 {
659  uint32_t flags, interrupts, error;
660 
661  /* Read current flags and interrupts and determine which error occurs */
662  flags = hgfxmmu->Instance->SR;
663  interrupts = (hgfxmmu->Instance->CR & GFXMMU_CR_ITS_MASK);
664  error = (flags & interrupts);
665 
666  if(error != 0U)
667  {
668  /* Clear flags on GFXMMU_FCR register */
669  hgfxmmu->Instance->FCR = error;
670 
671  /* Update GFXMMU error code */
672  hgfxmmu->ErrorCode |= error;
673 
674  /* Call GFXMMU error callback */
675 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
676  hgfxmmu->ErrorCallback(hgfxmmu);
677 #else
678  HAL_GFXMMU_ErrorCallback(hgfxmmu);
679 #endif
680  }
681 }
682 
689 {
690  /* Prevent unused argument(s) compilation warning */
691  UNUSED(hgfxmmu);
692 
693  /* NOTE : This function should not be modified, when the callback is needed,
694  the HAL_GFXMMU_ErrorCallback could be implemented in the user file.
695  */
696 }
697 
721 HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu)
722 {
723  /* Return GFXMMU handle state */
724  return hgfxmmu->State;
725 }
726 
733 {
734  uint32_t error_code;
735 
736  /* Enter in critical section */
737  __disable_irq();
738 
739  /* Store and reset GFXMMU error code */
740  error_code = hgfxmmu->ErrorCode;
741  hgfxmmu->ErrorCode = GFXMMU_ERROR_NONE;
742 
743  /* Exit from critical section */
744  __enable_irq();
745 
746  /* Return GFXMMU error code */
747  return error_code;
748 }
749 
757 /* End of exported functions -------------------------------------------------*/
758 /* Private functions ---------------------------------------------------------*/
759 /* End of private functions --------------------------------------------------*/
760 
764 #endif /* GFXMMU */
765 #endif /* HAL_GFXMMU_MODULE_ENABLED */
766 
770 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine)
This function allows to configure one line of LUT.
void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu)
Initialize the GFXMMU MSP.
GFXMMU LUT line structure definition.
This file contains all the functions prototypes for the HAL module driver.
void(* pGFXMMU_CallbackTypeDef)(GFXMMU_HandleTypeDef *hgfxmmu)
GFXMMU callback pointer definition.
void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu)
This function handles the GFXMMU interrupts.
HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers)
This function allows to modify physical buffer addresses.
HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu, uint32_t FirstLine, uint32_t LinesNumber)
This function allows to disable a range of LUT lines.
HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu, uint32_t FirstLine, uint32_t LinesNumber, uint32_t Address)
This function allows to copy LUT from flash to look up RAM.
HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu, HAL_GFXMMU_CallbackIDTypeDef CallbackID)
Unregister a user GFXMMU callback. GFXMMU callback is redirected to the weak predefined callback...
return HAL_OK
HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu)
This function allows to get the current GFXMMU handle state.
uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu)
This function allows to get the current GFXMMU error code.
HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef *hgfxmmu, HAL_GFXMMU_CallbackIDTypeDef CallbackID, pGFXMMU_CallbackTypeDef pCallback)
Register a user GFXMMU callback to be used instead of the weak predefined callback.
HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu)
De-initialize the GFXMMU.
HAL_GFXMMU_CallbackIDTypeDef
GFXMMU callback ID enumeration definition.
HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu)
Initialize the GFXMMU according to the specified parameters in the GFXMMU_InitTypeDef structure and i...
void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu)
Error callback.
struct __GFXMMU_HandleTypeDef else typedef struct endif GFXMMU_HandleTypeDef
GFXMMU handle structure definition.
void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu)
De-initialize the GFXMMU MSP.
GFXMMU buffers structure definition.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))