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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 m0 R% P$ ?+ y( @& h#include <linux/init.h>
; g$ ~& f% r+ L0 V3 u#include <linux/module.h>
! L7 ~, s8 s7 c: ^9 p#include <linux/kernel.h>2 b* d+ ?$ m) Y6 b/ n+ I
#include <linux/types.h>* v, X+ v6 |  G4 J. W& Z% E' a
#include <linux/gpio.h>+ r* v; e2 s" E2 [
#include <linux/leds.h>
- f/ g  w+ u/ h+ Z' D3 M#include <linux/platform_device.h>
: g/ Z3 c# g( w" h
* g/ Z# r; \7 d+ @! t: q5 i3 B) C#include <asm/mach-types.h>
4 l/ v# \7 q3 C# p- E#include <asm/mach/arch.h># j( S7 _! v; s( n! S
#include <mach/da8xx.h>
! c2 b+ Q: I+ _) Z' m& v#include <mach/mux.h>4 N4 E8 N$ m7 v* X# A) S; o4 |

2 N8 B6 C& t+ e' F5 z, i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- l6 X2 _! Z  e7 r/ B7 X# I8 d
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* a2 M& a& H/ h) S4 f- m2 ?#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 j9 _8 ]5 A0 f: A
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 H5 q' V& H  T0 d6 f& G! {1 T
% o. O8 }7 v, ^( w
/* assign the tl som board LED-GPIOs*/
! J% x6 d) X# h2 S( ]# f* ^static const short da850_evm_tl_user_led_pins[] = {
4 Y- B3 e: `1 P  N        /* These pins are definition at <mach/mux.h> file */
' U6 I4 C/ k: v- w; H5 ^        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% G: U) `* i( Q0 q" I
        -1( H- ?  K# b' x/ \4 H1 G9 H
};
. [6 ?, Y% d' r4 F$ E1 U; ]; d7 X& C
static struct gpio_led da850_evm_tl_leds[] = {! H) R: ^# g! f! l6 |
        {0 J7 Y; T6 l5 S) j9 e5 h
                .active_low = 0,
* h& H$ _5 }; x% ?8 ]. N, o                .gpio = DA850_USER_LED0,5 S; t1 t* d. B0 o" o) s, S* R
                .name = "user_led0",
. M8 ?- j2 v+ Q9 H3 K& V1 c! g" V                .default_trigger = "default-on",* ~% G- n! T9 Z% ]/ F. l
        },' [+ o% Z) A& O( U# q
        {
1 g, [8 t, b9 A$ y6 y" D6 R, T: _                .active_low = 0,
% j- f* c+ K! ~& P                .gpio = DA850_USER_LED1,
3 H4 h4 p5 b, X+ E1 F1 x( w                .name = "user_led1",
+ ]* W5 N8 s% y                .default_trigger = "default-on",
- N/ c: ^" h* K6 N! i. I        },
& b: P3 P4 m; t7 q        {
5 a, X. ?  K8 i                .active_low = 0,
$ L4 H7 N( {" C5 @$ ]                .gpio = DA850_USER_LED2,7 i) ]' J8 D4 g1 T! }: P
                .name = "user_led2",2 S' b- w2 ^/ u. a  S, T
                .default_trigger = "default-on",
' T9 c4 H6 b+ O7 o& K        },; }; S9 s$ p$ v6 m/ H  |0 y7 b
        {
' ]1 J& K, o  k, q                .active_low = 0,
( }. @& k  w+ w3 y" @: }. V' C+ Y                .gpio = DA850_USER_LED3,
0 l' J0 S4 A5 g8 x9 B                .name = "user_led3",5 e. u! t4 v2 H" Z
                .default_trigger = "default-on",
* D3 v% E0 n8 b6 e+ D        },3 |6 Z( h& f% U  \( [
};) Q( }" X% U1 o

0 ~  G! M1 N7 B& `4 F, Y3 dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' X( `! B3 \( Z* \7 k3 J1 \; w        .leds = da850_evm_tl_leds,/ n& @! c! ~( \
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) |; g/ J: t- y/ J};
* X  ]" g$ D3 u! @0 H
! f9 s) F2 _' ?4 @3 h+ [- N1 _static void led_dev_release(struct device *dev)
/ H6 N# Q9 {; ^3 q; l0 U{
7 C$ q4 r& b% e};
% N  [4 o" P; n7 \) d5 m" i
! A7 {) v, s$ l5 b1 g. dstatic struct platform_device da850_evm_tl_leds_device = {
8 S2 K" V- H; l; G$ O# W        .name                = "leds-gpio",
  K' e, r+ ^( ~, S, n3 }+ [4 c6 m        .id                = 1,
" Y8 P9 }& d2 l; g9 W# p1 z" @: q        .dev = {- ~) }  D) [! L: F8 O
                .platform_data = &da850_evm_tl_leds_pdata,2 o1 ~: _; \9 Q+ s% C6 c$ {
                .release = led_dev_release,' T; T) L& R) l
        }
: N- G! ?4 H3 d% H+ s};  H5 X9 i* x5 S+ g6 v, @9 {9 R
( D6 @7 x, q! f
static int __init led_platform_init(void)9 B4 H( C) n$ i- g/ {
{6 h1 M0 P! w. C/ d. ^
        int ret;
: a1 b7 S3 C5 T# e! k#if 06 N6 T: _( N# k% C2 _- ]
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
  P) B5 U5 \7 y9 a        if (ret)
3 B  a+ }% x7 p, f* e2 l                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ i0 r: u1 t7 [' _                                "%d\n", ret);' v) [& c3 q) U7 p& h
#endif
: U* ^. \% C5 k0 f) Y4 |$ L        ret = platform_device_register(&da850_evm_tl_leds_device);
2 F( R; P& {8 v' X- o; H        if (ret)) c" z: U9 L5 ]- B1 y
                pr_warning("Could not register som GPIO expander LEDS");5 q3 r( D1 d' e
        else
3 G: W$ ~2 Z: {- H$ @: g                printk(KERN_INFO "LED register sucessful!\n");
, z2 F' e% [' v6 p8 ]
4 R( f, w) _' L. @) I        return ret;4 k9 q: w+ j" c; M/ s: ?: e& c3 ?
}
$ L% f4 z0 D+ B6 B6 r! L# Q) H8 l; e2 f
/ q# {2 T; {$ e& {static void __exit led_platform_exit(void)% q) X; z% @" K9 F6 H. q1 ^
{
  @  x8 V' r6 X) X$ W6 g        platform_device_unregister(&da850_evm_tl_leds_device);; M3 `; |( y& m& h
$ D5 c8 K& B! Z0 O# D5 L. N1 I
        printk(KERN_INFO "LED unregister!\n");& R& L  G6 v* v
}
, `# ~4 _) ?. W, }  T4 f
/ ], O7 S: ~; R2 @' _module_init(led_platform_init);& J2 q2 k. r! ^; x. H2 }
module_exit(led_platform_exit);- r7 o% }* O$ f2 Z1 l

% q/ C* t% u0 V+ ]7 R0 tMODULE_DESCRIPTION("Led platform driver");' Y! e  G3 m/ G$ e
MODULE_AUTHOR("Tronlong");; q2 Z" ?# [! r8 g& v4 V$ H# ?
MODULE_LICENSE("GPL");
$ q4 w, E5 G: [: d( S& }/ r. R' M
) ?; S+ ~5 Y4 o8 a; ?& n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-19 16:51 , Processed in 0.041819 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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