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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, P& X7 W0 B; T7 l  ~/ f2 o6 y# r#include <linux/init.h>6 N# R' \3 U* c( K
#include <linux/module.h>8 R; e* }  d4 X/ [( v5 C: Y
#include <linux/kernel.h>
+ V5 ?& _/ m' V" j#include <linux/types.h>
% ?. Z: l9 n; ^+ @#include <linux/gpio.h>
  e3 l4 e5 \2 ~" t: u#include <linux/leds.h>
0 _3 \8 ~% l4 I7 F#include <linux/platform_device.h>
5 V+ s4 x& _' C& m5 a. ?
. W. a5 h' [$ e: {! Y#include <asm/mach-types.h>8 @' u' \6 z" V9 Q$ q' X
#include <asm/mach/arch.h>8 M0 V/ Y. ~. h% I% C6 ^" ^/ d. Q- ^
#include <mach/da8xx.h>+ a* E' Q* y  z/ i6 W, D
#include <mach/mux.h>
  R$ ?/ b7 m$ W/ v$ f- c$ d* f3 e9 W5 F% _# k5 S
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 f, s" e- A0 Q# B7 k#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)6 S6 [/ e) N. ]4 Y( t* b
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! ]' f6 y. J6 A$ J
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), B8 I3 P" Y3 E

