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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  D; Z' A/ v' I1 M7 e& g; _/ }1 F#include <linux/init.h>
3 z4 y' X' t6 ]1 c#include <linux/module.h>
5 O: ^; ^. M" X8 D#include <linux/kernel.h>
5 Y# o. d8 D5 F6 ~" L! k#include <linux/types.h>
0 ^/ V: F3 s/ L- G" I3 v#include <linux/gpio.h>
6 M! Y+ `& \: }1 n+ L#include <linux/leds.h>
2 ^$ w8 F8 T7 S#include <linux/platform_device.h>
7 c! i% A4 _% V* |- a  @& P! @0 f8 H8 W  s
#include <asm/mach-types.h>
& V) t# }$ W. o+ v- a6 p/ B) w5 @#include <asm/mach/arch.h>) r, X  p+ t: r$ u5 y& m
#include <mach/da8xx.h>; ^' Y) Y: V: ~) w
#include <mach/mux.h>9 {$ T: {* W' W# W& A

5 C, x' E. D0 T2 O( ^9 s1 \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, e' ^: F0 X5 c- ~' e0 L7 ]#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 m+ N2 t. c( z0 t$ ^5 L/ B2 i  D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 ?) c; R. u" F) F( s& j' `#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
% S1 Q& l" \" p% F: |( |. l% P- [0 f3 j5 _. P# D$ g
/* assign the tl som board LED-GPIOs*/9 z& J  R' N" f% h$ o$ O
static const short da850_evm_tl_user_led_pins[] = {
8 T) U0 g) [& j! O& e        /* These pins are definition at <mach/mux.h> file */# b0 R, U  I* i8 w% [( ?
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- }# U  N% O/ I$ O1 d6 ?( Y. H
        -11 f* X; t4 ~0 e- e
};/ E) _5 b  C' x5 q+ p# I; U0 |! l

