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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 o2 F  A! N. @
#include <linux/init.h>
* t7 b9 p- m  J) v; X#include <linux/module.h>; q( E* l7 q, }6 j- W* |* s
#include <linux/kernel.h>
0 X' P5 b! d5 }3 d#include <linux/types.h>1 f0 |4 O2 J* V6 l8 Y1 p; v+ R
#include <linux/gpio.h>" |3 q$ H4 r4 F) q" j7 ]7 z/ _0 ?- |
#include <linux/leds.h>7 G4 H! O  M3 y, n$ O
#include <linux/platform_device.h>
* F1 M* J) m& d2 i+ k  U3 s% y( A
0 l  Q* g- T' r2 L#include <asm/mach-types.h>
6 E2 Q9 h2 J4 x5 ]/ N: b% |) x#include <asm/mach/arch.h>/ L; N( Q: _  p, s
#include <mach/da8xx.h>
2 [+ U9 p; Z( \+ s- ?* o" \3 a$ Z#include <mach/mux.h>
% m' a" P6 F9 L  S
' c1 G9 t" T7 z; S+ r#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) S7 T. B2 L: b. P' z) X#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 o$ D5 }7 V, z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 t0 V4 l* z9 a/ r
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)0 G$ @/ `! N% b+ D6 i$ Q# V# A

6 p- ]# r* q0 Y  M1 k0 J' ~/* assign the tl som board LED-GPIOs*/
5 w+ Z* A9 W4 {+ M7 V: ~static const short da850_evm_tl_user_led_pins[] = {, J0 L! n6 h6 X: H0 A
        /* These pins are definition at <mach/mux.h> file */5 D5 x0 `. q: Q: ^
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# ~% |/ Z7 X( s/ @1 ^" ]$ i1 S8 J        -1
6 s4 R: E' [5 K% o1 m4 A& `};6 F: p" [5 c. _
1 n6 M4 s; A* e' l8 V2 w' b
static struct gpio_led da850_evm_tl_leds[] = {( q- [" W  q( t- f% `) i1 U
        {6 y; u5 {# [+ K+ P1 U# b; G" r
                .active_low = 0,
' y/ K; [1 _! V- k, o( E- r7 D                .gpio = DA850_USER_LED0,9 V+ d8 P- U( q! l- g3 W: d# f
                .name = "user_led0",
9 e) r, \4 Q4 ~  `  b                .default_trigger = "default-on",
2 I4 ~. L% @! F$ S/ R! T        },) ]! j7 I3 X/ Q( t! O
        {  u+ H# A" T' [
                .active_low = 0,. ?7 H+ ]! W4 L' V6 P
                .gpio = DA850_USER_LED1,* E4 ], F2 }" m3 t; X0 _% d  [, U
                .name = "user_led1",
8 d3 t& b0 t2 u$ J& j                .default_trigger = "default-on",
0 L: m/ D& C2 A4 N  q        },  s# ~# z  _* r! w0 y$ i) g# D
        {3 `! C8 g! n$ {0 {6 C+ K
                .active_low = 0,1 m) c+ t9 u0 `. u' \$ R
                .gpio = DA850_USER_LED2,
# i6 I  j9 }8 H9 }. i& s: K                .name = "user_led2",7 u# q2 v  ]" J7 n3 b
                .default_trigger = "default-on",6 F" _: P* \! u
        },# s7 ?0 Z8 f7 i0 f
        {. b. {4 m  l! R% K4 Z/ }
                .active_low = 0,
) M1 g/ r# [% K8 _9 l2 u) n                .gpio = DA850_USER_LED3,
7 s# u4 E1 @3 ~                .name = "user_led3",
) _; j2 y4 z5 S, \                .default_trigger = "default-on",2 I! ?0 A# p/ L3 W
        },9 b# K  v* ]: X2 S
};$ r+ Q) n# m' H# A) w
% n' k2 l3 E; }; _& _: P6 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 X. s! T2 c8 V. o2 ^
        .leds = da850_evm_tl_leds,9 `& @* f9 v  L3 d$ {0 D8 o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ D) q( A5 P& Q: Z  P4 A7 {
};% l/ L% G# x8 E0 W; S2 C8 X0 C6 j

7 o1 V2 [( L5 a/ J) p8 M9 T1 wstatic void led_dev_release(struct device *dev)
* V4 A' o( C8 W& Z. k{  }& V3 U! p+ g1 l' ^; J, p5 X
};
* S! ]% Y6 p/ ~) C& L, u2 b( \6 w! y
static struct platform_device da850_evm_tl_leds_device = {
4 n. ?- ~, D: P& s, K0 r3 w9 Q        .name                = "leds-gpio"," i# q$ A- a% E5 Q( Y
        .id                = 1,
( ~( Q, o7 r1 D5 p6 m  Q6 D        .dev = {& @) ^8 R2 a9 g0 _* o; o  I
                .platform_data = &da850_evm_tl_leds_pdata,! E2 e. c  p+ T8 u8 J& X/ Q4 ?
                .release = led_dev_release,5 T6 ]$ `5 i" S
        }0 F$ [8 m- p5 w4 D8 D, c
};
; U2 |0 e; p$ c0 t! _& G4 [7 D1 P0 u
static int __init led_platform_init(void)9 f1 @: H2 ]% G% s
{1 H7 _7 v, H, ~; ~
        int ret;
0 T( k% h& S& P, O0 b" R1 H#if 0+ G9 _9 F* p1 R( v/ a- [
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ T0 d" w& `3 y+ y  }        if (ret): o  P& q# |& K: y+ o1 E) J
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ r8 m1 _# D+ Y  L# T9 U                                "%d\n", ret);
% f/ J3 r4 N- w! R) H6 L  \; r7 L#endif
, ^; F% B3 c( b& D8 _% d        ret = platform_device_register(&da850_evm_tl_leds_device);
" ~/ I& b5 t8 N/ O3 j8 c        if (ret)
/ g" u% g% ?; U) W                pr_warning("Could not register som GPIO expander LEDS");
& d, K& L( g( c: S        else" l8 a' \1 h1 l) p, Q% W6 X5 o- G
                printk(KERN_INFO "LED register sucessful!\n");, B8 N1 w( ^* _5 e8 V* o
- f$ A1 G' o- u3 ~" D7 Q
        return ret;1 w* a# U5 \! p# \
}, D) L3 k7 h- z$ r

8 x5 m0 T8 N1 q" h' `0 z4 y4 Y$ cstatic void __exit led_platform_exit(void)/ [9 X$ |2 b2 ]8 o' @
{( X5 ?5 G" o7 @; |  G( ?$ {& u
        platform_device_unregister(&da850_evm_tl_leds_device);& _' ]. G$ [" y3 W4 Z9 |2 P

* N, T) r8 M8 M' H2 s        printk(KERN_INFO "LED unregister!\n");3 D7 r  l" j1 g7 ]7 u5 L/ O
}
0 N, s( n" G7 Z1 g2 K+ C5 O8 z" R& c" a% @& |4 L+ M( l8 K
module_init(led_platform_init);
- Z0 s) c# w0 ?* [module_exit(led_platform_exit);
- S( R( K# j8 ~0 P8 J. h  y! ~4 r' e6 u4 F
MODULE_DESCRIPTION("Led platform driver");
0 I+ Q* ~5 C( M  _! hMODULE_AUTHOR("Tronlong");
, K1 z, k; F/ u) cMODULE_LICENSE("GPL");
% A  Q/ U$ O2 w3 P  ~
& j6 c, R% g, a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-29 15:47 , Processed in 0.036576 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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