当前位置:网站首页>[FFH] little bear driver calling process (take calling LED light driver as an example)
[FFH] little bear driver calling process (take calling LED light driver as an example)
2022-07-02 12:25:00 【Harmonyos technology community】
One 、 Process Overview
The process of driving calls is very similar to that of pure code development , This article focuses on the logic that drives the call .
Create directories and corresponding source files –> Write driver calling code –> Write and compile build files BUILD.gn–> Compile, burn and run
Two 、 Source directory structure
stay ./applications/BearPi/BearPi-HM_Micro/samples/ Create under directory
my_led_app Source directory
*my_led_app.c Driver call source code
*BUILD.gn Source compilation script
As shown in the figure

3、 ... and 、 Write driver calling code
stay my_led_app.c Write the following code in
This part is the key part of this article
OpenHarmony The driver call in the device development of is different from the driver development of single chip microcomputer , In the past, the driver call of single chip microcomputer often used the way of library function call , but OpenHarmony The driver call of adopts that the driver exposes a server, Procedure passed Dispatch How to send instructions . It's a bit like ROS Topic publishing and subscription in the message communication mechanism . stay OpenHarmony This part of the program called by the driver in belongs to the user program , It is the content of user mode , The driver is the content of kernel state . So the user program cannot directly access the driver , The above code passes Dispatch Send instructions to the driver to realize LED The light goes on and off .
3.1 Send instructions to the driver
Let's take a look at my_led_app.c in SendEvent function Pass through Dispatch The code sent to the driver
This code implements sending instructions to the driver
The code received by the driver instruction is Last article Medium led.c In the driver code LedDriverDispatch function
3.2 Receive data from the driver
Just realized sending instructions from user state to inner core state , Empathy , Kernel mode can also send data to user mode .
Let's take a look at the driver code that sends LED Code of status information ( stay led.c in LedDriverDispatch Part of the function )
The following is the part received by the user program
Four 、 Write and compile build files BUILD.gn
stay BUILD.gn Add the following code in
5、 ... and 、 Compile burn
Refer to the previous article Linux The next configuration is little bear pie - Hongmeng · Tertiary equipment development ( Southward direction ) Development environment of
6、 ... and 、 function
Connect the serial port to the little bear terminal
Want to know more about Hongmeng , Please visit :
51CTO Hongmeng technology community jointly built with Huawei officials
https://harmonyos.51cto.com/#bkwz

边栏推荐
猜你喜欢

倍增 LCA(最近公共祖先)

The differences and relationships among port, targetport, nodeport and containerport in kubenetes

Initial JDBC programming

Map and set

Go learning notes - multithreading

WSL 2 will not be installed yet? It's enough to read this article

Sparkcontext: error initializing sparkcontext solution

arcgis js 4.x 地图中加入图片

Go学习笔记—多线程

Deep understanding of P-R curve, ROC and AUC
随机推荐
Map and set
Find the factorial of a positive integer within 16, that is, the class of n (0= < n < =16). Enter 1111 to exit.
Docker compose configuration mysql, redis, mongodb
刷题---二叉树--2
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
Docker-compose配置Mysql,Redis,MongoDB
OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
输入一个三位的数字,输出它的个位数,十位数、百位数。
Find the common ancestor of any two numbers in a binary tree
Drools executes the specified rule
Drools terminates the execution of other rules after executing one rule
Leetcode739 daily temperature
还不会安装WSL 2?看这一篇文章就够了
PyTorch nn. Full analysis of RNN parameters
arcgis js 4. Add pictures to x map
mysql索引和事务
MySQL and PostgreSQL methods to grab slow SQL
上传文件时,服务器报错:IOFileUploadException: Processing of multipart/form-data request failed. 设备上没有空间
Writing method of then part in drools
二分刷题记录(洛谷题单)区间的甄别