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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 [! W' I5 d# `0 m( B+ i1 i
#include <linux/init.h>; }  y9 Y) c" ?0 p4 X5 G; w( L0 C4 I
#include <linux/module.h>3 q  ]& h/ g5 W; H/ G% w& T' W
#include <linux/kernel.h>% E: p" ~2 G- n
#include <linux/types.h>& q1 c1 K/ }8 ]' l' ^( r
#include <linux/gpio.h>. h4 X! i2 h! @* W  n, A
#include <linux/leds.h>
0 W# t, k& W2 p. |7 x4 i! ~: }- E#include <linux/platform_device.h>9 G. x! \# }" J% f! u

0 S  G) t# V; _6 g. R/ j% w& t' h& f#include <asm/mach-types.h>2 Q, Q* B5 r8 R- a: I; t
#include <asm/mach/arch.h>
; C9 w3 l0 l) N( A: s#include <mach/da8xx.h>7 ^  [  _# w* Q  Z0 [
#include <mach/mux.h>
- v2 F2 |' y/ i( Z
7 H4 l# Z$ Y) }* S! d5 g* Y#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' o) S6 ~+ D1 s* _7 J+ V' j8 Z! f) g$ V
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ u( z  F7 ~* Y% ^- r: n
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' h. e6 l0 [6 t8 y" v#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)8 Q1 c. {$ L0 ?6 P

  A; @* r' [; f7 o" `% M, A/* assign the tl som board LED-GPIOs*/4 D* x8 w& T  T5 Q& \7 E6 L
static const short da850_evm_tl_user_led_pins[] = {
5 H1 `2 `" _; [# I: Q4 C  Q        /* These pins are definition at <mach/mux.h> file */* m, ?3 o9 P+ B6 ~6 h: j" D+ H- p0 E
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' K) A5 j5 ?  l' D
        -19 n) ]$ d* D' d$ X
};2 h  q% W, W4 d; S4 v4 S( f

/ Z, c& B" z% t. [8 Wstatic struct gpio_led da850_evm_tl_leds[] = {
% m8 F# W: S0 I        {4 b0 x7 M% ]0 _1 t% l9 E7 [
                .active_low = 0," U1 j  `' P( `$ ?2 |/ E
                .gpio = DA850_USER_LED0,
; g9 G7 |2 x9 {. g' ?  w5 P                .name = "user_led0",+ a; j& ]1 A* x! j
                .default_trigger = "default-on"," Z6 v4 j% Q3 [/ Z7 m
        },
& D3 e  m6 F+ S* I        {6 w$ ~- A# `4 q6 S! R# q4 c
                .active_low = 0,9 P7 G  K. A" E- a! Q* C/ t) n# p
                .gpio = DA850_USER_LED1,
9 Y+ e# b2 i' a# `2 x! w5 n: X                .name = "user_led1",
: k( ]/ n2 g+ W) d# a7 z) b& H2 Q                .default_trigger = "default-on",
, b! a1 p" S' b' t  @4 y+ r        },3 O7 ?$ Q  Q9 f- E5 h* R- b3 H
        {0 m) ?2 V1 C# l2 q
                .active_low = 0,
; x( V! E: I* |$ o3 J                .gpio = DA850_USER_LED2,3 [' Z% f1 k2 |, V* g8 |9 [. W
                .name = "user_led2",
  ~& N& r. K6 c' n, n                .default_trigger = "default-on",
. D3 n' O0 V/ I  `, Y  R) m: v  ?        },
) \0 C- Y2 D% o' Q, R! f" [        {; Q& D* b: q: s
                .active_low = 0,2 T5 W5 ]' B& L% y
                .gpio = DA850_USER_LED3,# g: L1 p/ r  G: \% C
                .name = "user_led3",7 h3 G0 e! B, I! b1 d# n" E! C. [
                .default_trigger = "default-on"," |* j1 @$ g+ {* o/ y
        },, [, @! p8 m( D1 g  D) Y/ L# e
};- Z5 C# `3 D3 F* M1 l! H
3 t7 P( ?  Y6 g3 f6 C1 a- G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) S# W2 f& ~) c7 g        .leds = da850_evm_tl_leds,$ \9 S1 F  }) s8 v1 Y& i
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' ~- H6 O$ n9 p! u- s: \% X' F7 L
};
, G' j) J0 z) |" ?5 w7 E: ]: L' G& z* P8 W6 p6 G, g- d! Y+ l
static void led_dev_release(struct device *dev)( g. }4 |+ q' [
{
* `2 K7 Q& I! R};
0 q9 L0 _( |) [; g3 Z8 B1 C7 w& ?1 Y* B5 @
static struct platform_device da850_evm_tl_leds_device = {0 g- n# `( v0 ~  P. X- S
        .name                = "leds-gpio",
8 D" _  L/ R5 k; C6 k* C4 |        .id                = 1,
* V! w3 r% C  m6 ?. V# k7 P& W        .dev = {2 M. D" @" j) |7 M
                .platform_data = &da850_evm_tl_leds_pdata,
. Y9 W2 d3 V3 V1 X$ ~                .release = led_dev_release,+ d# K; M5 ?) _( R9 A5 v
        }
; E3 }7 ?/ Y1 E* B* o};
9 W- M6 f% \( G5 i$ g
! S% H' c# l/ E/ e0 astatic int __init led_platform_init(void)
, {# Z( l: Z9 A3 n% s{
2 T7 m, i9 r5 F7 r2 [        int ret;
3 F$ F1 _: e" `, n% a7 ?; g#if 0
8 M! B+ N5 \' i+ D  `* ]3 \/ z1 J        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! L' H8 P  B& @; u        if (ret)6 n* f0 _& p2 \
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# r! Y" D( |8 ?& K1 j+ A                                "%d\n", ret);- n% z6 \+ _$ k/ g! u, I
#endif
- p' a4 Z: a3 |/ w5 [' x% K        ret = platform_device_register(&da850_evm_tl_leds_device);2 l! R5 g8 E# W+ D" d9 V
        if (ret)
" N/ y+ e* G% a8 Z! j7 W: L: X! j                pr_warning("Could not register som GPIO expander LEDS");4 ^, X% o9 J/ N* V
        else
' e4 P9 d6 ~& Z% a+ C9 E3 ]& M                printk(KERN_INFO "LED register sucessful!\n");# J9 F$ O% }) ~0 j- T* d

. _/ f: [' F5 j! M" d        return ret;4 B! Z) o6 s; c% R- B8 H
}
5 d% H6 K( Y0 W$ R) u$ c
- H/ G9 M0 Y+ }6 P1 f. |  Kstatic void __exit led_platform_exit(void)
/ o  ]" }/ n6 y' u8 d0 n{
: ^9 A% x$ S9 t        platform_device_unregister(&da850_evm_tl_leds_device);" a( J4 R, v+ f0 r! q" l$ K
$ T- F" w) \" z0 E* L9 |$ A: i
        printk(KERN_INFO "LED unregister!\n");
# J8 c5 A( g. k5 P0 ?% H& D( a* n  e}/ d+ y6 ^* u) q# c% W
! B% T0 l. X1 Z$ R) }  M
module_init(led_platform_init);
3 ^) G/ X& A9 e9 B% ]1 l+ ^module_exit(led_platform_exit);
8 z' C) x' M8 Z9 R8 E* w
# m' c5 |$ R, tMODULE_DESCRIPTION("Led platform driver");( b4 T* [4 L; Q8 w+ r& a
MODULE_AUTHOR("Tronlong");
6 |( {# m/ R2 |2 U- k( oMODULE_LICENSE("GPL");4 E! I( P; f; |' @% K
, z( k% S8 H1 I/ [& k1 {+ e, i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 03:11 , Processed in 0.042789 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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