This chapter is the switch that sends data control LED lights through the Linux drive.
At the beginning of the LED lights through the drive control we need to create the LED drive device files :
First step: initialize the cdev with the Cdev-init function
Step Two: Specify the device number
Step three: Use the cdev-add function to add a character device to the character device array in the kernel
Fourth step: Create a struct class using the Class-create macro
Fifth step: Create a device file using the Devices creat function
While uninstalling the LED-driven device files, you need to call device-destory,class-destory, and unregistor-chrder-region (dev__t from, in turn). unsigned count)
We must know the register before controlling the LED on and off: including the LED has two pins, the control led needs to be completed by 3 registers, each register can use 4 characters, low with the Gpmdat register 4-bit to control the light off of 4 LEDs.
The LED driver can control the driver using two methods:1. Control the led via a string
2. control LED via I/o command
The LED driver test method can not only send strings to the LED device files, but also send I/O control commands. These test methods include executable program testing,NDK testing, and Java testing.
LED driver is a real Linux driver that deals with hardware . We need a more comprehensive understanding of the advanced technologies of Linux drivers and learn more about Linux drive technology so that you can skillfully write driver code.
Android Deep Development 7th chapter essay