程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 ], M; W7 v, K" Z) K) n3 x
#include <linux/init.h>
3 t4 F# {. [' y, a6 _#include <linux/module.h>6 o" ?2 _0 B& ]) I
#include <linux/kernel.h>( h; x( V, v/ O' P, R# s9 R
#include <linux/types.h>8 i# `2 N: \: ?8 k9 |+ I
#include <linux/gpio.h>5 r9 `' `% u: g: l
#include <linux/leds.h>
* ?$ w! ?8 {+ f, G# \#include <linux/platform_device.h>8 ?" A. y0 s" U9 E* A
0 r3 ?. s3 M& \4 L) Y3 q% M
#include <asm/mach-types.h>0 V- S9 }* s) Y( O; D
#include <asm/mach/arch.h>) D9 s& j2 q) p& F1 k' \5 U  F# F
#include <mach/da8xx.h>
# [: X6 E# i3 {% g8 ]#include <mach/mux.h>
% x5 d) f6 @( y+ A- J' l( t5 r% O  D$ L7 Y/ l
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 H+ K! c$ U1 c1 y% k3 J
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)" ]3 ?& ]6 H3 ^; k1 @0 q- s6 J
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 f( U, z$ T# a. \. ?7 \- S
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ B6 T; h% F- n6 [' |  G6 R- f# ^, g9 g, y# t' H& l- O
/* assign the tl som board LED-GPIOs*/8 }7 Y' u5 b/ H2 q
static const short da850_evm_tl_user_led_pins[] = {; m0 i7 p' O" B3 s
        /* These pins are definition at <mach/mux.h> file */
% y: q5 M% t! e1 Y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( D3 V7 H, f' ~. H
        -10 G* T& A; x% _4 o
};, v+ l! q) N# f# y0 x6 M

5 Q) g- J6 A" T; m# r& `3 s, Bstatic struct gpio_led da850_evm_tl_leds[] = {! x5 x5 `' l( }! Z$ T. ~$ ~) y
        {9 n) @4 o7 D# ?4 y2 r
                .active_low = 0,9 _9 h+ [$ Q" Z% r
                .gpio = DA850_USER_LED0,) g# L( W& i8 T1 A% K* Z) U
                .name = "user_led0",) R. V: O7 F  I* B# Y. k
                .default_trigger = "default-on",6 D8 x9 P; S) m' G/ E! b
        },( U+ h: P# k9 j
        {& s& t' d3 L6 R- e4 U, Y# Z
                .active_low = 0,+ M! M) b+ x* ^- e
                .gpio = DA850_USER_LED1,: y' o" @, U( H; A9 e3 i, |
                .name = "user_led1",. a4 b% B* E6 A! o5 \
                .default_trigger = "default-on",
6 L! _: ]& n0 b; R$ G1 R; A& c        },$ t( F# H& i$ D+ i: w
        {
6 v% D1 J. u+ v7 R                .active_low = 0,
5 A6 M7 i9 [" s' D8 `                .gpio = DA850_USER_LED2,0 n( ]9 _! o; {6 U% j' w, `
                .name = "user_led2",; U9 Y! S/ y3 i5 Y* h
                .default_trigger = "default-on",
4 ]' }& M. B- S" V/ L        },3 k; [- q; y) I2 K- r
        {1 d' U* c) \5 u' P# r
                .active_low = 0,# J  j- p/ \8 m4 \6 Y% V) E
                .gpio = DA850_USER_LED3," i% P! k# |# B# K) n8 P
                .name = "user_led3",5 Z7 P* L2 d+ V1 `! h+ X8 Z" u9 l# ]
                .default_trigger = "default-on",6 F$ R( A. \! z% T8 b% r
        },0 ?7 ~8 K7 l& O; c/ Z
};
. P  P2 e6 m7 M4 n$ X% G: S7 a& r2 B; q/ J0 ~3 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 A5 ]- {- U% f8 H& H        .leds = da850_evm_tl_leds,4 \# j6 M/ n8 ?* _: }; z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( a' \  |% o( O5 r) L# @
};
1 C1 q# `' j( S  g$ I4 w; d9 \  C
* A* W8 P7 z+ H; T# L9 v& M, xstatic void led_dev_release(struct device *dev)
# a) V9 F( ?& J" A{1 @) p6 F0 U8 E, C
};% V7 b" K! j& Z2 R
. V9 n9 {9 p  v( T
static struct platform_device da850_evm_tl_leds_device = {' s  @- T3 S+ Y7 Q
        .name                = "leds-gpio",5 E6 z8 }* T  v% P' |0 F0 H5 i: [
        .id                = 1,' j4 m: c2 b7 z& K; L: p
        .dev = {
; I3 u! b9 L2 j1 W                .platform_data = &da850_evm_tl_leds_pdata,
: w* E1 |- ?9 k. s% e8 R  e8 E                .release = led_dev_release,
. ]: _+ N2 i* _3 T# M# e        }
% {5 Q( q7 C; `  e& h1 I" h  U};
8 x2 z  f5 B2 c$ z% W( }4 Z, t/ J  r- R3 z
static int __init led_platform_init(void): K' O. w" s+ X. E! I$ }$ y4 G( D
{
$ a. z7 k/ y1 I        int ret;
2 n6 X, a+ v" z& r3 i#if 06 P% \3 m( R8 y" s% |8 E  y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" J& |  F$ h7 W5 V, M: l        if (ret)4 O5 K5 g, [+ ?6 V
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 G( b& t1 J6 q4 n
                                "%d\n", ret);; Q2 r! H: K' \, U; b! W' S
#endif6 Z$ j8 e+ `) f0 K' a, b
        ret = platform_device_register(&da850_evm_tl_leds_device);
( u. l1 H$ L. b1 F  f# f        if (ret)
3 n  z# {* Q9 S: W- n5 W% j                pr_warning("Could not register som GPIO expander LEDS");1 b/ I. N4 X' }0 G3 ^
        else' e# ~, H+ {. @# A+ ~
                printk(KERN_INFO "LED register sucessful!\n");2 ?7 i2 S1 d- V# ~$ S
1 G+ x( u4 d" K5 H
        return ret;
  f  _9 |& ^( w: e7 _}1 F% R9 G0 w9 i$ {/ M4 G

7 p5 P2 A* ?* I2 J! Xstatic void __exit led_platform_exit(void)4 M, ~: M6 s; l) p1 K& M& T6 l
{
$ V0 Z- _9 q4 Y, X7 `4 S9 |        platform_device_unregister(&da850_evm_tl_leds_device);* \5 H8 P' T" }+ F. x( W
1 Y" a" v* ?8 u+ y8 t! a2 I
        printk(KERN_INFO "LED unregister!\n");4 p# s. R, U& L/ @
}) i* l* o5 |  M* a) d  F) U

. W, x' ^$ S2 S2 imodule_init(led_platform_init);) X# v6 }4 b6 W' e
module_exit(led_platform_exit);
& i4 o  o2 `9 ~# [& L
6 F  A8 X; Q3 k4 o7 o$ oMODULE_DESCRIPTION("Led platform driver");
9 s% _/ s9 w  O) p1 L! I" TMODULE_AUTHOR("Tronlong");6 s3 m  N# N) ?3 f* U# i- z* x
MODULE_LICENSE("GPL");& L( z0 i2 m* M0 Y( ?- F6 X
2 S! k0 d% D$ M9 @7 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-14 01:05 , Processed in 0.037896 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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