Seventh chapter LED will blink for me: Control the Light emitting diode
The seventh chapter shows how to develop a complete, true Linux driver that can be controlled by sending data to the Linux driver to control the LED light switch.
The realization principle of the first section led drive
Instead of writing data directly to the memory in the hardware, the Linux driver interacts with the native I/O memory. I/O memory is mapped through various interfaces to the host and hardware in host memory. The memory management module of the Linux kernel is responsible for synchronizing the data in I/O memory and hardware. Every hardware that connects to Linux has a mapped address in I/O memory. The LEDs on the Development Board also have their first address mapped.
The second section writes the LED driver interaction mode: command and read-write device files
Experience the magic of LED drivers
The LED driver is provided in the form of a dynamic drive module (. ko file).
Creating LED-driven device files
Initialize Cdev with the Cdev_init function
Specify the device number
Use the Cdev_add function to add a character device to the character device array in the kernel.
Create a struct class using the Class_create macro
Create a device file using the Device_creat function
Uninstalling LED-driven device files
Set register and initialize led driver
Control LED
Module parameters for LED driver
Complete code for LED drivers
Section III test LED driver
General program for writing test I/O control commands
Test led driver with NDK
Test LED driver using Java
Fourth section led drive porting
The simplest way to migrate Linux drivers is to compile them under different Linux kernel versions.
If you need to migrate to another Linux kernel, you only need to modify the driver code so that you can run it directly on the target board without modifying the test program.
Porting Linux drivers as much as possible without modifying the Linux-driven interface, all calls to Linux-powered programs do not need to be modified and will not be unnecessarily troublesome.
Seventh chapter LED will blink for me: Control the Light emitting diode