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
static struct s3c24xx_led_platdata smdk_pdata_led1/*smdk_pdata_led4*/ = {
.gpio = S3C2410_GPB(5),//S3C2410_GPF(4),
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
.name = "led1",//"led4",
.def_trigger = "heartbeat",//"timer",
};
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:
static struct platform_device __initdata *smdk_devs[] = {
&s3c_device_nand,
&smdk_led1,
//&smdk_led5,
//&smdk_led6,
//&smdk_led7,
};
Finally, modify the smdk_machine_init function as follows:
void __init smdk_machine_init(void)
{
/* Configure the LEDs (even if we have no LED support)*/
s3c2410_gpio_cfgpin(S3C2410_GPB(5), S3C2410_GPIO_OUTPUT);
//s3c2410_gpio_cfgpin(S3C2410_GPF(4), S3C2410_GPIO_OUTPUT);
//s3c2410_gpio_cfgpin(S3C2410_GPF(5), S3C2410_GPIO_OUTPUT);
//s3c2410_gpio_cfgpin(S3C2410_GPF(6), S3C2410_GPIO_OUTPUT);
//s3c2410_gpio_cfgpin(S3C2410_GPF(7), S3C2410_GPIO_OUTPUT);
s3c2410_gpio_setpin(S3C2410_GPB(5), 1);
//s3c2410_gpio_setpin(S3C2410_GPF(4), 1);
//s3c2410_gpio_setpin(S3C2410_GPF(5), 1);
//s3c2410_gpio_setpin(S3C2410_GPF(6), 1);
//s3c2410_gpio_setpin(S3C2410_GPF(7), 1);
if (machine_is_smdk2443())
smdk_nand_info.twrph0 = 50;
s3c_device_nand.dev.platform_data = &smdk_nand_info;
platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
s3c_pm_init();
}
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
Previous article:S3C2440 Linux driver transplantation - button
Next article:S3C2440 Linux driver transplantation——NAND driver
Recommended ReadingLatest update time:2024-11-16 12:24
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Apply for ufun learning board, introductory & deep learning simulation, engineering skills
- I downloaded a source code from the Internet. Please help me find out what IDE this project was developed in. Thanks
- X-NUCLEO-IKS01A3 MakeCode Driver (Extension) Collection
- This strange circuit
- EEWORLD University ---- test
- What is ModBus? What are the differences and connections with RS485 protocol?
- Is this speed too fast? I have never experienced it properly.
- Application Differences between HT8691 and HT8691R
- Welcome the new moderator of the "201420208012" eSports
- What is the difference between a servo motor and a brushless DC motor?