The realization principle of LED drive
Writing LED drivers:
Before the test led driver needs to connect the development Board with the USB cable, then turn on the power, after the successful boot, execute the build.sh script file compile and install the LED driver, the smooth will automatically connect
If more than one device file is to be used later, the pointer variable cdev.list.prev and the Cdev.list.next pointer variable are concatenated to form a two-way link.
When creating a device file, be aware that:
Device_count indicates the number of device files created
The 2nd parameter of the Alloc_chrdv_region function represents the assigned starting device number.
Uninstalling Linux-powered device files requires calling the Device_destory, Class_destory, and Unregister_chrdev_region methods in turn
ARM control LED has three registers, three registers in memory has the virtual address, writes the data to these addresses, the processor uses the algorithm to map the virtual address to the physical address, and writes the data to the corresponding hardware port according to the physical address.
Drives the device files.
There are two ways of controlling LEDs:
Controlling Led->file_operation.write with strings
Controlling Led->file_operation.ioctl with I/O commands
Module parameters for LED driver
The Moule_param_array (NAME,TYPE,NUMP,PERM) macro defines the module parameters as specified by the Linux driver in the form of an array. Name represents the parameter name, type represents the data type of the array element, Nump represents a pointer to the variable that stores the length of the array, and perm represents the access permission for the parameter file.
Write a generic program that tests I/O control commands, interacting with device files: writing string data directly and I/O control commands. Writing data directly to a device file can be done using the command line, or through the write function, but the I/O command can only be emitted through the IOCTL.
A complete Linux driver is mainly composed of internal processing and hardware interaction, in which internal processing mainly refers to the Linux driver loading, unloading, device file-related action processing and business logic, and hardware interaction is mainly referred to through the function and hardware registers for data interaction
Android system porting and Driver development--seventh chapter--led Drive