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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" G' U  w% {% A; R/ Q& B6 C* ?. p#include <linux/init.h>8 Q0 J, r* v# D1 r0 `* s
#include <linux/module.h>
% N1 c" ]7 H! Z/ v* D#include <linux/kernel.h>
# e& Z2 y) H: a4 J( f#include <linux/types.h>
7 k* h; ^9 k% n) W#include <linux/gpio.h>
% Z+ e7 K' Y. D' o#include <linux/leds.h>
/ }+ [. |' [2 z#include <linux/platform_device.h>
2 `0 z% B: B& x- @- }# M6 s. j8 C) a& h; C# T' ^
#include <asm/mach-types.h>4 C* m, x  i0 w, y. i- `
#include <asm/mach/arch.h>
  v9 b" a4 |9 k/ a$ ~& {#include <mach/da8xx.h>- E: G5 x: X3 C# |6 `. P3 h
#include <mach/mux.h>$ m  ^/ k4 x1 z- M$ K- H) l

$ N+ l! T7 X' S% T& M) Y#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" Q  j4 m' U+ H#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 \6 K; {( X7 j+ `
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ f. l+ \# r. m4 x' [#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
) ~) T, s. G/ h  x+ B* r; \2 B
/ @  T; W  j, _, j% i/* assign the tl som board LED-GPIOs*/
9 m, g3 U. m# k4 t' W6 L- [static const short da850_evm_tl_user_led_pins[] = {
5 }# Z  I9 N. v) ~        /* These pins are definition at <mach/mux.h> file */
. W, L/ C  j  @& ~, I5 s0 k        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* {. `- v0 T6 U1 C3 n* _; z6 N
        -1/ O" {3 R: ~/ ?6 I9 _
};9 q5 _; ?, ~2 n6 i  [1 w' `

- q1 f& C0 f0 r+ Q- b! y+ @. Zstatic struct gpio_led da850_evm_tl_leds[] = {7 A. S: Y' r9 Q
        {
2 i4 p/ l. m5 O+ Q) G                .active_low = 0,
( t6 s/ m& S& X4 D! H2 v3 h# v! Q/ m                .gpio = DA850_USER_LED0,. s8 @3 T! b+ w  U" l% R0 U3 n' R
                .name = "user_led0",
% E& Y' x3 G' b                .default_trigger = "default-on",4 y7 }' X5 Q, i( h5 G3 L6 O1 J
        },
: T* b1 w& k7 \) A2 D        {
. e) g  A( V7 n3 _& z                .active_low = 0,
9 `5 {1 F" P4 O+ o) J8 D                .gpio = DA850_USER_LED1,6 b+ v0 I6 r9 q. p6 t; T: E8 H7 S4 _
                .name = "user_led1",) E4 ~; _( H: Y0 Y, E  |* n
                .default_trigger = "default-on",
2 ]' i# t2 E" w3 t- ?  `( K, B        },
3 M/ X% b& h9 i; F1 L2 ?0 U        {
) s) ^, k  i( u4 m) ?8 T                .active_low = 0,* K. N0 K8 F$ ~* y' n8 \* W
                .gpio = DA850_USER_LED2,
4 \4 z1 X" E6 Q* `$ ~5 }4 q' ?                .name = "user_led2",/ c+ {5 Y6 R0 \* o) C' r; ]
                .default_trigger = "default-on",6 i% M# j" O* f4 O7 M
        },
% P( \0 }) ^8 T2 k  `* e        {
: K# j# f" x. x" L" M. B                .active_low = 0,
. y5 U  y$ N/ W4 F9 T2 F                .gpio = DA850_USER_LED3,2 Q: ^+ D  D7 q5 h* [
                .name = "user_led3",8 {  ?9 i6 b* O
                .default_trigger = "default-on",6 E' U8 o  z5 h3 Q* i
        },
/ {/ y# t( h% G6 J8 J};
5 y. `+ n# y6 W% x4 X* W" H( I6 V$ T6 e" H* {0 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) v4 S, m" `9 `& d& \  W1 ^( P: p
        .leds = da850_evm_tl_leds,
