当前位置:网站首页>[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

边栏推荐
- CDA data analysis -- common knowledge points induction of Excel data processing
- Drools dynamically add, modify, and delete rules
- kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use [ERROR FileAvailable--etc-kubernetes-pki
- Intel internal instructions - AVX and avx2 learning notes
- Lombok common annotations
- The differences and relationships among port, targetport, nodeport and containerport in kubenetes
- mysql表的增删改查(进阶)
- (C language) octal conversion decimal
- Leetcode - Sword finger offer 37, 38
- AI中台技术调研
猜你喜欢

深拷贝 事件总线

How does Premiere (PR) import the preset mogrt template?

中国交通标志检测数据集

寻找二叉树中任意两个数的公共祖先

倍增 LCA(最近公共祖先)

Distributed machine learning framework and high-dimensional real-time recommendation system

(C语言)输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。

Jenkins user rights management

CDA data analysis -- Introduction and use of aarrr growth model

There is a hidden danger in CDH: the exchange memory used by the process of this role is XX megabytes. Warning threshold: 200 bytes
随机推荐
【C语言】杨辉三角,自定义三角的行数
(C语言)八进制转换十进制
史上最易懂的f-string教程,收藏這一篇就够了
The blink code based on Arduino and esp8266 runs successfully (including error analysis)
LeetCode—<动态规划专项>剑指 Offer 19、49、60
Find the factorial of a positive integer within 16, that is, the class of n (0= < n < =16). Enter 1111 to exit.
Leetcode14 longest public prefix
There is a hidden danger in CDH: the exchange memory used by the process of this role is XX megabytes. Warning threshold: 200 bytes
Drools executes string rules or executes a rule file
基于Arduino和ESP8266的连接手机热点实验(成功)
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
Mysql database foundation
Addition, deletion, modification and query of MySQL table (Advanced)
mysql索引和事务
输入一个三位的数字,输出它的个位数,十位数、百位数。
HR wonderful dividing line
jenkins 凭证管理
Go learning notes - multithreading
China traffic sign detection data set
drools中then部分的写法