Browse Source

Refactor STM32LTDC driver to outsource hardware specifics such as clock setup to the board file

develop
Joel Bodenmann 4 months ago
parent
commit
6fa3520f2a
  1. 21
      boards/base/STM32F746-Discovery/board_STM32LTDC.h
  2. 1
      changelog.txt
  3. 15
      drivers/gdisp/STM32LTDC/board_STM32LTDC_template.h
  4. 25
      drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c

21
boards/base/STM32F746-Discovery/board_STM32LTDC.h

@ -393,6 +393,27 @@ static void configureLcdPins(void) {
#endif
}
static GFXINLINE void init_ltdc_clock()
{
// Reset the LTDC peripheral
RCC->APB2RSTR |= RCC_APB2RSTR_LTDCRST;
RCC->APB2RSTR = 0;
// Enable the LTDC clock
RCC->DCKCFGR1 = (RCC->DCKCFGR1 & ~RCC_DCKCFGR1_PLLSAIDIVR) | (1 << 16);
// Enable the peripheral
RCC->APB2ENR |= RCC_APB2ENR_LTDCEN;
}
#if LTDC_USE_DMA2D
static GFXINLINE void init_dma2d_clock()
{
// Enable DMA2D clock
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
}
#endif
static GFXINLINE void init_board(GDisplay *g) {
(void) g;

1
changelog.txt

@ -8,6 +8,7 @@ FIX: Fixed GWIN console widget scroll
FIX: A warning and adjusted is made if GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE is less than 40 bytes.
FIX: Prevent compiler warnings on duplicate const specifiers.
FEATURE: Added support for ChibiOS 6.x kernel.
CHANGE: Refactor STM32LTDC driver to outsource hardware specifics such as clock setup to the board file.
*** Release 2.9 ***

15
drivers/gdisp/STM32LTDC/board_STM32LTDC_template.h

@ -55,7 +55,20 @@ static const ltdcConfig driverCfg = {
#endif
};
static GFXINLINE void init_board(GDisplay* g) {
static GFXINLINE void init_ltdc_clock()
{
// Setup LTDC clock and enable the peripheral
}
#if LTDC_USE_DMA2D
static GFXINLINE void init_dma2d_clock()
{
// Setup DMA2D clock and enable the peripheral
}
#endif
static GFXINLINE void init_board(GDisplay* g)
{
// This is function only called once with the display for the background layer.
(void)g;
}

25
drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c

@ -166,25 +166,8 @@ static void _ltdc_init(void) {
// Set up the display scanning
gU32 hacc, vacc;
// Reset the LTDC peripheral
RCC->APB2RSTR |= RCC_APB2RSTR_LTDCRST;
RCC->APB2RSTR = 0;
// Enable the LTDC clock
#if !LTDC_NO_CLOCK_INIT
#if defined(STM32F469xx)
RCC->DCKCFGR = (RCC->DCKCFGR & ~RCC_DCKCFGR_PLLSAIDIVR);
#elif defined(STM32F4) || defined(STM32F429_439xx) || defined(STM32F429xx)
RCC->DCKCFGR = (RCC->DCKCFGR & ~RCC_DCKCFGR_PLLSAIDIVR) | (1 << 16);
#elif defined(STM32F7) || defined(STM32F746xx)
RCC->DCKCFGR1 = (RCC->DCKCFGR1 & ~RCC_DCKCFGR1_PLLSAIDIVR) | (1 << 16);
#else
#error STM32LTDC driver not implemented for your platform
#endif
#endif
// Enable the peripheral
RCC->APB2ENR |= RCC_APB2ENR_LTDCEN;
// Let the board handle LTDC clock setups
init_ltdc_clock();
// Turn off the controller and its interrupts
LTDC->GCR = 0;
@ -425,8 +408,8 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
static void dma2d_init(void) {
// Enable DMA2D clock
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
// Let the board handle the clock setup
init_dma2d_clock();
// Output color format
#if GDISP_LLD_PIXELFORMAT == GDISP_PIXELFORMAT_RGB565

Loading…
Cancel
Save