First, the realization principle of LED drive
Linux driver and hardware interaction principle: Linux Drive and I/O memory through the IOREAD30 and IOWRITE32 functions, I/O memory and hardware, memory management module is responsible for synchronizing I/O memory and hardware in Germany data.
Second, write led driver
Where 1 means open, 0 indicates off. When the string length is less than 4, it is equivalent to 0 of the following
1. Create LED-driven device files
(1) Initialize the Cdev with the Cdev_init function
(2) Specify the device number
The device number of the Linux device file is the primary device number and the secondary device number, the first 12-bit main device number, and the last 20 bits represent the secondary device number.
Device number Designation Method: Specify (hard code) directly in the code, dynamically assign
Multiple Linux device files can have the same main device number. However, the main device number and the secondary device number of the two devices will not be the same.
(3) using the Cdev_add function to add a character device to the kernel in the German character device array
(4) Create a struct class using the Class_create macro
(5) Create a device file using the Device_create function
2. Uninstalling the LED-driven device files
Call three methods in turn:
Void Device_destroy (struct class *class,dev_t devt)
Void Class_destroy (struct class *cls)
Void unregister_chrdev_region (dev_t from,unsigned count)
3. Setting the register and initializing the LED driver
4. Control LED
(1) control led via string
(2) control led via I/o command
Module parameters for 5.LED drives
If you have more than one module parameter in your Linux driver, you need to enclose these parameters in single or double quotation marks.
Third, Test led driver
1. General procedures for writing test I/O control commands
2. Test led driver with NDK
3. Test LED driver using Java
Four, LED-driven transplant
The seventh chapter led will blink for me: control luminous Two-tube reading notes