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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. W* o" z9 D" a5 Z. [8 G& A- Q#include <linux/init.h>
) p# p1 u8 h3 ^) I9 X  k#include <linux/module.h>
; d2 Q2 _; q. R2 {  Z#include <linux/kernel.h>
2 n' {+ X7 d, C: U2 u#include <linux/types.h>
" O" A! ?+ v4 L#include <linux/gpio.h>
! ?/ a9 A8 U; C: V#include <linux/leds.h>5 B* a8 U& R  v8 ]$ q7 {
#include <linux/platform_device.h>( G0 c& g/ Z+ h8 K
* p5 g6 I: B9 b
#include <asm/mach-types.h>7 O9 S+ s$ \0 B& A2 U
#include <asm/mach/arch.h>1 |( x! U9 G. l- X+ f  I
#include <mach/da8xx.h>
5 G& n9 p; n6 u% P#include <mach/mux.h>0 H5 B3 P" ~: r9 q+ _- |
( B4 c% ?/ d0 W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ L) H6 B/ N+ c, n4 F
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! E2 B0 c3 d( V#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! m9 x% G* q8 `- ?: p: a* J#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 N3 f; C4 B4 w* L9 R

, p3 K" y; ?2 y/* assign the tl som board LED-GPIOs*/
9 s5 H+ b) P( v5 T; Istatic const short da850_evm_tl_user_led_pins[] = {
) `) r8 n' M, t; @6 I4 c5 C        /* These pins are definition at <mach/mux.h> file */
+ }8 O' Z" S* {- z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- n, z2 H+ ?% m+ A9 ^3 [        -1
0 I5 d$ u5 a4 t# l1 b5 e8 Q7 V};! U" r% m/ m" S) [! T; `2 [

, P$ p) q" F/ H' L* Astatic struct gpio_led da850_evm_tl_leds[] = {
( d4 `6 m& D- ?: M0 ?8 p' L* l        {
- w5 y& Z- D( g' @3 o( B                .active_low = 0,) w: n* F# s+ }( Q- ]. Q2 f9 V
                .gpio = DA850_USER_LED0,+ D5 P3 w/ K7 Q8 z' R" p
                .name = "user_led0",
* w7 e6 w: S# T9 n9 J                .default_trigger = "default-on",
3 L/ s; o' j/ G+ ?( D* }( x" S        },6 N4 H2 [3 ?) F3 R
        {
" c4 p2 T- f) c, ^: ]                .active_low = 0,- b% W# k+ W  {. E! \4 O  Z- B
                .gpio = DA850_USER_LED1,3 R  ]& m9 W) q3 H" z  [
                .name = "user_led1",
7 n2 A' c2 _( N" ~' I0 x                .default_trigger = "default-on",
/ ~3 @! C. o3 k9 V) Y# c        },- x% G- B4 k9 m
        {
: B* _4 L, S) y+ F3 [7 p- U% c3 w( l                .active_low = 0,' A6 x9 ^! g3 ^
                .gpio = DA850_USER_LED2,( Y/ q2 X5 w& Z% l  a8 I
                .name = "user_led2",/ [. P( g( f: N1 A
                .default_trigger = "default-on",
6 ]  S8 Z% l; [  H, L* T& r) c9 r        },2 w+ b7 u  A( G/ g. G
        {: h0 F! Z. c% T9 J5 S3 W/ N
                .active_low = 0,
7 M+ B6 s  p6 R& Q1 T  p4 s% T                .gpio = DA850_USER_LED3,! B* {2 ~8 X7 {1 s
                .name = "user_led3",
( _5 ~- M8 V6 Y- r; t  m/ [$ f                .default_trigger = "default-on",1 w( `4 P. h/ W2 v! n/ g* V
        },
3 N: n% K/ w2 a! y# l};
: c' _* u2 T4 @7 D
5 a1 z5 I7 N! U5 S' n5 Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ U4 y' |3 |; o, K: `
        .leds = da850_evm_tl_leds,
. {5 x9 g( R+ L% p: ^- M  V3 p: r. a        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. k$ l7 R" i2 ~4 |7 \) ~
};- `# X& r4 b  Q7 R
+ i$ q' L3 w* X* U9 F$ g3 k
static void led_dev_release(struct device *dev)
/ [2 ?! U9 P+ P/ Z% t9 J& \{
& [7 \7 Y( O$ S+ S9 ^. o3 {};# r0 m# t; I4 j2 b: h& @
: b6 A% r; A# ~' {# k+ r
static struct platform_device da850_evm_tl_leds_device = {
9 t* _8 f$ c2 V3 D        .name                = "leds-gpio",
8 P( c6 _4 Q! }4 k# I! R" [4 G        .id                = 1,. q8 w" f: l, G( l7 g
        .dev = {7 w7 \) _( b0 c, s3 i/ r
                .platform_data = &da850_evm_tl_leds_pdata,3 E, t8 z7 G. ^. X& f; ~7 M% @
                .release = led_dev_release,& }. ~. H0 g; _2 G7 y
        }) b3 X6 E7 K6 i& s4 G$ S
};4 q% C  B5 S& [2 w9 X8 Z4 ]3 F8 K( ^

7 C& Y% v1 C. v! {4 rstatic int __init led_platform_init(void)
1 J# b& F$ R1 j4 o{( S' \1 T! z* i, @" K: h
        int ret;
9 r3 ?: m/ r0 d: Z#if 0
- g0 u; ]" k6 `* Z' o0 q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 b+ ?0 v# j- i0 ~- Z% }- z- c( Q6 i
        if (ret)
+ e3 F+ b! m3 e3 {) ]! m' G                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: a% ~/ _2 Z! Q% u9 e! k$ n% b8 F                                "%d\n", ret);, P( F' u# z" d0 q: C9 R! U+ }. u
#endif
. N$ G1 H2 J/ _- ?- }        ret = platform_device_register(&da850_evm_tl_leds_device);
' i( i: P4 a# I6 s# }# q        if (ret)1 [$ {5 k& Z# b
                pr_warning("Could not register som GPIO expander LEDS");
) {' k1 g; j7 \- m7 h& V' X        else
- z( K1 q* ~+ R  Z                printk(KERN_INFO "LED register sucessful!\n");
: u, U$ i# M, |0 F3 b
  _/ C! P8 c0 Q) c& U        return ret;
& Y) B" k  T9 u# `, F}! ]! w0 j6 z- F, f; K
( Z! v0 x, I3 x! n* _/ d
static void __exit led_platform_exit(void)7 `; k2 P/ h6 z0 f+ e
{( X0 u5 G3 E( K+ J
        platform_device_unregister(&da850_evm_tl_leds_device);- m1 }5 p: B1 `* C' \0 ^' A

* @4 Q' M0 D1 T        printk(KERN_INFO "LED unregister!\n");. W# u; ^" e, A6 d
}( m2 ~3 j0 a' t, K# z! ~

. L' x9 `; S: N# umodule_init(led_platform_init);
4 G: [5 N) p0 mmodule_exit(led_platform_exit);
& W) T* K- ]1 q! ~7 Q
6 H) B; r  X- V, F9 WMODULE_DESCRIPTION("Led platform driver");' r: B9 P; r6 l7 ~2 o$ m
MODULE_AUTHOR("Tronlong");2 l3 ]& Q* G; B$ k) |3 u
MODULE_LICENSE("GPL");
+ }+ J1 d" |0 t5 \' w# t" P+ b, A
" ?( ]/ r6 z: E* u3 O3 ~9 Z; [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-28 23:36 , Processed in 0.038581 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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