The eighth chapter introduces the second experiment: Buzzer driver, make the Development Board sound
This paper introduces the principle of buzzer and realizes a complete buzzer driver, which can control the opening and closing of 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. This section describes the principle of buzzer implementation and implements a complete buzzer driver that can be turned on and off. PWM drives are implemented differently than led drivers, and PWM drivers are made up of multiple files, which is the standard implementation of most Linux drivers.
There are many ways to reuse Linux-driven code. It is divided into static reuse and dynamic reuse, and static reuse is code-level reuse, which is to compile the code that needs to be reused and the documents that use the code together, resulting in an executable file or library (. Ko and. So, etc.). Code sharing is the use of symbols (constants, variables, functions, etc.) that are exported from another driver module in one drive module.
If you write a Linux driver that is correct, it can be loaded and unloaded normally, but in some cases there may be exceptions for some programs, and Linux drivers may not unload properly. If you test the Linux driver in a way that dynamically loads. ko files on the emulator or on the board, even if the Linux driver cannot be uninstalled properly, the dynamic Linux module will be unloaded from memory as long as the emulator or Development Board is restarted.
Let the board make a sound