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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 h, j! X" }0 J1 W
#include <linux/init.h>, F( J& r1 L% T% \# d0 j8 q
#include <linux/module.h>
/ N$ y. h2 q' n1 [/ G#include <linux/kernel.h>; m# r, f6 I% P6 I2 t/ L7 ?
#include <linux/types.h>
4 T5 \5 D( Z4 r' O1 y$ h- ~#include <linux/gpio.h>
, {2 e) ~& B, o1 n#include <linux/leds.h>- D. I( _; \" ^* ^0 O& h+ M+ u
#include <linux/platform_device.h>
' @2 I; f/ O9 A7 }4 X' q# }5 f2 Y& t) i8 ]6 l. f- N% h
#include <asm/mach-types.h>
0 O) S' K0 X$ ~# K5 f) w#include <asm/mach/arch.h>* ?1 @: c6 G4 `# L+ P
#include <mach/da8xx.h>
4 j. c+ O+ p* M0 J" K1 [0 s, Z: g#include <mach/mux.h>0 Y8 n/ U+ `: n9 S0 f  W1 J

( G: t% u4 O: w4 C' B2 i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 u# Z' _6 K2 m) X/ E7 B
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( w& g6 g7 g/ P5 k2 H5 y, h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  {. k' l; ~1 Y- ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  H4 I# h+ Z) T; Y
4 y: t* e  p+ X8 Y/* assign the tl som board LED-GPIOs*/
9 g0 d; `6 V$ t$ V3 ystatic const short da850_evm_tl_user_led_pins[] = {* z; B! }1 F* ]* A: V" O9 K! l
        /* These pins are definition at <mach/mux.h> file */2 O% l- N/ D( N% `% B
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, \, ], G* e1 N% N3 t        -1/ n6 Z9 F8 J  o2 y) c! t+ P
};& |8 m; V2 q7 S7 F- d; p  c, U: G7 Q' x
$ ]! n$ J, }( T  A5 ^/ L
static struct gpio_led da850_evm_tl_leds[] = {8 J( A2 H6 g3 N
        {
/ F3 |8 q' Y1 i( r6 O: ]                .active_low = 0,8 X# v' }5 h; ^# `, v" \
                .gpio = DA850_USER_LED0,, Y& f7 D/ X% L, W. ~" T( n" ?
                .name = "user_led0",! A3 F0 _2 Z. u1 X" y! ^! t; \7 }/ X
                .default_trigger = "default-on",; P/ K9 H" L/ [' p- w
        },
7 t3 C# t9 U5 ^  O. w0 W        {. g6 I! ^; D4 V  |" l9 T/ Z  T' t
                .active_low = 0," O0 E( M) x& j% M
                .gpio = DA850_USER_LED1,- V' x2 c+ P8 ]3 X8 {! w8 V5 u
                .name = "user_led1",7 b6 b3 ?) a% S; D! k8 P. ]
                .default_trigger = "default-on",
( B' s6 D# ?- f8 D        },3 Q; s1 F( y* Y; G
        {, J1 i/ C  |2 N
                .active_low = 0,5 i+ x* c6 G) G/ T0 ]
                .gpio = DA850_USER_LED2,
6 [! u. A; H9 ^5 X) z                .name = "user_led2",: Z) E; i9 Q% J' a2 M, o1 f  V
                .default_trigger = "default-on",
: A" \) e! B) J  c        },  i! ]! u5 L% y( ], t! t! l
        {, f7 y2 Q6 G/ r
                .active_low = 0,
5 j" r$ J: A2 S9 Z- ~( [8 i3 M2 P                .gpio = DA850_USER_LED3,
2 r1 r4 ?4 d, @$ L: o6 m' S1 W" X* P) k                .name = "user_led3",6 q/ B/ c& M+ g0 M& Q4 [
                .default_trigger = "default-on",
* X+ t# V- x$ l1 v1 L# K/ t3 `/ M        },9 n) t! q" A9 J# q
};
$ ^% I0 @" v$ Y/ e% z( j
4 P$ i6 C6 ~: nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ A" W8 w( W2 i* F0 f
        .leds = da850_evm_tl_leds,
/ K. ]5 K( Y: K- f: x        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( p) l, o' _$ V- _
};' l, d9 b% B7 ]
8 @* G" Z/ D! T! Q; U$ g" `3 W
static void led_dev_release(struct device *dev)
' g! s! E" J! a{$ q% }% g7 a6 |' S" S
};2 a  c4 K1 t/ I7 `2 Y# y. M( x
* G- @5 q' b1 E
static struct platform_device da850_evm_tl_leds_device = {
# P- m. Q, b  L" p* Y' T        .name                = "leds-gpio",& k" E6 I" _, L" Y) ], I' q
        .id                = 1,% K; k. W! E' P% S+ E
        .dev = {7 n2 L6 r: y* N8 E8 d2 i
                .platform_data = &da850_evm_tl_leds_pdata,
$ ^* S, u4 }1 A                .release = led_dev_release,
9 G  i5 d5 G2 u0 q( \$ Z: }  x        }
4 w( F( w  m+ i/ m: W) N; W};: x3 v) l' B" c+ N1 [

* y7 X' d3 }, Z4 |" Y$ v6 V2 ustatic int __init led_platform_init(void); H5 S% J% Q& t) L5 j
{
, x  l4 \6 y9 x" i6 z: _        int ret;7 @0 f4 F. h; L: K+ d" W$ \9 f$ V
#if 0) B% f# @& ^) Y# K, w# z4 u
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 Z) f# {# v8 s! c        if (ret)
5 h5 u6 u5 X0 w  c7 n                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 y( H! ?2 w+ Y                                "%d\n", ret);
( ?$ ]( j2 h/ b5 t+ r# {#endif! i$ ?2 N6 ]2 ~. T9 |9 v; F4 N
        ret = platform_device_register(&da850_evm_tl_leds_device);2 V$ C6 w. I4 c( x. p" m
        if (ret)
6 `0 R$ G6 M8 U                pr_warning("Could not register som GPIO expander LEDS");' y3 ~3 J! o% @4 A" e. v% g( @3 Q
        else5 n$ w% t6 j0 M8 v% A5 m! b# i
                printk(KERN_INFO "LED register sucessful!\n");! c/ Q, f% P1 K; T5 t$ X" e

9 [6 a& `3 P+ L$ c8 [# O. t        return ret;1 X; e* ]5 O# w  R' a: @' C
}
- O& G7 A, Z) X" D
- E2 L; r8 l; S" fstatic void __exit led_platform_exit(void)6 G; J' L5 J) S
{8 E$ i" {1 n6 B; a) F2 R& V
        platform_device_unregister(&da850_evm_tl_leds_device);: Y% o. I4 m9 j: |* x( l

8 i, L; H  K4 j& V$ ~5 e        printk(KERN_INFO "LED unregister!\n");
' q" y+ a: b% r% a}
5 e! O6 [5 O$ G( e& A! j- A% p* G, S
module_init(led_platform_init);0 X2 u  `6 h& r
module_exit(led_platform_exit);/ M5 ?4 U8 P  H5 L  Y5 U0 @7 m: Z" P% n
) Q! b- l  c- D5 v) M- S, s
MODULE_DESCRIPTION("Led platform driver");, ~6 ]1 [" M4 }2 j% v7 Z
MODULE_AUTHOR("Tronlong");$ u9 n, s2 w% [1 v
MODULE_LICENSE("GPL");
  o, g) N/ k5 Y0 [: p3 n/ F. r1 c' V9 }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-23 12:03 , Processed in 0.040700 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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