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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。2 K' B0 F/ @( @
#include <linux/init.h>
. o/ i- T* F7 X#include <linux/module.h>
+ d& l7 \/ i  v% _8 _) c$ p#include <linux/kernel.h>- `# K0 k: q! f# _3 |6 o3 N* d
#include <linux/types.h>
' |1 T6 C! {9 I, P8 ?#include <linux/gpio.h>, R3 ~5 r7 b# a% h
#include <linux/leds.h>+ u+ \+ c7 o" t; N$ c
#include <linux/platform_device.h>, `: C, b9 z! \% c1 e- T1 n
, T7 {% p9 n$ _- h; `: i
#include <asm/mach-types.h>: Z1 `% X( J0 R" b
#include <asm/mach/arch.h>
2 @2 `* ^1 ]/ e3 F, P9 q#include <mach/da8xx.h>. A) m3 L! A5 R6 d0 G
#include <mach/mux.h>
2 g- ]- Y- }, S9 s& P. O  l# l- }) H% O1 d- l+ K6 i& Z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
# v3 i: c2 ?* @$ _#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' p: Q# Q. x, c; j' c9 V#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)  v) h' h0 ?$ w
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 O- F, v4 p+ x2 T, r

  m$ |: X! Z2 l; N/* assign the tl som board LED-GPIOs*/5 J( s. z* J$ g6 D: @  d
static const short da850_evm_tl_user_led_pins[] = {, Z; A: u: L1 @
        /* These pins are definition at <mach/mux.h> file */: T7 `. v( B! _  u5 Q: _$ ?
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; \3 Z- s0 f7 e
        -1" X, `4 p1 l* X$ g0 j
};
) d/ `  V2 O$ R/ U/ {" M2 |' `/ [  _5 _# U0 H- w
static struct gpio_led da850_evm_tl_leds[] = {  ^( d' M) U: v* M& t5 o
        {
# v9 E( X% v: r& |! }                .active_low = 0,& Y! f6 C1 u% _5 |" t. z5 a2 x4 {: g
                .gpio = DA850_USER_LED0,
: |- _+ [# i* p8 i                .name = "user_led0",0 T" R# m" _- M, T' [6 f
                .default_trigger = "default-on",
2 i1 I; F0 ?5 S0 D6 X" h6 ^        },' M; f0 A! g. J' b
        {; h) x. ~: G% Z4 j
                .active_low = 0,
+ U) }/ Q* R2 c; y8 H: T/ `                .gpio = DA850_USER_LED1,
% L" D9 Y. u( Y2 j( X$ p                .name = "user_led1",
3 }5 D/ R/ T# m# p, m                .default_trigger = "default-on",1 v+ G7 X. [5 X0 s* K4 l
        },
9 z( E6 a/ F2 j% e        {9 J+ f+ G" j* \, a2 z* t! n' W0 b
                .active_low = 0,$ @1 X/ h/ @$ Q0 r3 Q) `
                .gpio = DA850_USER_LED2,+ f& q8 `" n) s' _. ^
                .name = "user_led2",
/ Z7 i( x% l' b4 Z: {' ~  B                .default_trigger = "default-on",  M7 N1 z/ L, i* n- L( Z
        },8 \7 s3 U4 N+ }0 n4 h" x1 q
        {
2 {: L: H! ?+ j, ]" @5 c3 P' R; B                .active_low = 0,
1 r- J% p! U$ Y1 A! V3 h3 _                .gpio = DA850_USER_LED3,) X5 ~9 l9 y3 c: ~/ a0 J
                .name = "user_led3",( Y8 W. F$ \3 h3 W; W
                .default_trigger = "default-on",
  H4 o! O$ F- }+ I        },
8 E& }; @* X+ ?( I};4 Q: y+ N" `6 Z! g/ i9 y/ g) x8 _
% M9 q2 ^% D: m4 P5 v( K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  i& O3 U$ p; p1 n  i0 s        .leds = da850_evm_tl_leds,
$ Q- n% d' R# h, O. g        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 {& s( z6 @% b: ~( c8 g: O};+ r% O/ W$ q9 |! q2 [& N
# w! h: r, q  T8 }: @+ ~
static void led_dev_release(struct device *dev)- d4 X0 @* o# \
{: K/ e, h; \; q
};9 r) h/ i# `3 z9 r2 d& M4 o3 _7 V
# Z* ^6 Z! h. R+ w
static struct platform_device da850_evm_tl_leds_device = {
6 _4 h" k- M# C  T0 g. t        .name                = "leds-gpio",
8 Q" ~" j/ }, J( Y- S+ D7 P        .id                = 1,8 C3 J, E! l( }4 x
        .dev = {  u1 ^- l% C4 c' R4 d+ |0 u6 D* u
                .platform_data = &da850_evm_tl_leds_pdata,' b1 p' i, m9 }
                .release = led_dev_release,
' }( Q- R, I) k3 B- o        }9 L% M) |+ A/ w% F  n- q% t
};% F; \" |. S  w8 f

- m( {. a6 u3 E: ]2 H8 U4 ~static int __init led_platform_init(void)& f* ~. C" e; z& {2 U6 c) e, Q+ e
{$ k3 |4 Z( a" p+ k6 a% l! \& {4 t/ a
        int ret;
1 J% D) U& h$ U! e$ _+ [2 k#if 0- U* N# @0 A0 Q4 e: Z4 k0 n
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- P5 N6 O0 \* t1 v- ?        if (ret)' H4 C" b' d1 U& h. w
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- u/ {  ~' j5 F. O
                                "%d\n", ret);
8 M7 B+ c( T: K* s( q* [  S#endif
+ d! E$ R% M# Z8 P, [) E' Q9 U        ret = platform_device_register(&da850_evm_tl_leds_device);
! v& A: L# S1 G/ h        if (ret)
$ L+ V3 T+ E: H1 g3 @& o                pr_warning("Could not register som GPIO expander LEDS");' x2 @! F2 X' W4 O* _: }
        else+ m1 A4 ]! D4 H& [$ A
                printk(KERN_INFO "LED register sucessful!\n");8 ^! r7 {; n5 `, T: {4 h

4 b& c& s. N7 a! B' l        return ret;" Q* E1 O. _) O4 w5 M
}
" ?$ K- [/ Y8 `5 \  Z! A2 C* J
- k% A9 z9 `. W  ^0 D; s/ }  Dstatic void __exit led_platform_exit(void)
7 l- Y% @2 o) Z{  W+ S$ B9 b/ W7 @+ _6 C2 }
        platform_device_unregister(&da850_evm_tl_leds_device);. [+ O+ C8 Y3 q& @: M% |0 }* v

7 o2 ^" p, G( E8 Q; L+ L        printk(KERN_INFO "LED unregister!\n");5 M; T( G, l# j0 P3 r
}
5 n7 @# r4 {" ]% E2 c- y+ z
( W1 {/ A' \* U* f1 N. s' q) tmodule_init(led_platform_init);
0 B/ D% S) _- D7 \module_exit(led_platform_exit);/ n0 R7 Y& t6 S% C: T2 Y

8 g8 H( [0 {0 i% e& g3 Z+ {: AMODULE_DESCRIPTION("Led platform driver");
; T  |- Y7 Q. j' h/ W- R0 j7 AMODULE_AUTHOR("Tronlong");; W8 y5 m! o6 `, s
MODULE_LICENSE("GPL");2 ]# d# l# v1 X  c. m
! m: F  U  O4 |6 ~& k9 K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-11 11:39 , Processed in 0.045031 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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