Android transplant and Driver development eighth chapter experience

Source: Internet
Author: User

There are many ways to reuse Linux-driven code. The standard C program can be used in the way. Put the code you want to reuse in a different file (declared in the header file). If you want to use some features, include the corresponding header file (this way is called static reuse). You can also use another way of dynamic reuse, which means that a Linux driver can use the resources (functions, variables, macros, and so on) in the other ← Linux drivers. When compiling multiple source code files in a C or e++ language, if A.C uses a function in the Z-B.C file, you need to: to use the extern predefined B.I: function in the a.c file, extern does this by telling the compiler that the function name, number of arguments, parameter type, and return value type of the function.

The most critical step in the step is to write the makefile file with the following code:

F Makefile
Obj-m. : = MULTI_FILE_DRIVER.O
Multi_file_driver-y: = Main. Fun. . Product. .
Or use Make_file_driver-objs:s main: Fun. Pr.duct

Code Chu is divided into two types: static and dynamic. The method described in the previous section is static reuse of code, which is a code-level reuse that compiles the code that needs to be reused and the consumer who uses the code, eventually generating an executable file or library C.ko,. So, and so on. The ability to unload a Linux drive module that is not able to unload from an exception condition. These conditions are as follows: 1. Initialization function crashes 2. The Unload function is blocked.

The buzzer driver principle is that the buzzer is also called PWM (pulse width modulation), the basic principle is to control the buzzer by pulse to open and stop. Convenient, this book will be a bee and collectively referred to as PWM. The PWM is connected to the TOUT1 port. The PWM drive is similar to the LED driver implementation process and may be simpler. In the 8th chapter, just to demonstrate how to divide a Linux driver into multiple implementation files, a simple PWM driver is used. Through the study of this chapter, we can master the common code reuse mode of Linux driver. In addition, this chapter introduces a method of forcibly uninstalling Linux drivers. I hope we can practice more in the experiment class later.

http://www.cnblogs.com/suntao123/

Android transplant and Driver development eighth chapter experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.