For most Linux drivers, the need to interact directly with the hardware, this chapter focuses on the use of Linux drivers to control the light and dark of the diode, that is, the Linux drive to send data control on the Development board LED lights switch.
The first section introduces the realization principle of LED driver. The Linux driver does not write data directly to the memory in the hardware, but interacts with the native I/O memory, the Linux kernel provides multiple functions that interact with I/O memory, each hardware connected to Linux has a map header in I/O memory, and the LED on the Board has its first address.
In the second section, the LED driver is written in the following steps:
(1) Test the Development Board, turn on the power switch
(2) Create the LED drive device file
(3) Uninstalling the LED driver's device files
(4) Set register and initialize led driver
(5) Control LED
(6) Set the module parameters of the LED driver
(7) The complete code for the LED driver is given.
Section III describes the test led driver
(1) General program for writing test I/O control commands
(2) test led driver with NDK
(3) test led driver using Java
The fourth section introduces the porting of LED driver, the simplest porting is to compile it under different Linux kernel versions, while porting driver should pay attention to modify the driver's source code, try not to modify the driver interface.
This chapter is to realize the driver development through the specific control light emitting diode, through the experiment to understand the Android drive The example, understands the Android drive the transplant. Drive transplant is the essence of Android, in the process of learning must be careful to master every detail concept.
Seventh chapter LED will blink for me: Control the Light emitting diode