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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 J* C7 ~# ]" ~6 x#include <linux/init.h>
, ]% o4 k: N3 v2 @#include <linux/module.h>
8 N$ a) }8 x& q) S9 e  F! _#include <linux/kernel.h>
# e% P% {; y( Q$ E#include <linux/types.h>
8 R3 I# {* A" d8 n5 c#include <linux/gpio.h>" P# g3 \1 G. O2 m: o
#include <linux/leds.h>  [0 e. M0 b8 z  U6 c
#include <linux/platform_device.h>
5 n' y! B! s' |4 n, K7 w7 e
  }& }( R0 V/ [$ C, ?* E% R% k#include <asm/mach-types.h>6 ?9 }# B* M7 u" d" T
#include <asm/mach/arch.h>
9 \% K4 R$ ?% P#include <mach/da8xx.h>
: r4 A/ \4 D& S* x1 J# J; ]#include <mach/mux.h>! s9 e, \. D# m

9 K) u: ^4 j, C- n  K" L#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* s) ]/ v) z" n#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- f( w. \6 b9 O#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 u( o9 r0 s! n1 M& {# C( a- }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# Q: Z3 s0 ]' p0 |
$ y: ~& W0 P5 t/ D' D/* assign the tl som board LED-GPIOs*/
+ F# e# ]2 ?& |8 `9 X3 Fstatic const short da850_evm_tl_user_led_pins[] = {# u9 |  `) D. ?' L' |. ^7 @
        /* These pins are definition at <mach/mux.h> file */0 Q- f" Y) c9 w0 \6 O
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  H: t' I5 K8 R
        -12 {+ |: q# U$ x
};+ g8 d7 a8 k) B
. K8 ?+ n, c4 q- N, G
static struct gpio_led da850_evm_tl_leds[] = {# d7 c1 F3 u3 z6 F$ v
        {
4 T' s, R! S# n- R# U1 F- v6 h$ Y                .active_low = 0,8 V; L8 U; t" |8 h- ~6 A
                .gpio = DA850_USER_LED0,& ^4 V, |0 C: L: ?0 u: y
                .name = "user_led0",$ N, F5 ^3 k+ _. G: |; x' y. D
                .default_trigger = "default-on",
0 \" ~7 H+ s1 a& I1 b) \- Q        },* t# W" n' [; h3 @; |3 T
        {, t( d3 @* [% V; B
                .active_low = 0,
# H, @7 q  I0 Q  Z                .gpio = DA850_USER_LED1,
4 k6 k; X) X7 n. R( z( R                .name = "user_led1",
% {& P! ]6 _% W) T                .default_trigger = "default-on",
1 h  _) E1 _8 d" m        },
9 y! F1 o* h8 Y7 }2 ~. ]        {
* p5 ?7 @% H; C                .active_low = 0,3 U+ ~1 @% u6 k/ n
                .gpio = DA850_USER_LED2,3 ~1 a6 R# Q" @! s
                .name = "user_led2",& @5 ?# Q6 T8 S
                .default_trigger = "default-on",
8 t$ G, x* }4 |! P% g2 G        },
- X2 F% X0 [# A- u, \: F' B        {
, p: r- c5 x" K) Y6 m                .active_low = 0,( r9 G! t& k- S5 r4 B
                .gpio = DA850_USER_LED3,
; ^  X- p& S. p# [5 q                .name = "user_led3",
8 V; g5 c! E6 g  _% ~2 F$ r                .default_trigger = "default-on",  j4 e5 C+ [; j  p+ F& K
        },
+ e- @7 h  d& P, i6 h0 O};
( b. Y- Q9 I! D, N
+ @3 Q0 h* Y% a2 k9 d1 Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ `9 c# X+ {# R+ N& @  D        .leds = da850_evm_tl_leds,
4 A& }/ j3 u3 Y& C" q, I2 j* P        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* H5 Q! z& Q6 K- l  C5 P9 f; o
};
* W3 g9 A' @2 M' q6 F- U2 [# i
+ Z5 f/ B  z' q3 o$ [. }static void led_dev_release(struct device *dev)( _4 d- R6 E* X2 f
{
, k0 h! v; u. Z) b7 @7 g* K- e};
" }  q7 q* R; M- {: m3 R2 d0 k+ p4 y9 z; N5 G) ~+ n& f
static struct platform_device da850_evm_tl_leds_device = {
; ~! L7 \) m$ L* A; Q        .name                = "leds-gpio",
' j6 x1 t0 D0 `# `, Y7 U        .id                = 1,
8 }' g; g" a/ Q" h( ~        .dev = {
* p: Y! z/ A- n& Y- ?! f                .platform_data = &da850_evm_tl_leds_pdata,
$ T. Q: q9 [/ s9 B3 u: P                .release = led_dev_release,5 V% G+ q1 z5 L: d& f7 s. R; }
        }% I* G1 F: G  t8 `
};3 h* q0 ~% o4 G# ~: M  {8 t
9 u2 ?* l( m3 i! Q3 {: \5 v
static int __init led_platform_init(void)% ~6 O/ A" O/ z0 t( X0 L5 F
{; r' v8 T, C" K! v+ q/ E- t4 X
        int ret;6 t$ R  n# G: c: G
#if 0
8 B. s3 }6 ~. e        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ c& I/ _1 r5 s* j: ^) g7 ~        if (ret), E1 z2 a# D4 W: i6 N0 D/ j
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- [4 b: D- l" _& Z4 a
                                "%d\n", ret);! S; s& S+ C, S. d4 H! w$ v
#endif
' i" G7 u$ g) c" \5 Y        ret = platform_device_register(&da850_evm_tl_leds_device);
) K! P; D" v9 D  J0 p5 l        if (ret)
2 d( [% i) u0 [- J* f: |3 t2 V                pr_warning("Could not register som GPIO expander LEDS");
) G7 z+ ]2 i5 ^8 w        else1 s: k, X5 R# C9 M
                printk(KERN_INFO "LED register sucessful!\n");; a( ~* B! f4 F  U$ C

# h1 r/ d& f: A; b2 ]1 y4 o% K        return ret;0 ]$ o# G: h9 r2 T
}
. t, ?% E9 {3 D  R0 w! U5 V2 P, ~! `( N2 b+ f- w: j  P
static void __exit led_platform_exit(void)- t& ?# W( ^  U( K
{/ m1 d* [, y) d; a
        platform_device_unregister(&da850_evm_tl_leds_device);
9 P4 ]$ O4 C. W( q
- R" J( h% v2 w. x0 ]        printk(KERN_INFO "LED unregister!\n");
  R! V. e, x) o3 E2 T( r& ?% [9 V# `}1 I; o7 H7 F) C' n3 [: z0 M
4 u1 V" N- E* K1 O- [. s$ p
module_init(led_platform_init);
; R$ X6 U. L& e5 `5 G. c! N0 @module_exit(led_platform_exit);
7 ~' n; f0 E/ @, f1 P) Z* u2 P# c* R
MODULE_DESCRIPTION("Led platform driver");
6 v. L0 }9 _5 b' {MODULE_AUTHOR("Tronlong");
1 V: t" F+ X* l2 qMODULE_LICENSE("GPL");7 H- q, u) }* x5 D' B
9 ?+ U! b0 u: r6 B; B; W$ c  J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-20 23:27 , Processed in 0.094295 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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