1
介紹
本文介紹由e2 studio自動生成的FSP LVGL pack的使用說明,Pack的生成方法可以參考前面的介紹文章。用戶可以通過添加該pack,以可視化的形式添加和配置Little VGL,包括Little VGL的分辨率、色深、DPI以及官方的demo等進行配置。用戶不用再做移植Little VGL的源代碼,不用再繁瑣的添加各個頭文件。本次實驗所用硬件為EK-RA8D1,如下圖。確保板子的SW1-7切換到“ON”
2
軟件架構
通過pack生成的代碼主要在ra→fsp→src→rm_lvgl_prot和ra→lvgl兩個路徑下
3
安裝教程
1
打開e2 studio菜單中“File”→“Import... ”
2
在彈出的“Import”對話框中,選擇“General”→“CMSIS Pack”,點擊“Next”
3
在彈出的“Import CMSIS Pack”對話框中,點擊“Specify pack file”右側“...”,指定需要添加的pack文件
4
“Specify device family”選擇“RA”,點擊Finish
4
使用說明
1
重新打開e2 studio
2
新建工程,新建工程步驟不再贅述,F(xiàn)SP版本選擇5.1.0及以上,Board選擇EK-RA8D1
3
新建好工程后,添加LVGL的stack,這時候會提示GLCDC的時鐘沒有打開,切換到clocks選項卡,enable LCD的clock,選擇PLL1P,讓LCD時鐘輸出為240MHz即可。
添加MIPI DSI driver,左鍵點擊Add MIPI DSI Output(Optional)→New→MIPI Display(r_mipi_dsi):
NOTE
Enable LCD的clock后,r_glcdc的紅色提示會消失。
修改LVGL顯示分辨率:480*854,enable 2D
使能touch
修改glcdc的名字為g_display_lvgl:
4
添加2D驅動,如果上述步驟沒有enable 2D,此步驟可以跳過。New Stack→Graphics→D/AVE 2D Port Interface
添加完2D stack后,在BSP選項卡中heap給2D使用,同時加大stack的值為0x2000:
5
添加I2C驅動
修改I2C的配置,Name: g_i2c_master1, Channel: 1, Slave address: 0x5D, Callback: g_i2c_master1_cb, Interrupt Priority Level:Priority 12
6
添加GPIO中斷,修改irq的配置:Name:g_external_irq3,Channel:3,Callback:touch_irq_cb
P510設為input模式,IRQ選擇為IRQ3
7
配置引腳,改變SDRAM的引腳驅動能力:PA00 -- H, PA08 -- H, PA09 -- HH, PA10 -- H, P404設為輸出模式,初始化為高電平,PA01設為輸出模式,初始化為高電平
8
點擊Generate Project Content,生成代碼
9
添加應用代碼,做一個LVGL下拉控件。修改 hal_entry.c如下:
左右滑動查看完整代碼內容
#include "hal_data.h" #include "dsi_layer.h" #include "lvgl.h" #include "lv_demos.h" FSP_CPP_HEADER void R_BSP_WarmStart(bsp_warm_start_event_t event); FSP_CPP_FOOTER #define RGB_565_REG (0x1F << 11) #define RGB_565_GREEN ?(0x3F << 5) #define RGB_565_BLUE ? (0x1F << 0) /* Global variable to keep track of requested application */ void SysTick_Handler(void); #define LVGL_TICK_MS 1U static volatile uint32_t s_tick ? ? ? ?= 0U; static volatile bool s_lvglTaskPending = false; #define LVGL_TASK_PERIOD_TICK 3U static void DEMO_SetupTick(void) { if (0 != SysTick_Config(SystemCoreClock / (LVGL_TICK_MS * 1000U))) { while (1) ; } } void SysTick_Handler(void) { s_tick++; lv_tick_inc(LVGL_TICK_MS); if ((s_tick % LVGL_TASK_PERIOD_TICK) == 0U) { s_lvglTaskPending = true; } } #if LV_BUILD_EXAMPLES static void event_handler(lv_event_t * e) { lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); if(code == LV_EVENT_VALUE_CHANGED) { char buf[32]; lv_dropdown_get_selected_str(obj, buf, sizeof(buf)); LV_LOG_USER("Option: %s", buf); } } void lv_example_dropdown_1(void) { /*Create a normal drop down list*/ lv_obj_t * dd = lv_dropdown_create(lv_scr_act()); lv_dropdown_set_options(dd, "Apple " "Banana " "Orange " "Cherry " "Grape " "Raspberry " "Melon " "Orange " "Lemon " "Nuts"); lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 20); lv_obj_add_event_cb(dd, event_handler, LV_EVENT_ALL, NULL); } #endif /*******************************************************************************************************************//** main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. ?This function is called by main() when no RTOS is used. **********************************************************************************************************************/ void hal_entry(void) { /* TODO: add your own code here */ fsp_err_t ?err; /* Fill the Frame buffer with Blue, to zero out info from previous execution runs */ uint32_t count; uint16_t * p = (uint16_t *)&fb_background[0][0]; for (count = 0; count < sizeof(fb_background)/2; count++) { *p++ = RGB_565_REG; } DEMO_SetupTick(); lv_init(); lv_port_disp_init(); #if Touch_Enable lv_port_indev_init(); #endif lv_example_dropdown_1(); #if LV_USE_DEMO_WIDGETS // ? ? ? lv_demo_widgets(); #endif #if LV_USE_DEMO_STRESS lv_demo_stress(); #endif #if LV_USE_DEMO_BENCHMARK lv_demo_benchmark(); #endif #if LV_USE_DEMO_MUSIC lv_demo_music(); #endif // ? ?lv_task_handler(); /* handle the tasks of LVGL */ while(1) { while (!s_lvglTaskPending) { } s_lvglTaskPending = false; lv_task_handler(); } #if BSP_TZ_SECURE_BUILD /* Enter non-secure code */ R_BSP_NonSecureEnter(); #endif } /*******************************************************************************************************************//** This function is called at various points during the startup process. ?This implementation uses the event that is called right before main() to set up the pins. * * @param[in] ?event ? ?Where at in the start up process the code is currently at **********************************************************************************************************************/ void R_BSP_WarmStart(bsp_warm_start_event_t event) { if (BSP_WARM_START_RESET == event) { #if BSP_FEATURE_FLASH_LP_VERSION != 0 /* Enable reading from data flash. */ R_FACI_LP→DFLCTL = 1U; /* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */ #endif } if (BSP_WARM_START_POST_C == event) { /* C runtime environment and system clocks are setup. */ /* Configure pins. */ R_IOPORT_Open (&g_ioport_ctrl, &IOPORT_CFG_NAME); bsp_sdram_init(); //SDRAM pins need to be set to HIGH drive strength in pin configuration } } #if BSP_TZ_SECURE_BUILD FSP_CPP_HEADER BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable (); /* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */ BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable () { } FSP_CPP_FOOTER #endif
10
編譯,下載到EK-RA8D1,連接MIPI屏,會得到以下結果:
至此,已經(jīng)完成LVGL的移植以及測試。下面我們直接配置FSP,把官方的demo使能起來:打開configuration.xml,配置如下:
配置完成后,點擊Generate Project Content。修改hal_entry.c:
#include "hal_data.h" #include "dsi_layer.h" #include "lvgl.h" #include "lv_demos.h" FSP_CPP_HEADER void R_BSP_WarmStart(bsp_warm_start_event_t event); FSP_CPP_FOOTER #define RGB_565_REG (0x1F << 11) #define RGB_565_GREEN ?(0x3F << 5) #define RGB_565_BLUE ? (0x1F << 0) /* Global variable to keep track of requested application */ void SysTick_Handler(void); #define LVGL_TICK_MS 1U static volatile uint32_t s_tick ? ? ? ?= 0U; static volatile bool s_lvglTaskPending = false; #define LVGL_TASK_PERIOD_TICK 3U static void DEMO_SetupTick(void) { ? ?if (0 != SysTick_Config(SystemCoreClock / (LVGL_TICK_MS * 1000U))) ? ?{ ? ? ? ?while (1) ? ? ? ? ? ?; ? ?} } void SysTick_Handler(void) { ? ?s_tick++; ? ?lv_tick_inc(LVGL_TICK_MS); ? ?if ((s_tick % LVGL_TASK_PERIOD_TICK) == 0U) ? ?{ ? ? ? ?s_lvglTaskPending = true; ? ?} } #if LV_BUILD_EXAMPLES static void event_handler(lv_event_t * e) { ? ?lv_event_code_t code = lv_event_get_code(e); ? ?lv_obj_t * obj = lv_event_get_target(e); ? ?if(code == LV_EVENT_VALUE_CHANGED) { ? ? ? ?char buf[32]; ? ? ? ?lv_dropdown_get_selected_str(obj, buf, sizeof(buf)); ? ? ? ?LV_LOG_USER("Option: %s", buf); ? ?} } void lv_example_dropdown_1(void) { ? ?/*Create a normal drop down list*/ ? ?lv_obj_t * dd = lv_dropdown_create(lv_scr_act()); ? ?lv_dropdown_set_options(dd, "Apple " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Banana " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Orange " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Cherry " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Grape " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Raspberry " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Melon " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Orange " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Lemon " ? ? ? ? ? ? ? ? ? ? ? ? ? ?"Nuts"); ? ?lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 20); ? ?lv_obj_add_event_cb(dd, event_handler, LV_EVENT_ALL, NULL); } #endif /*******************************************************************************************************************//** ?* main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. ?This function ?* is called by main() when no RTOS is used. ?**********************************************************************************************************************/ void hal_entry(void) { ? ?/* TODO: add your own code here */ ? ?fsp_err_t ?err; ? ?/* Fill the Frame buffer with Blue, to zero out info from previous execution runs */ ? ?uint32_t count; ? ?uint16_t * p = (uint16_t *)&fb_background[0][0]; ? ?for (count = 0; count < sizeof(fb_background)/2; count++) ? ?{ ? ? ? ?*p++ = RGB_565_REG; ? ?} ? ?DEMO_SetupTick(); //為lvgl提供心跳 ? ?lv_init(); ? ?lv_port_disp_init(); #if Touch_Enable ? ?lv_port_indev_init(); #endif // ? ? ? lv_example_dropdown_1(); #if LV_USE_DEMO_WIDGETS ? ?lv_demo_widgets(); #endif #if LV_USE_DEMO_STRESS ? ?lv_demo_stress(); #endif #if LV_USE_DEMO_BENCHMARK ? ?lv_demo_benchmark(); #endif #if LV_USE_DEMO_MUSIC ? ?lv_demo_music(); #endif // ? ?lv_task_handler(); ? ?/* handle the tasks of LVGL */ ? ?while(1) ? ?{ ? ? ? ?while (!s_lvglTaskPending) ? ? ? ?{ ? ? ? ?} ? ? ? ?s_lvglTaskPending = false; ? ? ? ?lv_task_handler(); ? ?} #if BSP_TZ_SECURE_BUILD ? ?/* Enter non-secure code */ ? ?R_BSP_NonSecureEnter(); #endif } ? ?/*******************************************************************************************************************//** ? ?* This function is called at various points during the startup process. ?This implementation uses the event that is ? ?* called right before main() to set up the pins. ? ?* ? ?* @param[in] ?event ? ?Where at in the start up process the code is currently at ? ?**********************************************************************************************************************/ ? ?void R_BSP_WarmStart(bsp_warm_start_event_t event) { ? ? ? ?if (BSP_WARM_START_RESET == event) ? ? ? ?{ ? ?#if BSP_FEATURE_FLASH_LP_VERSION != 0 ? ? ? ? ? ?/* Enable reading from data flash. */ ? ? ? ? ? ?R_FACI_LP→DFLCTL = 1U; ? ? ? ? ? ?/* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and ? ? ? ? ? ?* C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */ ? ?#endif ? ? ? ?} ? ? ? ?if (BSP_WARM_START_POST_C == event) ? ? ? ?{ ? ? ? ? ? ?/* C runtime environment and system clocks are setup. */ ? ? ? ? ? ?/* Configure pins. */ ? ? ? ? ? ?R_IOPORT_Open (&g_ioport_ctrl, &IOPORT_CFG_NAME); ? ? ? ? ? ?bsp_sdram_init(); //SDRAM pins need to be set to HIGH drive strength in pin configuration ? ? ? ?} ? ?} ? ?#if BSP_TZ_SECURE_BUILD ? ?FSP_CPP_HEADER ? ?BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable (); ? ?/* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */ ? ?BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable () { ? ?} ? ?FSP_CPP_FOOTER ? ?#endif
編譯,下載。得到結果如下:
如果實驗過程有問題,可以下載本倉庫中e2studio_project下的RA8D1_simple_demo和RA8D1_widgets_demo兩個完整的工程做對比。
基于RA8D1的LVGL FSP配置以及使用已經(jīng)介紹完畢。
審核編輯:劉清
-
CMSIS
+關注
關注
0文章
40瀏覽量
11942 -
MIPI
+關注
關注
11文章
312瀏覽量
48769 -
時鐘輸出
+關注
關注
0文章
4瀏覽量
5649 -
I2C驅動
+關注
關注
0文章
9瀏覽量
7100 -
LVGL
+關注
關注
1文章
91瀏覽量
3083
原文標題:基于RA8D1 MIPI DSI實現(xiàn)LVGL
文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關注!文章轉載請注明出處。
發(fā)布評論請先 登錄
相關推薦
【瑞薩RA8D1 CPK開發(fā)板】RA8D1移植ThreadX操作系統(tǒng)
【瑞薩RA8D1 CPK開發(fā)板試用】開箱與點燈
如何優(yōu)雅的在OpenMV上使用LVGL
![如何優(yōu)雅的在OpenMV上使用<b class='flag-5'>LVGL</b>](https://file1.elecfans.com/web2/M00/C4/8A/wKgZomX0EhWACv8DAAAUet8ikhs451.png)
基于Arm Cortex-CM85內核的RA8D1作為控制器 通過MIPI DSI實現(xiàn)LVGL顯示
![基于Arm Cortex-CM85內核的<b class='flag-5'>RA8D1</b>作為控制器 通過MIPI DSI實現(xiàn)<b class='flag-5'>LVGL</b>顯示](https://file1.elecfans.com/web2/M00/ED/59/wKgaomZitWuAOqWNAACBUodRsT4191.png)
基于瑞薩電子RA系列的野火耀陽RA8D1開發(fā)板產(chǎn)品簡介
![基于瑞薩電子<b class='flag-5'>RA</b>系列的野火耀陽<b class='flag-5'>RA8D1</b>開發(fā)板產(chǎn)品簡介](https://file1.elecfans.com/web2/M00/EB/03/wKgaomZWyWqAF2l3AAAbN7pwg2I917.jpg)
《RA8D1 Vision Board開發(fā)實踐指南》上線啦
![《<b class='flag-5'>RA8D1</b> Vision Board開發(fā)實踐指南》上線啦](https://file1.elecfans.com/web2/M00/C4/8A/wKgZomX0EhWACv8DAAAUet8ikhs451.png)
【Vision Board創(chuàng)客營連載體驗】RA8D1 Vision Board Camera 初體驗
【Vision Board創(chuàng)客營連載體驗】RA8D1 Vision Board 實現(xiàn) FAL 同時調用片上以及外掛 Flash
【Vision Board創(chuàng)客營連載體驗】RA8D1 Vision Board初體驗
瑞薩RA8D1 CEU介紹與使用說明
![瑞薩<b class='flag-5'>RA8D1</b> CEU<b class='flag-5'>介紹</b>與使用說明](https://file1.elecfans.com/web2/M00/C0/44/wKgZomXUJ9-AeK4aAAAZndD3W_c276.png)
評論