Android system transplantation and driver development-Chapter 7-LED driver and android driver development

Source: Internet
Author: User

Android system transplantation and driver development-Chapter 7-LED driver and android driver development

Implementation principle of LED Driver

 

Write LED driver:

Before testing the LED driver, you need to use a USB data cable to connect to the development board, and then turn on the power. After the startup is successful, execute the build. sh script file to compile and install the LED driver. The connection will automatically be successful.

If multiple device files will be used later, connect them using the pointer variable cdev. list. prev and cdev. list. next to form a two-way link.

Note the following when creating a device file:

Device_count indicates the number of created device files.

The first parameter in the Alloc_chrdv_region function indicates the allocated start device number.

To uninstall the device files of the Linux driver, you must call the device_destory, class_destory, and unregister_chrdev_region methods in sequence.

ARM controls three registers for LEDs. The three registers have virtual addresses in the memory. After data is written to these addresses, the processor uses algorithms to map virtual addresses to physical addresses, write Data to the corresponding hardware port based on the physical address.

The device file of the driver.

There are two ways to control LEDs:

Use a string to control LED-> file_operation.write

Use the I/O command to control LED-> file_operation.ioctl

LED driver module Parameters

The Moule_param_array (name, type, nump, perm) macro is defined as a module parameter in the array format specified by the LINUX driver. Name indicates the parameter Name, type indicates the Data type of the array element, nump indicates the pointer to the variable storing the array length, and perm indicates the access permission of the parameter file.

 

Write a general program to test the I/O control command and interact with the device file: directly write string data and I/O control commands. Writing data directly to the device file can be done through the command line or the write function, but the I/O command can only be sent through ioctl.

A complete Linux driver consists of two parts: internal processing and hardware interaction, internal processing mainly refers to the loading and uninstallation of Linux drivers, action processing related to device files, business logic, and interaction with hardware. It mainly refers to data interaction between functions and registers in hardware.

Related Article

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.