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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。# ]1 p* }  w. J' P5 R
#include <linux/init.h>: o1 c) H- A, p% T) L" q% F+ j
#include <linux/module.h>
! w( H# c2 q- ~' e- L#include <linux/kernel.h>8 p8 @, e% H3 Q) ^
#include <linux/types.h>- f( `$ @+ Q! `; L
#include <linux/gpio.h>
8 t; `2 b, \7 D/ a5 w6 `#include <linux/leds.h>& {% q  i) `; k9 w2 @
#include <linux/platform_device.h>9 c; k7 _, y! O3 a' S

7 Z7 Z, L' h- W& e5 V#include <asm/mach-types.h>! W9 c1 ?' T# w: h8 b' u
#include <asm/mach/arch.h>
3 O  B/ F3 H4 Z2 `# g4 K/ g! f#include <mach/da8xx.h>
) K9 Y6 g/ l5 w/ D' q$ O' W, l7 R#include <mach/mux.h>. T+ I' J* G. @; o

. }5 j' u6 n3 X* X1 Y2 i. t9 W#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' h/ A4 f+ H, c* m; X#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
& o* f6 ~5 H1 M% W9 i#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, u  B* K  A9 j8 V2 C& N+ ]#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
1 n* C& T7 `4 }3 m
1 b, N/ I' Q0 ?6 t" X8 w- @/* assign the tl som board LED-GPIOs*/
) L/ q+ [3 R, B- t/ Mstatic const short da850_evm_tl_user_led_pins[] = {
  n8 |. t* V8 i        /* These pins are definition at <mach/mux.h> file */
, ~) S- M6 y+ Y/ U& M. I& }1 v& l        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. v6 g1 v0 D* t/ r        -10 ?8 m( |4 K( |% b
};
6 Z0 h" _8 C' O, O; ~, R
; X* }; @4 v% Q/ t, H8 w8 Xstatic struct gpio_led da850_evm_tl_leds[] = {
) C: T  \+ q% f0 @6 ]        {. m5 y: k" ~* e* w1 y/ a
                .active_low = 0,
; E- ]1 S" I( W3 q: ]( o                .gpio = DA850_USER_LED0," s9 H  P& m7 ^+ u
                .name = "user_led0",
) G, [  r1 i* t, ~' x& s                .default_trigger = "default-on",
2 k( G) s: E! r' E7 G0 p5 l        },, r+ W' ^' E# J& u& s) M* \
        {" |% Q' C6 ?1 Q$ ]0 w5 |' l( {2 w1 i
                .active_low = 0,% E. g7 N. ^4 l# m  U5 g& @
                .gpio = DA850_USER_LED1,/ d2 H: b) m5 t: J- `5 P7 C9 I7 k6 H
                .name = "user_led1",
+ O( }* N, J0 o; r  ?                .default_trigger = "default-on",( D0 z: A" P7 n  \* \8 P/ Y
        },
3 n/ ]. ~8 {3 \, L2 d5 V4 e! i        {
" v, u2 l1 Z: ^( Q. Y7 D                .active_low = 0,
. ?8 V, D0 I. N/ g5 ?' }0 V* Z+ J                .gpio = DA850_USER_LED2,
( S7 X  c- [( r( r+ S+ e: u! {                .name = "user_led2",
7 O. C- s) i. \* \                .default_trigger = "default-on",
1 d  b& G# T3 I' z- [  U9 a        },2 Q7 [6 h5 O6 E% C7 o+ }
        {
3 m0 t* s3 x  n9 F; p. q7 R                .active_low = 0,) g6 C% E( b8 H' }" n. K8 @
                .gpio = DA850_USER_LED3,
  w, f4 S0 f- L4 k" X# X5 R                .name = "user_led3",* T9 A' v8 d5 [7 U  k/ a
                .default_trigger = "default-on",
; O. Z2 j% U) S9 g( @! A        },
2 p7 t' S8 ]7 R# @2 I: _};' J, V) t$ ]# u8 K% G% }. j6 y( _3 R) m
7 M5 ?, w3 l5 ]/ p7 |$ B$ H* t4 L2 s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 I( K, U8 @( F1 O
        .leds = da850_evm_tl_leds," ]1 N# J# s. l& a
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& ]8 z7 l; N/ Z) |& G8 v. D' u};4 y( J' I, h- h
" m9 k! n/ b' l  k5 Y" c: e8 N
static void led_dev_release(struct device *dev)
) D. L( U, |+ h2 _{- t, `8 ^& \8 F# U: G
};5 Z; V( f! o: m
. `: j$ B# U0 \' b- G  `% z
static struct platform_device da850_evm_tl_leds_device = {
0 n0 B; O5 g2 x9 ]        .name                = "leds-gpio",& G8 l4 r; L) \8 I1 E+ y8 J  u& Y* F$ M
        .id                = 1,
