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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ N% I. ^$ b. x: s' J#include <linux/init.h>" V4 I8 a3 Q" d- z$ Q
#include <linux/module.h>6 K3 U4 a, W9 W* A
#include <linux/kernel.h>. j- [# u! X4 Z* h6 D$ z: @4 R; ]
#include <linux/types.h>- y2 j8 `+ K9 g* I9 z
#include <linux/gpio.h>( _. ]( {  }' {2 |
#include <linux/leds.h>
2 R( K9 [+ V& s3 r. y#include <linux/platform_device.h>
1 ~) ]  n  X7 e! s3 I' w
; d2 |% f5 X  p) b1 a# a; C! K5 D. T  C#include <asm/mach-types.h>1 \! e& C: s0 i! a9 y$ A
#include <asm/mach/arch.h>
+ B7 k% @4 L, i$ i#include <mach/da8xx.h>
) e) s2 C; n4 @9 q  F' l#include <mach/mux.h>; b/ a0 h7 y) i

. k9 M& _/ i8 z( r/ T( J6 U#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: ^) s2 V/ R# n% |" c#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- c) f8 c% Y+ f  y#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) |# j9 n6 U/ f8 z' E
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). b  f6 f, D( ^$ f$ M

) w0 ~: \9 |7 I2 {/* assign the tl som board LED-GPIOs*/
" {- n. |# Q2 V3 _static const short da850_evm_tl_user_led_pins[] = {0 P( e0 V; M$ U5 E5 y
        /* These pins are definition at <mach/mux.h> file */7 O* j( U! i6 O% J4 I  I9 w
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. f+ |" \8 G  U3 M
        -1& p: N" \/ e$ K$ ~7 z
};. y$ Z. i5 P0 ~4 `: H# ?& T

% ^% v. r4 m2 ?' g5 e2 h  {+ dstatic struct gpio_led da850_evm_tl_leds[] = {& U' u& j' J/ {% h+ I- {
        {
& S8 z- Y: H6 W! E) I2 O                .active_low = 0,
. r7 S4 J5 g' j) u4 }5 t                .gpio = DA850_USER_LED0,8 I8 y3 R4 Y  g5 P( G
                .name = "user_led0",
8 Z+ ^$ d7 Z3 E+ I! y* K) n                .default_trigger = "default-on",4 e4 j0 i9 \. _
        },6 M' `9 ^- Y' w+ j5 F' o
        {
. P( F: C/ W3 }- r                .active_low = 0,6 t" B3 R- |5 F0 E7 I
                .gpio = DA850_USER_LED1,
% O# ^7 }4 d9 w) Q# k                .name = "user_led1",! x; j2 B0 |2 |* m) P1 d0 T3 O
                .default_trigger = "default-on",/ |& N; S* @  H5 g( q0 A* E
        },
6 C  P7 Z& B6 a) E        {! L; n; I9 D$ T7 j- Y
                .active_low = 0,8 ]) n) r3 Y. n
                .gpio = DA850_USER_LED2,, g0 T/ s% N% d6 x8 W% c5 \
                .name = "user_led2",& b2 U6 s) V& q  v, P
                .default_trigger = "default-on",# p; s: o! Z5 j* E: L+ l, w
        },
1 r$ }" W! k/ J- Y  U$ f4 @" A        {. c& \8 o2 I- W! t( [
                .active_low = 0,4 Q# H) }8 w: B, S
                .gpio = DA850_USER_LED3,/ A# }' S7 J' K5 E
                .name = "user_led3",0 H/ {2 o1 G; J/ a7 x
                .default_trigger = "default-on",
1 T: e8 r& \9 }/ g8 n, I+ P1 D& ]        },9 O( d# J% m4 E1 A- Z# O
};
5 M( N9 d- x, N+ J, J$ a. j7 k& X
3 j! x) @& u: U: cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* n8 _) P0 H' X: \
        .leds = da850_evm_tl_leds,$ s& ?# C# V6 ~# s$ w& D
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! }. k: I) Q' |, p% A+ W
};
" e  e1 Q' L0 [; ~7 g7 u9 P7 h4 K0 S. v8 P9 V- w
static void led_dev_release(struct device *dev)- h+ f: S+ j" I
{( `7 \$ _: E3 Z. D7 e9 A" q( Q
};
0 ~0 T) f8 _$ l! {( `, B  Z% @. T3 Y
static struct platform_device da850_evm_tl_leds_device = {. z7 u/ e2 f" C) Z$ a
        .name                = "leds-gpio",/ m( i4 }2 p* P
        .id                = 1,
  W8 J. I) s* A. A8 c' ]        .dev = {2 C+ w8 ^9 w: x, x/ r
                .platform_data = &da850_evm_tl_leds_pdata,7 l5 D+ `& |: s9 ?6 l
                .release = led_dev_release,
1 _- R" W: U5 U* N7 D        }' Y! s1 E9 e. v) X; r$ G4 W! [4 G
};; q+ S' Q- ^* l2 N  D

. J. J* c* z" r2 ^. t% C- q" p$ Rstatic int __init led_platform_init(void)
7 k; e7 `5 }" m( E& e9 H6 ~{
/ k# p) y& r, b5 `, J- b        int ret;; R8 [3 u+ C8 @6 x; H- K; m, E
#if 0
& i' j- C) y) j4 S8 }        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ L0 ?7 K1 B1 z5 E; p
        if (ret)/ k6 z' h- H2 q0 C3 h
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 D3 K9 @) J3 s                                "%d\n", ret);
) d! O6 N# g7 y/ ?! ~: l, R#endif
( E* ?; b" H$ @5 }% v; G        ret = platform_device_register(&da850_evm_tl_leds_device);5 d1 R" K. p: _  \% Z2 m* [
        if (ret)6 H, K* A# k+ f- x1 B- Z
                pr_warning("Could not register som GPIO expander LEDS");1 I6 S, R- g% ~3 K/ f: D2 s3 m; L
        else
2 K4 e* F* [2 w% V( g9 |$ b! S                printk(KERN_INFO "LED register sucessful!\n");
# p6 X1 K4 |: h* z* Q4 x
' Y' f2 s2 o+ a9 x4 Y6 ?! V: P        return ret;* b8 i# q' A2 S4 v, B' z, ~7 o; k
}
* i1 \# `$ H- u+ A  \! r8 G4 N/ p$ ^2 m
static void __exit led_platform_exit(void)
' `: t+ |' A+ i{* Y5 p5 ]+ K# P. y; K7 }
        platform_device_unregister(&da850_evm_tl_leds_device);
# K+ n4 K! e% ^# N. [1 g* {. s, @7 G1 X" A4 w: ~" D& K
        printk(KERN_INFO "LED unregister!\n");
( F4 V" p  y8 o+ ^8 H0 A* h}% j# o' G' }/ v2 q! k8 g9 q
. L, [) t# l, n% A
module_init(led_platform_init);' q) ]: f& L) |6 T* B
module_exit(led_platform_exit);- {) }; J$ ^! T1 a& h* b" f
% g+ |4 v% b' e: @" b' z
MODULE_DESCRIPTION("Led platform driver");
( J2 K" r1 M6 xMODULE_AUTHOR("Tronlong");$ `# z7 ~, |+ N$ k5 |
MODULE_LICENSE("GPL");
2 J) r) ~6 C' m% R1 g2 @
4 \  u7 @2 M( V3 q& }) B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-8 18:01 , Processed in 0.040577 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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