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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* r  m* X# \0 |
#include <linux/init.h>! t: k* [" ~' Y+ |% J: t( x. I0 {
#include <linux/module.h>
; v7 B6 r7 E; L: G) n) M#include <linux/kernel.h>
0 d- C0 n+ I2 Q5 k: z#include <linux/types.h>8 x4 v* ^: q3 _  ]
#include <linux/gpio.h>/ l  M# i3 y4 y/ S) x
#include <linux/leds.h>
4 Y( L3 f' F4 s7 N! D7 X# v#include <linux/platform_device.h>
( e6 V, z4 v( _! R3 M1 N
" b9 |/ U" w" h- _3 d#include <asm/mach-types.h>2 w0 Y" B# ~+ H5 R( l+ m
#include <asm/mach/arch.h>
. ^1 ]+ s; `3 z, ^  _( y#include <mach/da8xx.h>1 h; t, M/ d) `
#include <mach/mux.h>$ V4 \3 B; g8 L, w8 _9 A* f, h
" h1 S# B' p+ I  H" l+ ~; T
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: W; T& i  F7 f+ a#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( Y$ V& U, B) W& F#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ u! S& Q( N1 x
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), H/ Z8 g$ ]: P/ q! {1 R4 J* _1 g2 ^6 E
/ s- t% K0 Q  l) O0 {- C% y: D
/* assign the tl som board LED-GPIOs*/- Q2 J7 n) i2 d$ c: F
static const short da850_evm_tl_user_led_pins[] = {
& @& M$ Y+ m0 [+ P7 w        /* These pins are definition at <mach/mux.h> file */
3 N' v3 l9 Q3 n, v$ m) W        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ U. [1 E- Z, g6 Y6 Y8 a        -12 V6 j/ `& ^2 l2 |! P
};0 _& T7 D3 C1 z! x3 S  \3 g

$ I5 Q; h: |9 Mstatic struct gpio_led da850_evm_tl_leds[] = {, R; ^$ o& i# L. d+ \- k
        {
0 J; s9 G$ f2 \0 P; m+ j                .active_low = 0,
) T: f% b: Q# G5 V% s' Y, X                .gpio = DA850_USER_LED0,7 H  C! h  P( {: T$ }! v
                .name = "user_led0",
/ R- v; P! b8 K8 p) d7 t5 T5 G2 X                .default_trigger = "default-on",
$ L* x2 q0 L. e. |' z        },% j+ K4 p; n0 |9 t) H
        {7 O) c1 p5 O+ x1 _
                .active_low = 0,' U; s! [+ \: e2 N6 ~9 M
                .gpio = DA850_USER_LED1,
4 L% a! O  O" U/ W) Y                .name = "user_led1",) X( E* z8 a: x) o' R
                .default_trigger = "default-on",- P$ Z' I" V# q: r4 T
        },