+ |8 H  J  m: ~0 j( ^static struct gpio_led da850_evm_tl_leds[] = {1 k( ]1 o7 Q% G% e8 \7 k* g
        {- Y. C5 U$ Q+ @/ G2 V) g" Z  d  q
                .active_low = 0,, q" G& G5 w% i1 X* I
                .gpio = DA850_USER_LED0,
2 v: `: i$ J% L4 j, @                .name = "user_led0",
# g* W7 R+ e- O* Q                .default_trigger = "default-on",# U. ^- ~; D  I) R8 F
        },
  {# |0 k' d+ g' p- G" s        {
+ y9 s4 {( y, T6 [/ g% l                .active_low = 0,
6 x: z- _) A$ r! a                .gpio = DA850_USER_LED1,: Y8 O: z& d4 h+ b* X
                .name = "user_led1",
7 s' R2 g& [1 f+ ~) I' q                .default_trigger = "default-on",
% ~7 t* }  C/ u  d; U        }," h2 [( A8 R& e" w& }) @9 B
        {
" z7 c/ {) ]& X+ i) O/ c9 f/ `                .active_low = 0,
$ Z+ j( m6 a1 s4 s( T: o2 }                .gpio = DA850_USER_LED2,: M" P, u' O3 B7 i
                .name = "user_led2",* d* A" t7 X2 Q- a2 u7 a: M8 D. q, g0 }
                .default_trigger = "default-on"," F  a7 _' N4 X, Y( |
        },
& T7 q9 O3 Y7 \" b3 H/ g  _        {
8 R$ t9 }( \  ~, K                .active_low = 0,
4 {6 b- P. A1 F4 Y; M" ?4 E                .gpio = DA850_USER_LED3,
5 Y) t& n/ l+ A) h4 |                .name = "user_led3",
+ u6 s$ X, K, o# {3 f; F                .default_trigger = "default-on",
- H5 ]2 a+ \* {" q  l        },& U% Q, ~& L% `4 h& w! Q
};
, P- }$ B' b4 x' u
. |) i3 J, X- Z) o6 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; ^. h; A9 e  |* o8 J
        .leds = da850_evm_tl_leds,1 E+ Z$ {# k) M$ n" F5 x5 ~1 t
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 A& \+ o3 z1 ?};
+ ]& P  Q; x9 `5 P1 M* ]/ |; d- |( [2 |& [* B: y9 P9 F/ k5 D
static void led_dev_release(struct device *dev)
! i+ y$ _8 X( j  N. K% }0 [8 b* |{7 a0 O. U' h& A/ E6 q, a' c& G  Y
};
$ z! }4 B3 P( W1 e$ Y+ \/ B  |0 s1 H' N5 C2 F
static struct platform_device da850_evm_tl_leds_device = {, {  e4 E3 k, ~1 j# n
        .name                = "leds-gpio",
7 Z+ u' P/ q2 N' j7 Q        .id                = 1,0 q: _6 P* D  Q6 A
        .dev = {) P0 F: B" ]; b% M' K7 x
                .platform_data = &da850_evm_tl_leds_pdata,5 ~! w- T9 X+ `  c- I
                .release = led_dev_release,
) o* \' T) J$ ?& o' l        }
7 n; K# K. }1 A# A4 F, ~# ^/ `};
- B+ V. M0 V1 v) L5 c3 Y, W2 ?
+ A1 t9 u, l7 m0 B  w/ Ystatic int __init led_platform_init(void)" L! F3 H% z5 l% U: c, |8 w# o; H: P+ |
{
8 h5 y. `2 T4 N3 c        int ret;
% P# g/ G1 Z7 N" b#if 0
9 Z/ d2 c- O! ]# x4 z! L3 N        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 l; G' C8 _; K0 Q        if (ret)
6 ?* c6 w3 B2 Z4 x                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& x2 V$ Q% B! B- Q# E
                                "%d\n", ret);
. k4 R# g2 {- M; W* X) q#endif$ a1 q+ n- n# T# z3 H, E( K/ d
        ret = platform_device_register(&da850_evm_tl_leds_device);
) m8 c% W/ F  M( G        if (ret)
1 P4 _- ~8 L% Y; l# y                pr_warning("Could not register som GPIO expander LEDS");6 D0 J4 I0 V% a2 o; V3 ]2 q% Q) V
        else% p4 O; V" K) V3 B1 \# x
                printk(KERN_INFO "LED register sucessful!\n");$ x: `$ I" R/ r" ]) D
: C# n9 i+ Q4 m9 f: p$ s1 d
        return ret;
9 g, T+ Y" U1 y4 ]# \" t}
5 Y( y, J0 T! N7 z; b
- O& k2 L2 G/ Y9 x/ y; B( @5 n  l/ rstatic void __exit led_platform_exit(void)
# f, l/ A$ G' j! z7 R) @) y7 r) p{6 W: X3 I" Z4 V0 W
        platform_device_unregister(&da850_evm_tl_leds_device);
$ G3 w- R# W% X6 B8 c/ @( Q; S
/ D4 k9 N- ]* C. p0 i        printk(KERN_INFO "LED unregister!\n");
! ^3 Y' S4 R6 x$ t6 ?1 g5 d8 W}& R9 o# G+ ]+ F& w, S+ t
7 n. o" Q1 ^, X) ]. N
module_init(led_platform_init);7 H1 _8 q1 O  w9 N# P
module_exit(led_platform_exit);
) {9 p- O3 i1 n& n2 B) A, P& b* ?
3 @9 Q, b! y0 Y( Z3 ~0 H$ ^MODULE_DESCRIPTION("Led platform driver");2 W: n3 v  ?/ G
MODULE_AUTHOR("Tronlong");& v6 }6 `$ ?$ n2 L& y$ P( B6 y
MODULE_LICENSE("GPL");
1 |) V) X5 d9 j7 U# _4 x/ H$ [5 Z3 u( R8 k2 ^. A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-5 17:23 , Processed in 0.042604 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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