程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 6812|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。3 g- \; R, y5 ?  W, a- D& d
#include <linux/init.h>
" I8 z# r3 i5 k" c#include <linux/module.h>
+ N9 |! G5 T# J* A5 Q#include <linux/kernel.h>
2 \8 S/ T* S" d% f; R. r: S#include <linux/types.h>
" P1 u6 c3 `! B# g* ?8 u#include <linux/gpio.h>$ W; W5 f# r' H; a
#include <linux/leds.h>% a" x: u3 N& C; `8 F
#include <linux/platform_device.h>
: C# T1 S" A8 I& W4 t% o4 A2 [! V3 s( U2 B2 }( \0 W$ _
#include <asm/mach-types.h>
1 R) ?' D6 e7 ]7 u( Y9 m#include <asm/mach/arch.h>" A  b& O& i+ F# V8 d' f
#include <mach/da8xx.h>$ B+ p+ Q0 m3 ]$ Q" b+ m
#include <mach/mux.h>
* @) Y; j" H9 j- l
) S5 T+ V& t* n/ `% C  V2 S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)& o  @6 k1 {: @* P, w0 U( u
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! M5 w) @9 |3 m
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" e% [6 ^' ~2 T( I; X1 u. V
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# F0 P1 e3 r" N3 A) A! R9 z
1 z6 P& @" ~3 |0 E0 B/* assign the tl som board LED-GPIOs*/
1 y8 ^' R- S$ H, T3 \; A5 Xstatic const short da850_evm_tl_user_led_pins[] = {
# ]5 J3 f, ^7 T% l        /* These pins are definition at <mach/mux.h> file */' Y0 `: R- @7 z0 C2 {+ s
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 R' F' _9 L/ P        -1* P6 p5 p1 L) A
};- [- e! ~& t" i- u; S

1 j3 ?8 V; M) d0 m4 ~8 l# ?static struct gpio_led da850_evm_tl_leds[] = {
# P3 U4 |( E/ N4 b, E' H: k- V' u        {* V# n, @/ t( S: G1 o
                .active_low = 0,! @+ w) \1 A* N) g7 w
                .gpio = DA850_USER_LED0,  s8 J: s5 f0 u7 P: h
                .name = "user_led0",# {6 x* c& K: w# b
                .default_trigger = "default-on",
# w" l. F9 o! x( ]  ^/ G- l+ L7 U        },
/ x4 }4 H) E: Y; M        {1 F; D) I3 |9 b! ^- W! Z
                .active_low = 0,, G0 N& z4 a  C2 F( {
                .gpio = DA850_USER_LED1,
& B, X2 q3 }5 r! j. C2 r                .name = "user_led1",7 O. L7 i0 h# L4 C1 t  F0 v) A
                .default_trigger = "default-on",- A8 N3 ~3 w7 T  j
        },
9 [9 i3 [5 T- \# f3 |        {
6 ^( ~) t( ~) w) R# Q                .active_low = 0," ^0 X7 }* z- _. V+ q
                .gpio = DA850_USER_LED2,
* Z, Q; _" b8 U2 L( Z" p5 C                .name = "user_led2"," D( r- \6 U) w
                .default_trigger = "default-on",  t, @0 G5 `+ D
        },
; S( `8 k, r# {7 q8 U7 \        {8 Y* e1 }; _0 ?8 |8 X6 ]8 ^. Z8 d
                .active_low = 0,7 x2 B/ E. X; k. I3 M4 E
                .gpio = DA850_USER_LED3,
/ O5 Q4 I1 ~  H. o. e                .name = "user_led3",
7 k6 r" N6 n/ Y                .default_trigger = "default-on",2 |: ~' d# |' W0 N+ P
        },/ c; s# L: ?6 \. Q$ O
};6 b4 S1 r$ N, `& K  t

. `. G0 p/ o2 V1 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( i( H$ o3 [- E0 T+ S1 \. r# V% b        .leds = da850_evm_tl_leds,
, Q) @* r1 K7 h9 d- O/ i        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ D# ~! p9 i" ^
};' d( Z! k# f7 o' `
. C+ e% S+ ^: S. t& Z( X& N) E9 c
static void led_dev_release(struct device *dev)7 |5 i. t5 J) Z' D
{  U  c% N& t0 M  A' q
};
5 k. \& j6 R2 P7 s0 B1 @" y/ m9 W0 B- X8 o% K. v
static struct platform_device da850_evm_tl_leds_device = {" c! [) h/ \3 |, ]* W4 f
        .name                = "leds-gpio",
, Z' E% C4 o+ d. B& ^) s        .id                = 1,
& D' ?, l7 i( J) k7 c+ i: f        .dev = {' |) F; O+ Z! B" V! ~
                .platform_data = &da850_evm_tl_leds_pdata,
" s. N/ ]4 b% W1 M, a" y" z0 M                .release = led_dev_release,+ I4 w0 @. u! o$ M  y
        }
: v: U/ {: Z2 [5 B% w" z};
4 n; |4 w' d# s; H4 Y0 D4 _
5 b! B# O/ _' B& x3 E, P0 Qstatic int __init led_platform_init(void)
# d) e! }( z! {+ }5 L{7 O  j5 o9 p3 L" H
        int ret;
  k  \( i8 B8 c! c# C#if 0+ ~! h6 m. [3 K- s# k
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! Q  j4 T4 l: @0 d( S9 x8 c8 E        if (ret)
! P$ |% G  ~% N3 i+ L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' `7 k3 r7 @+ V
                                "%d\n", ret);9 v% s1 g: ?1 X3 ~. J
#endif
) T. W" `6 U& b, v  W5 l        ret = platform_device_register(&da850_evm_tl_leds_device);! O! R7 C) s# J/ R* U
        if (ret)
$ E, \5 s+ T% P# u                pr_warning("Could not register som GPIO expander LEDS");+ A* z: k. C  |% R5 [5 R
        else( T# z: s7 {- c) G9 H' o
                printk(KERN_INFO "LED register sucessful!\n");
; h4 E& J. |9 \( R$ J7 u: N& n/ Y% h# o
        return ret;0 W) Q4 U. s  A, {% E8 u, r
}: |/ N% D3 f5 [" F
5 `9 D3 L: v' L  o
static void __exit led_platform_exit(void)
4 B! ~4 K9 i1 {3 d3 x4 }{! t. N) E4 w. k; w* x, W
        platform_device_unregister(&da850_evm_tl_leds_device);7 j9 ~6 T3 _+ R% K5 R, `0 M
9 C* I; l1 P' p) r* K1 P9 n! i
        printk(KERN_INFO "LED unregister!\n");- A1 ?$ Z5 P( q* ?& [1 C( j
}4 s; |8 ?0 P, ^; ]9 x

9 M$ B4 o: k* Lmodule_init(led_platform_init);
( s  V0 ^/ |- g2 O: p6 h( [) Emodule_exit(led_platform_exit);
5 h" O) D1 Z* f: M/ R! ^5 F( r) h5 q$ x
MODULE_DESCRIPTION("Led platform driver");- b1 ?# V) W" |4 g" X% v( e# A% r
MODULE_AUTHOR("Tronlong");
7 c% l4 M/ s" yMODULE_LICENSE("GPL");
( |+ d% p; A$ p4 T* Y1 h: M& A4 `
) A& C4 X  j* X' s( B! v
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-12-2 21:04 , Processed in 0.039543 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表