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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, ^, _8 @% _( [% O5 a2 _0 P3 F! j#include <linux/init.h>9 e2 H' x3 C" g
#include <linux/module.h>2 W# H7 r5 g" Q* F7 c2 C
#include <linux/kernel.h>
, v, B1 N3 m# n) H4 N" |1 Z- t#include <linux/types.h>
0 t" H/ o* [0 F) G; d#include <linux/gpio.h>
& K5 b$ P+ q3 ^: f1 z# E, f2 x#include <linux/leds.h>' e9 [" j# K0 L0 `) f9 O) \+ m8 |
#include <linux/platform_device.h>
4 |& d8 ~. v+ P3 m/ `
! v. C4 w4 _2 u0 S8 N% {#include <asm/mach-types.h>) A! V$ K* Y' X  ]) q
#include <asm/mach/arch.h>
8 v, H- B& e+ C7 ?9 S#include <mach/da8xx.h>7 T9 n: I# ^3 W) h# M
#include <mach/mux.h>/ ~4 d# K8 H3 H3 \' I' `$ j& c9 |+ k
4 ~( H, f7 w. f6 O$ t  H% m8 d
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; M. m* M! U8 K8 D2 \+ o/ s#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 v1 C" B) W" x4 B
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)7 y8 B& c2 E7 ~* h/ S
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 S7 y# _2 u/ E+ r
: Y9 ]) _% a. b5 e2 l' f0 G/* assign the tl som board LED-GPIOs*/
: y) ^8 e8 e0 P* ?, Q- @static const short da850_evm_tl_user_led_pins[] = {
6 q& ]& p( A/ C        /* These pins are definition at <mach/mux.h> file */
! a' ?/ X/ D% K! x- w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ U' z, i5 @8 \5 R7 G3 e, {5 k        -1$ i3 N" ?: W4 e3 a  z8 Y. W2 s
};4 h& [! p4 l7 ?+ w* _# o

" ~6 |: O( T& K8 L2 S( ~static struct gpio_led da850_evm_tl_leds[] = {/ `) u5 `6 y& n4 P1 |
        {; ~, c  E! z- l$ J( h' P; T
                .active_low = 0,
/ G' z) l! ?1 }, i                .gpio = DA850_USER_LED0,0 |) n$ s/ p/ W4 J7 v! h5 z" ?7 i
                .name = "user_led0",
, b' t* a+ Y0 Z0 x                .default_trigger = "default-on",
7 j1 \$ d( G8 w' U        },
3 \% R" k+ D' d2 z: h        {
- }* q" g( [7 d" Q. P3 r7 m                .active_low = 0,
% U+ y1 O; W5 u9 J  w                .gpio = DA850_USER_LED1,! v. t+ h; |& i' {
                .name = "user_led1",% T3 i! n; H% b$ W9 Y
                .default_trigger = "default-on",% Z* l" j' l0 D9 D  {2 V
        },/ Y3 }  Y/ a8 n/ X; c6 g5 ]' B% ]& A) `
        {
5 ^/ V& q. O8 b6 o                .active_low = 0,9 S! h% P( o+ p$ p( `. g. u
                .gpio = DA850_USER_LED2,
0 d0 U- _3 L9 o4 D7 I% P- C$ r                .name = "user_led2",# _0 W$ G6 e/ ~8 L/ w4 _- A
                .default_trigger = "default-on",# e1 q! w: {+ \. U3 B+ H0 b
        },
7 ^& o" Z# }4 C$ ]4 _9 L        {: P+ J4 Y7 F7 p% f" V
                .active_low = 0,9 M3 _/ Y4 N( o' i) ]
                .gpio = DA850_USER_LED3,
& M% f6 J: {* S) P% N                .name = "user_led3",6 I2 o+ G" p1 `. x; c, r' @0 \
                .default_trigger = "default-on",' {- Q( r9 e6 s6 m6 V& |
        },: V, p8 w' J6 K0 S, T) c: z5 H  v7 `
};
$ L* R- ^  u$ m: y2 m2 H/ x, b/ U
+ g! u3 ~' G* W( ~% ?9 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" w: m9 e5 c" P% {        .leds = da850_evm_tl_leds,
, A' C  v. d: ^, h6 [* x        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( X2 Z$ M, z7 Y: y8 v};' G4 l- L7 K( U' a

% [1 a! _* P1 lstatic void led_dev_release(struct device *dev)
, _! C( p% _$ b/ b! I5 P5 O& A9 v{: d# ~, R' R& \, f% b& c, Z# g
};
  C$ X* d1 [' W6 g0 i. b! U
+ [3 V, f* o- Z/ I  h/ g  ~static struct platform_device da850_evm_tl_leds_device = {
% R/ n. C  Y$ S* S8 N+ k        .name                = "leds-gpio",
" g) N% r) A( q6 N. B8 a        .id                = 1,* v, {7 ^9 U2 T2 ~
        .dev = {# D; P; {9 h  |+ V: s
                .platform_data = &da850_evm_tl_leds_pdata,
" y  m/ N2 O2 c                .release = led_dev_release,5 N% w. o: U- C5 C$ [
        }/ u# M2 M9 m; ~- {- a1 u/ a
};2 ~& a# `) `1 O9 d1 a- x
7 R, W& {: _9 O3 w- J4 C8 f
static int __init led_platform_init(void)
9 z2 R0 [2 E. V+ D2 M{# P: e/ k- k/ p% y
        int ret;
) r7 l+ X3 ?8 t; h6 o#if 0  K2 q7 Y$ {) `/ y1 R& X
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% l, F/ a' i! y        if (ret)
' O8 R6 M# ^! P                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ P4 e0 D8 W5 \" [4 \% ?3 N                                "%d\n", ret);% {2 r' E1 s0 w" {" ]( F" p7 s0 u) w$ W
#endif& l) D" [$ q/ c8 o. ]+ g% {/ B
        ret = platform_device_register(&da850_evm_tl_leds_device);
: y- _; K6 G% ?3 x2 M( {        if (ret)
/ [# h$ v+ P! p. ~' \* E4 [4 _* L                pr_warning("Could not register som GPIO expander LEDS");) g: T& l9 q6 j4 d
        else
7 k- o6 h; [: `& h. R8 U                printk(KERN_INFO "LED register sucessful!\n");
) ~5 B/ ^+ R: e& y" s5 a; B0 i4 N) B. u2 u& x6 H
        return ret;
  J9 `7 S9 x# l# b% X# k}
6 o8 o# x, W: M, X# R, n0 b/ w' h* q4 V+ x- |! [, ~( Q
static void __exit led_platform_exit(void)
" c) P- U' C% P+ u2 s! D* q{0 r3 a* Q0 K8 o# P* q) S) ^; w
        platform_device_unregister(&da850_evm_tl_leds_device);
5 f2 P4 B/ P1 l0 V. X
' v& d" n) y/ m# w/ I6 M        printk(KERN_INFO "LED unregister!\n");  ?* `/ u% M. J* B
}
* D& w# Z8 G4 y$ w
1 N3 U, o& b. Q, `module_init(led_platform_init);
6 ?2 g) H& Y7 }% a8 amodule_exit(led_platform_exit);& e5 O% M: w( r( m- V. ?
' Q3 Z7 _" O) z7 f; C
MODULE_DESCRIPTION("Led platform driver");
, J, p8 P3 T' P; CMODULE_AUTHOR("Tronlong");3 M$ C/ H$ g& m- V$ o7 [3 {
MODULE_LICENSE("GPL");/ f. m, e9 t, ]6 M
2 ~$ m+ @9 E: {1 J1 V
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-10 19:44 , Processed in 0.037580 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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