71 lines
1.6 KiB
C
71 lines
1.6 KiB
C
#include "lcd.h"
|
|
|
|
/* Enable interrupt. */
|
|
void BOARD_EnableLcdInterrupt(void)
|
|
{
|
|
EnableIRQ(LCDIF_IRQn);
|
|
}
|
|
|
|
/* Initialize the LCD_DISP. */
|
|
void BOARD_InitLcd(void)
|
|
{
|
|
volatile uint32_t i = 0x1000U;
|
|
|
|
gpio_pin_config_t config = {
|
|
kGPIO_DigitalOutput,
|
|
0,
|
|
kGPIO_NoIntmode,
|
|
};
|
|
|
|
/* Reset the LCD. */
|
|
GPIO_PinInit(LCD_DISP_GPIO, LCD_DISP_GPIO_PIN, &config);
|
|
|
|
GPIO_PinWrite(LCD_DISP_GPIO, LCD_DISP_GPIO_PIN, 0);
|
|
|
|
while (i--)
|
|
{
|
|
}
|
|
|
|
GPIO_PinWrite(LCD_DISP_GPIO, LCD_DISP_GPIO_PIN, 1);
|
|
|
|
/* Backlight. */
|
|
config.outputLogic = 1;
|
|
GPIO_PinInit(LCD_BL_GPIO, LCD_BL_GPIO_PIN, &config);
|
|
}
|
|
|
|
void BOARD_InitLcdifPixelClock(void)
|
|
{
|
|
/*
|
|
* The desired output frame rate is 60Hz. So the pixel clock frequency is:
|
|
* (480 + 41 + 4 + 18) * (272 + 10 + 4 + 2) * 60 = 9.2M.
|
|
* Here set the LCDIF pixel clock to 9.3M.
|
|
*/
|
|
|
|
/*
|
|
* Initialize the Video PLL.
|
|
* Video PLL output clock is OSC24M * (loopDivider + (denominator / numerator)) / postDivider = 93MHz.
|
|
*/
|
|
clock_video_pll_config_t config = {
|
|
.loopDivider = 31,
|
|
.postDivider = 8,
|
|
.numerator = 0,
|
|
.denominator = 0,
|
|
};
|
|
|
|
CLOCK_InitVideoPll(&config);
|
|
|
|
/*
|
|
* 000 derive clock from PLL2
|
|
* 001 derive clock from PLL3 PFD3
|
|
* 010 derive clock from PLL5
|
|
* 011 derive clock from PLL2 PFD0
|
|
* 100 derive clock from PLL2 PFD1
|
|
* 101 derive clock from PLL3 PFD1
|
|
*/
|
|
CLOCK_SetMux(kCLOCK_LcdifPreMux, 2);
|
|
|
|
CLOCK_SetDiv(kCLOCK_LcdifPreDiv, 4);
|
|
|
|
CLOCK_SetDiv(kCLOCK_LcdifDiv, 1);
|
|
}
|