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/0 memory, which is located in the kernel space. The so-called 1/0 memory is through a variety of interfaces (PCI, USB, Bluetooth, Ethernet port, etc.) connected to the host (PC, mobile phone) hardware (network card, sound card, camera, etc.) in the host memory mapping. 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 1/0 of 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/0 storage and hardware. Every hardware that connects to Linux has a map header address in I/O memory. You need to specify these first addresses when reading I/O memory using functions such as IOREAD32. The LEDs on the Development Board also have their mapping first address. The steps to write the LED driver are as follows: First, create the LED-driven device files: Step one: Initialize the Cdev with the Cdev_init function
Step Two: Specify the device number, and step three: Use the Cdev_add function to add the character device to the character device array in the kernel; the fifth: Create a struct class using the Clascreate macro; Then uninstall the LED driver's device files. Set the register with the initialize LED driver. The LED driver can be controlled in the following two ways: The LED is controlled by a string, and the LED is controlled by a command. After the LED lamp code is written, then the LED light test. You can also use the Java Test LED light driver. After the test is complete, the LED light can be transplanted.
Seventh: LED will blink for me: Control Light Emitting diode