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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。0 ?3 u( v0 b2 b+ j" }% v& T3 ]! K
#include <linux/init.h>; ?7 M8 k+ d6 A
#include <linux/module.h>& Q3 t2 t: }- I. M2 {/ h' g2 t- t; n
#include <linux/kernel.h>
- e4 W- q" \4 D$ U#include <linux/types.h>4 F  i8 h7 p6 a& @) }$ _* c
#include <linux/gpio.h>: e! a. r& L- @1 V7 E+ x9 Q& v, r4 I
#include <linux/leds.h>
8 A- O3 j0 Z* |! R7 P0 |; `#include <linux/platform_device.h>$ T5 ]! e7 G' F. m) T* T
1 n4 t6 u$ ]4 s/ C; R
#include <asm/mach-types.h>
* {- x7 Q! ?/ ]& W#include <asm/mach/arch.h>6 l: M5 J& H8 g1 n; [. j
#include <mach/da8xx.h>
) g5 F- V) W9 A#include <mach/mux.h>+ |, Z% d) X0 o1 q. ~9 q

$ U6 o# w0 S; `9 @9 w$ R#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 Z7 u4 D' c% F$ a#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 X7 c/ T8 G* t2 [/ }1 ^#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 B. [* C8 }& M; k
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' l& X# C5 Z/ h1 x1 H

5 `6 V' q- p, r5 m/* assign the tl som board LED-GPIOs*/
2 H7 Y* D9 v$ R5 q+ gstatic const short da850_evm_tl_user_led_pins[] = {; ^+ u- ^$ M' e! @$ f2 R
        /* These pins are definition at <mach/mux.h> file */
8 F( S1 U& t9 {% |) D' [        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 h. Z9 _# K, n' @% s0 a1 N
        -1
, f6 R9 H+ x  O1 O# `4 M  A};
( e0 K  O" }/ p. O6 L, r# m
  x% z1 @1 Q0 C' D8 n: }static struct gpio_led da850_evm_tl_leds[] = {( }+ s% b% j8 Z* i0 m
        {" `2 n* d0 o  @
                .active_low = 0,
6 S2 k) j! ^# t1 B+ q0 O) b                .gpio = DA850_USER_LED0,
$ l( w3 \9 Q0 I+ U                .name = "user_led0",: }( ^, K) ~. {$ Z9 `, i
                .default_trigger = "default-on",
- g% |4 D, J  L& x6 l7 H8 M        },
6 \' r. h* b" a9 d        {/ a" ^' h1 d/ V
                .active_low = 0,
1 z9 J6 p; Q. D. R- D                .gpio = DA850_USER_LED1,
; E0 [# i+ D; }; Y* g. i                .name = "user_led1"," f6 w6 |+ Z4 K: k- Z
                .default_trigger = "default-on",
9 A: z- I! H, h+ F7 j        },, L. o; t* d% ~4 Y
        {
- T8 [1 i: I5 s" z9 a                .active_low = 0,
) {: |: b5 I9 B) D4 a, t& x) O                .gpio = DA850_USER_LED2,
7 M1 K7 t2 Q2 d$ z) z                .name = "user_led2",# H8 l% j( N0 j' o
                .default_trigger = "default-on",
2 ~) z" C: w9 `& ~        },
- i" O% \: ^) s' y        {
2 }3 `0 b' q2 g% ?5 A" z( g                .active_low = 0,
* w& @3 m* Y' E7 k+ M$ T+ R                .gpio = DA850_USER_LED3,
# y& k: X9 O4 B$ C                .name = "user_led3",
0 V+ @& `$ J; U4 V9 n                .default_trigger = "default-on",
+ B% n" h/ D- U( d        },7 G* R- R; j/ b
};  T( r( s+ N3 M

* d8 Q! r3 E: h/ {, e0 Y4 ?& mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& _& _* G! u) ]/ ?- J  t        .leds = da850_evm_tl_leds,1 g: B6 Y; O1 P# F" f7 R/ w
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! {3 ^: j. S- T};
2 N1 z* \2 t: F
7 `( [- J4 P. I- Ustatic void led_dev_release(struct device *dev)
' u0 y; V  a1 q$ d2 Z: l/ b& _{
# B2 L6 I, `1 _};, H6 V' U& A9 D  O/ m
' ?- j, e& H; |
static struct platform_device da850_evm_tl_leds_device = {
8 N, I0 S# [' C: k, b7 C, A+ T' F        .name                = "leds-gpio",
' M: W0 J9 E. o; i: _        .id                = 1," G& y  ?  l6 S5 W$ N$ D1 v9 n
        .dev = {
0 l) @; h% M- b0 _/ a" b* R                .platform_data = &da850_evm_tl_leds_pdata,5 G8 O, J  g# E9 ?! A, z
                .release = led_dev_release,; H# ]/ F) t+ c; ^
        }
+ d; z- z/ V: U/ t" `};3 K7 E3 k4 d5 }$ }
2 f1 p" a- |4 b/ C: m  ?
static int __init led_platform_init(void)/ w7 m$ M$ `. }# u- \
{* t$ @$ f+ g$ J7 P
        int ret;2 i9 _* L/ d. b  W
#if 0$ l0 @: Q, h9 [! j! V" w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 ?+ o9 u: {' q0 h+ ^7 \
        if (ret)
- A$ C# [0 w! E. r- ^7 r/ o                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 h  A# J' l, U* ~                                "%d\n", ret);" S* m( c, C! A% G# y: U: e
#endif
) N" m6 C  }% W6 D  Z9 j6 _        ret = platform_device_register(&da850_evm_tl_leds_device);; w0 N# {4 N( J0 C) F
        if (ret)7 k% b3 h2 d) `  c8 F" Y5 C9 O
                pr_warning("Could not register som GPIO expander LEDS");
1 X/ W; v  a6 q/ [        else
! c# l# Y' ]( K! ~6 j6 B9 O" I: ?4 H: V                printk(KERN_INFO "LED register sucessful!\n");
! J( b0 I# }2 _( z+ O% {) c
* m5 l0 W1 H, D/ ~        return ret;% U7 s- o& a1 l  D  t% p
}4 h" H+ P6 S9 M/ I# L0 `7 G7 V

: q* a8 u- _: Z% ]9 j# cstatic void __exit led_platform_exit(void)1 m" R" i2 N; x0 ]
{
2 L& a. H2 E: F: S        platform_device_unregister(&da850_evm_tl_leds_device);
+ q& b3 o4 x" j! Z; C
& ]+ q" V$ g2 t: ?; p; ~        printk(KERN_INFO "LED unregister!\n");5 Q8 w4 D9 P0 _' e7 P( U) ]
}
9 y4 q( L8 O  _9 e) Z" ]8 B. H8 \0 c& B: T
module_init(led_platform_init);
' T! b' g9 z8 w+ h- Z' Ymodule_exit(led_platform_exit);
, f+ k, t) K; P' e8 j: T
7 t2 d: ]% R; e3 h: HMODULE_DESCRIPTION("Led platform driver");5 X: x2 Y# c9 U
MODULE_AUTHOR("Tronlong");/ f3 l; f# J) p& N
MODULE_LICENSE("GPL");
0 A8 t8 |; F( {* e, P& h* m& H9 |" b) ?; U* A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-10 10:25 , Processed in 0.037371 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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