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