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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; n3 c' E/ B7 X) ?: \, X7 K  P8 i
#include <linux/init.h># f3 e4 P% U# e
#include <linux/module.h>
  b8 C5 c' S& n" a3 e#include <linux/kernel.h>
+ E0 F, g! j! ]1 j#include <linux/types.h>/ f" x; U: U( D/ I+ c3 O3 o- a8 z" \+ ?
#include <linux/gpio.h>8 P2 r( K" \/ M, Z
#include <linux/leds.h>5 i8 v( v, P- e! ]; `
#include <linux/platform_device.h>
9 z3 v& v: x- T9 R
1 j2 I8 Y  @/ j/ N3 W# d5 {) `#include <asm/mach-types.h>
+ |7 y3 }8 Z5 s( g#include <asm/mach/arch.h>' }- n/ d! E0 C6 r
#include <mach/da8xx.h>$ r# L& o4 n9 m4 g( \, A
#include <mach/mux.h>
1 i, t6 l  ?4 H! H  l6 k5 c! B! X6 o: N5 Q9 J( a  A7 g1 ~
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' c. j+ x- M' d/ B1 b#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& r8 ^/ G/ }) {# C" A$ u% ?1 \
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): J; J/ {7 [: D: B
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 M& [* F) _& K2 a! A% A( _

; }" Y) a0 i; j8 c% m; w8 g, E/* assign the tl som board LED-GPIOs*/  m5 q) V1 o0 l, Z* [! M. u
static const short da850_evm_tl_user_led_pins[] = {  q% F7 V$ ]6 Q  [; G
        /* These pins are definition at <mach/mux.h> file */
4 C1 |7 n: T0 G* o( J, g4 |        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 l1 ?- y8 t: X; W9 k
        -1# B8 o7 r; v% D4 {- v& R
};
$ r: A" R9 w7 X3 F6 ^
9 L6 W# V! i# k( W9 e1 K/ \' Tstatic struct gpio_led da850_evm_tl_leds[] = {9 f$ D4 q' S2 s/ c7 [! P
        {( s. |$ ^% |3 v1 _4 V2 r* F" T9 k
                .active_low = 0,
, _7 X& r7 M6 H% `& ?2 x                .gpio = DA850_USER_LED0,5 H9 d! A, G$ c( d  U% j2 g2 i
                .name = "user_led0",- X3 T) B, N; [. ~4 U
                .default_trigger = "default-on",
/ w/ _- p: F) G  C9 m, O        },
# M) S- y- M3 W, ~# z" h  |        {
# o  k: p$ R: U9 W" y9 `                .active_low = 0,
8 _3 V0 ?; m6 J) G, h                .gpio = DA850_USER_LED1,
6 l! f( Q; J' q/ S6 p- o                .name = "user_led1",7 }6 X, h! u) b2 N7 y& Z7 F
                .default_trigger = "default-on",
6 S9 N# E) N2 ~" \9 p2 q1 C        },7 R0 o- C+ X+ G) f; \/ r- f' K
        {* J! B4 K) g/ }5 G9 X
                .active_low = 0,* X8 i" l! M2 q  {  }$ `; [; e0 b
                .gpio = DA850_USER_LED2,
( }3 x; G0 Q% U                .name = "user_led2",3 y: z  m& k6 x+ X1 a
                .default_trigger = "default-on",
. S$ V* B+ l* f# m; y        },: r0 U5 S. U+ z% Y# Q
        {
' e  t  e4 `# ]9 v$ D% S                .active_low = 0,
' A5 }! B% \/ u+ }: D/ S                .gpio = DA850_USER_LED3,
  h* m4 x3 ]/ P* n                .name = "user_led3",
& a1 I5 I0 x2 l                .default_trigger = "default-on",
! l, R& P; z/ h        },
9 M3 L# {( F. R/ a};) Z8 H# L, C7 P6 w

' [1 V& ]" U3 I' gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' m3 Y3 S' B7 B
        .leds = da850_evm_tl_leds,9 @/ h; R0 V6 H' B  W
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 U' C8 z+ |6 D};) r* S; g: I8 m+ E. U9 o* h
" J4 ~8 L, O4 Y, J0 M3 J
static void led_dev_release(struct device *dev)  \, }& `, M& K# l5 ^' z
{6 @7 u( u: L- k: F% p
};
0 G( d6 E2 ?8 N% u' b
1 |7 x% i. [* wstatic struct platform_device da850_evm_tl_leds_device = {+ {  n7 b+ J9 e! T1 s  p5 F8 H; K
        .name                = "leds-gpio",
' Z+ v$ N. R4 g- N! n        .id                = 1,
9 C7 k- i+ r8 S8 S        .dev = {
- m( G- j4 C, P+ c" c4 s                .platform_data = &da850_evm_tl_leds_pdata,& }( e, H0 A2 D7 _
                .release = led_dev_release,
" a+ D* L+ }- s! Z        }& a9 {' B0 T) D7 a/ v+ @
};" a4 i  f. w3 y

; N" Y4 i! @: t4 w, r* j' Jstatic int __init led_platform_init(void)" u8 M7 A; `3 z0 L
{, @0 e1 h  B7 r; u
        int ret;% Z7 |: l" X* j
#if 0
+ p4 N3 M: ^0 q/ T7 ^# {* o( l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 D' n( x2 u( H3 w8 |7 j! S3 g, @' o
        if (ret)9 ~2 ^+ ]) J$ t& b
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& Y9 z, E' D& z3 z5 t1 H$ z2 ]& k
                                "%d\n", ret);
6 A* E* ~* g$ w- y9 \, W/ r#endif
4 s4 q: A/ {, q) j& }        ret = platform_device_register(&da850_evm_tl_leds_device);
( G8 D; ]7 w5 \2 J/ p& s6 a8 @# c( @        if (ret)
0 @7 x  y6 ?  a5 i4 @( [                pr_warning("Could not register som GPIO expander LEDS");* B' Y5 P: a9 @
        else3 d6 u# \: h5 s, _6 f
                printk(KERN_INFO "LED register sucessful!\n");# E% S" X* E! l% C; e% ?
2 E8 B& n! C8 n( J& V- N: ^' r) f
        return ret;3 b( w2 ~' y, c* [# D4 n
}" x: \0 G5 A$ U3 e8 ^
1 @: o* A$ j$ |0 k+ F( \# c# c+ B. ^
static void __exit led_platform_exit(void)
( ?% |, a3 v8 q) j{) }! f! |( p  b, E# `
        platform_device_unregister(&da850_evm_tl_leds_device);
9 _0 K7 }; ?4 ^, v, Z" i; o: F" d! q9 ?
        printk(KERN_INFO "LED unregister!\n");
* {7 i6 t8 ?1 Y}
7 `' j: m  _0 W' C( j0 d2 k
  }; K* j4 l% g* ~! ~& mmodule_init(led_platform_init);9 o/ j: C- D' O1 ~$ x+ J# y) }
module_exit(led_platform_exit);5 q' o( T3 F( U4 }' J( _
( u: x- ^$ {  \
MODULE_DESCRIPTION("Led platform driver");
8 q, A5 D4 M& V  o5 MMODULE_AUTHOR("Tronlong");9 C$ K+ j+ L6 z+ c0 E  W! L
MODULE_LICENSE("GPL");
7 B/ b! x! `& C- B, r0 b5 ~! F# X+ l
# m1 S0 H2 _: {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 05:55 , Processed in 0.037104 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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