The 8th chapter:
This chapter mainly describes the principle of the buzzer, the realization of a complete buzzer driver. The main use is PWM driver, PWM is composed of several files.
The first introduction is the reuse of Linux driver code. Compiling is a Linux driver that consists of multiple files. The two full Linux drivers are word_count and led drivers, all made up of a source code file (. c). However, for complex Linux drivers it is necessary to use multiple source code files to store different function codes, resulting in a KO file or Linux kernel.
Then the Linux driver module relies. Code reuse is divided into static and dynamic, in which the module relies on the export symbol: the exported symbol in a drive module using another drive module. Two macro export functions are used in Linux drivers, Export_symbol and EXPORT_SYMBOL_GPL, respectively. Since there are two Linux drivers, you need to specify two Linux modules in the makefile file and uninstall the Symbol_consumer before uninstalling the symbol_producer when uninstalling the two Linux driver sequence.
In addition, the Linux driver is uninstalled in the event of an exception. Initialization function crashes, unload function is blocked. The buzzer actuation principle is to control the buzzer opening and stopping by means of a pulse. (PWM) PWM is controlled using the Gpfcon register of Port F. The macro corresponding to this register in the Linux kernel is s3c64xx_gpfcon. The macro represents the virtual address of the Gpfcon register. Test buzzer: Use to the IOCTL, first enter the/root/drivers/ioctl directory, execute the build.sh script file to compile and upload the ioctl file. Before testing the PWM driver, compile and install the PWM driver, then go to the/data/local directory of the Development Board terminal and turn on PWM.
Android Deep explore HAL and Driver Development-—— 8th Chapter