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.
First, we need to understand the principle of LED driver implementation. 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.
Then start writing LED drivers:
1. Test the Development Board, turn on the power switch
2. Create the LED drive device file
3. Uninstalling the LED-driven device files
4. Setting the register and initializing the LED driver
5. Control LED
6. Set the module parameters of the LED driver
This chapter gives the complete code of LED driver can be used for reference
The final test led driver, this chapter describes a number of complex testing methods, not only can send strings to the LED device files, but also send I/O control commands.
1. General procedures for writing test I/O control commands
2. Test led driver with NDK
3. Test LED driver using Java
In addition to LED-driven porting, the simplest porting is to compile it under different Linux kernel versions, while porting drivers should be careful to modify the driver's source code as much as possible without modifying the driver's interface.
Although the LED drivers are not complicated, we have to be aware that different Linux kernel versions and less hardware platform-driven porting can help us understand Linux technology in depth.
Control Light Emitting Diodes