NXP
/
rt1050_emwin_gui_demo
RT1050 GUI demo using emWin library
source/board.c@0:dd702039127a, 2018-09-20 (annotated)
- Committer:
- alejandroRL
- Date:
- Thu Sep 20 19:16:34 2018 +0000
- Revision:
- 0:dd702039127a
emWin GUI Demo for RT1050
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alejandroRL | 0:dd702039127a | 1 | #include "board.h" |
alejandroRL | 0:dd702039127a | 2 | #include "fsl_gpio.h" |
alejandroRL | 0:dd702039127a | 3 | #include "fsl_clock_config.h" |
alejandroRL | 0:dd702039127a | 4 | #include "emwin_support.h" |
alejandroRL | 0:dd702039127a | 5 | |
alejandroRL | 0:dd702039127a | 6 | /* Initialize the LCD_DISP. */ |
alejandroRL | 0:dd702039127a | 7 | void BOARD_InitLcd(void) |
alejandroRL | 0:dd702039127a | 8 | { |
alejandroRL | 0:dd702039127a | 9 | volatile uint32_t i = 0x100U; |
alejandroRL | 0:dd702039127a | 10 | |
alejandroRL | 0:dd702039127a | 11 | gpio_pin_config_t config = { |
alejandroRL | 0:dd702039127a | 12 | kGPIO_DigitalOutput, 0, |
alejandroRL | 0:dd702039127a | 13 | }; |
alejandroRL | 0:dd702039127a | 14 | |
alejandroRL | 0:dd702039127a | 15 | /* Reset the LCD. */ |
alejandroRL | 0:dd702039127a | 16 | GPIO_PinInit(LCD_DISP_GPIO, LCD_DISP_GPIO_PIN, &config); |
alejandroRL | 0:dd702039127a | 17 | |
alejandroRL | 0:dd702039127a | 18 | GPIO_WritePinOutput(LCD_DISP_GPIO, LCD_DISP_GPIO_PIN, 0); |
alejandroRL | 0:dd702039127a | 19 | |
alejandroRL | 0:dd702039127a | 20 | while (i--) |
alejandroRL | 0:dd702039127a | 21 | { |
alejandroRL | 0:dd702039127a | 22 | } |
alejandroRL | 0:dd702039127a | 23 | |
alejandroRL | 0:dd702039127a | 24 | GPIO_WritePinOutput(LCD_DISP_GPIO, LCD_DISP_GPIO_PIN, 1); |
alejandroRL | 0:dd702039127a | 25 | |
alejandroRL | 0:dd702039127a | 26 | /* Backlight. */ |
alejandroRL | 0:dd702039127a | 27 | config.outputLogic = 1; |
alejandroRL | 0:dd702039127a | 28 | GPIO_PinInit(LCD_BL_GPIO, LCD_BL_GPIO_PIN, &config); |
alejandroRL | 0:dd702039127a | 29 | |
alejandroRL | 0:dd702039127a | 30 | /*Clock setting for LPI2C*/ |
alejandroRL | 0:dd702039127a | 31 | CLOCK_SetMux(kCLOCK_Lpi2cMux, LPI2C_CLOCK_SOURCE_SELECT); |
alejandroRL | 0:dd702039127a | 32 | CLOCK_SetDiv(kCLOCK_Lpi2cDiv, LPI2C_CLOCK_SOURCE_DIVIDER); |
alejandroRL | 0:dd702039127a | 33 | } |
alejandroRL | 0:dd702039127a | 34 | |
alejandroRL | 0:dd702039127a | 35 | void BOARD_InitLcdifPixelClock(void) |
alejandroRL | 0:dd702039127a | 36 | { |
alejandroRL | 0:dd702039127a | 37 | /* |
alejandroRL | 0:dd702039127a | 38 | * The desired output frame rate is 60Hz. So the pixel clock frequency is: |
alejandroRL | 0:dd702039127a | 39 | * (480 + 41 + 4 + 18) * (272 + 10 + 4 + 2) * 60 = 9.2M. |
alejandroRL | 0:dd702039127a | 40 | * Here set the LCDIF pixel clock to 9.3M. |
alejandroRL | 0:dd702039127a | 41 | */ |
alejandroRL | 0:dd702039127a | 42 | |
alejandroRL | 0:dd702039127a | 43 | /* |
alejandroRL | 0:dd702039127a | 44 | * Initialize the Video PLL. |
alejandroRL | 0:dd702039127a | 45 | * Video PLL output clock is OSC24M * (loopDivider + (denominator / numerator)) / postDivider = 93MHz. |
alejandroRL | 0:dd702039127a | 46 | */ |
alejandroRL | 0:dd702039127a | 47 | clock_video_pll_config_t config = { |
alejandroRL | 0:dd702039127a | 48 | .loopDivider = 31, .postDivider = 8, .numerator = 0, .denominator = 0, |
alejandroRL | 0:dd702039127a | 49 | }; |
alejandroRL | 0:dd702039127a | 50 | |
alejandroRL | 0:dd702039127a | 51 | CLOCK_InitVideoPll(&config); |
alejandroRL | 0:dd702039127a | 52 | |
alejandroRL | 0:dd702039127a | 53 | /* |
alejandroRL | 0:dd702039127a | 54 | * 000 derive clock from PLL2 |
alejandroRL | 0:dd702039127a | 55 | * 001 derive clock from PLL3 PFD3 |
alejandroRL | 0:dd702039127a | 56 | * 010 derive clock from PLL5 |
alejandroRL | 0:dd702039127a | 57 | * 011 derive clock from PLL2 PFD0 |
alejandroRL | 0:dd702039127a | 58 | * 100 derive clock from PLL2 PFD1 |
alejandroRL | 0:dd702039127a | 59 | * 101 derive clock from PLL3 PFD1 |
alejandroRL | 0:dd702039127a | 60 | */ |
alejandroRL | 0:dd702039127a | 61 | CLOCK_SetMux(kCLOCK_LcdifPreMux, 2); |
alejandroRL | 0:dd702039127a | 62 | |
alejandroRL | 0:dd702039127a | 63 | CLOCK_SetDiv(kCLOCK_LcdifPreDiv, 4); |
alejandroRL | 0:dd702039127a | 64 | |
alejandroRL | 0:dd702039127a | 65 | CLOCK_SetDiv(kCLOCK_LcdifDiv, 1); |
alejandroRL | 0:dd702039127a | 66 | } |