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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
! U: P% S8 Y5 t6 N. E' x#include <linux/init.h># J+ T3 N; t$ X: B8 e, S1 X( Y# L
#include <linux/module.h>1 M) ?0 k, u$ f; B
#include <linux/kernel.h>
9 c; E/ W9 ]; b# u, M#include <linux/types.h>
8 ^' a, A, O8 x' h0 R# D#include <linux/gpio.h>
/ [: |7 ~0 Y1 b1 ]  B- z; r8 ~" ]" N( N#include <linux/leds.h>
3 h6 Q" J* S: u  X) X; V- m#include <linux/platform_device.h>% n0 n% n7 i: I. {1 I& @" m
- C7 J* x- R% N3 q$ f( B! v
#include <asm/mach-types.h>
* k* \3 F$ o. V5 I8 U' l) ?! |#include <asm/mach/arch.h>
! C- W" h9 N  M( L0 |, x#include <mach/da8xx.h>
  Q6 H0 o, e' {" o" V% o#include <mach/mux.h>
9 {; u# j5 W: ]2 s0 C: O+ X5 k/ x( I" J) C) e
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 ^- {* R  }0 J0 I0 A
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)+ V7 U9 j' y% {) o& Z/ Z
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ c/ V  }" U) z1 O#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)% }4 a- I+ u: b& d- s# i
$ |; U9 a* a/ c, t2 l% j
/* assign the tl som board LED-GPIOs*/
! i- C8 F) i6 d% tstatic const short da850_evm_tl_user_led_pins[] = {3 B2 \" Z: s! \& e" x5 k% m
        /* These pins are definition at <mach/mux.h> file */
" P! o. |" z4 g# |! G) M$ h        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 b1 B. p, p6 h9 Y
        -12 {! D' O7 ^5 B5 k
};
  f) Z7 i& z! a, Z4 P  ?2 {: j; ~9 d- d1 O- ]* d
