Seventh chapter LED will blink for me: Control the Light emitting diode

Source: Internet
Author: User

Seventh chapter LED will blink for me: Control the Light emitting diode

The seventh chapter shows how to develop a complete, true Linux driver that can be controlled by sending data to the Linux driver to control the LED light switch.

The realization principle of the first section led drive

Instead of writing data directly to the memory in the hardware, the Linux driver interacts with the native I/O memory. I/O memory is mapped through various interfaces to the host and hardware in host memory. The memory management module of the Linux kernel is responsible for synchronizing the data in I/O memory and hardware. Every hardware that connects to Linux has a mapped address in I/O memory. The LEDs on the Development Board also have their first address mapped.

The second section writes the LED driver interaction mode: command and read-write device files

Experience the magic of LED drivers

The LED driver is provided in the form of a dynamic drive module (. ko file).

Creating LED-driven device files

Initialize Cdev with the Cdev_init function

Specify the device number

Use the Cdev_add function to add a character device to the character device array in the kernel.

Create a struct class using the Class_create macro

Create a device file using the Device_creat function

Uninstalling LED-driven device files

Set register and initialize led driver

Control LED

Module parameters for LED driver

Complete code for LED drivers

Section III test LED driver

General program for writing test I/O control commands

Test led driver with NDK

Test LED driver using Java

Fourth section led drive porting

The simplest way to migrate Linux drivers is to compile them under different Linux kernel versions.

If you need to migrate to another Linux kernel, you only need to modify the driver code so that you can run it directly on the target board without modifying the test program.

Porting Linux drivers as much as possible without modifying the Linux-driven interface, all calls to Linux-powered programs do not need to be modified and will not be unnecessarily troublesome.

Seventh 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.