程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。/ G8 Z7 H9 t) T1 p1 I9 h
#include <linux/init.h>
% d: Q! P4 m* e% r/ i#include <linux/module.h>
) `% M' o! c: o2 n; R# {. J& M#include <linux/kernel.h>$ ?) N) O$ \/ S& Z5 u$ c' k
#include <linux/types.h>$ t+ W, g4 f5 }
#include <linux/gpio.h>
. B) i6 h3 {3 ]9 u/ W0 g! H#include <linux/leds.h>4 [$ I9 p4 W3 G; U/ S- T
#include <linux/platform_device.h>
+ s# I* i% |) g$ L- T; y" d, @1 q4 P2 Y9 r& [- p' T+ B0 ?
#include <asm/mach-types.h>  |- Z' M" O) |6 d; Z' w! L, i
#include <asm/mach/arch.h>$ f8 w4 e3 ]: a$ V
#include <mach/da8xx.h>/ I; m! y; I' D' x& C
#include <mach/mux.h>
% T4 j9 G' S1 N& }8 p: G; ?2 T
" e4 C8 O, c6 [2 X0 O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ _7 x2 B7 B! I3 s4 Q/ p; ?#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 B4 ^. r7 U0 u+ a2 `1 K
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- ^! F+ v* G; B5 t7 U- g#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): i4 \$ V5 D" ?6 r8 @6 z
) C0 B  a5 P# A3 L
/* assign the tl som board LED-GPIOs*/. \$ P/ G) a- _) w2 g# s
static const short da850_evm_tl_user_led_pins[] = {0 I9 q) Q/ C$ ~4 ?# r) ]
        /* These pins are definition at <mach/mux.h> file */
5 C* W+ H! u; F* O& D- u        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 J$ Q5 P3 \5 k$ z# z        -14 S. ?) }5 e  A
};( S8 \: d# a" q: \: h
3 p8 V* f( ?) z- I0 e' B8 D+ p
static struct gpio_led da850_evm_tl_leds[] = {( c; R0 M- P8 s7 m' @, R( C
        {. ~* z  ]! b! D8 I
                .active_low = 0,
) Y# z9 o  y4 c- ?3 W# o                .gpio = DA850_USER_LED0,* O/ z/ D) Z* l
                .name = "user_led0",
7 U0 l- ~, I; }                .default_trigger = "default-on",
( M5 ^: }- w# C8 d' O" R3 f" v        },4 V: j3 Y& N# [% _
        {
& u" K2 y' o- W! G$ ?/ I- H                .active_low = 0,. E: M2 W' \/ O0 w; L
                .gpio = DA850_USER_LED1,
0 `( Y3 G+ _/ Q4 t+ C) `, S                .name = "user_led1",+ _8 c4 S. Q6 y( u7 N" p) m
                .default_trigger = "default-on",; I. D* }6 ~4 f# F+ |( c
        },6 [& d6 U$ ]$ E8 l3 j
        {
5 e" x5 I* q# e' H2 x$ r5 |9 u                .active_low = 0,# L0 x1 D" q* z# \
                .gpio = DA850_USER_LED2,
& K: n; W  f/ I$ K# i, l                .name = "user_led2",
5 ^& C: [1 c9 n3 n                .default_trigger = "default-on",
2 j" g3 B* ?  a8 _) E! Q7 q8 r        },. P- F% s  q2 M/ w, Q
        {" B1 S5 d7 B1 Q) G: L
                .active_low = 0,. K; Y) s7 T) e! l9 P& a
                .gpio = DA850_USER_LED3,
) d6 V+ q+ T$ S5 t) s% C1 G+ V                .name = "user_led3",
9 d1 g+ _* W7 b; ~- Z5 n                .default_trigger = "default-on",
) v, R# K$ k  R  f6 A8 i        },
" l0 A+ b& k/ O  ?$ f. }' H1 W  z};- q3 `8 b8 u) p  ~9 E  M

