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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 A8 I& U2 x: n; K) d0 M  j#include <linux/init.h>8 ]+ M3 `3 Z" }8 m+ z
#include <linux/module.h>
, H! `: l3 P* `: U! M#include <linux/kernel.h>
+ z$ ]! v; s3 c#include <linux/types.h>! {( E  p% x; ]
#include <linux/gpio.h>4 x& V3 d! b  v7 p3 K
#include <linux/leds.h># Z) S+ }4 `/ Y5 [3 b- ~
#include <linux/platform_device.h>. m* E( ?/ Y/ K- i" a

  p; c% W0 q, X! p7 @1 o! B0 r#include <asm/mach-types.h>
8 C) B5 W. I  J5 g, n+ L#include <asm/mach/arch.h>
5 M/ T7 N5 ]9 A+ Z3 B+ l# j0 h#include <mach/da8xx.h>7 N5 ~* g: {/ `1 p  X7 Q' B
#include <mach/mux.h>
* d4 z. U; a( A& j0 q) p1 X$ }* ^7 s
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)4 c8 |1 X! i9 p: y- D& O! j3 F- b
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
% O, q1 g! X2 d+ k#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. J( {* s6 j$ _8 Z$ `" a#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ Q6 C3 A& ]6 G& v; C
- a7 x  y9 g' R: J
/* assign the tl som board LED-GPIOs*/" ?6 x( X: ~9 k
static const short da850_evm_tl_user_led_pins[] = {. o3 V- m% w+ ]% T( G. B
        /* These pins are definition at <mach/mux.h> file */" l. q5 C( c! x  c8 q' s
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 x& ^( `8 n0 U# {
        -1
* A5 S. t8 A1 R& Y};
- l! M/ Q, o' ?: s) T3 t0 g5 k! n" r3 q
static struct gpio_led da850_evm_tl_leds[] = {5 W: B% v' q0 S* C; Z1 q
        {/ S# t# F+ W. V3 k/ @
                .active_low = 0,
/ p; ^" d) T- A2 N5 g  K3 L                .gpio = DA850_USER_LED0,5 X' h& u+ k, R+ T: b0 W
                .name = "user_led0",% F7 F( c3 U2 |, h. D  W  X0 z
                .default_trigger = "default-on",+ c( d. F+ |& c/ A$ A! |
        },
0 R5 t: d+ \+ P  r& K, a/ i        {( _1 ^7 k% b( I
                .active_low = 0,
& ?5 j0 Y$ c- e& H                .gpio = DA850_USER_LED1,. S+ x# P2 G* e% @4 A7 d8 a
                .name = "user_led1",8 [8 x& P1 n7 Q/ u
                .default_trigger = "default-on",( G+ M- d+ i" c7 h6 }# r: O
        },5 V+ E# v9 y' O  J% J# ?. ?
        {
7 {( _  E, D' N' ]7 b, [5 {                .active_low = 0,& I1 o* l# K. q" r8 U5 e7 Z
                .gpio = DA850_USER_LED2,# f. H, O' F/ N2 _5 g+ H$ g* f' F
                .name = "user_led2",
- _4 h' I: M& |& S4 F' }                .default_trigger = "default-on",
" f) _5 H. n3 ^( d5 c9 ?( J- @        },
5 x6 Y+ H3 `! W        {6 [4 X+ \' n* A/ o* p. Y
                .active_low = 0,3 ~$ L, w5 u+ T2 O! E
                .gpio = DA850_USER_LED3,
9 d6 J9 j1 `, M" L) Y* ^                .name = "user_led3",. u; J! q2 z' M! F) h
                .default_trigger = "default-on",8 M3 d% ~0 y  c5 W5 C# y" b5 w' _
        },
7 h* e0 h  T! Y# o- R5 h};1 F  e& I: G9 X; k" H4 C8 B
6 u% B  i) M( M1 `3 q* I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ I/ ]& ?) H( n( q6 Z
        .leds = da850_evm_tl_leds,7 V. ?9 Q8 X4 M) h% V) O
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" W2 F. c) W, D9 s. P- U7 e};. b$ R2 s& I- j9 f1 X+ N" S
' C( {- G* S" w. v
static void led_dev_release(struct device *dev)$ ?/ ]" }# k6 O
{
1 N( y2 U( R0 g};  v" x9 H; @  c, r* |+ M- F9 L; F

! N7 g+ L7 y# S3 M5 ostatic struct platform_device da850_evm_tl_leds_device = {- O) y" h0 ^& c0 D
        .name                = "leds-gpio",; u4 p( S- h3 }
        .id                = 1,4 ?3 W+ A  D" F( k1 `
        .dev = {# N# V; E# F1 B' s( F# t
                .platform_data = &da850_evm_tl_leds_pdata,% A: ~0 z: Y5 N$ `1 g/ v) ?
                .release = led_dev_release,: G; X; U1 s; x7 m
        }0 U( N: Q" a; ~
};
. N) ?6 D+ n& s0 U+ o; o% @2 d6 f# K; J1 c/ r
static int __init led_platform_init(void). U- F) S" v) ~2 Y( S
{9 l, X2 ^% z  }. o( P0 Y
        int ret;
  C+ d' c9 I, C& S1 ^+ G% c#if 0) S. k. m/ `& b- X& S4 ?& D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; m  ]% ^+ t1 ]8 Q. M8 G        if (ret)+ l' h$ o2 }6 B0 V
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 y0 m+ n$ l( A1 X0 X" W; N
                                "%d\n", ret);! j5 d- D- p" L3 [
#endif1 e& o. r% C. }/ \$ C
        ret = platform_device_register(&da850_evm_tl_leds_device);( P3 b  o% f8 W
        if (ret)
: C6 \/ n  A+ R5 {                pr_warning("Could not register som GPIO expander LEDS");, R" s3 Z8 H4 \" x! _9 H
        else
+ W1 {7 {- K* l+ |( i0 B                printk(KERN_INFO "LED register sucessful!\n");  J# v, y: P9 o  g' g

$ U3 S- l1 f, n' Z0 U        return ret;( C4 \& b/ R6 C' Z% I$ o! c
}
' \+ H" [" R8 l
* W. d1 N4 Q, y: ]$ P1 G9 Ustatic void __exit led_platform_exit(void)
+ s" T& ]- y; n  M$ B, V8 g1 f{4 \& L3 `& k5 ~
        platform_device_unregister(&da850_evm_tl_leds_device);" m/ u, h2 m2 r8 I% A

& g/ B6 H9 z7 K  R        printk(KERN_INFO "LED unregister!\n");
  o. c' A; M/ ^& M}
+ e' @8 _9 z# J% A" u/ c! S# g; G3 S. ~$ {% t9 V0 j& y3 E' p
module_init(led_platform_init);5 C+ n# N5 {4 G0 S5 `; `
module_exit(led_platform_exit);
  S1 X3 O9 p7 f2 b$ [  A5 G' S. M
  P. W$ p; R- b8 wMODULE_DESCRIPTION("Led platform driver");
) ^8 `/ J& Q7 ~& }8 VMODULE_AUTHOR("Tronlong");
3 d9 F  ^/ _4 e* A" T  oMODULE_LICENSE("GPL");1 F, `6 b1 d2 i& Y! W& O( D

$ \6 M8 l: ~7 u# R' I5 J7 f
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 16:56 , Processed in 0.050114 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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