3 N$ m3 j( Y9 x2 x/ p8 V1 B# F        {4 b* r1 }1 J% L. ?4 o0 f/ y3 c8 g' E
                .active_low = 0,
; Q+ x/ S# V8 S, m0 g6 K# K                .gpio = DA850_USER_LED2,
+ j, P( R/ C0 l' f. P                .name = "user_led2",1 B- ^# Z6 j8 d) L1 o& P
                .default_trigger = "default-on",
5 [. _# E# m- B- X( {        },
( L5 `3 X% Y% |& k+ F* a9 e+ a        {% |9 T1 @! D9 |
                .active_low = 0,
5 Q/ y6 B1 J( y% c& F, p( l& i4 U                .gpio = DA850_USER_LED3,
' w1 _& E$ l# {# e  x6 Y9 K/ |! b5 {                .name = "user_led3",
% Z3 S2 \" d$ }6 e7 n, Z                .default_trigger = "default-on",- _, k6 J9 z; {7 }& b+ ^
        },
$ [4 a9 ^! E4 `};, A8 g4 P- j: y

- [% `8 y* t' S. X/ ?9 W* \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ k6 G8 D; l: U& f( a, i( y; x        .leds = da850_evm_tl_leds,
0 D, S. U2 ]3 o# h8 m; |        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: O; {. @( _  e+ t5 L3 o) @- c};
0 P% m( o" ^9 H8 }  }8 p# {+ {$ H
* }# L* [3 C: w$ y( V; Cstatic void led_dev_release(struct device *dev)( \, f6 }( e9 K# e) d9 x
{0 p# p; ?  y, C$ B8 Q' G2 ^
};: U- E/ J- L( G; o/ Y: O) j8 i% ]

7 b2 Q% h0 m  `  O$ |' Y7 ]static struct platform_device da850_evm_tl_leds_device = {" T3 l% [$ ?4 `% |& H
        .name                = "leds-gpio",7 }! I0 O: E% V+ Q5 f
        .id                = 1,$ t) Q- i& r+ n% O+ `
        .dev = {9 F- M) ?- R0 |5 |) ]6 i
                .platform_data = &da850_evm_tl_leds_pdata,$ a* r! D: ^. w% L1 U# N4 ^# c: p) ~" Q
                .release = led_dev_release,2 s' p0 a; |. I  E. n; G+ o
        }
& m5 `7 [5 R: T$ f# K* r: [};) G1 l4 w  S2 C2 v" I: S% Z: u

" Q# n2 Z0 ~# H- @8 e5 ?( v+ ~/ Estatic int __init led_platform_init(void)
3 R( j( O: \7 l+ T{( V, g" _' M$ j5 G1 H8 l
        int ret;( Q) S& c1 _2 d5 {$ d0 q
#if 0
. r. f3 n1 `% Z& a2 L- W' P        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ ^8 [" F% M+ T- w. [        if (ret)
1 B1 }6 F! j0 X4 ?                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ x7 Y, f! g9 `* c
                                "%d\n", ret);1 X# R+ j+ f! u' @5 D" v5 ~
#endif& t) U* O- {& {& o
        ret = platform_device_register(&da850_evm_tl_leds_device);' O1 z* g; g9 o9 S5 o3 F+ |7 `3 V5 F
        if (ret)
; |# a  M$ K% ^  {5 ~% X2 L( S                pr_warning("Could not register som GPIO expander LEDS");
. i' i4 }% Z$ C7 E' i& `: m; Q/ D        else+ \8 ]# e9 D2 f
                printk(KERN_INFO "LED register sucessful!\n");
- V7 s, T5 t. ^4 v7 N7 B( n' T/ O% ]" |5 v5 t. D
        return ret;8 _% r. M: |. W2 n
}- `- N1 D9 f. \3 Z; t# D3 D% B
! e3 S. y' Y  _9 q4 T, P2 h
static void __exit led_platform_exit(void)5 C& _9 M2 W: }; o5 _- J) b
{: l; V3 |2 W* C4 n/ r$ ?
        platform_device_unregister(&da850_evm_tl_leds_device);/ s9 o5 ]% _& \" q, _

9 X1 p$ T7 X4 y, y3 ]  r4 b        printk(KERN_INFO "LED unregister!\n");4 s+ M% k2 w: u
}. @0 {! S: \" V: s: i" I
+ ~% L) [( M+ L' v8 T
module_init(led_platform_init);
$ [, D0 F, n/ c4 Z0 i1 B# ?module_exit(led_platform_exit);& J8 o/ s5 h3 r1 f9 R5 d' R& g

" H& M1 b6 z. [+ ~* wMODULE_DESCRIPTION("Led platform driver");
8 J: U$ b. o' C; w7 tMODULE_AUTHOR("Tronlong");
' N- @0 `( J7 t- B5 q( mMODULE_LICENSE("GPL");
. B2 e8 M8 G, w) r/ {) a) t0 ?& `) R' d* x# x- ~2 u% p
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-9 21:45 , Processed in 0.042944 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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