By learning Android Deep Exploration (Volume one) HAL and Driver Development eighth chapter Let me know how to make the Development Board sound, how to write a buzzer driver. Understand the code reuse of Linux drive, code reuse is divided into static and dynamic two kinds.
Linux-driven code reuse there are many ways, you can use the standard C program, the code of the important code in other files, if you want to use some features, include the corresponding header file, this method is called static reuse, Another way of dynamic reuse is that a Linux driver can use resources from another Linux driver.
If you test the Linux driver in a way that dynamically loads the. ko file on the emulator or board, even if the Linux driver is not normal, the dynamic Linux module will unload from memory if you restart the emulator or development version, but if you restart the computer every time it is easy to crash the machine, you need a way to solve this problem , the Linux driver can still be uninstalled without booting the machine when the Linux drive cannot be uninstalled via the Rmmod command. Our solution is to find the first address of the system assigned to the Linux-powered module struct to be unloaded from the/proc/kallsyms file, and then forcibly convert the first address to the module struct pointer.
Buzzer driver principle: Buzzer is also called PWM (pulse width modulation), the basic principle is to control the buzzer by pulse to open and stop.
Android Deep Explore (Volume one) HAL and Driver Development chapter Eighth