1 E1 H5 G) c4 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! C( B9 ~/ S2 d% o, i1 C! B- {
        .leds = da850_evm_tl_leds,
1 ?& e( {# d9 M: }' O4 H0 @        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ C. F: V+ `2 a! X3 @  q1 J
};% [  ~6 ~2 G+ t4 \

  E' U/ s+ u1 g; ]$ C$ z& ^$ Y& [static void led_dev_release(struct device *dev)7 n7 \6 s9 [; x+ R
{
3 T: l) w8 Z* y; }' B};
: U  w- M5 Y6 g
  \0 r" Y: u- qstatic struct platform_device da850_evm_tl_leds_device = {& z! F0 B  i  P/ @- i
        .name                = "leds-gpio",
2 [6 O" y: M* y; B" d/ O+ `        .id                = 1,
) G+ @  R2 e- K5 k! k) X" Z1 x! L        .dev = {0 X  E1 c% r7 w, o. U3 G. \' K
                .platform_data = &da850_evm_tl_leds_pdata,
# b9 M* m4 J( c2 h3 _  U                .release = led_dev_release,: h' T% A! e) [1 ^+ Y( \7 }! x
        }
6 M/ t! F. `9 X+ c( n9 M};" D" [2 e! O; A! H+ H* c
0 _. o$ n* p* e
static int __init led_platform_init(void)
: c3 V. r8 @8 W/ p# g{3 _0 D; A6 }% Y$ s0 S
        int ret;
. f. e0 z; f% h( ~' {% |#if 07 B7 l1 ~  r6 j2 M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 F0 V2 ~2 `6 C7 I! W5 s4 |1 F
        if (ret)7 L( ]! p. N4 J8 ]  \/ L
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 h; d/ {1 m9 ^% {+ K; q2 \                                "%d\n", ret);4 F( w8 H1 E" o5 F. @; y  I: g
#endif$ R4 w# W2 K; m* M
        ret = platform_device_register(&da850_evm_tl_leds_device);) N' |2 |5 q! D9 D  S0 q
        if (ret)8 L. z- Z4 l; Q( s* R, ?
                pr_warning("Could not register som GPIO expander LEDS");2 W. a7 c# Y8 m  p" d+ _
        else) p, Q! \" B4 w4 T7 k
                printk(KERN_INFO "LED register sucessful!\n");
4 M8 e4 C! G1 T
4 R3 A$ s, \3 o( u* n        return ret;6 K0 @2 {. A+ o7 d7 \* J2 B
}+ N% C# Q, G) V0 v. }& }: V  ?9 @3 T: T

4 d( O- W* ~* Q( x& J4 E( Cstatic void __exit led_platform_exit(void)
. i1 S  W6 u  Q7 E* X$ U% V+ g{
7 b/ n: j; p6 s& u$ r2 v. i        platform_device_unregister(&da850_evm_tl_leds_device);" E  C! [, U$ k/ w3 m* D% V
/ y* C8 W' w& ^4 {7 X( }
        printk(KERN_INFO "LED unregister!\n");" p; H. H+ N2 G7 M# ]6 n
}
- ?4 U( |/ d8 y0 v7 ^' v6 K4 ?  J/ z6 z7 R
module_init(led_platform_init);
! M5 ~: r7 \+ N2 Z# z  w) nmodule_exit(led_platform_exit);& H  ^$ `. m$ o! j) j: h! D

' X# d, K, Y0 a( H' d0 Y) ?4 MMODULE_DESCRIPTION("Led platform driver");
" D+ J1 k: c, G1 B! I$ |MODULE_AUTHOR("Tronlong");
2 G( z; _# g9 ]/ Z% ?MODULE_LICENSE("GPL");1 M1 f+ N8 W; Z8 P& z

& k' ^( c5 X$ f% x2 _3 [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-2-15 13:59 , Processed in 0.038614 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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