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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& Z4 q, f5 Q+ B( B#include <linux/init.h># Z) Z% t9 C  [1 Q6 W( L3 q
#include <linux/module.h>
- b5 c. M8 n9 U3 ~  W% K9 a2 p#include <linux/kernel.h>: \7 r: V+ ^, e- N: w  k% @: R5 {
#include <linux/types.h>
. D, K1 F1 x8 W  m% \#include <linux/gpio.h>- ^/ ^- |8 X& m& i/ v" Z+ m
#include <linux/leds.h>
2 b# M; O, W# H/ r7 T" G5 Q#include <linux/platform_device.h>
# A: \* [( o$ T/ u( ~) T: \2 N& U9 B  p& {
#include <asm/mach-types.h>; n4 ~7 N& Z, w  q8 l7 Y
#include <asm/mach/arch.h>
) c4 q0 t6 H& X: b& r#include <mach/da8xx.h>3 m9 O1 q6 L/ H. l9 K$ c" m; q
#include <mach/mux.h>; f) s8 v5 U, e# f

1 {& W/ f- T$ O, e- Z# _#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ G( s' S" K- P% t& Y8 \, n; p#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)* V7 p* x5 x* z0 Y! X
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* r2 D, Y6 T, s3 S* ?! w4 E1 }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( I6 Y( @8 g/ ~- F7 ^1 X

2 H4 G( k  Y2 D3 T: {* o* U3 `/* assign the tl som board LED-GPIOs*/
: \- X( N. [- [% P; lstatic const short da850_evm_tl_user_led_pins[] = {2 `, e* r3 }# P: z2 h. E. L
        /* These pins are definition at <mach/mux.h> file */( |. O% s1 e; f9 S8 e& N7 k, x1 F
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" x1 V+ ]6 a* H0 I+ c" f9 u: e        -1. n0 }4 p  p+ L# W" @
};
* C/ u& z% u, Q9 c) X, F9 V" l/ ]9 [% t8 D
static struct gpio_led da850_evm_tl_leds[] = {" V) z1 k9 `8 P( J
        {
# h0 N; T0 B3 U8 y' w4 O                .active_low = 0,+ x$ n: r: }) v
                .gpio = DA850_USER_LED0,' U) Q" i- v5 {* O8 M& W+ X- h( l, r
                .name = "user_led0",; x7 K2 s3 y6 N3 A! A
                .default_trigger = "default-on",
8 O; K) n- X# m, H$ E& D+ J        },9 Z+ h' p( u0 q& O  w4 n+ c
        {2 b1 p+ l0 P1 E' e2 s! Y9 E+ {
                .active_low = 0,5 ?3 H4 h$ k0 ~9 T8 ~$ h7 z  c
                .gpio = DA850_USER_LED1,
3 c3 x/ D  x' K, A                .name = "user_led1",! Y+ m1 Y5 C/ V; z
                .default_trigger = "default-on",
7 c8 D" E7 ~3 C  P        },; W! e' x; k- M9 E" F" l  Q* ?- o
        {( n5 F; T$ L/ O. j( o, b5 O! z
                .active_low = 0,
9 R/ o1 q- @! c+ N: w                .gpio = DA850_USER_LED2,& W" |0 l' X( p- e
                .name = "user_led2",4 d4 y) N, S1 j+ S# H) n
                .default_trigger = "default-on",' E) A0 q8 }8 O# \! f
        },7 X& D# y2 O0 D. @% C* L1 Z0 d
        {; s9 [6 U0 s" m4 ~$ \% ~. L' d
                .active_low = 0,
- \& ~' l+ P4 @                .gpio = DA850_USER_LED3,/ a" \" v9 J9 d4 ]5 r* M. H
                .name = "user_led3",
! t1 h" t+ \6 K. x) e                .default_trigger = "default-on",
, }& b+ Q) k6 Y        },
) v! g' F  Y" t7 K};
0 z5 e8 z9 Z9 B) P8 i4 B8 ]' p% _) u$ K# N8 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, c  ?) i0 W9 A5 ?! M: d. W
        .leds = da850_evm_tl_leds,/ J" W3 N$ \4 Q( z# t7 C# P' e" M% t
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 O0 [4 ?9 e& ]2 O' p" S5 r
};
' y- [- S+ ^, h  ?* O. S
) z% t; ~7 e% Wstatic void led_dev_release(struct device *dev)+ O* h, J6 v6 k* P
{& b1 ^; E. k4 n# }
};
5 F0 t" j4 N  X/ \' v. F7 v, S6 c- {1 ]: ?, V. X4 f
static struct platform_device da850_evm_tl_leds_device = {
  V3 Q% a: w% J" S- g- f! k        .name                = "leds-gpio",# B) L' x1 ]6 n0 d) }3 y
        .id                = 1,
2 T9 Y" n. z7 S4 s6 r. {6 P        .dev = {
1 ^6 Y# ~+ N. z* I: G+ c  S                .platform_data = &da850_evm_tl_leds_pdata,& W% e  c/ j7 z
                .release = led_dev_release,, w2 i$ A, u- x2 [) Q
        }; E$ c$ B: l4 {/ }- p& @7 L
};3 L/ y; m+ q2 d+ z1 V0 t
2 A/ Q% P, T; A8 B/ x7 \
static int __init led_platform_init(void)
, ^. V9 Y6 v! F) b8 |{
: C# j- ~& [" |        int ret;' G8 D; C6 h/ c  P8 A  z+ J
#if 07 q& x# Y1 O+ d4 O9 z/ G' x
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  m( y6 s1 L1 Y9 T" {" `
        if (ret)
, D, A, ^6 b' k                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 m( ^. R. f, [) N                                "%d\n", ret);
9 X9 W, [) }2 F$ |# s#endif
. w$ f, V1 ?! b6 A        ret = platform_device_register(&da850_evm_tl_leds_device);
& {% Z- v2 c" P$ U9 h" i0 z        if (ret)
0 Q1 c! E; f5 a' [                pr_warning("Could not register som GPIO expander LEDS");
! H  X! m4 T. j8 [2 o9 X' A        else: R+ \3 T# A* S  T2 R
                printk(KERN_INFO "LED register sucessful!\n");6 ]; ?: {. K0 V2 L

' W) `, W/ x6 S        return ret;% j) O) h  f5 t
}2 a/ ^9 _% X7 h

0 J( A9 V# G  k6 ~static void __exit led_platform_exit(void)$ ~0 L! y- U6 N/ N$ o5 i3 ?
{
& u# ]  ^( R% t# l6 J* Q        platform_device_unregister(&da850_evm_tl_leds_device);  L/ s* O3 y# q

: Y8 w1 z, N4 }: e- H  {        printk(KERN_INFO "LED unregister!\n");
% a7 d; D9 o! H0 H$ V+ s4 b}
2 h& ^0 b6 U3 ?
$ E/ I, }! ~1 S! |: ymodule_init(led_platform_init);
% h8 K# ?+ x) l; x! S, ^8 dmodule_exit(led_platform_exit);% j5 k0 ~) \0 h7 l" s1 }. }

' K; n/ z3 x6 b, P- UMODULE_DESCRIPTION("Led platform driver");' t/ @; }2 S# e
MODULE_AUTHOR("Tronlong");
  K' E* ^/ Z9 s, g8 n1 jMODULE_LICENSE("GPL");
" L% H9 Z7 o2 U2 z0 N$ }+ i8 ?/ L; N% L5 q3 T: g1 Q- }  Y. v
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 16:48 , Processed in 0.046489 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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