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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) D, M( r3 f" U- ?6 }5 o#include <linux/init.h>- N8 y: s6 P* `* U5 P
#include <linux/module.h>
5 ?& ?( u* z( `8 \, ?; c  Y- _#include <linux/kernel.h>
$ d3 C% p% {" F" C0 ], J% G#include <linux/types.h>
/ O8 V9 N0 N  c5 v0 k& \#include <linux/gpio.h>3 F7 N. x, Q$ H* _1 R1 ^( i
#include <linux/leds.h>
& t( y3 t; W! e#include <linux/platform_device.h>
6 L0 _! t; l$ ~5 w  s1 n* P
: S0 g) T& s# M5 A: X. o$ Y; I, X#include <asm/mach-types.h>- o1 t, ~! Y# ~9 w, J
#include <asm/mach/arch.h>
: M' V, }; X) k#include <mach/da8xx.h>
# c. c: U( j& _% D; a, m+ j#include <mach/mux.h>
3 S9 Q3 {1 y8 x, Q0 f+ `0 H5 `4 E. J2 a2 R7 V; o; l
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- E! h& b4 v& f$ h) P# X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
% d" B2 x. l" C3 f  ~#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
6 P4 f6 G( r( }2 P& K7 h+ X2 k#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) Q8 P/ c6 u3 \/ B0 }" Z
4 Z! S" t! o% E0 r3 C* p# @' T
/* assign the tl som board LED-GPIOs*/
% f. L! M$ X% ustatic const short da850_evm_tl_user_led_pins[] = {
# B1 @7 _) k8 g" g; C        /* These pins are definition at <mach/mux.h> file */. m" O* k( w( F) v! W
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  f& g. N8 Q2 J6 l- m
        -1. X8 r) [' P) m6 T
};' _0 |9 M1 T; _

2 B, c' c- T* t) Q' O  m, xstatic struct gpio_led da850_evm_tl_leds[] = {0 E. M( `& {9 \) P' ^# R4 z
        {
$ f: `5 ^1 z' L, c6 U- ?) E                .active_low = 0,
' E4 g! T* J  N+ X/ Z& t1 g+ T                .gpio = DA850_USER_LED0,( m2 T+ ?* w; d+ U
                .name = "user_led0",; J2 K$ G( o1 H- O
                .default_trigger = "default-on",2 F5 C. r- R- i6 c9 N4 L* R
        },3 b( W8 h5 P  j" x
        {
6 u: B% K3 k) Y; y5 x                .active_low = 0,
" \" A* e6 _; G                .gpio = DA850_USER_LED1," i' j9 |" G( e" U/ v+ ?+ ]2 ^
                .name = "user_led1",
5 E% L/ Y! ^2 x                .default_trigger = "default-on",
1 [, ~# g! |" P: `, E9 p, \9 a! N        },  @( u0 `" @$ ^
        {# J; R) `$ t% g1 b( C  U
                .active_low = 0,
- g7 H# e% n! n+ x  h4 |                .gpio = DA850_USER_LED2,
# Q: H1 s2 t4 ?                .name = "user_led2",* p+ Q3 L  Z: \# F+ ?
                .default_trigger = "default-on",1 N& T% P( p3 v
        },
. Q! A" c- K9 E/ J/ H        {
! A% n- u' r# F+ ~8 Y                .active_low = 0,1 B# ?% y/ v- ^- p8 a: |. }' B( t
                .gpio = DA850_USER_LED3,7 [9 H) S, D3 J- X; L7 j( D
                .name = "user_led3",
- y" o- q4 u/ ^4 f: H' Y                .default_trigger = "default-on",
1 m; r: C& x( n) e2 X6 ^        },! B# T1 h4 i7 d( i7 t& D
};
: ^: |  X# z1 R1 K$ l$ z, O/ B; w( Z; t. ?) N* b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- O  l7 @5 d3 t
        .leds = da850_evm_tl_leds,* N/ r  C6 b" P  X
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: [' Q, l* c  I# J6 c3 p+ _
};
: K6 ^% p) A  ^+ F  D' d4 h# F) C% }; ?' K! U0 T
static void led_dev_release(struct device *dev)
8 d- k% A  o2 {! o- ]/ f) E1 E{4 h1 {- p* J. n6 c% l
};' Y" X9 \: e3 U- T  s
" Y: @/ F' m, e; M
static struct platform_device da850_evm_tl_leds_device = {& a3 x+ A( i  R. I: ^' q+ W
        .name                = "leds-gpio",. G% X+ u) g9 [7 c$ L% E$ w# L
        .id                = 1,
' M9 f7 @1 |4 @! U        .dev = {
( k* n* }; J, k- |8 e                .platform_data = &da850_evm_tl_leds_pdata,: W; Z) a, v! W& H$ y) C; R
                .release = led_dev_release,
" s2 B) D# n/ B7 w, @7 w        }* H3 t. x; {4 o) b/ Q
};
1 |! C: l% ?* u+ l( [1 _6 p4 e2 i. k& _8 o  w
static int __init led_platform_init(void)
. c( B+ v2 y0 e% J1 z1 I2 X3 J& v{
8 U# i6 l" V9 H* O' V! q8 ~7 L* y        int ret;
' e0 S$ J5 _1 K1 f" E; q$ \1 i' Y#if 0
, j1 W: ?2 ?% Y' A+ l9 S# p        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 L$ B! l# Q9 Z
        if (ret)
3 F+ o' r- ]) v; E, b                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" Q& o  k* Z0 V' }9 T                                "%d\n", ret);$ K3 m* @! E8 |8 m% L4 J
#endif
- p6 ^: y. N  D6 [$ P1 s7 Q2 H        ret = platform_device_register(&da850_evm_tl_leds_device);
/ c4 M$ h. y' J' H2 K1 H        if (ret)
, g5 n$ r: [# z0 a, J# q+ _: j; j                pr_warning("Could not register som GPIO expander LEDS");1 P$ p+ y, {$ @4 B* Q3 d
        else
) u, R2 l) O% _# E% e3 w1 J( B# {                printk(KERN_INFO "LED register sucessful!\n");
; p' }5 X/ T) T6 S; n4 @0 u' D6 c4 x, j+ b1 }% D. e
        return ret;
$ U" J# Y. r& A7 h* v8 o  g6 k}
, i) `6 k. ?( ~: U0 D
2 |& V- H3 P% q# A( D/ o8 o+ wstatic void __exit led_platform_exit(void)% _3 o( t+ v+ g/ Z8 _
{) ]$ P- C: M% L2 Q/ X
        platform_device_unregister(&da850_evm_tl_leds_device);
- _; t0 v7 x! }5 o! h3 S4 A& t9 v- H6 B
* ^+ o+ m# u$ s  L        printk(KERN_INFO "LED unregister!\n");2 e0 A8 a+ A+ O5 U, C9 r1 M/ @
}5 b8 c$ h% ?; ?. B
9 x; P! f& Q# b- C7 c2 V' u/ y
module_init(led_platform_init);9 v( ^+ j4 k/ v) K& t" J
module_exit(led_platform_exit);- V7 F3 {) O' s) t

- ], @% B9 \  A" b" ]8 XMODULE_DESCRIPTION("Led platform driver");( Y& }# ~" e/ J- ?# Z" o
MODULE_AUTHOR("Tronlong");
& E. z  @8 l+ T0 X2 e# a9 |) N# G2 JMODULE_LICENSE("GPL");1 P: n! B  `9 x% S0 L
1 x0 K' W5 R  ~& k5 v
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-5 21:37 , Processed in 0.038898 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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