static struct gpio_led da850_evm_tl_leds[] = {8 O  H8 h1 S+ T
        {
9 ^7 d& |, X+ s8 A  C4 Q9 |                .active_low = 0,3 w/ ~' Y2 _' f  V: F
                .gpio = DA850_USER_LED0,; F9 b% ?% Y# |( R- ]0 H
                .name = "user_led0",
4 R/ i* j! A7 b# i6 w1 U$ k* P% d1 I                .default_trigger = "default-on",
* s8 i' L4 j+ L5 G1 {! t& N        },9 D, K/ K, x2 K, p: N" p
        {4 R' l; w3 ]* H' E: _9 C
                .active_low = 0,
1 C+ q5 M) b! u0 E" x! O. L                .gpio = DA850_USER_LED1,
; N' r9 [6 v- |                .name = "user_led1",
  N3 `; e8 _% ]! t  {                .default_trigger = "default-on",
! I5 c* P0 Y9 u$ S& w+ S: r, Q        },7 `7 |9 a/ v7 @; a( y8 i: |3 z
        {
- U6 A" Z9 O8 f                .active_low = 0,
8 k/ [6 |! d" U9 U1 @1 g0 g, k                .gpio = DA850_USER_LED2,
- s+ i+ h0 j; n  i                .name = "user_led2",9 p# x5 ]& U, X, A0 s3 q
                .default_trigger = "default-on",& A, I" k0 P5 B' @9 ], Q1 J
        },/ t1 Y3 ?  x( B) v. g
        {' P$ Z7 j- I5 h. {! G% b9 {' x
                .active_low = 0,7 r  R: P) R* J
                .gpio = DA850_USER_LED3,+ f3 Y1 [, I# s5 D9 F; Z# r
                .name = "user_led3",
9 w" b4 L; Z1 {+ o+ T                .default_trigger = "default-on",
0 p3 Q+ \# h* p5 X; e* w$ l        },
( x" _3 C  r4 g) q, C, G. g6 D};
( ^8 \6 q; J! O& O; v. ^) s0 u  B" h5 Y5 D9 [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; y7 O5 t) o% \; Y" v# W' T5 c        .leds = da850_evm_tl_leds,
& i- ^8 g: a2 E4 S( d        .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," o/ o2 L0 s; T; {/ B) X# Z
};
" r( Q6 _9 V$ o2 E% k8 d8 I
8 x% F: ?; m8 }. kstatic void led_dev_release(struct device *dev)6 L% f3 ?  P0 p2 w+ h
{* k6 p/ ^# ^3 h
};2 Q1 n% s6 ]6 M& n  R) ~
, y. g- w+ G3 _5 s
static struct platform_device da850_evm_tl_leds_device = {1 }, a+ G6 ]( l  k( r( C- i
        .name                = "leds-gpio",
8 d8 ]2 d( A/ j% e  G        .id                = 1,: a# L( w! h, c. _0 v! j
        .dev = {; m' Z7 x% v5 x; h9 x
                .platform_data = &da850_evm_tl_leds_pdata,
# v% {' A8 Y6 S# w9 B1 s) r' s                .release = led_dev_release,
/ L3 z! i" s+ N  V- l        }2 d2 n' T  h4 i8 B8 B/ O) h
};- N. G+ d& F, t& t* L3 A; K
8 g0 r5 Y. U& @2 e" s: V' S8 K
static int __init led_platform_init(void)2 L% y' N) t) k+ v6 _; s
{  |$ p6 D- y- G- f$ y+ H0 }
        int ret;
6 j! {) W8 U) p8 j5 B8 }) U  J#if 0
3 U1 l* O* m$ R        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ t! y3 y- Z6 }( l. x/ Z        if (ret)' I+ G) Q) P+ b# V
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; t  j5 g% n/ B& N  V' j6 M                                "%d\n", ret);
3 `6 @3 ]1 F* y# z- Y#endif
. S1 r( e1 _; A/ v        ret = platform_device_register(&da850_evm_tl_leds_device);; c; q4 z/ K& B4 {% G: V6 j9 ?5 c
        if (ret), o4 t( Z4 l- I" x$ b, Q# f; R
                pr_warning("Could not register som GPIO expander LEDS");
5 q7 o1 j6 B+ j6 N( P. K- V( ^7 C        else
' M' G0 k& @' p0 M                printk(KERN_INFO "LED register sucessful!\n");
+ ~& j4 |1 e1 E0 t+ s" D+ R5 X% W4 u# }' ?6 e3 k9 z. o$ C4 [
        return ret;
! H! u  P# N5 Y; i4 G( f; Q# s- h}/ A- Q: x5 H" ]$ F

) V+ D2 _+ X  d4 I3 Dstatic void __exit led_platform_exit(void)
3 a% C7 H5 a  E& y& _3 C  i4 a{
- s$ I6 a# [. H2 b# |        platform_device_unregister(&da850_evm_tl_leds_device);
+ I% Z( j& t; E& @
7 @% \% n. m( i0 h; K; J1 H% ?0 ?        printk(KERN_INFO "LED unregister!\n");7 L3 w% C* p% G& \+ a& K* c, M; @
}
$ E9 ]; ]) M/ d# W4 I
% \; x! l, ^/ E0 t, fmodule_init(led_platform_init);
- d0 B% y/ P; D* u4 e" bmodule_exit(led_platform_exit);
7 X1 R3 {/ x: n3 x1 s9 o4 O8 Z9 f4 Y% L( K) X5 m
MODULE_DESCRIPTION("Led platform driver");
& `. C7 C3 {( P6 l* [0 u6 F+ yMODULE_AUTHOR("Tronlong");4 ?. c  |( ?, P+ h$ i4 U
MODULE_LICENSE("GPL");
# @7 q# `$ E! h( ~* J0 H9 B/ w3 ~6 |" A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-13 10:59 , Processed in 0.042357 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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