steering-wheel/TouchGFX/target/generated/TouchGFXGeneratedHAL.cpp

161 lines
4.6 KiB
C++
Raw Normal View History

2023-03-06 21:21:00 +01:00
/**
******************************************************************************
* File Name : TouchGFXGeneratedHAL.cpp
******************************************************************************
2024-06-11 19:38:14 +02:00
* This file is generated by TouchGFX Generator 4.23.2. Please, do not edit!
2023-03-06 21:21:00 +01:00
******************************************************************************
* @attention
*
2024-06-11 19:38:14 +02:00
* Copyright (c) 2024 STMicroelectronics.
2023-03-06 21:21:00 +01:00
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include <TouchGFXGeneratedHAL.hpp>
#include <touchgfx/hal/OSWrappers.hpp>
#include <gui/common/FrontendHeap.hpp>
2024-07-21 16:30:53 +02:00
#include <touchgfx/hal/GPIO.hpp>
2024-06-11 19:38:14 +02:00
#include <touchgfx/hal/PaintImpl.hpp>
#include <touchgfx/hal/PaintRGB565Impl.hpp>
2023-03-06 21:21:00 +01:00
#include "stm32h7xx.h"
2024-07-21 14:34:44 +02:00
#include "stm32h7xx_hal_ltdc.h"
2023-03-06 21:21:00 +01:00
using namespace touchgfx;
namespace
{
2024-07-21 14:34:44 +02:00
static uint16_t lcd_int_active_line;
static uint16_t lcd_int_porch_line;
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::initialize()
{
HAL::initialize();
registerEventListener(*(Application::getInstance()));
2024-07-21 16:30:53 +02:00
setFrameBufferStartAddresses((void*)0x24040000, (void*)0x240A0000, (void*)0);
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::configureInterrupts()
{
2024-07-21 14:34:44 +02:00
NVIC_SetPriority(LTDC_IRQn, 9);
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::enableInterrupts()
{
2024-07-21 14:34:44 +02:00
NVIC_EnableIRQ(LTDC_IRQn);
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::disableInterrupts()
{
2024-07-21 14:34:44 +02:00
NVIC_DisableIRQ(LTDC_IRQn);
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::enableLCDControllerInterrupt()
{
2024-07-21 14:34:44 +02:00
lcd_int_active_line = (LTDC->BPCR & 0x7FF) - 1;
lcd_int_porch_line = (LTDC->AWCR & 0x7FF) - 1;
/* Sets the Line Interrupt position */
LTDC->LIPCR = lcd_int_active_line;
/* Line Interrupt Enable */
LTDC->IER |= LTDC_IER_LIE;
2023-03-06 21:21:00 +01:00
}
bool TouchGFXGeneratedHAL::beginFrame()
{
return HAL::beginFrame();
}
void TouchGFXGeneratedHAL::endFrame()
{
HAL::endFrame();
}
uint16_t* TouchGFXGeneratedHAL::getTFTFrameBuffer() const
{
2024-07-21 14:34:44 +02:00
return (uint16_t*)LTDC_Layer1->CFBAR;
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::setTFTFrameBuffer(uint16_t* adr)
{
2024-07-21 14:34:44 +02:00
LTDC_Layer1->CFBAR = (uint32_t)adr;
/* Reload immediate */
LTDC->SRCR = (uint32_t)LTDC_SRCR_IMR;
2023-03-06 21:21:00 +01:00
}
void TouchGFXGeneratedHAL::flushFrameBuffer(const touchgfx::Rect& rect)
{
HAL::flushFrameBuffer(rect);
}
bool TouchGFXGeneratedHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)
{
return HAL::blockCopy(dest, src, numBytes);
}
void TouchGFXGeneratedHAL::InvalidateCache()
{
// If the framebuffer is placed in Write Through cached memory (e.g. SRAM) then
// the DCache must be flushed prior to DMA2D accessing it. That's done
// using the function SCB_CleanInvalidateDCache(). Remember to enable "CPU Cache" in the
// "System Core" settings for "Cortex M7" in CubeMX in order for this function call to work.
if (SCB->CCR & SCB_CCR_DC_Msk)
{
SCB_CleanInvalidateDCache();
}
}
void TouchGFXGeneratedHAL::FlushCache()
{
// If the framebuffer is placed in Write Through cached memory (e.g. SRAM) then
// the DCache must be flushed prior to DMA2D accessing it. That's done
// using the function SCB_CleanInvalidateDCache(). Remember to enable "CPU Cache" in the
// "System Core" settings for "Cortex M7" in CubeMX in order for this function call to work.
if (SCB->CCR & SCB_CCR_DC_Msk)
{
SCB_CleanInvalidateDCache();
}
}
2024-07-21 16:30:53 +02:00
extern "C"
{
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef* hltdc)
{
if (!HAL::getInstance())
{
return;
}
if (LTDC->LIPCR == lcd_int_active_line)
{
//entering active area
HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_porch_line);
HAL::getInstance()->vSync();
OSWrappers::signalVSync();
// Swap frame buffers immediately instead of waiting for the task to be scheduled in.
// Note: task will also swap when it wakes up, but that operation is guarded and will not have
// any effect if already swapped.
HAL::getInstance()->swapFrameBuffers();
GPIO::set(GPIO::VSYNC_FREQ);
}
else
{
//exiting active area
HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_active_line);
// Signal to the framework that display update has finished.
HAL::getInstance()->frontPorchEntered();
GPIO::clear(GPIO::VSYNC_FREQ);
}
}
}
2023-03-06 21:21:00 +01:00
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/