18, the implementation of LED driver program

Source: Internet
Author: User

Example of device driver for LED

The order in which the characters are driven is: the first is to build the kernel module frame, then the character driver, and finally write the open and IOCTL functions to implement the LED light control driver.

The first is the LED.C code:

Implementation of Makefile:

Files generated after make:

Next is our application: led_app.c:

Compile the Build Led_app program:

Put two files: A driver file, a executable program copy to the Development Board.

First execute the driver file: Insmod Led.ko, then cat/proc/devices. View the main device number:

The drive device file is then created according to the device-driven main device number:

Then, as above, we run the program, the parameter is 1, the light is full-lit.

Finally run the above command, the lights are all out.

This is a full-drive hardware operation.

18, the implementation of LED driver program

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.