7th Chapter LED will blink for me: Control the Light emitting diode

Source: Internet
Author: User

The so-called I/O memory is a mapping of the host's memory through various interfaces connected to the host's hardware. The LED driver also provides two ways of interacting: command and read-write device files.

Steps to create a device file:

1th Step: Initialize the Cdev with the Cdev_init function

2nd step: Specify the device number

The device number of the Linux device file is the primary device number and the secondary device number, where the first 12 bits represent the main device number, and the last 20 bits represent the secondary device number. There are two ways to specify the device number:

(1) Specify (hard-coded) directly in the code.

(2) Dynamic allocation.

3rd Step: Use the Cdev_add function to add the character device to the character device array in the kernel

4th step: Create a struct class using the Class_create macro

5th step: Create a device file using the Device_create function

LED drivers can use the following two ways to control LEDs:

(1) control led via string

(2) control led via I/o command

A complete Linux driver consists of two parts: internal processing and hardware interaction. The internal processing mainly refers to the Linux driver loading, unloading, and device file-related action processing (read and write device files, send I/O commands to the device file), as well as business logic. The interaction with hardware mainly refers to the data interaction with the hardware register through IOWRITE32,IOREAD32 and other functions. The porting of Linux drivers on different platforms is also handled in these two parts. Porting between different Linux kernel versions is primarily the first part of porting, which is the internal processing of Linux drivers.

7th Chapter LED will blink for me: Control the Light emitting diode

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.