3 Y. t* S1 ]: t' v        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- f7 B1 Q1 L( j6 o
};
' \: I6 n8 m/ c" @0 t$ D8 ^. N% T/ n, n( K
static void led_dev_release(struct device *dev)
5 o2 i  g7 u) K) i: a{" o- I1 }' q8 [; ~
};
$ E4 g& G! r0 H" V& G" d$ J8 A+ A" Z7 r
static struct platform_device da850_evm_tl_leds_device = {
9 Z; a& t+ M* w1 Z6 |8 X5 \0 W        .name                = "leds-gpio"," @+ D6 K+ X$ O8 M, T8 c5 |8 R3 x
        .id                = 1,2 g0 r7 a% Z& R$ G9 l
        .dev = {4 U$ Q( M  _3 x& Z4 t( {
                .platform_data = &da850_evm_tl_leds_pdata,
8 I* g! y0 R6 F; G0 L$ }7 j& j! V                .release = led_dev_release,
( T$ L% x) ?, q, P# g1 N9 k        }8 t  u, ?* o! K) o+ v+ i2 `+ K
};. V1 r/ @* V5 i: p) E  O
0 p( }; C# x7 v1 U% Q
static int __init led_platform_init(void)1 C1 Q" T& @, d: j0 a; l; T) V
{& ~- U6 w  |$ A& ^+ F) J
        int ret;
( C" x' Q  I: |6 n4 ~1 r3 @#if 0
7 p8 ?7 h* x8 c7 t. d3 ~        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- j4 l) M9 Y9 D4 j7 b9 k        if (ret)
' ]4 R* W, b+ T9 S& N                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 v( a" a' m) i; ^! X4 F                                "%d\n", ret);; l* G0 B# P. ]/ `
#endif7 K  b2 j1 x; U8 D
        ret = platform_device_register(&da850_evm_tl_leds_device);% v' _/ N( l) b( a
        if (ret)
4 h; e, \5 L4 h0 l' h& o. {                pr_warning("Could not register som GPIO expander LEDS");% S) k7 A3 J& z! Q, |
        else4 k* U6 T" Q. k8 k0 v
                printk(KERN_INFO "LED register sucessful!\n");: d6 S% N0 x: W- @2 b
: j5 e" x  B% @5 m
        return ret;
" t8 N" ~! S' n# s, }}# {0 C6 U' F6 F$ i# \0 t1 q
# Z2 g* @# ?3 |9 e  M- M7 q
static void __exit led_platform_exit(void)
) V& h+ h* |$ f. h{
; z3 A7 ]: R' q. i& C, r! s# r. w  s        platform_device_unregister(&da850_evm_tl_leds_device);
; x( @6 G7 R' J/ q, F- S' X2 A: }4 }4 T3 _6 D/ E7 V0 T
        printk(KERN_INFO "LED unregister!\n");+ o4 j9 O1 p. r$ ~
}
1 M+ o3 S/ C0 K& Y) v! f% ?
2 B: M1 y4 k+ C* ~  |8 Hmodule_init(led_platform_init);
. A2 ]4 L$ v7 L) |; U9 I6 B' ]module_exit(led_platform_exit);6 g7 P& F+ z2 O2 K! r

7 W5 Q6 Q4 f3 l4 S5 |; J4 mMODULE_DESCRIPTION("Led platform driver");
# o' x6 s4 k7 g" W# f# vMODULE_AUTHOR("Tronlong");
4 s, J. b' S3 x7 C3 [; ]) x# J+ rMODULE_LICENSE("GPL");  K" V3 @5 ~) d% ]! u
4 e' v" q- Y& D( a4 `- e* |
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-6 11:10 , Processed in 0.041356 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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