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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 l$ v3 j2 y+ }6 s: m# l
#include <linux/init.h>
$ L2 G* Y4 \0 ?! d8 v#include <linux/module.h>) S, k% E/ Y1 B, ~8 n$ j9 c. h
#include <linux/kernel.h>: X* a6 D* Q+ F
#include <linux/types.h>: a, C, D: N& ]! @7 \2 v
#include <linux/gpio.h>3 n& d+ C5 V$ t
#include <linux/leds.h>9 V% P/ P' p. G. z" Z9 ~- y
#include <linux/platform_device.h>
* `: T/ R  A* J1 p% l) B# C; V
6 `% [8 l& x8 Q, C#include <asm/mach-types.h>6 T8 j6 C) \8 j% ?4 @- ?" J
#include <asm/mach/arch.h>
. y& k7 O. m# Y: X6 `# j#include <mach/da8xx.h>
' Y0 }3 a6 l7 p5 z. ^#include <mach/mux.h>
- Y2 G! V5 }8 B" P4 i# Y
* l7 e$ d  x. ^, H3 Z- Z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 `7 s. Z" ~7 V6 D3 R! F4 F+ w
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- l& l/ L3 }5 [) e#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)  _. a' y/ X& d
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ o: r! Q6 F2 @. l
, O' J  o; I, h; m
/* assign the tl som board LED-GPIOs*/2 Z+ n( n! m5 N# x
static const short da850_evm_tl_user_led_pins[] = {/ v" S+ k8 P4 ~, [+ b3 U, r1 O
        /* These pins are definition at <mach/mux.h> file */
# d3 |" R; J/ d! N$ L: q        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- J; P% N' ?9 G' Y        -1
, ~& [* }% Y2 K$ r) o};$ J& {" v# X: |( h8 Y1 \. g* m4 G  p

' {. u0 t  s: @/ L6 D$ `static struct gpio_led da850_evm_tl_leds[] = {
- b; o9 ^+ k& ]6 K* J0 i8 m8 F3 _        {
6 |7 D5 H% a. l: b                .active_low = 0,
; R  W$ b6 R$ J                .gpio = DA850_USER_LED0,6 G/ x4 `7 }2 b! O9 l# w  m
                .name = "user_led0",
' w& }# r) @3 c6 O7 X6 i                .default_trigger = "default-on",
% q9 F7 O2 s4 X" M        },
7 [& T6 n' C5 H* i        {1 P5 s  ]+ ~& H9 _" F9 N! U
                .active_low = 0,
& \2 _# l* ?6 }9 V! i3 S9 X                .gpio = DA850_USER_LED1,
4 P/ x5 ], J) q+ M                .name = "user_led1",) ^. s. n3 ?0 Z! M- z
                .default_trigger = "default-on",! l% t; D0 ?- H! U# [& t, C7 S) s5 W" q
        },
" c0 S, Y& v/ ~0 V3 X        {
4 n/ h% J% {( G! K+ J% E- f! u, b                .active_low = 0,' Y0 u$ f& i/ }7 B, h* j0 l
                .gpio = DA850_USER_LED2,
- @$ ~7 D) X" N6 f2 E                .name = "user_led2",% t6 j$ D+ u8 C# r; H
                .default_trigger = "default-on",
9 @# V! u8 |% \8 M9 G        },
1 w/ d  |6 {# t4 g        {7 ^! f' a0 [# y4 C! O
                .active_low = 0,
8 }  A3 E1 R5 l7 Z# e$ \! `1 l7 U                .gpio = DA850_USER_LED3,5 j% G3 v& V0 k! p2 r" b& F
                .name = "user_led3",
1 o5 t1 a9 [/ ]" g1 g                .default_trigger = "default-on",
) C4 e' M1 l* S: T( s6 u        },+ [  W! _+ [. h
};+ S+ O& P+ t) X8 u9 P; L; S0 Y

) w* U( o* X7 ?9 i1 `% n3 i0 M# |/ S: S0 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 N& _: T/ ?  g4 m0 w+ k" [+ Z- l        .leds = da850_evm_tl_leds,
) j$ b( o; w5 t' a' Y# v; E        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 E" R$ j. H- ?, @};
, z% e% G0 o- a5 e2 X4 l; s2 z* s. p6 m+ D, s2 J7 j. G9 s
static void led_dev_release(struct device *dev)
# _6 X2 x. o0 r$ h' [/ t( V7 d# b6 x3 L{
! C5 Z- w4 U/ b) D+ N$ ?& p" s4 M};; {, w' X0 w/ R2 Q' U# ?
6 L" i; y6 F% ]4 }9 E
static struct platform_device da850_evm_tl_leds_device = {- Y' S2 T  k8 v+ u# |+ l
        .name                = "leds-gpio",
5 g' Z/ x& j/ P/ Y3 z+ o0 Z  X        .id                = 1,; ~6 E" O, A! I7 u* L0 d( ?6 x
        .dev = {
" B( i" w0 m+ S1 c8 T* S                .platform_data = &da850_evm_tl_leds_pdata,
0 V/ Q/ z; h8 m7 m7 ~$ n                .release = led_dev_release,
& p' p9 C) P+ a4 d$ g5 s# l        }* }* R. \1 X* \2 s, h$ ]
};* i" f, t6 e" U7 n/ N
) b- g! ^: {3 _$ L$ s* X. S+ k
static int __init led_platform_init(void)
' X8 |. E( M  d+ V) q) G{
) m# N  r* j; |) y( K2 Q        int ret;
0 \! C8 F  U  M, Y  H% {#if 0
6 V- J2 }' }9 J+ b5 G9 z8 r        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
  `' N$ x4 U1 N8 M: o* Y4 }        if (ret)
+ X4 t. j7 {: Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* a8 k& N" q5 r3 r% q6 M3 h
                                "%d\n", ret);  F0 H& O. a. d
#endif
: G6 G  d* f3 V) J& k        ret = platform_device_register(&da850_evm_tl_leds_device);. L! z0 q) h3 S2 B" z( n2 f
        if (ret)7 F8 u: T  f& X* a1 U
                pr_warning("Could not register som GPIO expander LEDS");
