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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ B' L2 b, z- @9 b3 A#include <linux/init.h>. V3 C; q) q2 p  ~
#include <linux/module.h>
/ t) m. c/ O, T2 n#include <linux/kernel.h>) L  z) S' ^- p
#include <linux/types.h>' r7 P' l# l* q7 M1 X8 K
#include <linux/gpio.h>
3 G1 u; E" L! h6 s/ w- ]! H#include <linux/leds.h>
4 I; v( W! ^) g8 F% _5 {1 B0 N$ @#include <linux/platform_device.h>: C, H; s! T* r$ `+ D

2 X$ R- P( R! T+ M$ ~  E& @! y, b/ G! r#include <asm/mach-types.h>% i3 A1 M1 p* D0 Z  Q
#include <asm/mach/arch.h>+ t3 w) v1 C! i( Z2 C
#include <mach/da8xx.h>. k" {7 W0 y) b4 Q
#include <mach/mux.h>/ V' o: n9 c" y) ]
" b% w  ^8 z. }+ L: m1 Y  l$ F
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; F3 n/ q8 c  S6 C+ `4 d  h! v. N#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 ?+ s3 Y% z. \7 [1 e3 i9 z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 i5 U; n6 g4 q: m2 Q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  n0 K4 b; H5 v4 y& Y. P' e/ R# h: v" O
/* assign the tl som board LED-GPIOs*/
1 w: T( Q! q! R- Q+ }  Tstatic const short da850_evm_tl_user_led_pins[] = {- a8 I% E, z2 J  F
        /* These pins are definition at <mach/mux.h> file */" Z3 O3 ~; ~: J
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! [5 ]5 X! J" x$ ^1 ]' Z
        -10 }4 _7 w5 F. S: |# b) l* g
};
/ A- T, n* D7 t* F
+ P+ l6 b$ X5 J- o9 Z+ l* Nstatic struct gpio_led da850_evm_tl_leds[] = {
, }; s4 H! I1 a: h# G( Y8 ?        {+ S1 I  e. W( g+ r) ^: d# r+ _
                .active_low = 0,
0 z) z1 S5 a! l0 \                .gpio = DA850_USER_LED0,+ r! J3 |& [+ [# n5 K* g
                .name = "user_led0",
& d- n; o* O. N* ?) Z                .default_trigger = "default-on",
0 s/ Y( ~( g( O- \8 d        },7 B1 \8 p* a& }- H
        {- p" O! p. z2 m0 O( ?5 {' k, o
                .active_low = 0,
" @$ J8 ^% z  r                .gpio = DA850_USER_LED1,, W1 r" ~$ J3 c  G: J6 [+ y
                .name = "user_led1",2 V! M, O, H, @# q" N$ @( I, o
                .default_trigger = "default-on",; B/ @& g4 B8 |
        },
$ H0 r  Y& `7 O; [' a: k6 Y        {6 E6 U, }4 D+ T
                .active_low = 0,
8 S1 T: h* h3 n* k* o# }                .gpio = DA850_USER_LED2,
# p" J5 y7 B: X# c. f% G                .name = "user_led2",4 I# ?* k7 M  f8 D5 v% A
                .default_trigger = "default-on",& F- k$ y) {6 O/ |# [! {- E5 G
        },' |9 A2 z) C* |  e
        {; X1 \% q& g& V* `) Q
                .active_low = 0,
% Z3 p5 y4 |  `  B5 }/ x1 o2 f; D- K7 W                .gpio = DA850_USER_LED3,4 N: x7 q. P, g% W; {. K, U* _
                .name = "user_led3",
% M0 @* O" z! [! _                .default_trigger = "default-on",/ ?; ~( I% q& I% ~0 a/ z0 F
        },
1 m, ~% p, l; k) U& q};  r+ f$ z$ [4 W: J
" _# `+ Q3 F0 [+ e. e5 M( b( }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" R- Q% |) {! v
        .leds = da850_evm_tl_leds,. {+ L" [, v* @& A+ _* ^# U
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 F, C& }: o1 z6 X) s' ~7 G};! x! B5 N3 V2 l
& C; ^9 o( B9 k: u6 S
static void led_dev_release(struct device *dev)
1 i( ]5 H6 T( U; l# T2 ]0 L{
( F$ M6 x6 q( _* X};
# w. r+ ]9 r+ T
+ z8 r; ~4 k- p- f6 t4 zstatic struct platform_device da850_evm_tl_leds_device = {- ^/ }2 E1 c% @" A2 `& @  E5 @* n
        .name                = "leds-gpio",
1 {* z3 y9 S$ j3 {1 u. A9 r        .id                = 1,0 @% w% Z# U9 F4 n) U" U" N: D/ a
        .dev = {6 |  ~6 G# [, I" X5 p
                .platform_data = &da850_evm_tl_leds_pdata,
- w2 u5 T+ I: R& V7 t1 p                .release = led_dev_release,
; }5 ^6 [/ O) U8 c$ l0 S! X, y# s        }
- d- C5 Y+ R0 }- P};
/ Y- I- e0 C: O, A) l/ L. U1 B7 N& G7 o( x
static int __init led_platform_init(void)
* G$ T" P* Z2 n! L2 P8 w{
+ k- y. B& a) C  ~6 {& ^        int ret;' l" c% |" X" c- T$ s
#if 0; ?* q7 _9 W  V: f! k( s
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* I5 N$ n- ?( j8 m4 [, m& ]        if (ret)
5 ^9 k, C$ e1 q                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; p+ Z4 P* U* L, Z% p$ T9 q; ?
                                "%d\n", ret);
9 Q/ @5 ^8 R, s2 _7 h#endif
5 D8 t2 E9 Q+ M$ G4 E        ret = platform_device_register(&da850_evm_tl_leds_device);
- Y: A* B4 `2 q6 j, f* k        if (ret)
0 M9 C, `4 V, o: q4 S6 S; ]                pr_warning("Could not register som GPIO expander LEDS");
. n% f3 S8 T6 {# p; d8 {: L        else
5 l0 a! p% {. G$ I2 g                printk(KERN_INFO "LED register sucessful!\n");
" |% [3 B6 O0 T$ R% J
2 I1 e) b2 s# G7 ?+ P, z9 {- M1 O        return ret;
$ A& t& K1 w+ X: u4 [}: r5 g5 Z) S$ h0 I2 e

1 Q( b6 m, _# y8 V# [5 Sstatic void __exit led_platform_exit(void)
- t; h9 \2 I. r, c. g9 [; [; B& p{
' Z2 w$ C1 }- u0 D" ?  w) f$ H: o$ P        platform_device_unregister(&da850_evm_tl_leds_device);3 H% g& }7 d5 z' O% i7 j
; F4 o$ p6 V$ i, a2 ?
        printk(KERN_INFO "LED unregister!\n");
0 e2 M2 M$ k+ p7 E2 J" C5 n" ^}, F* ^: q) j. h1 t# j- v  t8 H

4 c8 ]$ M* n6 ?4 r- D7 }# Emodule_init(led_platform_init);
! O$ |" L4 \8 m1 y7 A& bmodule_exit(led_platform_exit);4 E, N8 B& s6 P5 Y# G* r6 ^4 H/ J

2 I+ s! K! n% h. K# F- j9 |# RMODULE_DESCRIPTION("Led platform driver");2 b! n8 X9 p/ z" }$ M% h
MODULE_AUTHOR("Tronlong");
/ q  u7 i2 C- B1 X+ E5 }MODULE_LICENSE("GPL");
: V, f1 j2 [  E, [3 i3 N2 M) {2 e3 S3 p" t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-26 17:25 , Processed in 0.041380 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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