In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "what is the method of porting LiteOS bare metal driver to 02LCD". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. LCD bare metal driver
The development board uses a 1.3in TFT color screen with a color depth of 16bit and a resolution of 240mm 240. The SPI interface is used to communicate with MCU.
two。 Migrate LCD bare metal driver to LiteOS copy bare metal driver files to LiteOS project
The bottom layer of LCD is driven by SPI, so in addition to the spi.h and spi.c files generated by STM32CubeMX, you also need to handwrite the driver files of the LCD screen on this basis.
When copying files, as mentioned in the previous article, copy spi.h to the Inc folder, copy spi.c to the Src folder, and then copy the driver files lcd.c, lcd.h and font files font.h written by yourself to the Hardware folder.
The default project provided in IoT-Studio has copied these files and does not need to add them again, as shown in the figure:
Add driver file path
Because the entire project of LiteOS is built using make, after copying the driver file, you need to add the path to the driver file to makefile and add compilation.
The project.mk file indicates the path to all files in the project:
In this file:
C file path
HARDWARE_SRC: the Src folder under the Hardware folder
USER_SRC: corresponding Src folder
Header file path
HARDWARE_INC: the Inc folder under the Hardware folder
USER_INC: corresponding Inc folder
As follows, the underlying SPI interface code spi.c path of the LCD driver is added to USER_SRC:
The underlying SPI interface code spi.h path of LCD driver is added to USER_INC:
The LCD screen driver file lcd.c based on SPI driver is added to HARDWARE_SRC:
The LCD screen driver header file lcd.h and font file font.h based on SPI driver are added to HARDWARE_INC:
At this point, copy the file to the LiteOS project, add the newly copied file path to the makefile, add the project compilation, and complete the migration of the driver.
3. Initialize LCD with LCD bare metal driver
In the previous article, I described in detail two ways to initialize a device in LiteOS:
Initialize before the system starts scheduling: the device can be used by any task in the system at any time
Initialize in a task: the device is generally only used in this task
The LCD devices migrated in this article do not need special tasks to operate LCD, so they should be initialized before the system starts, and then each task can be displayed by operating LCD devices.
Add the LCD initialization code to the HardWare_Init () function in main.c:
In order not to affect the later experiment, comment out the default character display code in the project:
Manipulate LCD
Next, first create a folder (if you already have one, don't create it again) to hold the code for this series of tutorial labs:
Create a file in this folder:
Write code:
# include # include static int lcd_demo_entry () {/ / Test shows the characters POINT_COLOR = BLUE; LCD_ShowString (0,0,240,32,32, "Welcome To IoT"); POINT_COLOR = RED; LCD_ShowString (0,32,240,24,24, "I am BearPi"); POINT_COLOR = BLACK LCD_ShowString (0,56,240,16,16, "LCD Test."); POINT_COLOR = GREEN; LCD_ShowString (0,72,240,12,12, "Powerd by Huawei LiteOS!"); / / Test drawing rectangle POINT_COLOR = BLUE; LCD_DrawRectangle (20,100,120,200); / / Test drawing circle POINT_COLOR = RED LCD_Draw_Circle (180,150,50); return 0;} int standard_app_demo_main () {osal_task_create ("lcd_demo", lcd_demo_entry,NULL,0x400,NULL,2); return 0;}
Then, as before, add the lcd_driver_demo.c file to the makefile in user_demo.mk and add the compilation:
Finally, configure to open the macro definition in .sdkconfig:
Compile and burn, you can see the display of the LCD screen:
This is the end of the content of "what is the method of porting 02LCD to the bare metal driver of LiteOS". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.