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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 m& m8 l/ S( c: c1 o' R#include <linux/init.h>/ C% \4 J* C( W, g8 s2 [8 h
#include <linux/module.h>
; a, X1 N& p: k0 G$ n( R#include <linux/kernel.h>
- R& r$ c  K5 w' P1 r#include <linux/types.h>: B# F  U  x7 ]' l* Z0 P7 X& L
#include <linux/gpio.h>  U" M/ v4 _1 |
#include <linux/leds.h>
9 e2 c2 a2 D" I0 h" ~#include <linux/platform_device.h>
% O( y: r7 o4 W% p
3 e& C; H/ i' H" X#include <asm/mach-types.h>* g5 ~8 l4 `, ^$ W. }1 v! t
#include <asm/mach/arch.h>
8 g) e$ G+ ]" o% F#include <mach/da8xx.h>- l( `* c' O" |/ x# O  e3 u
#include <mach/mux.h>
6 r. Z$ e& t3 M( N2 E. N1 @
1 P6 b4 o# I- g2 ^  I7 _& I2 k#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)* t  L. ?( `1 ^9 E* l4 B- U; a
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 B! c/ c; z* a. q1 }8 o/ F
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 V! M" }8 U, ]+ [
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ ]' k7 Y8 \5 m- j) |: [6 i: S
7 Z" u' U" V* h  s
/* assign the tl som board LED-GPIOs*/
% c# s( z" @$ _, ?static const short da850_evm_tl_user_led_pins[] = {
: `# a3 `* G. T7 N        /* These pins are definition at <mach/mux.h> file */
' Z6 [9 a5 M. C8 ^( F' N( ~        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 v& C3 _% R3 [0 l3 O. o
        -1
0 C% J% U. h! x+ W$ e};$ y; z. r3 [( c9 Y2 A

& Q) \$ K- K# N5 n7 t$ C' b. Wstatic struct gpio_led da850_evm_tl_leds[] = {0 A# |* }4 z5 i5 ?& ~' J0 H
        {6 j3 E5 ~3 M# h6 }+ T2 p& `' i6 H
                .active_low = 0,
9 H& [9 m  x5 Y$ s8 P- i4 k  R                .gpio = DA850_USER_LED0,
! D* v6 ^7 c" U( r. ?0 j                .name = "user_led0",
: g* }0 U/ f! Z$ f. S8 ?  I) h& [8 V2 y                .default_trigger = "default-on"," k) j& j7 u9 {7 d4 ?
        },5 m- K9 h8 F  L) N6 E; [
        {
( c% n0 w& n) F+ N5 y# @" `! z                .active_low = 0,
! j# [1 `# R' z* _                .gpio = DA850_USER_LED1,4 ~  r5 J% Y9 s3 V$ `! j+ I- p0 I, B
                .name = "user_led1",3 p& a/ C$ m' q: H7 F
                .default_trigger = "default-on",; u$ K$ g" ?7 ~, {: o
        },5 A: o6 ?4 J/ L2 D/ x9 b
        {7 ]" \% ?, g( Y9 q
                .active_low = 0,
  \2 U7 [! Q4 \8 c! P                .gpio = DA850_USER_LED2,, x: B4 V% b! h( U3 s  O
                .name = "user_led2",
/ d5 f+ M9 `3 l                .default_trigger = "default-on",
8 X3 i% i* d. t& n, G1 s        },
8 V3 }% E# X; V* Q2 x' `        {2 j1 P1 G2 L+ y  Q
                .active_low = 0,7 Y5 J+ w) [0 H+ {
                .gpio = DA850_USER_LED3,  R- N8 ^( {$ F. ~' O; R+ Q
                .name = "user_led3",! @- O" s+ D" p2 @! k2 O5 h% Y3 _
                .default_trigger = "default-on",  T) N  I7 O0 [6 `! W7 {8 c
        },
( u9 Z1 U( T5 U3 q6 h! g  h) e};* @1 n' v  c% @) [- J  n
" i5 t6 H8 a4 U: f8 R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ [  h3 n: |& M# }
        .leds = da850_evm_tl_leds,1 R0 \+ D8 R' I; B7 X. }7 B1 Z, C
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' u' w* c: Q4 K7 w
};7 Y# V; C+ n; n' n) J* M* I

4 ]6 P  S& j5 z! astatic void led_dev_release(struct device *dev)5 v  k* ]0 N- }0 N3 |
{
8 i; R% E# M6 l& E& U2 t+ L; I};
9 X3 s7 j5 d; J- [7 |4 P: u' a7 x- ~% g- x$ p, t! j
static struct platform_device da850_evm_tl_leds_device = {$ b) A4 |! L0 g# ^5 c
        .name                = "leds-gpio",' i9 K7 l) q, r3 }
        .id                = 1,  l) m! Q: l7 Q+ H" m
        .dev = {5 ?% g$ L& m( p- [1 E) E% O
                .platform_data = &da850_evm_tl_leds_pdata,9 L; a: {' [$ t' S
                .release = led_dev_release,
' P' z& q* f2 A" b! ^' s        }
1 @: E/ P4 H' b};
( c- \4 M) N) A$ m+ Y# ^% R5 J$ [$ q$ _/ s# x. v
static int __init led_platform_init(void)
$ D3 k7 f! H0 D+ w/ k" z{
, Q. v6 [+ @( G2 e3 C2 \8 I        int ret;
1 y& _' p" ]& l' j3 Q+ }% K  g1 S#if 0
5 M. _9 l4 ?& _1 n; a% Q1 h        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 h1 N3 s# M' G; }: `+ F: h; a- \
        if (ret)
# D5 y  b7 m8 @* g; m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& M9 P7 Z- [! s6 T                                "%d\n", ret);8 e2 j! M& z; e6 B% f8 b7 v6 U
#endif
9 U! P! l) I8 O4 J& P6 Z; c        ret = platform_device_register(&da850_evm_tl_leds_device);
, h* }$ r5 G% b  p- r! L) N        if (ret)
  b3 T% }2 _# ~  t' T3 M* h! D                pr_warning("Could not register som GPIO expander LEDS");
# _3 K5 ^# h! O3 i' Z* ]. v' |2 U        else9 Q  X  n/ @5 M; D: T% A
                printk(KERN_INFO "LED register sucessful!\n");
' @: z+ g3 t2 j" W% B+ ?
1 L2 Q- A) R/ d3 [6 Z        return ret;
( o4 z% D  i/ v' m9 o, o}
5 V3 F  h/ v- Z1 L+ Y+ s& o, T6 N1 v* a3 q8 t) t5 d
static void __exit led_platform_exit(void)
+ N+ O  D/ |+ B8 k9 J{! A$ G% u6 m) p+ D) |8 x4 b
        platform_device_unregister(&da850_evm_tl_leds_device);
0 X; ^4 M% T8 v$ H( ~  V4 ?8 t& b* v6 z  i9 E& j& X3 _: K1 N
        printk(KERN_INFO "LED unregister!\n");! ^8 S; |& O( j# j5 A+ N
}
' l% ?) Z  n# \& M  w9 u  p  u( h' l* `/ k5 [0 B/ e
module_init(led_platform_init);
: ~4 c4 f7 y6 Z8 q# O, @module_exit(led_platform_exit);
6 ], z  f$ {# R1 e# V
1 `5 {0 B% a6 `: p" [/ @MODULE_DESCRIPTION("Led platform driver");; ?+ I/ |4 r: S7 c' E8 Q' M
MODULE_AUTHOR("Tronlong");" m/ I6 I2 R% I4 C5 Q5 D; O
MODULE_LICENSE("GPL");) r& F! \, l; r# i! `, y
5 X# A% K) `# w8 Z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-30 07:24 , Processed in 0.038849 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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