- R% K1 t8 F1 C! s/* assign the tl som board LED-GPIOs*/. b- Y1 \' ~( O
static const short da850_evm_tl_user_led_pins[] = {
4 }. E) n" A9 b2 C4 U  M        /* These pins are definition at <mach/mux.h> file */
! a/ Y" T: I* g6 W6 O+ {" u# L6 S        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- E* {8 a1 S$ n1 x. x        -1
3 f) v7 g4 b) }* z* l& v+ {& h/ {};
. g$ i9 n' c" u+ f7 o) G4 S8 N8 z5 p4 x5 Y, G
static struct gpio_led da850_evm_tl_leds[] = {
# C6 C! Y/ f1 m  y8 P9 i8 T1 m6 \        {" I6 b0 S( }# i" [! E+ t3 V6 K
                .active_low = 0,
7 d) X. e& c( E8 U4 z                .gpio = DA850_USER_LED0,
3 j0 [" U: n$ X' x1 _  q: C                .name = "user_led0",
; N/ A! i/ r0 t; N( I$ ^                .default_trigger = "default-on",$ n- x) U9 Q4 c, s1 q' S
        },1 T2 K# v: {! r! j4 z
        {
( |) S6 ^  N+ _1 J/ f' ?' Y                .active_low = 0,# G5 W4 P' ?5 ^# ?, Y% h( T
                .gpio = DA850_USER_LED1,
$ f" s/ ]/ t+ `% [7 K3 N0 i5 w                .name = "user_led1",. G1 s. Y" s0 e8 T
                .default_trigger = "default-on",
2 M7 T/ k  p! R, ~# d9 ?        },! S8 h5 _8 ^5 x
        {
! m/ R; ~0 N% u5 x4 k% N3 n1 l, a                .active_low = 0,6 n) F& L/ ]0 f6 I7 {( w
                .gpio = DA850_USER_LED2,/ H% _5 ~, R8 [; p
                .name = "user_led2",0 e+ F2 k- [; c
                .default_trigger = "default-on",* T3 m. f. E3 B7 d6 _
        },
$ R, s: s$ ~# ]' q! c+ B, S1 N' P% A        {
$ D* f8 ]5 f2 g5 N# S' ]- c                .active_low = 0,
. Z, A! z" c5 z7 ^" ]4 ^: @                .gpio = DA850_USER_LED3,5 \9 }& a; ^' p. s# u: R; ~7 W
                .name = "user_led3",3 r3 s  [# I7 {0 k& O* \
                .default_trigger = "default-on",
5 R; B/ Z9 f( i, e2 b; g  l0 M        },$ C) m7 s8 w3 G  r
};; b, Q8 G: \. S" t7 v% y& h  R7 c
1 l, e  b3 Z6 ?% L6 L8 h# Y2 A4 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, S+ }2 p9 e" [  E+ U8 b        .leds = da850_evm_tl_leds,- L( R! O7 e, r1 J& X9 r( K. \3 v
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# o' q2 i; I! }% X};4 n2 X) d9 a. z

. @5 R6 V- N9 h: [static void led_dev_release(struct device *dev)( Z% T, ~' y* u) A" R: A9 P
{8 R- k0 n0 O% c7 M: ?4 n- N* D
};  c8 W! L$ v+ e0 D' R6 ^+ n

& b! U8 N  A/ m6 qstatic struct platform_device da850_evm_tl_leds_device = {4 c* _2 i7 T' V3 S" y0 m& Z3 D) K9 x
        .name                = "leds-gpio",
; D4 U5 U4 Z2 l" \4 c/ a- K        .id                = 1,/ R3 }) |4 h- q$ X6 V9 ^1 v3 p
        .dev = {+ Q" _) w! C0 O: B/ o& T
                .platform_data = &da850_evm_tl_leds_pdata,
+ w" g/ D9 B& D7 P) [8 D- t                .release = led_dev_release,/ q- X" A4 I  [4 z# {# ^  L1 C# d
        }
' B# N6 ?. {+ v: ^3 K; Q};
( U/ q- x5 l7 H9 r" d; I' C# X% l+ b, y1 o# |1 R5 J' B8 ~9 ^
static int __init led_platform_init(void)& @0 z& w, B- W. c6 r8 j4 X  z0 \
{3 y/ I; i( F- K! A
        int ret;
+ g6 R( q( T0 g6 r; L8 B#if 0* `; _' @- e: g  @) k/ a
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! Q& q8 {7 M/ P& Z" G; u5 s; D' ~        if (ret)
" Z$ w( k' d9 r6 R" U- F1 \/ }                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- s8 R% H& V+ e& }. s) |: C' b                                "%d\n", ret);- f$ V8 S% u* k& h" y3 B
#endif
) n6 H( w2 s+ D* j2 z. D        ret = platform_device_register(&da850_evm_tl_leds_device);9 A2 p$ `7 q; |* p
        if (ret)
4 h; c0 D* G$ U, b, F                pr_warning("Could not register som GPIO expander LEDS");
- M, h; Q: y' y3 _        else
  {: N2 F, k6 z) ~3 w1 V( b                printk(KERN_INFO "LED register sucessful!\n");6 b( I2 U6 H# K% X2 o1 p

# L3 B: m' M) _- _' q        return ret;0 K' ?; ~0 U  M5 D( x) Z
}! q+ x6 m- n* e$ c" \' `
. x- x$ K, @! F7 g; H7 z
static void __exit led_platform_exit(void). A: [. N2 h# E' D
{. u6 o5 n1 l8 S2 ~
        platform_device_unregister(&da850_evm_tl_leds_device);
4 o9 c4 n( _# g! d  F6 D
3 @# d- a8 B* w9 R9 y- s3 P5 k9 d/ Q        printk(KERN_INFO "LED unregister!\n");
, L" B* t( G  [}
: S6 U0 Q' o1 I0 H) G6 j. q8 q* i- r0 B; n9 E: P5 l8 w
module_init(led_platform_init);
6 L7 J5 N$ U6 v/ K/ G* U; y2 Vmodule_exit(led_platform_exit);
4 Q6 k. ^) b* m0 l
# K! d1 T1 x; Y  K. {: FMODULE_DESCRIPTION("Led platform driver");2 Q9 H4 Z: W2 v
MODULE_AUTHOR("Tronlong");- q& ?7 b  n: g( n8 H
MODULE_LICENSE("GPL");
! t) r. M7 G  g1 V* e  R) O5 l$ e5 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-19 05:39 , Processed in 0.037950 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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