嵌入式开发者社区
标题:
程序注解
[打印本页]
作者:
rgf
时间:
2018-1-19 19:02
标题:
程序注解
求大神给下面的程序做注解,请稍详细些,谢谢。
4 b3 L q) h" B( z- p
#include <linux/init.h>
2 D, Y" e! d1 q7 S% W
#include <linux/module.h>
" U$ |4 `% @9 @( I- w. {
#include <linux/kernel.h>
: Z: _' c' S. o- A; y
#include <linux/types.h>
' {3 @& z! n; j. _$ V
#include <linux/gpio.h>
! h; L6 T9 c% s, C0 f
#include <linux/leds.h>
2 }* z( }; Z9 E* b8 k% e" h
#include <linux/platform_device.h>
3 ?; \# c3 K0 |: b6 \# b
& v1 v: P1 X% V6 z5 |1 H
#include <asm/mach-types.h>
3 Z1 C ]4 z1 [7 X: N5 Y3 ^6 `" o
#include <asm/mach/arch.h>
8 n" I; I9 _' g# r9 h. ~
#include <mach/da8xx.h>
& }5 u9 {7 v5 q/ r
#include <mach/mux.h>
7 I' g5 B O! `; y7 n" [" q
( l" b, A3 x- A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 U9 N9 S8 V. R. t0 y6 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 t' H- n1 ?! E) S8 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 w* D% h! s( T" }5 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 J7 @# s/ N+ U |3 ?& f
6 I+ D6 E/ J" i$ W$ c5 n
/* assign the tl som board LED-GPIOs*/
$ S" y' ?& z( S! T
static const short da850_evm_tl_user_led_pins[] = {
$ w# W# |& r& Y
/* These pins are definition at <mach/mux.h> file */
' T/ d- Y7 `0 W0 [3 H+ Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 L0 c- H" z8 G$ q* |# c1 A
-1
o Y5 \" q2 u r, [% c" Z
};
$ F- W7 z1 Q$ e7 v, l
6 f. j" O7 K! c' n: h( {
static struct gpio_led da850_evm_tl_leds[] = {
[/ W( K9 p( ]" y# Z% C" O$ k: a
{
/ U9 p. t; N W7 V: K; v
.active_low = 0,
, m; _, }4 n- ]) b0 ]
.gpio = DA850_USER_LED0,
7 q2 q1 `) M0 c) m* ^' v
.name = "user_led0",
3 z8 x6 ?* s1 R2 S
.default_trigger = "default-on",
! h4 H, H4 g7 F9 {0 j9 F0 Q2 `* a
},
$ g& b- S/ P" b0 V. v8 O8 I
{
, {; _/ n# |7 T6 ^
.active_low = 0,
/ t4 Q* s; x' n4 a+ j9 V
.gpio = DA850_USER_LED1,
2 {; c) Y7 e! ^: C/ x8 R1 |
.name = "user_led1",
; J9 x/ G7 J+ ~% `: I
.default_trigger = "default-on",
3 e" h# c, H2 c
},
7 h- J D3 a# ~& M3 E) X2 A
{
$ d) A8 ?8 N$ K+ }! G
.active_low = 0,
& M: W* k. ~% n
.gpio = DA850_USER_LED2,
. S3 h" ^$ x# o, U
.name = "user_led2",
1 B1 t0 X! R* a0 Z% [" l
.default_trigger = "default-on",
" O; N7 m- a) ?. W9 o
},
& F* X; I! J6 b- N
{
' {& [+ W \5 j8 h% R8 R
.active_low = 0,
4 o7 T8 |) o8 e7 Y% h
.gpio = DA850_USER_LED3,
) a5 q9 C. l) P9 n
.name = "user_led3",
* F* ?% `) Z9 k2 _/ q8 c
.default_trigger = "default-on",
5 F# Q& ]' D/ X# q
},
- i6 O% p+ a2 n# e
};
4 V# g7 y5 P8 E# z, z
% X) Q$ J5 c' z) r; w% P2 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: {0 I0 n8 f$ D: H
.leds = da850_evm_tl_leds,
1 Z- I* W7 h' Q9 q2 Y1 f$ q4 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) D( {1 I7 g: r' H
};
O* r9 ^+ ?& o& r* i) m) U
5 {9 n5 L0 ^- s* t9 W
static void led_dev_release(struct device *dev)
% z0 H+ Y8 ~& e( Y, I- w
{
# c' X m3 ^/ P7 ~ n& Q
};
, `' P1 b: t' T* P
3 q4 _" y/ C5 V8 P% y1 ^
static struct platform_device da850_evm_tl_leds_device = {
$ i+ t0 `1 a2 p/ }: ~5 H( U
.name = "leds-gpio",
/ J0 y9 W0 F: T
.id = 1,
* \6 l( _) n6 ~
.dev = {
& m* b( B9 t+ `3 C
.platform_data = &da850_evm_tl_leds_pdata,
% ?, t' r8 f# Q# |* F; k8 V
.release = led_dev_release,
! ~ J; P- {. H/ E* w
}
6 s+ Y3 _1 U7 e8 p3 f* H
};
7 Q2 f) ^' U' b
4 D9 Q" n; F4 g) N' S
static int __init led_platform_init(void)
% g# [& Z; k) ~2 s# w
{
9 }1 Q2 l+ }, g" F% M. @+ f- W( M! w
int ret;
8 Z# Q! f5 g; r1 i
#if 0
+ t, F. g6 N5 T1 ^3 i! |0 G7 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 g, R/ u- j4 B' x
if (ret)
, \1 ]' E& d+ y- X+ s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' s4 `% _3 }2 s; J \, k/ v8 l
"%d\n", ret);
, u2 Z% V8 j) Q0 l J
#endif
! b8 G2 f; L0 a
ret = platform_device_register(&da850_evm_tl_leds_device);
! c4 y1 U8 G: N# r- b, C8 n) o
if (ret)
) H! D5 ` j# |. T, R
pr_warning("Could not register som GPIO expander LEDS");
7 k+ Y J/ p" W4 M0 A/ j
else
2 |! r" Z& h0 O
printk(KERN_INFO "LED register sucessful!\n");
$ K6 @! \; [) ?0 v3 X
/ i1 O" H; u, V; l! w3 L
return ret;
1 p% T$ f' a) z3 n/ e: _$ T
}
# T9 j6 L& p! E5 j6 D8 `
" X$ i4 N/ t6 S) V
static void __exit led_platform_exit(void)
& r( J* {3 x* W' H3 _. u! Q
{
0 e' H6 X- G9 `9 Y
platform_device_unregister(&da850_evm_tl_leds_device);
- j/ l; b |: m- q
; F* X, c, l+ q" ~* u
printk(KERN_INFO "LED unregister!\n");
\ U, R8 l8 n) N0 s
}
& _0 v6 P: u2 o; E4 S
9 r8 z, Y! ]; [8 b+ S ?1 {/ N9 {
module_init(led_platform_init);
: M0 F/ D9 A+ ^ a8 e% q& U
module_exit(led_platform_exit);
. f6 m, } `, o
" R2 x+ i: x8 j& Y) w
MODULE_DESCRIPTION("Led platform driver");
8 [3 `: n: x i) p2 `
MODULE_AUTHOR("Tronlong");
* I5 G2 v- d# j( g1 v
MODULE_LICENSE("GPL");
& b0 s' v9 U3 y- p5 l4 I8 |
% M0 m1 A- B& |/ h9 R: _7 Y7 o
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4