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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
8 C0 o; A7 _( `7 \) ?#include <linux/init.h>
  z! l  e* p7 g7 C5 j#include <linux/module.h>2 C* Y( A7 j+ D2 W+ u
#include <linux/kernel.h>
) z8 ~" `: l9 ~" w" h  }#include <linux/types.h>
, z; q( \' f- ?* m6 Z* E#include <linux/gpio.h>
" Z: k; @, |. F% f# {* v2 }#include <linux/leds.h>, f8 q& C' n# W. ~( Y, g; f
#include <linux/platform_device.h>
. y; Q6 v- f+ k3 i
; z' B4 X! {2 j! x8 J2 `$ _$ \. o#include <asm/mach-types.h>
% b1 V; ~& w; l) X/ a#include <asm/mach/arch.h>
6 J) Z$ M4 H" }9 [0 Q" V  j: b#include <mach/da8xx.h>
0 }" s. u) \* D( L1 f# q5 W#include <mach/mux.h>
% B% e% T( F% N, f2 J4 t
" n. ?" \+ a, X  y8 f" N. R- v/ m#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 L! J- v; g8 q  H; _* P8 Q" E#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
  I6 B8 e+ u& D#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 n- `! Z  A; B9 @. F, B, Q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
1 S, p) n4 {* k+ g% R
2 C; F9 p0 J, L0 |1 W/* assign the tl som board LED-GPIOs*/, N! z: U) M4 c" A3 m4 d* W! c1 e
static const short da850_evm_tl_user_led_pins[] = {% w) X, S8 o$ {8 i- V
        /* These pins are definition at <mach/mux.h> file */
2 k9 }& H/ t" i, F        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  C+ t+ U: o4 T- b0 w" ?$ D  j        -1
5 ?3 l/ _- q; h. C9 P# [};9 H1 H8 O0 z( E% k5 W) g+ t: k
  V4 k" F4 I! F
static struct gpio_led da850_evm_tl_leds[] = {
9 G5 M, e8 n8 S: z" o/ F3 f6 `        {/ N! \# `! M% L9 d  m6 W+ b* p7 I
                .active_low = 0,0 t% M2 @4 t# \( p) F
                .gpio = DA850_USER_LED0,
3 s6 a: p, @" `2 Z1 u& q                .name = "user_led0",
- p7 a/ S. g! `' Q' c                .default_trigger = "default-on",! B% W; f6 X# W
        },% u' B6 }  x4 {! o- x
        {
. S5 w' [; M5 f# A% K" o" d                .active_low = 0,5 e. q- S& ]$ w
                .gpio = DA850_USER_LED1,
; L% S& w3 R* C" `                .name = "user_led1",$ M* ?/ O8 g4 k! i( B
                .default_trigger = "default-on",
2 N5 A1 @: E' _% d+ }        },
6 S. n$ b) i. v5 F% M9 x        {
/ V4 P; O* [& [1 i& S                .active_low = 0,
: `! }8 ?# Q# Z6 E0 t4 g                .gpio = DA850_USER_LED2,
% o" L0 L. \2 X: o: y                .name = "user_led2",. c3 S' {6 o  _' ]. Q
                .default_trigger = "default-on",6 d" D$ h# h9 J! D: w) U  p
        },
  q) g' `2 }; L# k/ L# i, A3 ?* P        {6 R/ b, t3 F) ~+ t. Y
                .active_low = 0,; E! q: S7 ^4 @$ G% C$ x
                .gpio = DA850_USER_LED3,% a) q! \9 _* J7 |5 L' D! R
                .name = "user_led3",& M; C4 F  D) A( M4 M" r. p
                .default_trigger = "default-on",
, H3 e2 {# s' C8 x. ^) n1 d        },1 ?/ _$ W- S# J# L, f0 ~
};
! N/ W9 O/ V) j) J% Y( P2 t: I3 V( X! K5 ^! l5 A1 Y0 _, n( H0 ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, ]7 C% s9 F) r6 s3 g- W
        .leds = da850_evm_tl_leds,9 V. a' O1 ?5 a2 g3 n3 ~$ o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 B+ S/ ?% c7 J7 J: x( @5 {
};( a# Y" r2 D/ M5 q
; r! D- q$ S* b% H5 c' A& f
static void led_dev_release(struct device *dev)+ w+ h. i! l' u& z) O# `: a# _
{4 S+ b  G! {0 N9 K9 K
};7 x0 V/ o; s1 v! r# d( ]
, p) l8 b. x/ |+ U# Y
static struct platform_device da850_evm_tl_leds_device = {
+ v  x% A5 x4 I* K6 N        .name                = "leds-gpio",! F6 Q$ G; Q8 Z6 o3 C
        .id                = 1,9 d: T8 u* ?9 j# k
        .dev = {
: W: S6 l- S) j' O                .platform_data = &da850_evm_tl_leds_pdata,+ O: A' a5 g" n( s; B# i) e
                .release = led_dev_release,
) g: k2 @( j* Z/ P2 k9 {        }
. E0 ^: G9 H5 d, |% }4 Y};
4 W5 ?, G) O% U9 l9 s, W" L% R
' V6 [( d& _, n, istatic int __init led_platform_init(void)' K) }/ {" I- B9 a% s
{
: I1 g* d$ G$ M8 O- h9 |) Z2 t        int ret;! z9 u. M2 c7 j
#if 0
6 V% D5 a, X0 S; S% K) g        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) z# s3 [' k/ q
        if (ret)+ L" ^- O* x) ^5 `4 j. F2 g
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ ^2 o8 w( o" O8 b0 m6 T; C
                                "%d\n", ret);! \/ V1 T2 f& {' \2 C
#endif
$ R. ^) {- \- ]( k        ret = platform_device_register(&da850_evm_tl_leds_device);
" i5 Z) S0 p5 V/ Q        if (ret)" d0 O+ |2 A3 t9 {2 _: h
                pr_warning("Could not register som GPIO expander LEDS");* R) e) k; Y$ [2 |
        else
8 N: A. [" C' s6 Q! N# |% w8 k2 t" o                printk(KERN_INFO "LED register sucessful!\n");
* @% C$ P, g+ v+ T1 _
. n3 q1 z0 Y+ Q* {! l        return ret;8 T! U0 [; S4 b3 Z2 e4 v( Q: V4 n
}
' g! a+ K/ b6 v* u# B- C1 `
7 ]+ m- e8 [0 t; u8 h( t1 Tstatic void __exit led_platform_exit(void)
& E2 ?8 ?/ L! U' }5 p! n2 s/ A{+ E# y3 ?: D- k, `
        platform_device_unregister(&da850_evm_tl_leds_device);
  f# L  F. }* R4 X9 K
8 H0 z8 h$ b/ W6 N, N, `* s        printk(KERN_INFO "LED unregister!\n");( A6 N6 o2 {7 L. y" I8 X6 B
}
5 J! d3 j/ u5 V) u9 K( v! F
7 ^, ?4 k0 ?, K- Z; S8 n' `module_init(led_platform_init);
3 b* K' L( ^) Bmodule_exit(led_platform_exit);; A0 ^" Z( y/ y% k

- E2 I4 M* x$ G! b  A3 e: Q9 oMODULE_DESCRIPTION("Led platform driver");
" }" Z7 n3 O& I6 a( TMODULE_AUTHOR("Tronlong");
- b9 d9 f/ U. iMODULE_LICENSE("GPL");2 i4 k1 t9 Q, x( _3 r" u/ p: K
# o. m& U+ w2 S) F: e: r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-3 05:00 , Processed in 0.035103 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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