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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 o1 {3 s6 w* c7 l
#include <linux/init.h>  V. b- @2 S) {# n3 x5 S/ e
#include <linux/module.h>
9 ]4 H9 P. P8 Z# Y) f- Y2 ]3 ?#include <linux/kernel.h>( W3 E* P# Z4 w! j* _
#include <linux/types.h>
+ C& }* G0 T4 Y+ Q4 ?#include <linux/gpio.h>$ I  ~5 t/ O/ O
#include <linux/leds.h>4 m( X- a+ }6 I% }8 K
#include <linux/platform_device.h>
" d! k1 I0 l3 d: B  g7 o" P% K7 V% H  c' u
#include <asm/mach-types.h>
2 u, `: d; s- a#include <asm/mach/arch.h>
/ a2 @3 @; o2 C, ?#include <mach/da8xx.h>
/ }  `$ t6 H9 z#include <mach/mux.h>
* W, d: s7 f0 X: v' g! o& S9 Q/ H4 k8 g$ q$ c9 x- J
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) j, `% M" ~: W8 J: ?0 v+ }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, G" w+ p" H. `- D, a" S#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 w- ^5 ?8 s9 R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
3 T( d% }0 R4 y( |
( L) }. o9 W- g0 L1 G/* assign the tl som board LED-GPIOs*/4 H& n# U( _; g* A9 X. S
static const short da850_evm_tl_user_led_pins[] = {7 w9 h8 A" v2 W, K; E% F+ x' ?7 Q' \
        /* These pins are definition at <mach/mux.h> file */# o( n7 Q7 w$ |+ h% i: T/ z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 f4 ?6 v* h/ |# v. m# l% f6 K        -1
1 m2 u1 c% v' p};$ `* i# z* w/ M0 T& S7 u+ w* E" _- h
* S, \9 B: r2 N( X) h6 B
static struct gpio_led da850_evm_tl_leds[] = {
, f/ O" _& F" \) F        {
% b% Y5 R) T: D- I/ W" F                .active_low = 0,
5 O: z3 Y- v5 d                .gpio = DA850_USER_LED0,& h7 o  P' F: j" @
                .name = "user_led0",
! }$ t8 _( K) H8 k                .default_trigger = "default-on",
' x: h7 g& b: }; b- c        },
, \. |% S0 M) @/ g        {
" x. d- m. I9 o/ k# k: w4 Y) P                .active_low = 0,8 t1 f9 e/ _& n9 q  I
                .gpio = DA850_USER_LED1,) O/ y, N+ J3 R" n( W9 r+ J: @# n
                .name = "user_led1",
( q( D* `# I& ~; ]5 z3 v" U                .default_trigger = "default-on",
$ m6 p$ E  O5 b        },
3 I4 x& q% M; |% Y        {7 }/ h% \8 b! U- n
                .active_low = 0,7 x' p  X$ N) ^
                .gpio = DA850_USER_LED2,/ I+ \* l# f; H. J) Z- \
                .name = "user_led2",( n( s+ s. a! Z+ I9 B
                .default_trigger = "default-on",: b6 `! p- z( R$ s; [( o2 r3 {- s# A
        },
1 S. `4 @$ u8 F: m        {
8 u0 o6 p7 p8 N                .active_low = 0,: o( Y4 ]+ S6 H
                .gpio = DA850_USER_LED3,
" e5 Z! Y/ {7 l  B$ c! N                .name = "user_led3",9 X! r% y& a& d: W9 |( n+ t
                .default_trigger = "default-on",% A5 c6 b( |" ]/ x
        },. t4 }2 Q8 ]4 {" }, a# S5 x
};, w) |" x* J# E1 D: P9 m* [/ {- O
1 u1 {$ A' ?: o2 b8 s" k; w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ ]( a1 c1 y4 ~8 S+ V        .leds = da850_evm_tl_leds," G# {3 O% _0 c/ `9 u9 i+ ?& a
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, H* \2 _, Z* B3 Q, }};
1 D4 ^+ Z) r2 m) L2 V: q/ w$ {0 [; J/ g: q7 E3 R/ l  o8 U% _
static void led_dev_release(struct device *dev)0 I/ A& ^& s! K; m
{" ?8 w) ^% s& f( L) p( ~
};; h% T! h; W4 @* {: X4 t

8 z5 i# N0 Q- q/ e9 A# ~7 ~; [6 cstatic struct platform_device da850_evm_tl_leds_device = {+ O/ v9 l0 c5 s% Y9 i* L3 ^
        .name                = "leds-gpio",
% Y% K8 K9 X$ k. `( U. \) K% w        .id                = 1,( _0 @8 g; f( V5 X
        .dev = {- a6 v: c3 Z1 r( w
                .platform_data = &da850_evm_tl_leds_pdata,
9 C- P& \* }1 e1 R2 ]) Q                .release = led_dev_release,+ a& d) H1 i& J" b
        }
5 S( _- z( U* `0 {! [- N};. q* c, r4 c: ?- f1 }5 s$ c+ E

, u2 C( O$ ^6 O4 C4 Qstatic int __init led_platform_init(void)9 u, v4 P7 k/ \: r+ p& E
{
! F, {5 h* t* p4 P, v        int ret;( y: g& O. n( M( `. C
#if 0
& t/ i; A( q* A; n        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& S4 o+ p( I7 k! h4 ~7 E- m        if (ret)
8 j; R$ I0 b9 l& K; Q$ S                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 V$ D5 u8 ?( X* I9 z% p/ V
                                "%d\n", ret);
  y6 w0 V. y' r( W% L6 A. S#endif$ k8 `( w$ |% [1 t8 C8 w/ m
        ret = platform_device_register(&da850_evm_tl_leds_device);
3 J1 Y; ]* O8 ~7 s        if (ret)+ G# n6 [/ g9 }1 C- M
                pr_warning("Could not register som GPIO expander LEDS");% C& D) ]+ d* k- w2 t
        else
' K( l. Y& a0 R4 U+ `' M5 `0 I                printk(KERN_INFO "LED register sucessful!\n");
" }! f4 {3 F3 E6 n) t: B% Y3 H4 c6 w( ~
        return ret;- O  Z: [6 V1 m: L% b0 |: T1 P1 D
}. H" `  {, t: O" V) f+ v( E! t

: X& E; A& z! _- o  wstatic void __exit led_platform_exit(void): X/ s. w+ u6 p& a
{3 V+ Z  T1 i3 R5 `+ \3 Y6 X
        platform_device_unregister(&da850_evm_tl_leds_device);
0 F% k4 m! E0 U2 c' p/ ^( X, q1 j/ p& `8 b
        printk(KERN_INFO "LED unregister!\n");! p7 z7 a/ W2 f* L
}
4 A- N9 f! D! h& R9 W9 q1 I' N% Z3 j) [/ @, a" q$ _1 K
module_init(led_platform_init);
6 P. A' i- O! d9 k( w# wmodule_exit(led_platform_exit);, b! G+ D4 n+ R+ h

! n4 F& h- C4 [MODULE_DESCRIPTION("Led platform driver");) P! a! c% O- x( z! \8 j6 r
MODULE_AUTHOR("Tronlong");- ^* r  p) n; G& t6 h
MODULE_LICENSE("GPL");
+ s" }9 \' Y: S, |. s( L5 O3 P+ w# V( u0 T' W+ w
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-11 00:57 , Processed in 0.042655 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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