123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- #include "stm32l4xx_hal.h"
- #ifdef HAL_GFXMMU_MODULE_ENABLED
- #if defined(GFXMMU)
- #define GFXMMU_LUTXL_FVB_OFFSET 8U
- #define GFXMMU_LUTXL_LVB_OFFSET 16U
- #define GFXMMU_CR_ITS_MASK 0x1FU
- HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu)
- {
- HAL_StatusTypeDef status = HAL_OK;
-
-
- if(hgfxmmu == NULL)
- {
- status = HAL_ERROR;
- }
- else
- {
-
- assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
- assert_param(IS_GFXMMU_BLOCKS_PER_LINE(hgfxmmu->Init.BlocksPerLine));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf0Address));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf1Address));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf2Address));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(hgfxmmu->Init.Buffers.Buf3Address));
- assert_param(IS_FUNCTIONAL_STATE(hgfxmmu->Init.Interrupts.Activation));
-
-
- HAL_GFXMMU_MspInit(hgfxmmu);
-
-
- hgfxmmu->Instance->CR &= ~(GFXMMU_CR_B0OIE | GFXMMU_CR_B1OIE | GFXMMU_CR_B2OIE | GFXMMU_CR_B3OIE |
- GFXMMU_CR_AMEIE | GFXMMU_CR_192BM);
- hgfxmmu->Instance->CR |= (hgfxmmu->Init.BlocksPerLine);
- if(hgfxmmu->Init.Interrupts.Activation == ENABLE)
- {
- assert_param(IS_GFXMMU_INTERRUPTS(hgfxmmu->Init.Interrupts.UsedInterrupts));
- hgfxmmu->Instance->CR |= hgfxmmu->Init.Interrupts.UsedInterrupts;
- }
-
-
- hgfxmmu->Instance->DVR = hgfxmmu->Init.DefaultValue;
-
-
- hgfxmmu->Instance->B0CR = hgfxmmu->Init.Buffers.Buf0Address;
- hgfxmmu->Instance->B1CR = hgfxmmu->Init.Buffers.Buf1Address;
- hgfxmmu->Instance->B2CR = hgfxmmu->Init.Buffers.Buf2Address;
- hgfxmmu->Instance->B3CR = hgfxmmu->Init.Buffers.Buf3Address;
-
-
- hgfxmmu->ErrorCode = GFXMMU_ERROR_NONE;
-
-
- hgfxmmu->State = HAL_GFXMMU_STATE_READY;
- }
-
- return status;
- }
- HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu)
- {
- HAL_StatusTypeDef status = HAL_OK;
-
-
- if(hgfxmmu == NULL)
- {
- status = HAL_ERROR;
- }
- else
- {
-
- assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
-
-
- hgfxmmu->Instance->CR &= ~(GFXMMU_CR_B0OIE | GFXMMU_CR_B1OIE | GFXMMU_CR_B2OIE | GFXMMU_CR_B3OIE |
- GFXMMU_CR_AMEIE);
-
-
- HAL_GFXMMU_MspDeInit(hgfxmmu);
-
-
- hgfxmmu->State = HAL_GFXMMU_STATE_RESET;
- }
-
- return status;
- }
- __weak void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu)
- {
-
- UNUSED(hgfxmmu);
-
-
- }
- __weak void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu)
- {
-
- UNUSED(hgfxmmu);
-
-
- }
- HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
- uint32_t FirstLine,
- uint32_t LinesNumber,
- uint32_t Address)
- {
- HAL_StatusTypeDef status = HAL_OK;
-
-
- assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
- assert_param(IS_GFXMMU_LUT_LINE(FirstLine));
- assert_param(IS_GFXMMU_LUT_LINES_NUMBER(LinesNumber));
-
-
- if((hgfxmmu->State != HAL_GFXMMU_STATE_READY) || ((FirstLine + LinesNumber) > 1024U))
- {
- status = HAL_ERROR;
- }
- else
- {
- uint32_t current_address, current_line, lutxl_address, lutxh_address;
-
-
- current_address = Address;
- current_line = 0U;
- lutxl_address = (uint32_t) &(hgfxmmu->Instance->LUT[2U * FirstLine]);
- lutxh_address = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * FirstLine) + 1U]);
-
-
- while(current_line < LinesNumber)
- {
- *((uint32_t *)lutxl_address) = *((uint32_t *)current_address);
- current_address += 4U;
- *((uint32_t *)lutxh_address) = *((uint32_t *)current_address);
- current_address += 4U;
- lutxl_address += 8U;
- lutxh_address += 8U;
- current_line++;
- }
- }
-
- return status;
- }
- HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu,
- uint32_t FirstLine,
- uint32_t LinesNumber)
- {
- HAL_StatusTypeDef status = HAL_OK;
-
-
- assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
- assert_param(IS_GFXMMU_LUT_LINE(FirstLine));
- assert_param(IS_GFXMMU_LUT_LINES_NUMBER(LinesNumber));
-
-
- if((hgfxmmu->State != HAL_GFXMMU_STATE_READY) || ((FirstLine + LinesNumber) > 1024U))
- {
- status = HAL_ERROR;
- }
- else
- {
- uint32_t current_line, lutxl_address, lutxh_address;
-
-
- current_line = 0U;
- lutxl_address = (uint32_t) &(hgfxmmu->Instance->LUT[2U * FirstLine]);
- lutxh_address = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * FirstLine) + 1U]);
-
-
- while(current_line < LinesNumber)
- {
- *((uint32_t *)lutxl_address) = 0U;
- *((uint32_t *)lutxh_address) = 0U;
- lutxl_address += 8U;
- lutxh_address += 8U;
- current_line++;
- }
- }
-
- return status;
- }
- HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine)
- {
- HAL_StatusTypeDef status = HAL_OK;
-
-
- assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
- assert_param(IS_GFXMMU_LUT_LINE(lutLine->LineNumber));
- assert_param(IS_GFXMMU_LUT_LINE_STATUS(lutLine->LineStatus));
- assert_param(IS_GFXMMU_LUT_BLOCK(lutLine->FirstVisibleBlock));
- assert_param(IS_GFXMMU_LUT_BLOCK(lutLine->LastVisibleBlock));
- assert_param(IS_GFXMMU_LUT_LINE_OFFSET(lutLine->LineOffset));
-
-
- if(hgfxmmu->State != HAL_GFXMMU_STATE_READY)
- {
- status = HAL_ERROR;
- }
- else
- {
- uint32_t lutxl_address, lutxh_address;
-
-
- lutxl_address = (uint32_t) &(hgfxmmu->Instance->LUT[2U * lutLine->LineNumber]);
- lutxh_address = (uint32_t) &(hgfxmmu->Instance->LUT[(2U * lutLine->LineNumber) + 1U]);
-
-
- if(lutLine->LineStatus == GFXMMU_LUT_LINE_ENABLE)
- {
-
- *((uint32_t *)lutxl_address) = (lutLine->LineStatus |
- (lutLine->FirstVisibleBlock << GFXMMU_LUTXL_FVB_OFFSET) |
- (lutLine->LastVisibleBlock << GFXMMU_LUTXL_LVB_OFFSET));
- *((uint32_t *)lutxh_address) = lutLine->LineOffset;
- }
- else
- {
-
- *((uint32_t *)lutxl_address) = 0U;
- *((uint32_t *)lutxh_address) = 0U;
- }
- }
-
- return status;
- }
- HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers)
- {
- HAL_StatusTypeDef status = HAL_OK;
-
-
- assert_param(IS_GFXMMU_ALL_INSTANCE(hgfxmmu->Instance));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf0Address));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf1Address));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf2Address));
- assert_param(IS_GFXMMU_BUFFER_ADDRESS(Buffers->Buf3Address));
-
-
- if(hgfxmmu->State != HAL_GFXMMU_STATE_READY)
- {
- status = HAL_ERROR;
- }
- else
- {
-
- hgfxmmu->Instance->B0CR = Buffers->Buf0Address;
- hgfxmmu->Instance->B1CR = Buffers->Buf1Address;
- hgfxmmu->Instance->B2CR = Buffers->Buf2Address;
- hgfxmmu->Instance->B3CR = Buffers->Buf3Address;
- }
-
- return status;
- }
- void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu)
- {
- uint32_t flags, interrupts, error;
-
-
- flags = hgfxmmu->Instance->SR;
- interrupts = (hgfxmmu->Instance->CR & GFXMMU_CR_ITS_MASK);
- error = (flags & interrupts);
-
- if(error != 0U)
- {
-
- hgfxmmu->Instance->FCR = error;
-
-
- hgfxmmu->ErrorCode |= error;
-
-
- HAL_GFXMMU_ErrorCallback(hgfxmmu);
- }
- }
- __weak void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu)
- {
-
- UNUSED(hgfxmmu);
-
-
- }
- HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu)
- {
-
- return hgfxmmu->State;
- }
- uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu)
- {
- uint32_t error_code;
-
-
- __disable_irq();
-
-
- error_code = hgfxmmu->ErrorCode;
- hgfxmmu->ErrorCode = GFXMMU_ERROR_NONE;
-
-
- __enable_irq();
-
-
- return error_code;
- }
- #endif
- #endif
|