MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / efm32_spiLcd_init

Function efm32_spiLcd_init

bsp/efm32/dev_lcd.c:501–677  ·  view source on GitHub ↗

/ * @brief * Initialize LCD device * * @details * * @note * ******************************************************************************/

Source from the content-addressed store, hash-verified

499 *
500 ******************************************************************************/
501void efm32_spiLcd_init(void)
502{
503 struct efm32_usart_device_t *usart;
504 rt_uint32_t flag;
505 DMD_DisplayGeometry *geometry;
506 rt_uint32_t ret;
507
508 do
509 {
510 USART_InitSync_TypeDef init = USART_INITSYNC_DEFAULT;
511
512 /* Find SPI device */
513 lcd = rt_device_find(LCD_USING_DEVICE_NAME);
514 if (lcd == RT_NULL)
515 {
516 lcd_debug("LCD err: Can't find %s!\n", LCD_USING_DEVICE_NAME);
517 break;
518 }
519 lcd_debug("LCD: Find device %s\n", LCD_USING_DEVICE_NAME);
520
521 /* Config CS pin */
522 usart = (struct efm32_usart_device_t *)(lcd->user_data);
523 if (!(usart->state & USART_STATE_AUTOCS))
524 {
525 GPIO_PinModeSet(LCD_CS_PORT, LCD_CS_PIN, gpioModePushPull, 1);
526 lcdAutoCs = false;
527 }
528
529 /* TFT initialize or reinitialize. Assumes EBI has been configured
530 correctly in DVK_init(DVK_Init_EBI) */
531 rt_uint32_t freq = SystemCoreClockGet();
532 rt_uint32_t i;
533 rt_bool_t warning = RT_FALSE;
534
535 /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */
536 while (DVK_readRegister(&BC_REGISTER->UIF_AEM) != BC_UIF_AEM_EFM)
537 {
538 if (!warning)
539 {
540 lcd_debug("LCD: Please press AEM button!!!\n");
541 warning = RT_TRUE;
542 }
543 }
544
545 lcd_debug("LCD: Got LCD control\n");
546 /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */
547 if (DVK_readRegister(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI)
548 {
549 lcd_debug("LCD: Set to EBI mode\n");
550 /* Configure for EBI mode and reset display */
551 DVK_displayControl(DVK_Display_EBI);
552 DVK_displayControl(DVK_Display_ResetAssert);
553 DVK_displayControl(DVK_Display_PowerDisable);
554 /* Short delay */
555 freq = SystemCoreClockGet();
556 for(i = 0; i < (freq / 100); i++)
557 {
558 __NOP();

Callers 1

rt_hw_driver_initFunction · 0.85

Calls 15

rt_device_findFunction · 0.85
GPIO_PinModeSetFunction · 0.85
DVK_readRegisterFunction · 0.85
DVK_displayControlFunction · 0.85
DVK_enablePeripheralFunction · 0.85
EBI_BankAddressFunction · 0.85
EBI_TFTInitFunction · 0.85
efm32_spiLcd_registerFunction · 0.85
SystemCoreClockGetFunction · 0.50
__NOPFunction · 0.50
DMD_initFunction · 0.50
DMD_flipDisplayFunction · 0.50

Tested by

no test coverage detected