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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
5 m& ^! ~5 W& _' O/ S5 o#include <linux/init.h>$ O% X4 G; b2 a8 W
#include <linux/module.h>
3 m, F* J! B/ ~& w4 G! P! y( G% P#include <linux/kernel.h>
3 }! E0 a. K# l1 e) n' w9 q8 g) u# Q#include <linux/types.h>8 t  a% ?6 G# r( O/ o1 r
#include <linux/gpio.h>
1 W/ `0 y; I  B#include <linux/leds.h>/ U, S+ S; O) s: M
#include <linux/platform_device.h>
- B$ P- Y0 b( }( o1 m3 Z* m5 I( T% l. H9 G/ M! L0 v9 j! E
#include <asm/mach-types.h>. l! H: e6 j1 k# t% ]
#include <asm/mach/arch.h>& |, ^1 y1 j( S% q. }5 P1 L
#include <mach/da8xx.h>0 c+ `1 Y% c& H1 p+ V
#include <mach/mux.h>6 U5 w! n+ N4 s) y

5 J. u2 x; S9 [3 e) n7 f#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 z7 }! B  r% U9 r7 i" R8 C#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)6 W0 `+ ]) Y# g" \1 ^6 J
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! s4 v6 F8 B4 m4 I#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 D1 d3 N, Z: M/ U9 x. x; |
6 T) N5 ^6 {! m; r: J2 b
/* assign the tl som board LED-GPIOs*/
! m0 Z# P( I4 H4 x! m% O: mstatic const short da850_evm_tl_user_led_pins[] = {
3 |4 T9 G4 P0 H+ d        /* These pins are definition at <mach/mux.h> file */
$ q: v, A, h4 z( @/ z( L/ ~* V8 ^" q        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( j7 w6 L8 F- E, ^( K3 h        -1
6 w3 C, j+ Y3 F5 C};
; ~8 V9 ?" j% x" Y, {/ [/ A* [0 B2 w+ B
static struct gpio_led da850_evm_tl_leds[] = {$ G, ~% n. j  _# u3 i
        {
3 E2 m% J. h( K, r0 b                .active_low = 0,$ H7 I* ?% r- B+ {' x, g
                .gpio = DA850_USER_LED0,
4 ]/ k1 a# |3 w. \2 D                .name = "user_led0",
/ j. U9 o3 u7 N: W: a8 C6 K2 a                .default_trigger = "default-on",
& o* c: \5 t* Q" ?' O4 E        },
2 x$ m7 q: n; |" `$ Q        {, h' z0 p/ w6 ^5 O0 B! p
                .active_low = 0,( `; A$ [( y6 u0 Q: N% F( f/ k% l
                .gpio = DA850_USER_LED1,
5 }2 v/ o, i$ @( o- x- l/ O                .name = "user_led1",& d3 O/ g0 w* s5 z0 M
                .default_trigger = "default-on"," K0 V, n$ N" s$ w
        },, ^  i' |( e% t7 B) r0 q* g8 `) h
        {7 C/ ~, j; p2 ^  i, c8 h0 j5 d
                .active_low = 0,5 ~! U$ M) {$ r8 N
                .gpio = DA850_USER_LED2,
9 @) ]  \* c  U1 E4 \( \                .name = "user_led2",
2 Y$ B3 y; m( \: \" ]0 R6 ]7 @! Y                .default_trigger = "default-on",) E6 Y4 G8 X; ~' @
        },% ]3 e- N1 p. m8 y
        {4 H6 \& i  Q6 z
                .active_low = 0,
$ r3 l. a9 b2 S9 @  z' W% N                .gpio = DA850_USER_LED3,
3 {! C8 h& g& K0 W3 [/ [* h                .name = "user_led3",
0 r* P$ y: U  x7 i5 [                .default_trigger = "default-on",
; [( V! I: c/ o  @) ]        },
; q/ Q' w& q* o$ I};
3 n4 X. Z) u+ O5 ^  A" P( [; L3 t/ D% ]) y  Q7 A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 j7 i1 R, f" s2 i- @/ Z
        .leds = da850_evm_tl_leds,
- }/ Y3 H2 C7 B% v        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 G1 b0 E$ V, [5 Y, ?2 Q- o
};
: h2 `3 w+ }1 H: T8 C  ~* w" t) [1 a4 v3 r# {6 [$ K) _
static void led_dev_release(struct device *dev)6 y  C" Z4 w8 g
{$ l6 L, ^, O( ]! U, |& h
};
$ D# A! k, P% w$ Q5 X" e
) Q8 M" ]9 L+ V7 [static struct platform_device da850_evm_tl_leds_device = {
( W. q- j% {8 y8 o$ U6 N1 \/ F& V        .name                = "leds-gpio",
7 c5 e, c: ^8 Y$ K/ U* s# C        .id                = 1,4 Q, s5 ?. w+ I, _& c, ^4 T
        .dev = {2 Y3 b. V4 H% G" D
                .platform_data = &da850_evm_tl_leds_pdata,
5 i1 Q' e4 n) M0 ]5 `" {/ ^" K                .release = led_dev_release,- y# N' D& B0 ?
        }
* W" `# {" D: s8 M, m3 ^! w};* k- P/ b; [$ X8 M8 t, u
: ?  T4 T7 [" e; V' p2 Z3 m
static int __init led_platform_init(void)7 I% V! i/ \9 z$ @+ S
{1 B  }1 U2 ?- }* G* s# a% a1 g! R
        int ret;
/ e9 Q! @3 a) v6 v  X5 I$ J' c#if 0
, k4 W1 O+ d) A  w6 v4 x3 J. L) B8 a        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; o0 {3 Q/ q/ A. n8 F2 @" i/ ^: Q        if (ret)6 x& ~+ T8 [# A9 u- \9 z3 ^; R+ s& ?, D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. Z$ @. D- h3 t5 n% N9 M4 s                                "%d\n", ret);
& M, C  |* D6 N' @. T/ }#endif6 f5 o1 q) |0 A4 g+ y/ e
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ c* ]  N2 x( v% J6 B7 ^, w) {' g        if (ret)
+ l- l* X- `" ~1 T8 K( `) ]                pr_warning("Could not register som GPIO expander LEDS");
4 H2 r! F3 G- ]        else
$ U% f8 o8 }, c1 d                printk(KERN_INFO "LED register sucessful!\n");( p# ?, X# o7 L/ C; G' G

# U, F/ y9 D* B0 \/ [0 {        return ret;
/ `8 a" u' |- i}! E6 Z7 V5 p( q5 x7 S9 P0 W+ i
, v5 d) h. U3 `. `
static void __exit led_platform_exit(void)) Q: c; v% I. H: @) [0 E
{0 i& |  b0 ~" m3 `( S- D8 A
        platform_device_unregister(&da850_evm_tl_leds_device);
/ k# ?1 A* _9 g
' h# E- O- h* _" \& w, s  {5 }        printk(KERN_INFO "LED unregister!\n");& B1 ]' \" m9 Y; n* N. X$ m
}" e! x% m" `+ m7 s6 C$ G  F

* t( o2 j, T8 K. s# d9 v/ `module_init(led_platform_init);
: t  R% t" \9 ~4 ^2 ?8 Rmodule_exit(led_platform_exit);- m1 f) M6 }0 s) ]6 I
5 a( U1 s8 ^4 o, ^5 Y4 i
MODULE_DESCRIPTION("Led platform driver");  X+ m( s1 _8 @$ }6 g
MODULE_AUTHOR("Tronlong");. l$ C& z. Q) S2 ^, y) `
MODULE_LICENSE("GPL");! u# M1 J, U6 f, w7 y

4 N3 c% I1 G# ~5 a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-29 18:43 , Processed in 0.046908 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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