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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
+ Q8 j4 D, L) D. u5 L#include <linux/init.h>, O- h" _4 X# f& B' C- v
#include <linux/module.h>2 V% ]+ r7 `5 ^* Q  |' J  h6 ^6 D
#include <linux/kernel.h>
( ^% [% ?" i8 X4 z" C% a) v#include <linux/types.h>
; w! S  }* b  X6 a0 b, t#include <linux/gpio.h>
4 P" @& _6 @! y8 K" d) @#include <linux/leds.h>
# g8 q# x" O0 a; ^0 c: {5 m, G% d#include <linux/platform_device.h>
& V9 J/ s5 o- J9 t# {6 D
& L  M4 m) D2 T1 ]( w5 ~9 X#include <asm/mach-types.h>  J- t7 b/ ]& g) E5 ?- g* {! Y, y8 Y
#include <asm/mach/arch.h>
9 ]! p- j2 ?. z1 O. ]! T; L% r  f#include <mach/da8xx.h>6 s4 K: h5 k$ s3 y4 y# a! v3 J
#include <mach/mux.h>2 k( E6 K% Y7 n* d4 }" k# I
, a! ^1 u! a  F1 o
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)4 t1 o; V5 v- J* h- U# ?7 U
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)) ~8 G; w) I3 M" i' f9 k7 ]4 M' ~
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
1 \! s* C8 {; {$ r5 }( d- H2 F#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
% R3 T) O0 N# E( m' }. `3 E
- n: ^& Z& _* b, a, p7 `) b/* assign the tl som board LED-GPIOs*/
0 |! H# ?- e/ j+ x# y( B0 Bstatic const short da850_evm_tl_user_led_pins[] = {: d- G) x, P. A" p
        /* These pins are definition at <mach/mux.h> file */; Q2 l  w: @; u+ K
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, s4 k6 j! u8 T
        -12 k& X2 [( K" }" g) F9 N
};8 w3 F+ K; k3 p* P) z

) c. @4 G4 I: b. ~3 s$ Q, b! [static struct gpio_led da850_evm_tl_leds[] = {- A* ~( t7 P* @6 k8 q: ]
        {
; B& `* A/ u+ @- @" Y                .active_low = 0,
2 g% n6 e, \3 y, D6 z                .gpio = DA850_USER_LED0,
/ p8 n3 ]' W- s( h; [                .name = "user_led0",
5 H0 F' e3 R) b% ]8 R1 H) G, o                .default_trigger = "default-on",% _7 g/ @  s) P9 A2 N( u. V% D
        },
* q; m& |# D0 M: a( Z3 A1 W        {
; @0 ~6 ~6 H5 l; s                .active_low = 0,6 V; e% I! Z) m) }1 h* u. }' x( y
                .gpio = DA850_USER_LED1,
. h2 O( ~) A3 V1 ?                .name = "user_led1",
- A3 ?  ~! d3 e# K9 n6 j                .default_trigger = "default-on",8 X2 h1 B2 F7 `" n  F
        },5 G% c: Q! E: r
        {
6 I$ [6 i5 S6 x1 n                .active_low = 0,
& q' d8 ]( J# b, Q6 _+ W                .gpio = DA850_USER_LED2,; }% L% h& `- \0 |
                .name = "user_led2",
% w# u0 U4 a* h% e                .default_trigger = "default-on",
/ r4 N3 I9 T* O" y        },
: ?- [/ {: G) \; O. c        {
4 V! `+ e0 R9 ~" D0 I( l! D1 v6 d                .active_low = 0,: `0 M; P$ a1 f0 {
                .gpio = DA850_USER_LED3,
. C6 f9 A9 c7 l                .name = "user_led3",5 E( M+ c/ z4 j6 l
                .default_trigger = "default-on",% o* W4 n4 |9 i* }- P+ ?
        },
% p- c1 S5 w/ T4 c8 Y};
2 L0 z8 D8 r- {0 ^. @/ v0 j8 R1 |1 `) N; r5 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& w8 t( n: q- F; f9 `4 ?        .leds = da850_evm_tl_leds,
5 ~: C2 d$ O! g. _4 ^8 }7 X        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. z$ W6 k1 s9 j2 Z
};1 q# X" ~' |* L- M, Q6 ]' u+ |

8 X2 H4 F5 @& Ostatic void led_dev_release(struct device *dev)6 y: V- |! }1 }- n5 H7 T
{! I+ o# M6 }! R; b9 s! l
};
1 _+ h" Y' J& z: H) `* u5 e6 e9 S* D+ V. x
static struct platform_device da850_evm_tl_leds_device = {( D* A6 b! G9 n2 I3 B
        .name                = "leds-gpio",  b4 r1 T- X1 \! k* G
        .id                = 1,
, ]0 E2 Y+ J/ Y( P; e$ o: G        .dev = {
$ g! S" z1 R/ X                .platform_data = &da850_evm_tl_leds_pdata,
' `# m1 }) |$ K! |1 }                .release = led_dev_release,
. V4 ?& M7 \* K, [! a        }
, Y  Y5 b: A" r$ p5 x* D6 U7 I9 u};
/ R2 W# I; o/ [
# j: j9 T! j  kstatic int __init led_platform_init(void)9 \/ m- X% [- o$ V- u6 ?/ D
{
9 B5 n  q2 f7 M# w) p; [        int ret;
7 g5 k+ z8 G+ o#if 06 @3 }, r1 o2 T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* S4 T0 z8 U; T$ w5 m" {4 X3 \! x        if (ret)7 S5 f0 r9 \- T4 h% n1 B; T/ X
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 h! U- H! h3 M7 z
                                "%d\n", ret);0 E$ U( j  Q5 R7 u
#endif4 w3 `8 `" W( g1 Z" U
        ret = platform_device_register(&da850_evm_tl_leds_device);9 m1 M' w. D% F7 f7 A$ [. \
        if (ret)7 P. ]( l# c/ o* T% P5 H" s+ |
                pr_warning("Could not register som GPIO expander LEDS");* h0 M* D9 H( }6 g: {
        else
4 Q( {0 n3 M+ M. f                printk(KERN_INFO "LED register sucessful!\n");6 t2 U; }! u; Q& f

. L9 T  H! ^' h9 b2 }1 s        return ret;
& w- p; ]: H' a  z# Q}: l, Y$ @- `4 ]/ ]" `% u
$ A- K& [3 i7 F9 U, J
static void __exit led_platform_exit(void)0 J; ^( H$ E- m7 U1 N
{! `3 u7 f! ~4 e0 {
        platform_device_unregister(&da850_evm_tl_leds_device);0 ]7 W; q: i1 d2 k2 h

2 K3 o' r$ c+ m$ z; t& e6 X        printk(KERN_INFO "LED unregister!\n");
6 H& K' o& p$ J( F7 a% m# }/ w( E& Y}" o! G  A! Y; J, g% o( a1 }

/ U$ E! L% Y1 R* f9 R6 L  {module_init(led_platform_init);
$ c4 K7 S& M5 `! G: Z6 emodule_exit(led_platform_exit);% `) e7 E8 J. P6 Z

* G5 G" I- y9 u1 K1 PMODULE_DESCRIPTION("Led platform driver");% b8 T# s/ S! Q& V/ r$ _
MODULE_AUTHOR("Tronlong");4 F  r5 n1 r' G1 q
MODULE_LICENSE("GPL");
' t: K' X1 m# Z$ f" n
% ?7 g$ Z( U/ C2 Y, C$ Y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-2 18:22 , Processed in 0.039420 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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