This chapter introduces the realization of the original plow of the buzzer, and realizes a complete buzzer drive (can open and close the buzzer), the buzzer is also called PWM pulse width modulation, the basic principle is to control the buzzer by the pulse to open and stop. A buzzer is a hardware device on a development Board that can control the sound emitted by a buzzer by writing a specific value to the register.
In the process of completion, the first is to complete the Linux driver code reuse, the first is to compile the Linux driver composed of multiple files, and generate the Ko file, the last makefile file. It then relies on the driver module, which uses symbols from the back of another driver module in one drive module.
With the I/O command can open and stop the rank PWM,PWM drive consists of three files, PWM.C driver main program, pwm_fun.h the corresponding header file, PWM_FUN.C contains two functions to open and stop the PWM. First enter/root/drivers/ioctl execute build.h script file to compile and upload the IOCTL, before testing to compile and install the PWM driver, and then into the Development Board terminal/data/local Open and stop PWM.
PWM time-driven implementation is different from the LED driver, the PWM driver will be composed of several files. This is also the standard implementation of most Linux drivers. These files are co-compiled when the Linux driver is compiled. This section describes how to divide a Linux drive into multiple files. The data structure, function code in these files can also be used by several different drivers, so this is also an important method of code reuse. The PWM drive is similar to the LED driver implementation process and may be simpler. In this chapter it is only to demonstrate how to divide a Linux driver into multiple implementation files before using a relatively simple PWM driver.
PWM driver similar to the LED, it may be simpler, this chapter uses the PWM driver mainly for a more simple to divide a Linux driver into multiple implementation files, learn through this chapter, but also further grasp the code reuse method and forcibly uninstall the Linux drive method, you can not constantly restart the machine.
Android Deep Explore--hal and Driver Development eighth chapter