S3C2440 Linux driver transplantation——LED heartbeat

Publisher:神雕Latest update time:2017-09-23 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Development board: TQ2440

Kernel: Linux 2.6.32

PC OS:Ubuntu 11.04


    This article will explain the transplantation of LED drivers. The LED in this article is used to realize heartbeat, that is, after the system is started, the LED will flash at a fixed frequency like a human heart.

Unless the system freezes, the LED will not stop flashing.

1. Configure the kernel, as shown below


2. Modify the code


The TQ2440 development board provides 4 LEDs for user control. This article uses one of the LEDs to implement the heartbeat function.

This LED is connected to GPB5 pin.

Open the file arch/arm/plat-s3c24xx/common-smdk.c

Modify smdk_pdata_led4 to


  1. static struct s3c24xx_led_platdata smdk_pdata_led1/*smdk_pdata_led4*/ = {  

  2.     .gpio        = S3C2410_GPB(5),//S3C2410_GPF(4),  

  3.     .flags        = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,  

  4.     .name        = "led1",//"led4",  

  5.     .def_trigger    = "heartbeat",//"timer",  

  6. };  

Since this is the first LED on the board, change the name to LED1.


Renamed the smdk_led4 structure to smdk_led1.


Modify the smdk_devs array as follows:


  1. static struct platform_device __initdata *smdk_devs[] = {  

  2.     &s3c_device_nand,  

  3.     &smdk_led1,  

  4.     //&smdk_led5,  

  5.     //&smdk_led6,  

  6.     //&smdk_led7,  

  7. };  



Finally, modify the smdk_machine_init function as follows:


  1. void __init smdk_machine_init(void)  

  2. {  

  3.     /* Configure the LEDs (even if we have no LED support)*/  

  4.   

  5.     s3c2410_gpio_cfgpin(S3C2410_GPB(5), S3C2410_GPIO_OUTPUT);  

  6.     //s3c2410_gpio_cfgpin(S3C2410_GPF(4), S3C2410_GPIO_OUTPUT);  

  7.     //s3c2410_gpio_cfgpin(S3C2410_GPF(5), S3C2410_GPIO_OUTPUT);  

  8.     //s3c2410_gpio_cfgpin(S3C2410_GPF(6), S3C2410_GPIO_OUTPUT);  

  9.     //s3c2410_gpio_cfgpin(S3C2410_GPF(7), S3C2410_GPIO_OUTPUT);  

  10.     s3c2410_gpio_setpin(S3C2410_GPB(5), 1);  

  11.     //s3c2410_gpio_setpin(S3C2410_GPF(4), 1);  

  12.     //s3c2410_gpio_setpin(S3C2410_GPF(5), 1);  

  13.     //s3c2410_gpio_setpin(S3C2410_GPF(6), 1);  

  14.     //s3c2410_gpio_setpin(S3C2410_GPF(7), 1);  

  15.   

  16.     if (machine_is_smdk2443())  

  17.         smdk_nand_info.twrph0 = 50;  

  18.   

  19.     s3c_device_nand.dev.platform_data = &smdk_nand_info;  

  20.   

  21.     platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));  

  22.   

  23.     s3c_pm_init();  

  24. }  



3. Verification

Compile the kernel, burn it, and run it.

After the system starts, the LED starts flashing and can be seen in the sys file system as follows:

[root@yj423 leds]#pwd
/sys/class/leds
[root@yj423 leds]#ls
led1


Keywords:S3C2440 Reference address:S3C2440 Linux driver transplantation——LED heartbeat

Previous article:S3C2440 Linux driver transplantation - button
Next article:S3C2440 Linux driver transplantation——NAND driver

Recommended ReadingLatest update time:2024-11-16 12:24

Linux driver learning (2) - beep driver
// 0 sets the value in down_counter (beeping frequency) //------------------------------------------------------------- static int xiaoyang_beep_ioctl(struct inode *inode,        struct file *file,        unsigned int cmd,unsigned long arg) { unsigned long temp; if(cmd = 0) { //set
[Microcontroller]
Linux driver learning (2) - beep driver
S3C2440 Input/Output Ports
Port control description (see S3C2440 data sheet for details) Port Configuration Registers (GPACON to GPJCON) Port Data Registers (GPADAT to GPJDAT) Port pull-up registers (GPBUP to GPJUP) Miscellaneous Control Registers External interrupt control register   Use an example (LED running light) to learn
[Microcontroller]
S3C2440 Input/Output Ports
Using variable duty cycle to achieve dimming of LED driver circuit
  Pulse Width Modulation (PWM), short for "Pulse Width Modulation", is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in many fields from measurement, communication to power control and conversion.   PWM rectifier is a new type of power conver
[Power Management]
Using variable duty cycle to achieve dimming of LED driver circuit
Parameter passing rules for lighting an LED
1 Description Experimental platform: JZ2440 CPU: S3C2440 2 ARM-THUMB Procedure Call Standard (ATPCS: ARM-Thumb Procedure Call Standard) Figure 1 Usage rules and names of registers in ATPCS 2.1 Data stack structure The stack structure we use is of FD (Full Descendin
[Microcontroller]
Parameter passing rules for lighting an LED
How to deal with LED downlight failure caused by cold soldering?
  Under the same lighting effects and conditions, LED downlights are more than 80% more energy-efficient than traditional light sources, and their lifespan is more than 10 times longer than traditional lamps. They also have the characteristics of high light efficiency, easy regulation, and wide range of applicatio
[Power Management]
Linux kernel transplantation based on S3C2440 and yaffs2 file system production--compile kernel
1.3.4. Compile the kernel To compile the kernel, follow these steps: 1、make dep The meaning of make dep is: if you use program A (for example, to support special devices), and A needs to use B (for example, B is a module/subroutine of A). When you make config, you change the driver of a device from kernel support t
[Microcontroller]
Do you know the "four musts" for using studio LED screens?
 Not long ago, there was a report that Leyard assisted Zhejiang Satellite TV in building the first all- LED background news studio. This trend also shows that LED screens are becoming more and more popular in TV studios. However, the TV picture effects vary greatly during the use of LED screens. Some have bright col
[Power Management]
The secret of hybrid light source: LED application in projectors
  When talking about new light source projectors, we have to mention the hybrid light source projectors that have emerged in the past year. As the last new light source projector technology among the three major light sources of LED , laser and hybrid light sources to appear in the user's field of vision, it has sur
[Power Management]
The secret of hybrid light source: LED application in projectors
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号