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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- C5 D# d3 i) {0 G1 H% V9 X#include <linux/init.h>/ E1 P! ^3 y" {6 d6 y+ \8 h$ m
#include <linux/module.h>8 U" e6 g4 v* J
#include <linux/kernel.h>3 x$ ~; C6 z; |' }
#include <linux/types.h>/ d- A# V9 t4 v4 B/ v2 R
#include <linux/gpio.h>
0 B) W( C9 E1 }% U: n$ L+ p#include <linux/leds.h>: Y- e% N/ l) N6 R: Y: P+ |8 ^
#include <linux/platform_device.h>) t7 B, I# u7 a8 g! ]
: u$ j- R' l% Z2 l, i# _: Y, G
#include <asm/mach-types.h>! j1 ^: s" K9 G! H/ m5 }/ H
#include <asm/mach/arch.h>
  v, |. _( O, ~0 f, c. ]#include <mach/da8xx.h>6 S7 [& O. F8 G/ q
#include <mach/mux.h>- G: j, I: J2 n( T

: d7 }; F6 F3 i# h#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: a0 C4 t5 a& E1 I0 n#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 q  ?/ T/ a! k! \  {0 U#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ ^: f4 p$ f4 m: y- C
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
* ?; A: C6 A) y- r# t
1 \7 G+ p, U, l! ~6 {/* assign the tl som board LED-GPIOs*/
2 m1 W. g# d1 d# `' v; C) Lstatic const short da850_evm_tl_user_led_pins[] = {8 Y4 b( ^" Z/ \
        /* These pins are definition at <mach/mux.h> file */
% u& s" {+ U) L        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! i4 w' [+ o0 J. ]% J, `7 s
        -14 J+ h" {% s' s) [4 I& c0 A9 r7 p
};
! s; g* N/ F- G5 b% H+ w  S, r$ ~) G9 S0 i8 k) Y4 z( z% T
static struct gpio_led da850_evm_tl_leds[] = {" l- Y$ d% x: K3 g
        {
% B# R1 ~7 k( I, ^5 V# n                .active_low = 0,
& b8 G0 ?" x& f4 [6 t: l                .gpio = DA850_USER_LED0," R8 ~5 \$ g+ m* n
                .name = "user_led0",
' F; }: e  ~3 r' ]; y/ M                .default_trigger = "default-on",# `( ?; k- O7 n- k% o" g% ^
        },
' L0 U, Y9 j7 v& x- b  u% V        {) I5 I* q3 [" v( }) @) t+ t+ {" o; N
                .active_low = 0,
( a2 u  {6 f9 p) A3 s                .gpio = DA850_USER_LED1,
2 Z* n0 ~% y0 `+ x) @- ]$ K$ P0 {                .name = "user_led1",- h; D( V( W3 ~; g0 U* e
                .default_trigger = "default-on",  ^3 ?* ]2 Q* ?, @
        },
' X8 b$ W6 G6 ]0 ~1 X" g" W6 u6 H        {
2 R5 {' u0 d# k( {2 N                .active_low = 0,
- {* c. g) j8 W                .gpio = DA850_USER_LED2,
4 e& ~* d- C7 C' E  T8 s/ u& g                .name = "user_led2",: J5 t3 U- ^3 U. q8 Y" m; J
                .default_trigger = "default-on",
3 I( Z& s+ N. K# l4 j) E2 Z        },* ^* C: I6 K4 B6 t3 Z
        {7 Q2 S# M7 N) \1 \/ @( ?, J
                .active_low = 0,
" ^* T) n6 G$ C: n( u+ Y                .gpio = DA850_USER_LED3,; ]9 w9 v8 }0 L3 ]; C
                .name = "user_led3",
1 z/ D- d* T% H# P; g& ]                .default_trigger = "default-on",
4 ^4 P3 G7 e8 x) ]& S        },
2 h" ]' q1 _  x& Z. N; ~# z1 a6 W};2 p3 i" g- B% P: ?* G
8 j6 I  [( h1 ]9 N: l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! f" O7 J/ _3 W9 T. x
        .leds = da850_evm_tl_leds,
& [( |2 g; U# z$ y3 Z% s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 N- a2 k4 U/ ^; G( Y
};
$ f2 g% B1 R/ V% C0 q
3 m# m- g+ B0 U9 y# x7 Bstatic void led_dev_release(struct device *dev)
3 X) J5 F: P2 Q4 V{
' _) J) W1 K. b};
3 ]/ U# A9 O" u& Y+ }1 o3 P$ H
% ~% M8 f% W; ^* Dstatic struct platform_device da850_evm_tl_leds_device = {3 d/ c' {) f" V3 n
        .name                = "leds-gpio",! w; g+ q" w" ?3 r
        .id                = 1,2 R9 v" i* s0 U" I+ P* f, H
        .dev = {
3 a  U& b' A4 N/ Q                .platform_data = &da850_evm_tl_leds_pdata,, n; Y) s9 F& C4 Y; w
                .release = led_dev_release,7 S7 Z4 l$ J. [
        }
- m# n) ?' g% h4 M; I( ^- s( `; t# v/ ?};
- {( D1 N8 {' J: v: y1 N* `! k" ^% p4 c  i/ u% N
static int __init led_platform_init(void): j8 A' t! B$ @3 A; x/ i
{- p5 S) H# g8 H
        int ret;1 `: |  e$ U. P9 P
#if 0: d2 f5 H% q/ t6 [
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, X3 a7 v4 Q/ k% X! u" |$ u        if (ret)
, V0 S- n* m$ E; `4 d                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% E- N9 G( ^9 s! ^# h- X( o                                "%d\n", ret);+ o0 m$ k; H0 x; S, d
#endif0 n0 s+ z, U+ O# G, n
        ret = platform_device_register(&da850_evm_tl_leds_device);
! s3 t! _7 q4 F% J) h        if (ret)1 j6 A# c: l/ T9 G
                pr_warning("Could not register som GPIO expander LEDS");
* Z7 T2 y9 d( p3 _6 t3 r        else. e$ s( S* c( w9 J$ \0 o
                printk(KERN_INFO "LED register sucessful!\n");$ W% L: O8 R1 i) M
, |- A% y8 K+ D# z" V8 N
        return ret;* ^9 h1 ~" k$ Q( G
}& E% ]" C! g; O9 d$ z; f  u1 T# y
7 X' d# G* ?" S; w
static void __exit led_platform_exit(void)4 |; x1 Y2 d& L) ^) o. h) e
{
8 Q) h8 J/ w5 X* }3 z        platform_device_unregister(&da850_evm_tl_leds_device);
7 Q- b) w# e3 q. S1 u
+ j" g' C0 `- i; n        printk(KERN_INFO "LED unregister!\n");" U8 A# z1 U  H0 T+ k6 V
}9 V! Y0 T7 N, }9 ~8 D% L: v4 n" t

' h' W9 f, W% x% |module_init(led_platform_init);- R: @# j, i( y/ J5 m% t
module_exit(led_platform_exit);
2 D0 a7 d( ~1 P! V- u  n# q  w! I- J/ n* ^' {' f; P
MODULE_DESCRIPTION("Led platform driver");( p& Y& h1 g8 C, x/ b4 X+ V7 f
MODULE_AUTHOR("Tronlong");8 L" e1 }  e5 {
MODULE_LICENSE("GPL");
8 {8 N8 N# {! v" F0 i; ~/ \+ K
9 V1 m+ U4 t3 @; c& Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-26 04:52 , Processed in 0.043946 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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