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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& g; n2 J/ N1 ^0 ~. e" V' w- N& {#include <linux/init.h>
  e: h0 Q# M( I) b5 t#include <linux/module.h>
4 k- I  j; U3 z; @* P0 W#include <linux/kernel.h>: p  W! Y% x6 Z6 q$ P
#include <linux/types.h>
3 _- t! B" i3 I# ?. v7 R#include <linux/gpio.h>
# Y: y! k0 t2 B4 l" d/ l! {7 f) t! V#include <linux/leds.h>
0 }) @  P/ [" [7 x6 p#include <linux/platform_device.h>
# p$ P7 v9 A: f8 a7 G! i
# t* T( _- G8 {. I3 N/ V5 z4 C#include <asm/mach-types.h>- K6 M8 c, M- P  C
#include <asm/mach/arch.h>
$ h/ M0 F6 P0 J! A6 O1 J" q& |#include <mach/da8xx.h>
5 s  J$ Q) O8 S- V* Z) b! Q#include <mach/mux.h>8 ^( {8 _9 [' K- G, L5 S6 Y; T
' U/ e# C1 ?4 o8 Q6 b& o1 v
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 V  T8 y6 ], I7 W# [, O+ _& _3 d#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ B% t/ G1 P, l; c#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% h) a. ^& W! e# A; v9 K6 `- e
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) H% V/ w3 c" [+ |3 O5 z
. B9 t6 C, a! c( p
/* assign the tl som board LED-GPIOs*/
/ Y2 W* h# B0 f' `7 Mstatic const short da850_evm_tl_user_led_pins[] = {
: D9 y' P; u* [& i! o" A  Y9 d' g% ~        /* These pins are definition at <mach/mux.h> file */
5 m. P3 q3 o0 K; q: y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 k: E3 n1 B- a, {  a4 x        -1
0 ?; u2 c* @  s4 W};
# `7 e( S9 p7 Y) P5 C* m, p# s0 i
7 Q0 {, h0 U' Wstatic struct gpio_led da850_evm_tl_leds[] = {
& l, r# {  n2 l0 w        {; T" [' }% m  w( g
                .active_low = 0,
* l+ W; d1 U9 f4 T/ @% Z6 `  g8 y                .gpio = DA850_USER_LED0,
, p7 f: y' Z$ U' c/ q                .name = "user_led0",
4 r$ H8 c. C. A1 z) K" @' ~9 F; V& \                .default_trigger = "default-on",( q- C  \& D4 D
        },
5 R% q& C! ?: J, C        {
# E+ G2 j& ?  ^1 a' H                .active_low = 0,; d3 `! W3 {# L0 G
                .gpio = DA850_USER_LED1,. e0 ^8 R( R% |+ i6 @: ^8 E! n1 f
                .name = "user_led1",. Y; n# N4 `0 k0 J5 S3 P  `4 q
                .default_trigger = "default-on",
3 }6 |9 U( s; g5 p- r/ n# M7 z& u0 |; q        },. x* U1 m! x, I( X. W0 u$ v* A
        {
' |3 E9 c7 |9 [+ W" o: [                .active_low = 0,5 Z! T" f2 g: C5 m
                .gpio = DA850_USER_LED2,! P8 \7 P. k3 y% Y* p$ e% T9 s9 d
                .name = "user_led2",
2 ~" O& t/ t4 O+ ]% g                .default_trigger = "default-on",
# m8 e- ^' d* I- {" L        },
: t2 x- w1 O9 w# q* K( r        {. ~5 x* \- Y- ~* Z: j' A
                .active_low = 0,
0 z( y. _3 X, e! ?                .gpio = DA850_USER_LED3,4 [9 M; @4 I0 {& V! B, a; b
                .name = "user_led3",
/ D% i- X# B2 p" t: k* u$ ]1 P                .default_trigger = "default-on",: L) q7 J: L' H4 z* @
        },
; H* m4 D& }: _$ W* _: I};5 L) _6 u) Y* M$ a. f

0 A) W$ b$ K2 B: C0 e* tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 p: K" I* `7 ~' u) C        .leds = da850_evm_tl_leds,9 E: j+ T; z+ |- S
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& W! W  x7 l" c% J) d; O
};1 @3 w* G7 M; v% _0 s7 d3 }8 B

! m. l* V1 [5 `9 Q) mstatic void led_dev_release(struct device *dev)
2 @3 R- o- V3 g- w{
/ Y8 @* U$ j; s4 `};! k) j  N+ n# `( Z, M: v: V
$ J4 y0 u6 h* i
static struct platform_device da850_evm_tl_leds_device = {# F- s# Q+ `0 g4 ~$ S, ~1 [
        .name                = "leds-gpio",
9 P8 r/ J% i3 h0 r: R9 ^        .id                = 1,
7 B. {, N  U( ~2 h; M" w. a1 |        .dev = {( q0 V6 w( p8 N6 @/ M
                .platform_data = &da850_evm_tl_leds_pdata,
/ L, `9 p+ }, [4 C! ~; z! v( A                .release = led_dev_release,# Z$ ^, E+ @$ |; |
        }
. O0 g1 @5 v( v' R; b$ `};, i. H1 K, k0 R( o' }4 w! G

* \5 M6 P5 e" Q, \9 u* t% t8 c4 o* E/ D  {static int __init led_platform_init(void)
% o" w8 X. `% @1 l7 W{
# ]3 |+ K: B( G! x( z. x9 }        int ret;$ \- C, _5 v; d: j: i, I1 m
#if 0, u7 |. x/ Z8 \) P
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 _  \0 f- G0 k; O        if (ret)
: f; M; z3 }  e. C& `( Q" T' Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# Q& ~1 n0 f" H                                "%d\n", ret);
, ]. G7 S) G! q! B#endif
1 k& v  p( ?1 v5 m. Q0 z        ret = platform_device_register(&da850_evm_tl_leds_device);7 ]9 X1 @2 `  t7 C* N+ F
        if (ret): D" k: K3 [8 W+ A" C6 x" r
                pr_warning("Could not register som GPIO expander LEDS");
3 F$ z6 o: ?; `; p" U        else
7 E; M8 Q. B0 L                printk(KERN_INFO "LED register sucessful!\n");
; L( S) h1 C% @5 b3 ^, O4 a3 t4 \/ p( t5 ~2 a' n: }
        return ret;
; l6 F  ^$ o/ K6 Y; g8 g3 y}
! }6 u+ \) l% ?
; b' c+ G7 X" [% v  i2 ostatic void __exit led_platform_exit(void)
( w0 P# N0 a; y. e' G# p{: t: _: D: y$ t! _" h+ y
        platform_device_unregister(&da850_evm_tl_leds_device);
0 I& y! P' z# n: S- W- g" K" m* p
& Z% A# m0 Z9 s' O* D! N        printk(KERN_INFO "LED unregister!\n");
$ F0 ?% u; d3 }+ Z: `5 ?; J}
: z- P1 J3 M/ N8 [+ K9 p& g7 X; @- h  E: V8 I' m
module_init(led_platform_init);
& V. h. G, }, o, r  r  Omodule_exit(led_platform_exit);
" ^0 t/ L3 J8 J) z5 i
0 j) c4 w9 p/ \( P% PMODULE_DESCRIPTION("Led platform driver");
4 a3 g! `6 u8 R5 n" D* Q: \MODULE_AUTHOR("Tronlong");
& ~, _) O1 m$ r+ b4 G- w. `MODULE_LICENSE("GPL");
, }* `/ H) w/ C6 d! A" H
1 d( A9 S1 j) o$ t3 ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-16 17:15 , Processed in 0.039210 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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