当前位置:网站首页>[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
边栏推荐
- Map and set
- Initial JDBC programming
- Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
- 史上最易懂的f-string教程,收藏這一篇就够了
- JZ63 股票的最大利润
- FastDateFormat为什么线程安全
- SparkContext: Error initializing SparkContext解决方法
- Go learning notes - go based interprocess communication
- Le tutoriel F - String le plus facile à comprendre de l'histoire.
- Discrimination of the interval of dichotomy question brushing record (Luogu question sheet)
猜你喜欢
Simple understanding of ThreadLocal
Docker compose configuration mysql, redis, mongodb
测试左移和右移
5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
Experiment of connecting mobile phone hotspot based on Arduino and esp8266 (successful)
分布式机器学习框架与高维实时推荐系统
Sparkcontext: error initializing sparkcontext solution
Is the neural network (pinn) with embedded physical knowledge a pit?
SparkContext: Error initializing SparkContext解决方法
随机推荐
(C语言)3个小代码:1+2+3+···+100=?和判断一个年份是闰年还是平年?和计算圆的周长和面积?
Leetcode739 daily temperature
高德地图测试用例
高性能纠删码编码
There is a hidden danger in CDH: the exchange memory used by the process of this role is XX megabytes. Warning threshold: 200 bytes
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
Intel 内部指令 --- AVX和AVX2学习笔记
Is the neural network (pinn) with embedded physical knowledge a pit?
基于Arduino和ESP8266的连接手机热点实验(成功)
Tas (file d'attente prioritaire)
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
High performance erasure code coding
LeetCode—剑指 Offer 59 - I、59 - II
Docker compose configuration mysql, redis, mongodb
Sub thread get request
Jenkins voucher management
【C语言】杨辉三角,自定义三角的行数
5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
MSI announced that its motherboard products will cancel all paper accessories
drools执行String规则或执行某个规则文件