Writing LED drivers

Source: Internet
Author: User

1, create the LED drive device files:

(1) Initialize the Cdev with the cdev-init function

(2) Specify the device number

There are two ways to assign a device number: Specify it directly in your code (hard-coded)

Dynamic allocation

(3) using the cdev-add function to add a character device to a character device array in the kernel

(4) Create a struct class using the class-creat Macro

(5) Create a device file using the device-create function

2, led Drive in two ways to control the led

Controlling LEDs with strings

LED via I/O command

3, a complete linux driver mainly consists of internal processing and hardware interaction with two parts.

Inux Drive is also the main processing of these two parts in different platforms; porting in different Linux kernel versions mainly deals with the first part (internal processing); porting on different hardware platforms is primarily about dealing with the second part (interacting with the hardware).

Writing LED drivers

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.