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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& F) n" B' g( T1 ]! G' p+ `3 m#include <linux/init.h>
9 l+ f: l$ v! x- Q0 E#include <linux/module.h>% G8 V; J2 l& [. [
#include <linux/kernel.h>
- Y/ ~* ?4 i) b/ i% g. E#include <linux/types.h>
1 d- `# |& d. q$ {$ ~( R#include <linux/gpio.h>
' V$ P4 F; A& y4 W3 L. O#include <linux/leds.h>, }# L: C8 P- o/ j! k% A
#include <linux/platform_device.h>
- ]1 e- c3 x( N5 @/ P
8 M! ^2 D7 U& @#include <asm/mach-types.h>
; d$ g5 n3 j$ J, C% N5 V4 z; ^& \#include <asm/mach/arch.h>2 w5 C. C& p. Z6 u
#include <mach/da8xx.h>
1 J  h. Q2 H/ y& V8 E#include <mach/mux.h>
1 }" C3 n5 R; @$ G) H! m1 w$ P4 m  ]! u& r  B; N
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 l8 c& D7 j5 `) W3 r9 `
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' e. ~. k/ S0 S1 T#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). M% R$ j1 e1 Z9 `4 j% I
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  e. l- d6 P# t* m+ C; A# t) u, f% c/ n& `) z3 }- J
/* assign the tl som board LED-GPIOs*/: k  D- C. M$ n, ?4 w. Z) u5 f
static const short da850_evm_tl_user_led_pins[] = {! E3 D. p& }' @* t- [4 Z2 Y8 c$ q
        /* These pins are definition at <mach/mux.h> file */6 O8 k' C! ]7 `! D" P
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," K  b' N1 w: N( m/ ]
        -1
, Q2 E0 {$ t8 j7 ~" ~( J% X};
4 I9 Q- i- E1 `! b4 U' p5 Z5 k0 `- ]  ^# X
static struct gpio_led da850_evm_tl_leds[] = {5 k+ k5 R- w! c9 N6 u$ w
        {
3 N; l  h% k# e5 L  [                .active_low = 0,/ \2 G! i3 q  H5 j2 P
                .gpio = DA850_USER_LED0,
: Q/ m% x0 |5 }0 W# a- X                .name = "user_led0",
# \" t: E. e$ r0 S                .default_trigger = "default-on",; y9 b0 Z7 ^" G  Z- s
        },5 R) J. B( ^, [
        {- i* i$ p+ i8 B8 P: J* ?
                .active_low = 0,
7 J! d$ H: [* d7 x8 o% l/ Y                .gpio = DA850_USER_LED1,9 f. K5 c' [$ C1 r9 v/ Q( D
                .name = "user_led1",! s8 a6 m9 t- u3 y* a) A
                .default_trigger = "default-on",0 \3 G3 P+ ~& G3 Q1 v- V8 }
        },
7 m$ T: N* `: a& d5 d, e8 K5 x        {
+ w! M& H# C+ k* Y; h* ]                .active_low = 0,, ~. K3 ~# Q. J1 I  x- u
                .gpio = DA850_USER_LED2,# ]2 r5 {, l& `8 U4 f
                .name = "user_led2",
4 S! Z4 w% W+ A( x9 T; h) b                .default_trigger = "default-on",
( T, c! j3 B- I        },5 C7 y9 m# K: e4 h. w2 I
        {
# O( c  }6 y5 s, W) y                .active_low = 0,9 v3 x  |. k" ]
                .gpio = DA850_USER_LED3,) J7 H: U" @  v. \( _3 p, p- T
                .name = "user_led3",- \& i- \, X& K5 n" k' z; l5 p& x- i
                .default_trigger = "default-on",
" W) x9 [8 V; K        },
1 h) a. A1 c% f. t4 P/ l- @. L9 u$ |, n};
+ _$ Y- D8 V) V  T  s1 J
4 i# H; ~. J) G/ C" mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 q) X5 ~7 k/ E4 }        .leds = da850_evm_tl_leds,
: d" d2 G! d8 u: p4 m2 C        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 ]$ g) D3 y1 h! M) C
};
: g1 D& x0 c# A  E+ K# U- V$ `* ?8 ]7 n! b- i% T
static void led_dev_release(struct device *dev)/ o& H* T7 S, u+ h0 A! V% m/ p
{: X& b' {9 ]5 \9 o3 ~1 W( S
};  K: Q& O( j9 Z1 h1 n) @

- C- I% R+ k" R% Rstatic struct platform_device da850_evm_tl_leds_device = {
4 e! L# T% K; r$ @1 M7 j        .name                = "leds-gpio",
7 O# j+ u9 g, ?  V; x        .id                = 1,2 z. ^' Y7 C4 @/ A# w
        .dev = {7 ]% w  t- `9 T; c8 }% L2 [' z
                .platform_data = &da850_evm_tl_leds_pdata,( f& P  j3 U6 J% k% l: O
                .release = led_dev_release,. u) f3 N! T" w* c1 m) Q0 A9 \
        }
" l( M* M- n& Y, c6 d};
8 K& \9 d3 m; M+ H
7 Y: c% C. N' p- U4 v  Tstatic int __init led_platform_init(void)
: V# S. B& ^; c; \{: ^  l# ]" r* f( P; W
        int ret;
3 O: [3 W" |' C( t- A#if 0
, s+ j7 {' M, G/ o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 M) _+ O9 S  W, q& [- W7 z3 L$ L
        if (ret)' r$ u1 E5 f1 b/ w: x
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 {( m8 j! H- a                                "%d\n", ret);. E0 T* q9 w5 j0 h. m
#endif
6 F0 X7 a' y, z        ret = platform_device_register(&da850_evm_tl_leds_device);/ ^; B+ S) \8 C! B$ W' T( l4 C( A
        if (ret)2 U$ T- q5 y4 E5 B  L- ?
                pr_warning("Could not register som GPIO expander LEDS");
+ U; h; U, Z( S4 {        else
' l: @% y3 A, u                printk(KERN_INFO "LED register sucessful!\n");9 W' w2 x5 q0 e& f
' A# I# k" B0 F2 J5 c
        return ret;: H: x4 s7 Y/ O( k4 f3 i
}
  M. C; t/ A' B. O% _# E: ]' _7 _0 e3 R
static void __exit led_platform_exit(void)) X8 M. o( ?0 T$ ?: S& B  V9 t
{2 g5 O% B9 L# s
        platform_device_unregister(&da850_evm_tl_leds_device);
. S- J. g0 m! U. z4 a0 [! i! n7 B) |1 O) e. ^; j
        printk(KERN_INFO "LED unregister!\n");
  _. I  _! _, S& d+ F/ K5 H1 f}
3 ^6 b0 I) L$ J: W- s( F6 d
2 t8 p- g1 ^1 _& I( u7 Hmodule_init(led_platform_init);
) u7 H: B% ^1 T% s7 j' emodule_exit(led_platform_exit);8 k6 n; ~8 A+ O& h5 f( O
( U" U- V" K) l1 u. |. E
MODULE_DESCRIPTION("Led platform driver");
: d* n, e" v, ?MODULE_AUTHOR("Tronlong");7 B6 C$ t: P& W  Q
MODULE_LICENSE("GPL");
/ C& U2 E& D$ f* |, T- u1 G( D& I6 E& z5 k: u
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-3 08:27 , Processed in 0.040113 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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