LED Drive Implementation Experience
The realization principle of LED drive
Although the Linux driver deals directly with hardware, it is not the Linux driver that writes data directly to the memory in the hardware, but interacts with the native I/O memory. The so-called I/O memory is mapped in host memory through various interfaces (PCI USB Bluetooth Ethernet ports) that are connected to the host (PC phone) hardware (NIC sound camera). For example, a driver running on Ubuntu Linux only needs to access I/O memory in a host running Ubuntu Linux, and then the Linux kernel interacts with the data hardware in I/O memory. The Linux kernel provides several functions that interact with I/O memory, such as Ioread16, Ioread32, Iowrite16, Iowrite32, and so on. 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 map header address in I/O memory. These first addresses need to be specified when reading and writing I/O memory using functions such as IOREAD16, IOREAD32, and the LEDs on the board have their first address.
The principle of this example:, Led1-led2 respectively with Gpc0_3, Gpc0_4 connected, through the gpc0_3, Gpc0_4 pin high and low voltage to control the continuity of the transistor, so as to control the LED light off.
According to the characteristics of the transistor, when the pin output high, the collector and the emitter conduction, the light emitting diode light, on the contrary, the LED off;
Control the LEDs for Gpc0_3 and gpc0_4 by controlling Gpc0con and Gpc0dat.
Set up working directory, copy source code
$ mkdir Worker/driver
$ cd/workdir/driver/
$ cp/mnt/hgfs/share/linux-3.2-fs210-v3.tar.bz2./
$ cp/mnt/hgfs/share/linux3.2drivers/./A
Extracting kernel code
$ tar xvf linux-3.2-fs210-v3.tar.bz2
Compile kernel source code
$ cd/workdir/driver/linux-3.2-fs210-v3
$ cp fs210_defconfig. config
$ make Zimage
Compiling driver Source code
$ cd/workdir/driver/linux-3.2drivers/fs210_led
Modify the Makefile file, modify the path to our kernel source code and cross the tool chain. Save exit.
$ make
View the build-generated KO file and copy it to the NFS file system directory.
$ ls
$ CP fs210_led.ko/source/rootfs/
Execute the Make led_test command to compile the test file.
$ make Led_test
Execute code:
Launch the Development Board to view file system files
$ ls
Load Driver
$ insmod Fs210_led.ko
$ mknod/dev/led C 250 0
$ chmod 777/dev/led
$./led_test
Experimental phenomena
Led1 interval flashes.
http://www.cnblogs.com/cherry-blossom/
LED Drive Implementation Experience