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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. {6 z2 e! y4 m8 G  p( ^
#include <linux/init.h>
: `: f" H$ }2 w' j' g#include <linux/module.h>
& l- g* M- o9 C9 N7 P4 }#include <linux/kernel.h>
- n: W; ~7 i- P6 A7 T4 q0 c#include <linux/types.h>8 T+ W( V$ g1 [9 _3 p
#include <linux/gpio.h>
0 V9 Y; H: W( [! Z0 e" Z/ x2 \#include <linux/leds.h>0 w+ W& W/ t7 J: w4 u) C4 K
#include <linux/platform_device.h>
/ L7 M6 o- h0 ?) P4 N+ m+ T5 @1 g- Q# [( y" W
#include <asm/mach-types.h>' @$ Z" O3 k4 z& |
#include <asm/mach/arch.h>8 d% L2 j0 k6 w# d! y9 c
#include <mach/da8xx.h>' d* N+ n5 W2 H4 N7 G8 p4 s
#include <mach/mux.h>
" K! W! m, W1 B+ n
% D9 x* t% d+ k0 t; x. o#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), {* O# P2 W, ^2 B
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- O' o( N0 u0 A3 S; n#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)0 L; j' O, ~$ j% N) r6 e/ O! _
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- D* g' b$ B7 q$ p- C/ Z* R" m* N
+ B* g, c8 y8 N; g4 J! y/ J5 n
/* assign the tl som board LED-GPIOs*/
: e* A  R5 ^' l' M& Sstatic const short da850_evm_tl_user_led_pins[] = {! F; q  S6 Z, v- I; ]- K
        /* These pins are definition at <mach/mux.h> file */
1 d- j! p5 o9 |" k& |        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 H# ]1 E- x7 t9 s
        -19 k4 [8 K+ r( X. V2 C
};
5 F3 l% k% v7 D# c  |
, ?$ C+ `2 g( Ystatic struct gpio_led da850_evm_tl_leds[] = {; B! Y* I% n2 t
        {
7 f* N9 b  Y" }) J& ^% V                .active_low = 0,, k" h7 X: S, \0 y2 d7 N+ i3 ]
                .gpio = DA850_USER_LED0,7 L/ ~( U7 H5 b' T$ j
                .name = "user_led0",9 c# r1 q, L) l! g. A
                .default_trigger = "default-on",& _% g/ H- y" L8 v: y* I
        },
% J/ w; z/ w# k$ Z  s  P        {& \! U4 q; @- L1 ^# g! U
                .active_low = 0,
/ N* n8 ~+ P# U* j4 L                .gpio = DA850_USER_LED1,% P* ?7 k4 ?: f
                .name = "user_led1",+ s4 Z/ t( V& `7 \2 q7 c4 x% \1 R1 H
                .default_trigger = "default-on",6 M/ H4 ]# Z) \8 l4 o1 s4 k
        },2 p: U& f- r' S* R+ @# a! |
        {* w+ Q$ p5 a, K, y! z# h
                .active_low = 0,
* }& g( o. H% \9 c3 \: A0 L" \/ `- |                .gpio = DA850_USER_LED2,1 r( [- d) o1 N  Q& Y9 V8 {
                .name = "user_led2",
: n( C4 v; V  m# q% z9 Y                .default_trigger = "default-on",
. B% p; K( ^. I$ Z- ^5 q* G        },
, [5 P, y* g3 x9 S: \: T% m( ^        {  k8 U9 q3 D  d* c& W
                .active_low = 0,
( d. W% m1 _1 G6 M' w                .gpio = DA850_USER_LED3,- T0 f  e" k# l: K  r/ \' h
                .name = "user_led3",: m% r; F, Y4 l4 e; _" N
                .default_trigger = "default-on",: t7 z; E$ m' [: |
        },6 q; l5 B; V, @
};
# k# _4 ?8 m/ t- v/ T! s& g; g4 c4 w( \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 j( G. n6 k8 B/ S0 H        .leds = da850_evm_tl_leds,
$ ]6 A: \2 h' x+ s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 N6 ?5 `! t  C$ I};' S: J# j5 o. G' S1 A: |! G* G; R
% [. ^3 d) k" j0 G# W7 Y
static void led_dev_release(struct device *dev)3 [, E+ j( ~2 ~# M& Z- w$ Q6 F) p: W
{+ `; b/ ^/ a( ]* d$ {2 M; n/ P
};
7 k+ ~% i; _) C' f3 Y" i4 n! k7 |0 f
static struct platform_device da850_evm_tl_leds_device = {
0 e  d- R- x+ k/ J        .name                = "leds-gpio",& M3 N% G/ Y7 d, l7 ]1 Q: @$ Q
        .id                = 1,6 ]1 b8 |4 b" s9 `4 n/ `
        .dev = {
* b6 ]* F7 q3 _2 a3 n                .platform_data = &da850_evm_tl_leds_pdata,$ R' D& m5 f2 F1 f5 A% U
                .release = led_dev_release,$ C. b) w  h0 S% U$ _. p/ [
        }
: _7 D5 {: M# [" a9 m};
8 M: o: x3 e. ?* r' R* |9 n  J6 e2 C) Z$ u* m& }
static int __init led_platform_init(void)3 V6 t4 V; d8 q( |  p4 M7 Q
{
8 c3 p" f; s. g9 _        int ret;
6 S9 [1 y5 d1 X* C. [#if 06 g1 }) q) J' V* \! Y% y3 q2 V6 y! A" D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ g7 q$ t1 n# k6 J% }        if (ret)4 Y. d, J/ V" ]+ n$ O- U: }3 x
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( S+ k% |4 @3 U8 {( G7 y3 G                                "%d\n", ret);1 n& u. A9 p# E" [$ [2 D
#endif" |- J5 W) j" C0 ~$ D
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ B& O2 ]- p+ E) j        if (ret)8 D2 {4 v* O! Q
                pr_warning("Could not register som GPIO expander LEDS");
% Q+ F2 `; U3 l# [; E  n        else4 O) z3 B% `" _8 Z
                printk(KERN_INFO "LED register sucessful!\n");
& b' e5 p, i# j& @% N) u* Z% q
6 W3 {, Q$ S& r  D; N        return ret;
1 v5 i; T( b% @6 D. w( x. E2 L}0 @$ f8 V2 t* ~) d

7 @8 E# a' u& f- n4 i+ jstatic void __exit led_platform_exit(void)
- f0 U, K0 j4 `; P% d{
  x1 x, I" |; ]1 M        platform_device_unregister(&da850_evm_tl_leds_device);3 t' v& g9 Y3 F# t% [2 ]. c9 h

! @) \& k4 \: {7 I& x! A6 m        printk(KERN_INFO "LED unregister!\n");
9 B* y% P7 k9 P5 b" _5 t}
) p6 f& ^, l4 x6 o/ f9 n/ r
  X2 [) z) L6 J1 hmodule_init(led_platform_init);+ d1 V) O4 u) _. r& b! ^  S
module_exit(led_platform_exit);& y* x( a0 ]& V2 W4 k" l& w- P% M

5 x2 T* c+ D; s# {  {MODULE_DESCRIPTION("Led platform driver");5 \3 h8 L# ^9 \) E9 p* v
MODULE_AUTHOR("Tronlong");( j8 `" k5 s. U1 y% j) P3 X
MODULE_LICENSE("GPL");
9 G* o7 A# S  H  x+ v) M! D
6 m4 B+ n. g' o# y, A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-22 11:39 , Processed in 0.042783 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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