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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' J' P3 ]* ?/ x  H1 S$ y2 H! u# a
#include <linux/init.h>) f5 r/ @7 ~, r* C( p+ v
#include <linux/module.h>
1 W" i% _  @1 e#include <linux/kernel.h>
6 l' W' Q* C) u5 d4 C7 _* G0 C0 g#include <linux/types.h>
0 G$ G9 f. e- y#include <linux/gpio.h>) b+ l& s2 f: P+ C+ J  s
#include <linux/leds.h>
1 @4 R6 y6 ~$ m! U5 W/ b( h  X#include <linux/platform_device.h>
6 b; ~. m: K$ ^7 P
9 N+ Y2 u+ Q1 ]' L9 R* P9 ?+ t#include <asm/mach-types.h>0 z+ c! }9 Z( G" t8 `! \" N7 Y5 B
#include <asm/mach/arch.h>
# X3 b$ S9 i& t. H$ n9 s#include <mach/da8xx.h>; b' M9 d  W% b0 u
#include <mach/mux.h>
& N% |; J$ a0 f) x% `5 k2 e
. n9 a6 `0 P) ^) S8 f4 P/ w#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, U+ G( L9 k. p$ c1 E1 P# e4 I- L7 S#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  B5 C' x: m& @/ t; s# X- a
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 W9 U7 k  p" B+ b! G3 l' f$ q& M
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
7 ]! [; A& c) U4 b  D+ P3 X
+ p( _  D/ L/ B$ A* h5 u/* assign the tl som board LED-GPIOs*/6 F+ X3 y4 J  y+ T4 w# c
static const short da850_evm_tl_user_led_pins[] = {  N' p* p$ q  w3 ~
        /* These pins are definition at <mach/mux.h> file */
+ P  K% b  O2 k7 x9 V: U7 Y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% Y( C1 V3 C* ?/ x        -1
4 u, K+ G6 S7 L; `$ H};) M# s' V5 c7 K& r! h

! ~4 y# r( Z) e" X! wstatic struct gpio_led da850_evm_tl_leds[] = {* U* L3 Z7 T: v+ b  ^$ H
        {  C1 x* D+ ]6 n# q: t: A
                .active_low = 0,
, v) A0 W2 j) L$ l1 M                .gpio = DA850_USER_LED0,
  D' d: C8 }- h( W& x4 Q9 Z                .name = "user_led0",
7 O$ a# e+ J$ s+ `' [                .default_trigger = "default-on",
% Q. w4 |' A4 |' r! J        },
3 v8 ^# `/ {+ @  g% A        {4 t0 c; G2 C7 g" S8 g+ H% V3 U4 ]
                .active_low = 0,
2 g! W1 V9 {- U                .gpio = DA850_USER_LED1,1 C# c" |3 X9 X7 c0 D
                .name = "user_led1",% v- a/ J4 b, T
                .default_trigger = "default-on",# u0 z# S' Q" _6 Q4 K# ~# X5 a
        },2 r+ }- m' k$ J
        {/ Q1 p# m# X  Q; @0 B  v
                .active_low = 0,1 e" o8 ~& W, p5 A4 P6 [1 q1 {, j
                .gpio = DA850_USER_LED2,
: o. H4 S* c6 a8 I+ `. j1 w                .name = "user_led2",) B5 ~! ^( m) B" @5 ^
                .default_trigger = "default-on",
' t! g. Z" p! h7 y/ M        },
) y8 ?0 o( P, O0 B0 n) I& h  H+ g        {+ H1 g% o( V; N* b+ Y9 i2 ~
                .active_low = 0,, Z1 T! o0 P" b$ q7 e" x
                .gpio = DA850_USER_LED3,; `2 k1 B: a1 ^7 j
                .name = "user_led3",/ S' w4 Z2 K/ @2 H- F
                .default_trigger = "default-on",
9 d+ C3 o3 q' P! |/ S- A        },
6 U, C& w$ A+ s% ?# d1 r* r};
* Z# P1 a  n, h  }5 i, V
8 \& ~# {' O6 l) X% i" `4 lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- T' X. X% Y- x- [" k$ }        .leds = da850_evm_tl_leds,
# r9 V$ K$ l% x- x        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  |4 X) w5 p- k8 u( Z5 l4 k
};( A0 X& @8 e3 n+ @" W1 K  Z

0 k7 _; Y1 f% r8 S& Q2 [, Xstatic void led_dev_release(struct device *dev)" Z# d5 o  @( b
{9 N, s9 p8 R# T
};6 _# Y$ h! P6 s* Y; F) W
& y! P" o! ?, O+ q' N- }. m
static struct platform_device da850_evm_tl_leds_device = {
- E" D$ G! Q# ~& K2 D  M        .name                = "leds-gpio",
! v. Y. I6 K5 g: v4 ^1 p        .id                = 1,% g; ^0 j+ F0 I- M6 H; p2 Y/ q5 b
        .dev = {8 ]% |% J# p( a
                .platform_data = &da850_evm_tl_leds_pdata,
7 D+ A( s" G% l& i4 k" f9 D                .release = led_dev_release,  ]6 t1 A, ]0 @: \. W
        }$ N  s+ T! O( ]  @1 ^
};
: s, D  u6 H% ]" e% T+ D0 {
7 D" [  a: L7 K/ Tstatic int __init led_platform_init(void)
# ]) ~, h! B$ h5 ~{1 ]/ p# c. N. g3 h& G5 @
        int ret;
