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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ l6 x- \7 j: z7 |2 X/ R, @4 n5 s#include <linux/init.h>* B& h) Y  H1 _% I, n
#include <linux/module.h># ^- y5 m) Q: ]
#include <linux/kernel.h>* y1 [7 p0 Q7 s( w# O9 B
#include <linux/types.h>/ `5 G9 V/ W" O" ^2 V# c
#include <linux/gpio.h>
" J( ?! ]& G4 a9 K/ k* B  i#include <linux/leds.h>0 n% j7 C" T3 N6 A( K
#include <linux/platform_device.h>- N5 R$ u: j* u8 q

. T. f8 K4 y+ L  Y2 C7 C2 v#include <asm/mach-types.h>
- u! P" C' G4 s& O' i- x#include <asm/mach/arch.h>
3 y0 w2 J0 U: o( j. Y' B#include <mach/da8xx.h>; R) E4 s! T) U* `
#include <mach/mux.h>
3 O( w5 T6 B' |; `0 a4 X# b
! ^" O* I$ `. ]7 l#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 P1 i% I' Z9 z0 y8 Y
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 R, N' R0 Y9 m" p
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 w' M* O+ X' q2 u% j# J#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 V6 ~& E. H4 X- r+ l" \" u

6 N! z+ Z% A' |- {0 _% K  r$ q1 L. ^/* assign the tl som board LED-GPIOs*/
" @& Y2 j1 {8 a9 _3 X0 Zstatic const short da850_evm_tl_user_led_pins[] = {9 B- W, k3 s! Y$ ?0 ]+ q' X
        /* These pins are definition at <mach/mux.h> file */
( }/ R+ C! W: R9 ^% o        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! ]1 _9 L% ]! r5 p% g$ I# J6 X        -1
2 `  s4 |: q1 @% Y! m};
/ O, I$ X/ Q, P# f; J% t% l2 O; s2 f# {; Z  S- @7 J# i
static struct gpio_led da850_evm_tl_leds[] = {) m% x9 K5 W& t
        {
6 e: g& |1 p" _7 ?: ~% j+ C                .active_low = 0,
- x. |: k1 U. {  p& B2 p" |6 M. Q6 S                .gpio = DA850_USER_LED0,4 K8 G1 }7 z( @/ r
                .name = "user_led0",
7 A. _) D5 H( y                .default_trigger = "default-on",
9 T  v3 y8 ~! o1 [+ R        },- G- x- l! T# X! U
        {( S% |4 q; p+ M1 [# V
                .active_low = 0,
: h: K9 Q$ U1 N2 M8 f! o8 \) J                .gpio = DA850_USER_LED1,- ]; K9 Z2 l% a3 A$ ~, \- u
                .name = "user_led1",
: T) G# q7 E5 W) G                .default_trigger = "default-on",
2 q) G$ d% d* F4 T0 |        },2 d: C' N  b, f7 N
        {) C6 e+ i, i% J  W. l1 m" Q) z0 S
                .active_low = 0,1 r  J5 e; r3 v5 L, t" x+ o
                .gpio = DA850_USER_LED2,) x* g1 @/ ~& U! H  C) S+ w6 i
                .name = "user_led2",
- B7 a. U4 V$ O                .default_trigger = "default-on",; m) x1 l' ]" `7 b% f! P
        },' a9 Z& n5 I1 i) r& F) Q* E" r
        {# l3 d9 Z/ z/ X9 y+ h" D4 v
                .active_low = 0,3 R2 }4 }& Z" O4 W4 n2 R' T- h
                .gpio = DA850_USER_LED3,
6 H  S: F. c2 ]( T; w& r                .name = "user_led3",' B3 v$ V& S5 x5 J& w) [
                .default_trigger = "default-on",
% a* r8 h: D- c, T7 z. \        },
6 \) C# [; J7 T+ ]8 h5 |};
( m1 v6 D  T$ X, l# U4 @3 f- \- b2 |* h3 |9 r) ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 }+ F& D6 L) K9 _        .leds = da850_evm_tl_leds,3 N8 K1 ^3 K3 ^
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- P$ ?# L+ @8 `$ V( \8 M- e% }
};
5 t; A0 C" g$ q# M5 l0 K3 g+ b: w) @7 @) q% K# h4 \" Z. U
static void led_dev_release(struct device *dev); M5 w4 n4 o0 n
{8 N- M: m- i" ?- ^+ V4 K! V
};% C2 n8 D8 M' `2 W8 Z

0 V( T. R1 U6 qstatic struct platform_device da850_evm_tl_leds_device = {
; k4 I3 d. z. c# A9 `, }        .name                = "leds-gpio",  G4 h/ V* j2 e2 l2 O
        .id                = 1,
! |0 ?& p. v, `5 y5 O        .dev = {9 L% C% X1 t- v1 P" x0 V6 L7 l% _
                .platform_data = &da850_evm_tl_leds_pdata,$ C' u, \7 _" T. e+ B$ d
                .release = led_dev_release,- `7 E. a  R6 z; x! v( V
        }  P1 h1 r; i! B5 p
};
( Y& a. t- R, u3 {: v) s( c# H) O8 g6 c( ]# E8 S( M
static int __init led_platform_init(void)
, |/ n1 P1 [6 r* C' d* k$ }{
1 W6 K( [! h* [6 P9 `; }! J& ~5 Y        int ret;% N! d+ F, N; n3 W% F
#if 0
& \: M3 ~) T* s1 S        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 m0 H1 g, r, @, h3 F        if (ret)
- W% z! F8 Z' A1 \4 z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" o* }8 H' I; C5 E8 r9 e. l9 E                                "%d\n", ret);
) o/ V' K5 @) o9 L% d- G0 D% `; {#endif
  t7 v# G! w2 l' [# O" R# l; N        ret = platform_device_register(&da850_evm_tl_leds_device);
  ^3 U4 `- ^* Y6 J$ s3 i4 r        if (ret)
# m6 ~( B! F& z, D2 ~. u                pr_warning("Could not register som GPIO expander LEDS");; }* a' J- B. u: J- x
        else% K. l, X) j) T3 H7 n( Q0 e2 L, b
                printk(KERN_INFO "LED register sucessful!\n");
+ L$ O8 J  K) b. @5 `0 }( h- w& C# G; u- T' r
        return ret;
6 b6 A  ~" d! L! t! m}
% r6 x, T  f0 Y9 F6 ]. x* `6 s, w/ B2 a
static void __exit led_platform_exit(void)' T. N  M; v7 }
{6 X- D. U1 P5 N, d$ O
        platform_device_unregister(&da850_evm_tl_leds_device);' _9 M) W% ~/ o
2 Q) a. H+ D! l
        printk(KERN_INFO "LED unregister!\n");
% L7 d$ `; k+ ^) B. F' T& F}8 @1 ?' e: {5 B, Q; I& U
- r4 A+ R8 n$ A! n+ b1 w6 q
module_init(led_platform_init);
$ D* y! K' e; Z* Z( ^, O8 pmodule_exit(led_platform_exit);
! r' i9 w1 Y2 a8 u% `3 F/ a; c6 G0 m/ t) N/ h
MODULE_DESCRIPTION("Led platform driver");) c2 E1 U1 m+ g7 K3 @" i" b" a
MODULE_AUTHOR("Tronlong");5 u' [6 p: e6 f$ s
MODULE_LICENSE("GPL");' R7 t1 F) R' e: G* M; C1 k2 p
# g* b9 T. R, z7 ~# q0 W9 \: A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-12 20:22 , Processed in 0.051997 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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