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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* L% k& `4 y5 [8 a0 ]
#include <linux/init.h>8 ^  u* A& h$ ~5 T9 g. z' j
#include <linux/module.h>4 b  M) K: w" b, V( ~: p
#include <linux/kernel.h>
2 d: F6 E  K2 I- \+ }$ _4 r#include <linux/types.h>. u. n! Q! ^$ m, P- I0 h  c5 v
#include <linux/gpio.h>
! t2 F3 m. I: ^3 x* }# b#include <linux/leds.h>
4 A% F( y  M, m8 i2 L, o& h: |#include <linux/platform_device.h>+ h# e' c/ h6 M+ f  G  X$ [6 w- D
# d8 v. i5 u5 h" b, J; Y* |6 h
#include <asm/mach-types.h>6 Y' K1 j% e$ {' Z8 Y- i
#include <asm/mach/arch.h>
/ c$ J' X7 l+ p* y#include <mach/da8xx.h>
5 z( z$ j; V: {: W7 ?" ~#include <mach/mux.h>" C3 I- S+ I8 j
: Q  T& M; n, _+ F3 [
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# ~+ W0 M" m! Q8 e
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
  F/ m9 ^2 h) n, ^/ Z5 |. A#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' ?# D$ n' S$ l#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 K  v, J: S6 J: ]4 p1 V1 F. F
" l* ^. o8 @0 i3 d+ C% i! G4 M
/* assign the tl som board LED-GPIOs*/5 K9 m% q6 e; O( ~. ~1 G* p
static const short da850_evm_tl_user_led_pins[] = {3 X8 \' N* L- u3 m
        /* These pins are definition at <mach/mux.h> file */# X5 K5 i! I6 g' C) t
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) `: s& K" J8 v
        -1
! o+ u8 {$ f, p2 a. e6 w};! }* o/ \. v2 E& R/ d* ~8 B
- F/ Y& r. ~9 X% `# H2 I
static struct gpio_led da850_evm_tl_leds[] = {
* k9 _: I7 Y. {' i3 v        {9 j: r9 L4 z, B( C8 c. z
                .active_low = 0,
" L2 C# _  H2 C% e3 m                .gpio = DA850_USER_LED0,
) D! c- E4 x& B5 [$ v" \& F                .name = "user_led0",2 m4 L! L2 D6 w
                .default_trigger = "default-on",0 i- I  L' y  K
        },0 E" P: d- x' K) R- W
        {6 z9 b/ t/ ~. R- @9 S
                .active_low = 0," p) O$ f& y! @7 C
                .gpio = DA850_USER_LED1,: ?& k$ m6 o* \5 H# S" `
                .name = "user_led1",+ Q" s' W. q$ X3 g
                .default_trigger = "default-on",
) [$ s: L2 {3 f1 P7 P" X9 s! b        },
  I) L0 [: W1 B( U* q; G4 [  s& M4 \        {2 [0 |" q+ ^. j7 n8 {
                .active_low = 0,% |( c& S5 l8 C2 h% B
                .gpio = DA850_USER_LED2,4 [/ a; t2 j+ j  w% ~0 T
                .name = "user_led2",3 H  y# E8 Q$ c: X9 W( Z, E
                .default_trigger = "default-on",6 Q/ i: @! q) E/ ?( S  b. \
        },
* \" G) L# T! G) E        {! J- b6 Y$ C* Q# o$ F7 ^
                .active_low = 0,; t/ U) t2 ^) p0 ]  _8 E
                .gpio = DA850_USER_LED3,
4 Z% Z; N) u% u; J& h                .name = "user_led3",0 m0 g1 F( h0 R
                .default_trigger = "default-on",, d( [. ^& j/ n) ~, K7 x
        },1 I" ~9 f. r; i
};
7 u7 U8 L' k8 c3 K- ]4 U9 e  G% Q4 g, t$ h, ~! ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" s  p( E# \5 m" x! ]        .leds = da850_evm_tl_leds,7 M. j2 ]- \; q
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 L' m: X% K2 K6 c' {4 b  Q2 o};$ E: i- R7 g3 F# z0 W9 u

" R! y9 ~- i- v! i; Cstatic void led_dev_release(struct device *dev)4 M& T: G+ a4 d* j0 \1 u
{
7 _1 Z! j( C! s0 V& R% U* G};
  S: L  b8 }  i9 s9 q
' W% Q5 S2 A: z$ F9 R! u& Cstatic struct platform_device da850_evm_tl_leds_device = {
1 ]: G! V+ E0 Y9 P+ v& Y        .name                = "leds-gpio",0 }9 t: l6 ~) v& ~
        .id                = 1,
7 y) O: Z5 h6 s+ W6 \        .dev = {
% ?8 V* |+ {& g  {. Q7 X3 i" M$ o0 a                .platform_data = &da850_evm_tl_leds_pdata,4 J: h5 T: N9 g' \% K$ ]' w2 v
                .release = led_dev_release,- u+ I/ X' f* l8 }
        }
* m% Q9 s* {" K+ ~7 u};
  U: N& r3 a) m. N, E7 L3 Q3 y  \! \- s$ h5 Y
static int __init led_platform_init(void)9 E" [8 k0 W1 r, {6 O# V4 I  ]
{, e1 e. G0 D4 c# z% F7 k
        int ret;$ G) a: i# M2 a6 Q/ M& k- e* @
#if 0
! `, C5 n# l& F5 A2 k5 W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 P% n  U4 I1 i. X+ z        if (ret)- x) K8 W8 e' s
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 X' P9 q4 l% F- _
                                "%d\n", ret);/ R# @* S0 l, C$ `2 U/ U" ^, ^/ P; {
#endif
3 `4 V; h3 C5 z' w        ret = platform_device_register(&da850_evm_tl_leds_device);) W9 ~  G( N& j! S+ I8 ?# T5 i) U
        if (ret)
: L* W5 {4 C6 t6 b5 d3 a/ J                pr_warning("Could not register som GPIO expander LEDS");
6 T5 ^5 E+ N- @. v' H        else2 f# Z/ X) m1 ^" p
                printk(KERN_INFO "LED register sucessful!\n");6 J+ f9 X: p2 [' N! w  J

& Q' C) S' C$ q1 S2 m" b8 O        return ret;6 t; k' _  d+ b* ~  a: |
}" G/ R& ]2 N( x. z" m

! ~1 V- B1 R" K5 \static void __exit led_platform_exit(void)4 B9 @. |+ V- j+ P  K
{
5 G0 t3 Q$ n) s0 x* B! o        platform_device_unregister(&da850_evm_tl_leds_device);
; A8 t* V! w9 t+ v7 M5 M9 V' V
& k" O$ K& n' _  a% d$ X! `/ n) g        printk(KERN_INFO "LED unregister!\n");
; g+ F$ [0 R6 N& f}
8 n" u- G- R6 o0 m" g) w' N; H. }* S$ g$ N$ u
module_init(led_platform_init);
' ^/ h: A; W" \module_exit(led_platform_exit);
, }6 z! }! s9 [2 @7 y+ Q
5 ~2 R9 y( n/ R6 b% a7 ^MODULE_DESCRIPTION("Led platform driver");& w, s% K" T  s# g$ ?
MODULE_AUTHOR("Tronlong");$ P  K6 r4 z! o( l! z
MODULE_LICENSE("GPL");+ X8 |# Z$ O4 T+ l' N8 ~3 @6 _4 `
6 O" a% t  W9 \+ ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-23 04:50 , Processed in 0.042115 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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