Chapter 7 ---- pwm buzzer and ---- pwm buzzer
Linux code reuse:
You can load the header file to use all the original functions. The dynamic mode is that one driver uses the resources of another driver.
For an experiment like a buzzer, there are many internal files, and all the source code must have a lot for proper management.
If there are multiple files, module-y specifies all the files, and then a build. sh script is generated, executed using sh, and the log information is viewed using dmesg.
Code reuse is divided into static and dynamic. Static reuse is to generate the. ko kernel, and dynamic reuse is a module dependency. One driver uses the exported symbol from the other driver module.
Restart the Development Board or the simulator. ko file to automatically disappear. Unmount when an exception occurs: 1. initialize the function. 2. The unmount function is blocked.
To uninstall a driver, enter a bunch of commands to query the first address of the module structure, and install and download the force_kill_driver driver.
The implementation principle of the buzzer driver is basically the same as that of the LED, but the implementation method is different, because the PWM is composed of multiple files.
The basic principle of PWM is to control the opening and stopping of the buzzer through the pulse. GPFCON only uses the highest two to control PWM.
Static function struct, the open function of the PWM device file, which can only open the PWM device file at the same time using the semaphore control, and then close the function to release the semaphore, ioctl () function to process the I/O command, set the file_operation device of the file device, initialize the semaphore at the beginning, and remove the semaphore. Open PWM_IOTCL_START In the pwm. h file and stop PWM_IOTCL_STOP. Here we will explain in detail in the underlying Linux driver, generate the. ko file, and compile it successfully.
The test buzzer generally uses the parameters of the I/O command and can be voiced normally.