Android system porting and Driver development--seventh chapter--led Drive

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.