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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* A& d; E( m* k! q( A/ R; l
#include <linux/init.h>2 ]% A0 S: h9 U5 ?; p( @+ ^
#include <linux/module.h>! g! E. b* D% L4 @1 p
#include <linux/kernel.h>
/ K* k* a: H2 q" }  r#include <linux/types.h>
1 v; D# E% f0 I& n. b8 r* }#include <linux/gpio.h>
) Y' V4 s  x6 R$ h#include <linux/leds.h>" A6 x2 p1 V/ g
#include <linux/platform_device.h>
9 `0 t; }) h4 I) ]. B% f6 l$ u7 F1 ?4 B, g$ H: x# d/ t9 L
#include <asm/mach-types.h>
( b9 J: z# D: i6 M1 Z#include <asm/mach/arch.h>
% p0 J1 |! J% b#include <mach/da8xx.h>) N$ h( G/ l  M) [. X
#include <mach/mux.h>& K8 V! l+ {5 Z% x5 @9 w: d* h
1 _2 ^' C+ P9 s) F( B  t
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
- K( k0 A. q7 k" F2 f, N#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 f# D; S) Y" `( V$ h# b& z, x#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); ~  K& q- k' {
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
8 S$ G# W, U8 a. f- k* ^/ I$ c" D" I( b- R2 ]. l
/* assign the tl som board LED-GPIOs*/* n* y) d( I6 N$ U* d
static const short da850_evm_tl_user_led_pins[] = {2 k& a( I( n" H+ D
        /* These pins are definition at <mach/mux.h> file *// P2 _! a' V1 [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 ]& j2 w) T! M5 Y" S  A# U9 R/ w3 @        -1
1 @3 y! z; d) Y4 I. D};
3 |- S" L5 N# X5 Q! Q+ d# A3 U6 W7 Y' h+ u; X, `
static struct gpio_led da850_evm_tl_leds[] = {
2 ^. t4 w2 f* E1 o        {4 p: m7 J& |' l+ |5 J4 e3 ~3 |
                .active_low = 0,+ e( e; v' M* G3 o
                .gpio = DA850_USER_LED0,
  v1 i4 ]: U# v9 S: C/ \2 K                .name = "user_led0",
4 T, _( I* V/ V1 z7 t% k' k/ i                .default_trigger = "default-on",: x/ i+ t) v8 J4 z
        },
4 U# z& q: J. }: ?8 p6 ^        {! F- N2 i9 |) ?0 _8 ?; s% D
                .active_low = 0,) P+ h$ O0 K1 @% k1 e1 A4 K' r
                .gpio = DA850_USER_LED1,. A& O9 U$ W/ l, ^
                .name = "user_led1",
7 D9 G! ~8 l1 k7 K; t                .default_trigger = "default-on",
6 D/ j: |3 \- A0 z& J        },; O0 Z4 f! H1 }: m( O1 K5 V
        {
0 t% h/ @5 ^' o! V3 P1 A$ {  u; N) o                .active_low = 0,
8 k/ y" t( Z# |5 T  w                .gpio = DA850_USER_LED2,
# o. w9 A" o5 }9 j: ^, T3 X/ V                .name = "user_led2",
- ^2 O. E! h% R6 ?+ C; \% w1 ^                .default_trigger = "default-on",
: d% M# B$ o" O        },
& c1 E  m0 A3 F- M. W3 l        {
  }, m" q6 H: }5 ?7 A" w                .active_low = 0,
; t2 v' g2 Y- O7 w7 {                .gpio = DA850_USER_LED3,
) F$ n# M# V* _& w& }                .name = "user_led3",# z* `) P) g: \: }$ }7 ^% R
                .default_trigger = "default-on",  G. D; M, h% C
        },0 d8 f2 r1 A; d+ _
};% O9 o6 c" E. b1 y/ V7 t
& R, y4 v1 O, ^8 Y: Y7 `8 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 r( e: `$ R! l8 [! f3 C        .leds = da850_evm_tl_leds,5 g8 x) C2 \( ]
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ e" o7 r( c2 s6 N* i
};
. H1 A. |0 d: G9 N3 o1 S3 q& t$ Y
9 O- `6 P( z, q$ c1 lstatic void led_dev_release(struct device *dev)1 S7 D8 s" [5 j+ r$ {! o. F# K" ^
{
" V( `" w- n* C2 i: k6 O6 i};! f. _: I; }9 d7 U5 w, C4 G

$ _4 s; n% {9 V/ Istatic struct platform_device da850_evm_tl_leds_device = {9 d$ H4 Z) R. g+ W' D
        .name                = "leds-gpio",- d, N8 t# Q6 g# r/ F* I
        .id                = 1,
. i; h) ~) G2 g# }6 X        .dev = {$ F$ `+ g& y, O
                .platform_data = &da850_evm_tl_leds_pdata,/ [7 B: D9 J' q4 q, R0 Z3 `1 \9 \
                .release = led_dev_release,' c1 T3 O0 k* `- @0 Y# W
        }& |- K: O& S, m& L( B/ `
};5 J5 [5 @" O5 U3 h5 V5 e# T) `
1 Q! D% A" W6 g3 P
static int __init led_platform_init(void)9 y6 V( i! K+ p$ R+ B; V  z
{
+ m2 o/ D% g2 c% {/ j# y# M        int ret;
6 {+ U$ S7 q$ S/ Z#if 0' y5 D  M7 {* N" h( H
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" `7 R9 y; i* r1 n% Z& u0 k
        if (ret)0 j. ~- |+ D$ ^$ [
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; [4 l2 Y& M6 H( p5 G3 p
                                "%d\n", ret);2 P; x1 k* [! A  Z! L, a2 L
#endif3 c( c, z% d2 l& v& a
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ v3 v3 z6 p: y& m        if (ret)
9 Z/ Y  J3 H0 v' p0 z                pr_warning("Could not register som GPIO expander LEDS");
& r; W2 Q& x' o2 G  _9 p  \        else
+ ^! r1 h6 g8 s8 ~0 z                printk(KERN_INFO "LED register sucessful!\n");$ M, M# c  L7 Y/ N4 Z9 ~- n# h
6 C; J7 r% z4 W6 m0 a
        return ret;
5 C- o1 F5 i; b# D}& F1 |. I# P" u/ Q0 r: n9 G

  ~4 y+ }9 P6 s7 nstatic void __exit led_platform_exit(void)
: L$ G% S" t' H! y3 k, I" i4 m{* q9 ^# \: b5 D! W1 t8 t
        platform_device_unregister(&da850_evm_tl_leds_device);1 f! }/ P, T+ r7 z
. _4 q" ?  w* h2 W+ ^
        printk(KERN_INFO "LED unregister!\n");! ], N6 w$ {3 h5 o* Q* F7 S
}
4 ?- X( G# }$ B) i0 I
" |  o9 d6 ~. |/ d, smodule_init(led_platform_init);
& Z2 K# p+ y7 O$ ^- S5 Hmodule_exit(led_platform_exit);  X- J) e5 N& W% V( ^
! r; F( y7 |+ y5 u
MODULE_DESCRIPTION("Led platform driver");) D9 [$ f% p( d  h  y* K% I
MODULE_AUTHOR("Tronlong");
; B( ^7 L& m$ ^9 `MODULE_LICENSE("GPL");9 B( d( h8 f& S+ r$ p% N3 q

) A9 m  J, Q/ G* e1 L! v7 g9 z- ]' s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-24 16:57 , Processed in 0.048088 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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