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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 d1 ?1 Z$ [5 {; A2 f
#include <linux/init.h>0 x: g9 ]* Z7 T
#include <linux/module.h># @, s6 B" T& M; T9 T9 `3 l
#include <linux/kernel.h>1 }; M  F# y7 y, V
#include <linux/types.h>+ j' U- `4 ^0 a$ R$ T
#include <linux/gpio.h>
% U. K, q# W- g- o$ I, _#include <linux/leds.h>
- p+ D4 q1 Z6 Q0 U/ T#include <linux/platform_device.h>. _3 R% i2 }, t( e+ E& l
6 q4 s/ L: R: _* ~' ^7 \5 h
#include <asm/mach-types.h>  U: j, X2 ]# y
#include <asm/mach/arch.h>
( v/ j9 }1 F, ~0 @8 H#include <mach/da8xx.h>% P- f5 [0 V: n% Q
#include <mach/mux.h>/ _4 }4 P/ w8 h- @

. a% O8 K! _7 C0 C  `#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* C0 U. x! f# }5 Y  F6 F#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 j' O8 r8 }2 Q3 E
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
6 m' m+ [' q1 O9 G7 A#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. h2 d$ j8 [# w( v) r; u
( E6 N7 `/ L5 x/* assign the tl som board LED-GPIOs*/2 k0 ^% d% F7 m: s; S0 Z
static const short da850_evm_tl_user_led_pins[] = {3 x- I% k8 j5 B5 \5 q2 y
        /* These pins are definition at <mach/mux.h> file */
' ^9 Q' w( y& ?# `( s' N3 e6 s: |        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 ^5 V! J. @  q. Y1 C+ Y        -15 ?- P7 `8 p  A6 ~/ \# x
};
% ^& N3 T0 U" K& k( @6 D5 _. g: M( [! N$ I; S' |; R
static struct gpio_led da850_evm_tl_leds[] = {' \( M1 Q! i5 j6 `6 K, ~8 ~
        {
" @. y9 ~0 P! ^                .active_low = 0,' U9 R" R* ?/ T' ^2 G8 I
                .gpio = DA850_USER_LED0,
" e/ [9 @  k, a0 m# e" n                .name = "user_led0",
, c# ~( J( k& B3 [, E                .default_trigger = "default-on",4 O) x2 ]: ]1 x6 R6 O% U# d
        },
+ Q+ U7 a9 z& l* |, y4 ~. m        {
8 X- A& j  K( F. t# F# {                .active_low = 0,
7 [! A9 @7 m; R: N' Q$ R. D& L                .gpio = DA850_USER_LED1,
- K! `  J3 f. Y7 m                .name = "user_led1",5 i9 F/ D  Y7 t
                .default_trigger = "default-on",
; D. Q) T& h; m& _* D: I; [$ H5 ~0 l        },' |/ u' v0 X3 |/ w/ a
        {
) ~$ U% G/ C7 ?* ]6 a- `8 e                .active_low = 0,3 N" w. l/ J+ S- h( r( S
                .gpio = DA850_USER_LED2,
1 [5 j% u/ U6 T  O% q$ A! T4 m& J                .name = "user_led2",2 \; f5 }! \+ c4 Q
                .default_trigger = "default-on",
; c3 x% ^. D2 o3 _2 }        },
0 N1 `3 k0 w8 g' ~  f        {2 \! a* n2 u" ?( G% {2 ^' `/ G
                .active_low = 0,9 _, M7 E/ [& W3 W$ }
                .gpio = DA850_USER_LED3,3 ?* ~" O, [, Y7 Z, ^* K9 `
                .name = "user_led3",. p* c, u  s- p  y7 i7 W
                .default_trigger = "default-on",0 v; P1 Y5 f5 B3 L7 [7 c$ x7 ~+ Z$ M
        },- T* G6 Y6 w: H4 w9 U) _
};- O0 R$ K1 M  u
+ S6 ^% j* M5 w6 d2 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 b" G: t  L/ n0 \/ O! d- ^        .leds = da850_evm_tl_leds,/ ^9 Y+ B+ m& @7 j
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 ]% e& |" Y5 N# _5 d
};
3 X4 r* ~- o" h( a* g! R; ?/ y# O9 e; ^& Y1 q( Z
static void led_dev_release(struct device *dev); u/ ]7 D. A: J1 S% |; p
{1 L/ d* W( Z2 s
};0 z( d! h. @" p- h# j* c3 {/ L

% |! K9 y; m3 u) z8 Y: Z; vstatic struct platform_device da850_evm_tl_leds_device = {
/ y  V* R7 j, F" |7 |: W. u        .name                = "leds-gpio",
5 S  H3 E  {, H8 F& l5 [% A4 {/ M9 d        .id                = 1,
: s# P& f1 I$ c7 y        .dev = {/ z" Q) g+ R" A3 T; x: ?7 U
                .platform_data = &da850_evm_tl_leds_pdata,
* O' H, c! k" x3 `. g% M                .release = led_dev_release,
9 _. n: c9 G6 }; ?! U8 w6 i" C        }
4 J- k. R# G/ J/ x: ?};6 I' K. v! Y- x8 E/ E9 o

1 R7 t  c6 v) r1 o  i) y" Ostatic int __init led_platform_init(void)
6 N5 ?8 n  T" }4 j0 d{
- G5 z( n8 g9 c# g- b. T! C        int ret;) I: l0 P7 N2 R
#if 01 ^8 i; |1 u6 a( S
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 ^  q3 m+ ~& m        if (ret)
& E0 e& p  ]8 d' e) |                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 v+ Y9 D* e# b4 x! P" K' |
                                "%d\n", ret);- Y* e9 \% g# `3 O1 ]
#endif0 e1 ?0 m7 K) ?: g6 i/ x7 C& e& \/ G
        ret = platform_device_register(&da850_evm_tl_leds_device);
1 H: m( h- M2 z9 P! I) Y* c5 J. g        if (ret)2 N  z0 r- g1 d( v
                pr_warning("Could not register som GPIO expander LEDS");
0 k4 w5 L1 n" X5 z        else
: w, \3 z+ r3 X; m2 c                printk(KERN_INFO "LED register sucessful!\n");4 r$ W  G! n4 E$ ]
% [# H+ J) |  z9 L. C8 K2 I
        return ret;: _; s5 D3 _9 p0 i. A
}
0 R3 T& i" {' @' E+ y/ [
6 u# @: ~  E; D" Jstatic void __exit led_platform_exit(void)
7 N! d9 N7 M3 S0 a{
, ]3 `* M# d6 Z! G) S, ]3 @        platform_device_unregister(&da850_evm_tl_leds_device);
6 [8 T5 M; f1 H7 j% T# E) i/ L7 z+ ^% d  W3 c. B- a7 t" F$ a
        printk(KERN_INFO "LED unregister!\n");
& {+ w9 ~8 l5 P: y4 o% V}  f3 j6 @0 n( b2 S

- U/ Z/ m* Y+ omodule_init(led_platform_init);
1 i" X$ }% g, k/ mmodule_exit(led_platform_exit);
& e1 @$ X0 q' U$ E9 F; Y
) a+ l0 a0 I" s, [; O) H8 A; M" }7 BMODULE_DESCRIPTION("Led platform driver");
9 f: o0 d9 ?; G" f" qMODULE_AUTHOR("Tronlong");
% a3 a! x1 E6 q: [" J6 m3 SMODULE_LICENSE("GPL");& X# e1 P+ p8 }, P
+ N! l1 |7 u* r% j
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-28 07:45 , Processed in 0.036846 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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