9 \5 t- D/ M+ h6 m6 Z- f0 `#if 0  O4 k/ ~! g7 `/ ]; Y9 W
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# _5 k: l" y6 U4 ]4 [3 P, @( N$ j( C
        if (ret)& r5 g, a9 ~6 e# ^; W
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# i5 X% N) M; K" X. C1 k                                "%d\n", ret);1 i4 e: d1 j, F5 P# B$ d
#endif! Q+ }9 K) O4 ]; s3 }- w+ [/ T; B
        ret = platform_device_register(&da850_evm_tl_leds_device);) g( m7 d' l$ C2 _
        if (ret)
/ z- ?" v% _! l- Y. J! Q# D                pr_warning("Could not register som GPIO expander LEDS");
0 X3 I3 @/ y; v, ^        else2 f) ?% p1 W% Q( a
                printk(KERN_INFO "LED register sucessful!\n");
; H- J- Q; p& s' ?4 t) v2 K6 b1 c& \1 \4 a% ]2 Q
        return ret;+ s: z$ A  |+ v3 X7 w
}
) a; N9 R3 N1 |+ Z4 P* F* P' g/ R3 C# ?2 A( X8 a
static void __exit led_platform_exit(void)  p! F' o& [! C
{6 j$ r" i! H' `$ {! ?) m5 G+ j
        platform_device_unregister(&da850_evm_tl_leds_device);
, ^$ l% }& @, ~: m3 n" U) b. d& m* W% H# ?- W1 g
        printk(KERN_INFO "LED unregister!\n");/ f1 u* ]5 D: T4 E& s3 y
}, O: ?7 U" d5 ?4 ?# I: ?7 R) T8 }
, @7 ?& N) E1 z5 N* m
module_init(led_platform_init);
8 E- m- c; D. D' I7 c7 D$ c4 \module_exit(led_platform_exit);1 C. v8 O6 n8 @9 N6 v; A
5 c) Y3 O4 [8 N8 f& c, u. z
MODULE_DESCRIPTION("Led platform driver");
0 o/ H6 `; Z0 L' ^% N# f) d$ @: pMODULE_AUTHOR("Tronlong");  Z4 r& B! q7 x
MODULE_LICENSE("GPL");" I% U* y2 R% x! L( o3 A
: {# [& [4 E5 K9 i# j
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-3 05:27 , Processed in 0.043397 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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