6 o& Q" f/ j: \* ?% R6 u+ P        .dev = {
5 M+ g& K) B. a; k6 Q                .platform_data = &da850_evm_tl_leds_pdata,
. w* M8 w2 K, }                .release = led_dev_release,% V9 p+ r# P! n1 [
        }
6 S1 I- G* J# z0 h};7 V: i! l8 N2 F9 _2 X; R8 n; ~  m
" `" y0 J8 d, j* z
static int __init led_platform_init(void)
0 S1 U3 r4 [9 `! t* d, |{
) r) L# L; n5 I% {1 b7 B7 B        int ret;
- [/ k* [7 o; o! g1 s3 X' m3 M#if 0' v: a$ U8 d% E  K
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ A7 T5 f9 N5 \3 s/ ]. S+ h: z" p        if (ret)
9 B0 _* T( W+ b$ ^( C1 O                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" R3 C3 g3 a' ~/ y7 ^
                                "%d\n", ret);
( l- C, W: c, k  c! G3 [#endif4 m5 C% a0 w; U5 I$ M) L; H4 f
        ret = platform_device_register(&da850_evm_tl_leds_device);
* }$ W7 v3 y0 C) A6 b$ i        if (ret)% a, m% D- |; v1 R$ ^! v
                pr_warning("Could not register som GPIO expander LEDS");( @! a1 }3 J5 _/ u- ~! E: U
        else4 Y5 J/ {# m* N, z0 f. U
                printk(KERN_INFO "LED register sucessful!\n");
/ M; h# P& j$ a0 [4 \0 C% X5 ^- h! w2 P' ]7 K: W2 R9 }
        return ret;/ q. t) @  `" B0 b8 u
}
' P$ o5 [2 [* x8 K  T, p/ k" \+ R4 I8 [
static void __exit led_platform_exit(void), \6 t9 B& E/ a8 M& Y$ d
{
6 _9 C  H- v" j+ f        platform_device_unregister(&da850_evm_tl_leds_device);
0 V5 b; W) F5 h3 p1 ^" m" B$ k) ^
8 n# _' l: Y2 H" {3 v: L        printk(KERN_INFO "LED unregister!\n");0 i1 @7 j2 Q9 ^0 e, N- l' k
}& r  `; V% b. A0 |3 X4 I# k7 o
6 `' x2 B# h+ @- @/ d; u! l9 e5 g: f
module_init(led_platform_init);
0 R0 ?4 D4 D& z5 s. X) U1 G% Lmodule_exit(led_platform_exit);; S. O0 x. M! S6 r. L

3 l' D* [" `! Z$ g2 p+ MMODULE_DESCRIPTION("Led platform driver");4 f$ W1 I3 S) G) ~
MODULE_AUTHOR("Tronlong");
9 Y$ o! T  ]2 I9 d" _, w2 fMODULE_LICENSE("GPL");
7 z1 s' O3 z( z5 @
$ g" k  u  U: R- y' F2 }- L0 @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-12 03:21 , Processed in 0.040976 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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