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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# t% S2 O' B, ^  |) T#include <linux/init.h>
% M; ^. W; k6 b( [#include <linux/module.h>. ~. p$ H& A: a1 A" B7 Z+ B
#include <linux/kernel.h>
" \6 \4 D8 X: A#include <linux/types.h>
4 [( s, H6 q  Y" L7 e1 c( @* V$ g#include <linux/gpio.h>
- K  V, ~4 w) B# F#include <linux/leds.h>
8 X' Z  {+ }7 `  X#include <linux/platform_device.h>- b  r- v+ B) M8 o
1 u$ X% I: u: m$ _% E, _3 w* i0 h1 l
#include <asm/mach-types.h># Q' l6 I6 }# L1 n* C. X2 D9 @
#include <asm/mach/arch.h>! h, A6 g; F$ G+ k* K
#include <mach/da8xx.h>6 S7 ]) m6 Z5 W" R# X6 [: r
#include <mach/mux.h>' U+ V& q- X6 Z# G: b
9 g; z* A3 |( h9 b' M# x/ |+ e
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, k- j! @/ g& O( H& B/ e9 v#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: a7 b" Q: ?0 P; [#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
) [: w! C- @; B! ?% f$ J  V#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 \; E# W: c# a; `

, M- C$ M. v& c( q' D7 q/* assign the tl som board LED-GPIOs*/# u/ o- r- [; T9 s+ T
static const short da850_evm_tl_user_led_pins[] = {$ m9 `( d6 z* E
        /* These pins are definition at <mach/mux.h> file */
9 ?$ V. D/ ~8 I! w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 }$ O' X1 F" g! C; H1 G" I
        -1
; K) `2 k* v( v& p  Z9 t};, Q" a/ B1 J$ D1 u! Y8 d4 t

1 K' o+ @  \7 U2 s1 [, S8 _3 xstatic struct gpio_led da850_evm_tl_leds[] = {; ^' Y/ f  J2 c# S$ x: h9 C
        {& z- x: @' K9 N- S+ i
                .active_low = 0,  B" P, F' W+ V( w& }
                .gpio = DA850_USER_LED0,
0 {" s% }+ b- g. Q' N. A& b. y                .name = "user_led0",
$ o: h* }& C* \- |7 u                .default_trigger = "default-on",# u, z  l& |. b$ @. p9 ~/ a
        },
2 O: @4 n+ m; z2 [& y        {& i3 k  B8 h3 c. h# c, u
                .active_low = 0,
1 Z! `. i0 w7 V6 a* |7 A& C                .gpio = DA850_USER_LED1,
( m  Y- L+ ~" U2 L+ P6 ^                .name = "user_led1",0 y2 ^' w9 r: J; ]
                .default_trigger = "default-on",
- S+ U: y: F1 t9 L& z        },! P; ~$ m* c% H0 u( b
        {# L! F! m2 N+ ]
                .active_low = 0,
4 N/ W6 p0 s! U# Q2 y                .gpio = DA850_USER_LED2,
; ]: f& D: z( m* W                .name = "user_led2",
! F$ I$ i2 j9 O" @7 M7 N                .default_trigger = "default-on",% q9 A& O; E; z+ z# I+ k" ]9 L* O
        },
  @4 M4 d: ?, h, }' p        {
# V, b2 K$ g( A% f+ v8 a                .active_low = 0,' s! @& u5 y. ^, a# L
                .gpio = DA850_USER_LED3,1 m; B( E4 P0 x8 _
                .name = "user_led3",
; M- }; r# O; x: u4 j- W1 {& r                .default_trigger = "default-on"," U7 l  I9 `- x# N' ]  ^
        },9 a1 B- X+ c# a* y2 n# n
};* L" ]& c9 g" |& [! \
) j  y* G6 M# D" {5 U7 ~/ b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% F7 Y4 U9 [4 V- Q" m        .leds = da850_evm_tl_leds,& l7 F  ^0 ]% D1 R- g( a( j
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ n! P9 a3 A9 a, h  }+ `
};# G( L* A6 i! b+ r

. R+ m* \; E2 R" _- }' ~static void led_dev_release(struct device *dev)
1 Q$ o3 C& w7 N) \, d{+ o% U9 ~2 |: {1 U" V
};( T  E% \: l7 K4 r( J, Z" M& A
6 w6 e6 h  Z+ E" F6 ~2 ~5 I
static struct platform_device da850_evm_tl_leds_device = {# x& N* W  n; S7 i8 J
        .name                = "leds-gpio",2 H3 _. T; j2 j+ ~8 o/ V3 u) w0 v
        .id                = 1,
1 e. f8 L' L* I* k* X        .dev = {
! [5 @; }5 m: J                .platform_data = &da850_evm_tl_leds_pdata,6 n$ N. g( E1 D) Z' R5 l
                .release = led_dev_release,- e( ~' X+ V6 r6 p4 Z$ V- f# T$ s
        }7 e# P9 V+ e3 t2 [4 S
};
; x$ r/ w" ~! n& g5 f4 S) Z
3 G- ^* Y* }. Vstatic int __init led_platform_init(void)4 @, A4 e( @0 E  _8 U, A
{  X% @8 Q2 ]- ?* n- u; A! `
        int ret;
. o) g2 y* ]6 s: S( p1 R8 Q#if 03 y6 U' h# m: W# ^$ t
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 V' ?9 x. e# C0 _+ p        if (ret)
- E8 y& s: F0 R5 H                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") T7 M% Y; J2 c; L2 O# E
                                "%d\n", ret);
1 \6 c) k4 ~& f6 E$ S#endif
/ r$ O+ h. J& B# T2 l        ret = platform_device_register(&da850_evm_tl_leds_device);0 T4 G* ~  O) j& l( `
        if (ret)
) c( V* W7 C6 {% l" m                pr_warning("Could not register som GPIO expander LEDS");
% a3 K( m* s" S* ]! e& d' ~        else7 w6 e3 n: n3 ^+ V5 P
                printk(KERN_INFO "LED register sucessful!\n");
# l, A3 w' v0 }, ?" q/ w
  W; w9 }3 y! ?# f        return ret;$ Q2 N$ ^  V7 C; g3 z! n
}( b! T" ]' T3 o0 H- {
) r6 s" g' G2 \' [5 C
static void __exit led_platform_exit(void)
; J. h: `7 s' l0 g- r{2 [4 G' v$ r7 Z/ P: ]  D0 D- i
        platform_device_unregister(&da850_evm_tl_leds_device);. d5 F# L& _$ i$ `$ S. e
# `. o1 X% @/ i5 t/ x! r
        printk(KERN_INFO "LED unregister!\n");/ Y- V3 \7 M5 b
}7 @- Q! f# i3 {$ j5 u5 H, Y
: f  j! B  n& K
module_init(led_platform_init);
- P% ?. u! t7 `$ T/ a  ^' K# S5 ?module_exit(led_platform_exit);
2 n# B& Q6 s5 D5 \& I, i# M8 l
4 p* N1 X! N9 ]( w$ MMODULE_DESCRIPTION("Led platform driver");, B- j* Z0 ^& I& w
MODULE_AUTHOR("Tronlong");
7 [3 q5 ?/ s6 |, rMODULE_LICENSE("GPL");
) f( V' g$ j0 C) P, b% ]! w3 `0 R8 Q
* `+ f, {. |; a) ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-23 15:12 , Processed in 0.042906 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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