Eighth Chapter buzzer Driver

Source: Internet
Author: User

(1) Code reuse

Code reuse can be divided into two types: static and dynamic. Statically, a Linux driver that compiles multiple files 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 (. Ko,. So, and so on). Another way of sharing code: module dependencies, also known as export symbols. If you can only use a sentence to explain how to use the export symbols to achieve code sharing, which is "in a driver module using another driver module in the exported symbols (Tsuneaki, variables, functions, etc.", in the Linux driver can use the following two macro export functions:

EXPORT symbol (symbol name)

EXPORT symbol GPL (symbol name)

The export SYMBOL GPL is used only in Linux driver modules that use the GPL protocol.

(2) Forcibly uninstall Linux drivers

Scenario 1: Because the initialization function of the Linux drive module (usually the function specified by the MODULE_INIT macro) crashes, causing the initialization function to return normally, this behavior is that the current Linux driver module is useless by any other Linux The drive module is used, but the display has been referenced once.

The key to this situation is that the value of the reference counter is inconsistent with the reference. In fact, the reference does not exist, so you only need to clear the current Linux Driver module reference counter 0. The following two functions can be used to modify a reference counter.

static inline int try_module_get (struct module *module)//enable module to point to the Linux module-driven reference counter plus 1

extern void Module_put (struct module *module)//The reference count of the Linux driver module that the module points to is reduced by 1

Scenario 2: The Unload function is blocked when uninstalling a Linux drive using the Rmmod command, the system calls the Unload function ( Module_exit The function specified by the macro), the Linux driver is unloaded only if the Unload function returns successfully . If the Unload function is blocked (possibly caused by a dead loop, concurrency, and so on), the Rmmod command will also be blocked , meaning that the code to unload the Linux driver module will never be executed. The performance of this situation is that an execution of the RMMOD command will stop there and never return to the operating prompt of the system.

(3) buzzer driver

The principle of the buzzer driver: The beeper is also called PWM (pulse width modulation), the basic principle is to control the buzzer by pulse to open and stop.

Implement buzzer Driver

Eighth Chapter buzzer Driver

Related Article

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.