The LED will blink for me: control Light Emitting diodes

Source: Internet
Author: User

This chapter completes a real Linux Drive. The Linux driver is used to control 4 LED lights on the development version . that is, by sending data to the Linux driver, you can control The switch of the LED light. In order to address this driver conveniently, this book and later chapters refer to it as the LED driver.

The realization principle of LED driver is introduced. the Linux driver does not write data directly to the memory in the hardware, but interacts with the native I/O memory,and theLinux kernel provides multiple I/O memory interaction functions, each connection Linux of hardware in I/O in memory there will be the first address of the map, on the Development Board LED the first address of the map is also available.

AlthoughLEDThe driver is not complicated, it just controls the4aLED, "butLEDthe driver has includedLinuxdrive all the necessary parts of a completeLinuxThe driver is mainly composed of internal processing and the part of the hardware interaction drop. The internal processing mainly refers toLinuxdrive loading, unloading, and device file-related action processing (reading and writing device files, sending to device filesΝocommands, etc.) and business logic. Interaction with the hardware is mainly defined byiowrite32,. Ioread32such functions interact with the registers in the hardware. -linuxThe porting of the drives on different platforms is also handled in these two parts. If the differentLinthe transplant between the muscle nucleus versions is primarily1section (Linuxinternal processing of the drive, GeneralLinuxwhen the kernel version differs significantly,LinuFork'of the kernelAPlif the porting on a different hardware platform is primarily a migration2section.

Write a generic program that tests I/O control commands, interacting with device files: writing string data directly and I/O control commands. Writing data directly to a device file can be done either by using the command line or by the Write function, but the I/O command can only be done through the ioctl Issued.

A complete linux Driver is composed of internal processing and hardware interaction, in which the internal processing mainly refers to the linux driver loading, unloading, Device file-related action processing and business logic, and hardware interaction primarily refers to data interaction through functions and registers in the hardware

The LED will blink for me: control Light Emitting diodes

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.