9 _2 X. z: |9 }        else
- B; N3 q; G8 I  o$ {1 ~                printk(KERN_INFO "LED register sucessful!\n");
' y1 Z0 |1 u! \! P5 o. a3 N  h: u- K7 e
        return ret;  ?5 n$ r1 f/ `
}
6 Z4 v$ }1 I1 @6 K9 k( W
' L4 K+ [& k* Gstatic void __exit led_platform_exit(void)
- Z6 a4 w% ?8 x{- ~% q# y7 ?) f  _4 p: R
        platform_device_unregister(&da850_evm_tl_leds_device);6 `, w9 s$ s, f, `0 O
1 b) x/ O& `* H& A. m+ w; H
        printk(KERN_INFO "LED unregister!\n");9 ^1 m. t  o( O. c4 l: T* q6 l
}
3 r+ h7 J4 n7 D9 h8 r% i
* e; J. J* `# k  z' d* Lmodule_init(led_platform_init);
, z) V" _( a7 s+ a8 {module_exit(led_platform_exit);6 E0 B* {* ]+ P2 u

$ E/ F) j# z2 m; @) A& {) |4 ?$ aMODULE_DESCRIPTION("Led platform driver");
' \) U2 e- B% p, {) xMODULE_AUTHOR("Tronlong");
. Y# V7 W, L1 m+ p/ ?4 uMODULE_LICENSE("GPL");. ~5 j( y4 h4 d7 i' t
+ ~5 h7 f' _! t" n2 O7 G/ }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-9-23 11:54 , Processed in 0.040680 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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