嵌入式开发者社区

标题: 程序注解 [打印本页]

作者: rgf    时间: 2018-1-19 19:02
标题: 程序注解
求大神给下面的程序做注解,请稍详细些,谢谢。: j9 m8 |( B% \4 R- Y
#include <linux/init.h>
  U3 J3 r' x6 `: |" z$ i2 X1 U" x) g#include <linux/module.h>
$ j% T, B+ [6 P#include <linux/kernel.h>
5 E/ O2 c" i- U; F#include <linux/types.h>' i+ k5 }3 m! T5 P  p- j1 J
#include <linux/gpio.h>. i* I) b' W& @2 Y) U$ X
#include <linux/leds.h>
/ W7 N+ Q- W5 F, j& N) _#include <linux/platform_device.h>
4 W1 @7 F) x( s6 ~" Z; q9 G7 n8 I% }( _+ u! w0 J0 @
#include <asm/mach-types.h>9 X$ {3 u: F: l4 N" {  s: K
#include <asm/mach/arch.h>& x  C2 X  e+ P
#include <mach/da8xx.h>
4 r! x0 ]6 b0 W' H, ]#include <mach/mux.h>" f9 d& U- ]$ a0 H2 q7 T/ e
8 F  W7 H9 p! C
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); F, B1 l; _# k. `/ L: t! T, c. N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 t7 n5 F1 d# ?: w  r' i
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- H2 b2 r# [: L
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' m( S' O8 C) m8 }$ l# u  V9 A
. x/ w! D) y# E* f4 l  j, _/* assign the tl som board LED-GPIOs*/4 x, c5 }* q  r4 X  m6 i4 F( c2 E
static const short da850_evm_tl_user_led_pins[] = {" [- [* m6 i' K- e7 z
        /* These pins are definition at <mach/mux.h> file */, X! l9 ~, {' U3 m! i5 h! G) ^
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) P7 x% `2 _1 k; ^3 \9 K
        -1: ?2 ~: \! v. S
};
8 b1 U1 q) c+ R( v/ Y
3 O8 _5 W) c2 Y) U  Xstatic struct gpio_led da850_evm_tl_leds[] = {2 y; V- d5 I. t. z
        {/ I! v0 i  R4 b& W+ Y/ S8 y
                .active_low = 0,9 O+ {  m5 K3 C$ K' X: R
                .gpio = DA850_USER_LED0,) H- w3 }0 o; S' O( V5 W) w8 G
                .name = "user_led0",
- F1 A3 {0 E8 _6 R9 t, |) s                .default_trigger = "default-on",2 W6 U' m8 p+ ^3 k2 K
        },
4 [, S' S6 l$ d        {
3 p+ G" f3 r5 d6 |                .active_low = 0,/ t: m7 V: l4 H6 B( [9 h% k0 Q6 n$ k  z
                .gpio = DA850_USER_LED1,
& F! }/ x# G$ Q; H                .name = "user_led1",- o! ]& |# K; l% A7 ]
                .default_trigger = "default-on",
( v" j1 e3 P' |: p, w4 u        },3 |! I+ {5 B9 D$ o
        {
7 k! }1 m/ b  G, I# E$ @. e8 }                .active_low = 0,$ T* g) |& o# r) v: M! U* w* L
                .gpio = DA850_USER_LED2,- o2 a, K# U1 k+ @1 X9 _, \9 Z
                .name = "user_led2",
( h2 k2 q- x' r* b9 L3 I$ ]% K                .default_trigger = "default-on",8 I- a" c: J+ p. O/ p5 o6 U8 _5 K& m
        },
" [/ Y9 R  u9 t) ~% k  B        {
  A( [6 G2 J1 ]' y                .active_low = 0,: _% q) I, n; o, {9 u$ e% a
                .gpio = DA850_USER_LED3,
' k+ J. o# }! [8 _                .name = "user_led3",7 U) e, [3 V2 s; a9 N0 Q
                .default_trigger = "default-on",* S1 X6 c+ J, p" S+ p0 {# |3 W$ p% z9 _
        },: K2 J+ K8 W# [% [4 n' Y
};6 z/ E: K& Z4 K) L) s( Z
6 D$ {( R1 }4 A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 F' F* p' C1 \! U( L" a% k        .leds = da850_evm_tl_leds,) |! H( F( x% d% B
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) q. |0 |: |  S6 `};5 r  W/ Q- p  p5 z# D5 j  R
2 d( M2 \# ?) ^  U6 i; \1 m
static void led_dev_release(struct device *dev)6 L. O0 u( Z( t# ]2 e
{. B3 E! |! U3 W9 D( w0 p" z
};
# p, L) ^' R2 t$ m( M& Z+ y" X& D
4 U" A; H: K1 k9 A# O+ n" rstatic struct platform_device da850_evm_tl_leds_device = {
: c* f" i# F: N/ R- p        .name                = "leds-gpio",
' j0 J: _: Y0 U: f) U        .id                = 1,/ L  Q6 x9 q+ ~
        .dev = {
0 T, ^; W6 t& l" R6 Z6 n) S3 D" L" `4 d                .platform_data = &da850_evm_tl_leds_pdata,
3 H" b4 G+ Z4 I" m& @& n" r                .release = led_dev_release,0 o0 Q0 F8 F  G7 f6 X# e% F: l
        }
8 c7 W) B& g' u: E/ K};2 Z: V  t8 q4 Z1 i

( G3 g; Y; N. f9 G2 G6 ?' {; P9 vstatic int __init led_platform_init(void)
" }' H- j$ \1 A' l8 S5 j7 |{
/ P: M/ k, {/ Y2 O        int ret;" n# G) w5 Y9 K: _( x$ K
#if 0: v/ j% p- Z# l) G# T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; Y( E! W6 S- w# S( Q7 y  u
        if (ret)8 q1 c) b7 `) }! {  m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; A. I* h* ^$ Y                                "%d\n", ret);
: }$ E9 J7 E$ m0 \" w9 [% \0 j#endif5 ^/ E+ T8 m! @
        ret = platform_device_register(&da850_evm_tl_leds_device);* }/ T+ [7 M+ C9 W' a9 v( t
        if (ret)  f) p9 Q! l* u) z1 M0 g7 L" Y
                pr_warning("Could not register som GPIO expander LEDS");
$ k7 _, G, J  l! |4 t/ J9 @% ~        else
* t& m3 {. W- c& x6 \+ }                printk(KERN_INFO "LED register sucessful!\n");
2 P( r. J& I- ~0 M; Q/ l7 D
' }' r! s5 B$ M        return ret;! ]& t0 Q# a! U# {
}
9 P( o" N8 I' @9 U
0 R& U, o. K2 {' m7 Estatic void __exit led_platform_exit(void)/ u( M" B9 ~. g4 h! M. I4 O* f* [
{' b2 O. E7 y1 ^7 z
        platform_device_unregister(&da850_evm_tl_leds_device);: m$ [- c5 I: ~; z. d
5 x  s1 f9 D, U; p$ N
        printk(KERN_INFO "LED unregister!\n");8 Q$ @1 k  K. B) }% }6 e
}
$ S  t: g* Z! A6 U8 K& l3 r" j. C* r" z
module_init(led_platform_init);6 @% Z3 J$ N% B
module_exit(led_platform_exit);: x& b9 Q; L5 r

3 |( m) M* G7 AMODULE_DESCRIPTION("Led platform driver");8 P6 A' f3 `: f) r0 D
MODULE_AUTHOR("Tronlong");) b/ h/ u! c; x$ T; K
MODULE_LICENSE("GPL");
5 t5 T9 f4 m; e, @+ T+ _/ [+ ^2 d6 }! R: V0 |





欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4