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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 R2 I5 ^8 @" k6 S% h% \& n3 t#include <linux/init.h>
: o: _" d4 v' w; E' c#include <linux/module.h>8 k+ ?. a" h: J' G) s2 N( q( u/ S
#include <linux/kernel.h>5 S4 G: ?4 }/ j- q. G- x
#include <linux/types.h>
3 i. E6 ?" ^( N5 `* w6 U#include <linux/gpio.h>
* r' m6 b8 d2 l' ^+ H- h" U2 q#include <linux/leds.h>1 P! U8 s4 y2 N6 A/ S
#include <linux/platform_device.h>, K- M, j4 M- N- [* E8 I2 F5 y! y

( y3 P! V$ [( G* o#include <asm/mach-types.h>
! C- b' w' i2 P6 E#include <asm/mach/arch.h>
+ O. R* _/ a8 O  Q#include <mach/da8xx.h>$ a9 f7 [. \& p/ e! K# f) z
#include <mach/mux.h>
+ Q6 I3 T+ d5 S2 H' R/ {
$ a0 x' W9 A; m$ Z- W0 r#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 G4 j4 c6 J3 K+ t1 m, z
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)* ]. }9 n" c6 H' x! ~  N6 t( I6 M
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 K6 _- o8 G2 L6 J#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ _1 Q8 X$ M+ [# j5 ^7 \0 M- B3 q0 A. k
/* assign the tl som board LED-GPIOs*/
2 W" s. ]" S0 d- L8 H% Sstatic const short da850_evm_tl_user_led_pins[] = {" ~9 ~5 s# k3 }& c
        /* These pins are definition at <mach/mux.h> file */; A; D0 E5 J6 s4 _3 [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( y! ~- ?2 i4 c! x) B! a0 ~        -1+ d1 [# ~' p4 ~% w3 _
};6 J5 S2 c+ B6 K, w" w
5 Z& l- V: L; F: x+ w
static struct gpio_led da850_evm_tl_leds[] = {6 s3 B1 ~5 @. s* r' n% [" w
        {
* ^  v$ B6 o2 s                .active_low = 0,
. D# V; ^% M, k$ z. K: \; d                .gpio = DA850_USER_LED0,
, G0 d+ J2 q; |: z                .name = "user_led0"," I3 h" F9 B2 V! \1 M6 H6 F
                .default_trigger = "default-on",
9 i$ R- T' x3 J  @; }        },
( W& H% U4 W  c6 c* M        {
# N/ o0 F" G+ k; q, K                .active_low = 0,/ K& ~3 ~3 u. W3 Q
                .gpio = DA850_USER_LED1,
! a9 d9 l# C) g2 v; w+ B: `                .name = "user_led1",5 J7 ~9 v# l. r
                .default_trigger = "default-on",
9 B( z3 e7 x8 x+ T- s- k        },
9 B- u% F: \# e' X; y        {
$ H3 u! u" Y/ e1 v/ o+ [1 K* W                .active_low = 0,1 f. O6 W8 S6 I$ ~* N
                .gpio = DA850_USER_LED2,
$ P' D  d$ L) [; l+ E                .name = "user_led2",
' s# H6 h- l* L+ W- d                .default_trigger = "default-on",. h3 R, e. X' \5 P8 m3 y
        },
0 A) c' {' q  z, r        {
' l! v7 P, J) A( k+ Z# j                .active_low = 0,
4 V, x5 D( ~8 o, l! z6 g2 \5 u                .gpio = DA850_USER_LED3,7 @6 A; J' g8 R4 P9 R
                .name = "user_led3",5 F1 H& A, }, p
                .default_trigger = "default-on",; x6 r! ?7 \) j- l! V0 b* ]1 ?9 `
        },7 h# \# d0 w8 V
};  a& P6 I5 ^1 e- u$ p3 L
5 ~, E/ t: A% u6 }0 `. U9 J2 H( \! {% T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# Y' E* i' k% K- O( A  q. z: R
        .leds = da850_evm_tl_leds,  b& l) h& C* S2 Y, X5 W
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 h2 |7 v6 {, |, `7 E; r
};1 U: N2 H0 V9 y' n$ I6 L- \; q: [

% l) t! q7 @8 _* W- R0 `3 Astatic void led_dev_release(struct device *dev)# h+ S" F) d; @9 J
{
8 E7 g; A0 t! K" h};6 e; |* ^# w* F4 b1 f: N- U+ }
  D; b" ]4 i: Z4 t4 `5 ]- I- w# S
static struct platform_device da850_evm_tl_leds_device = {
6 e$ ]" {3 ?9 @; D) m( I) L9 i        .name                = "leds-gpio",
* _2 \4 P& T; z& X+ T4 e        .id                = 1,
0 f3 P8 F; L, J) f) S* X        .dev = {9 K+ z7 q3 I# N8 w' q$ T
                .platform_data = &da850_evm_tl_leds_pdata,) c% }% w/ Z. Q0 v8 ~! C3 \
                .release = led_dev_release,2 f: B+ v& |5 ~* p1 J2 R  J( U- u
        }
4 r' @  P; Z* s0 v7 V};
* q# j+ T% Y# J+ y: ]) T# O" X
static int __init led_platform_init(void)
* k! K3 ?5 O, J4 ?6 X8 S{
, }: K# b" ^" X7 ^9 k        int ret;  j$ F# U2 b( i6 {; K; K
#if 0* a, @& [8 G3 @5 b2 u
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( X( X3 J  \% T9 n4 C( i; z
        if (ret)3 m, U& \& n  L, ~( I4 S4 D1 P7 d
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! }$ n* X; q' `# J! I                                "%d\n", ret);
3 L" T, [( m+ i+ @#endif) r+ \3 k2 C1 n* f
        ret = platform_device_register(&da850_evm_tl_leds_device);9 K- n# x8 I/ W2 T
        if (ret)3 }- J4 n7 R/ D7 Y/ Y, J+ W
                pr_warning("Could not register som GPIO expander LEDS");9 ~1 b- K: z: g3 }. k4 i. R) p
        else  V  M! A/ `' U, q0 V( }
                printk(KERN_INFO "LED register sucessful!\n");( y! ?! s! E+ i6 d, }
, W1 I- I/ }1 C% W: v
        return ret;: G* h% A7 j# S) S' X
}
/ b5 k3 g1 m# W8 v
! \  Z. ~: N5 G2 D9 X: C2 |2 @static void __exit led_platform_exit(void)# ~' j5 w4 u( T) Z0 A' A$ s
{
+ `$ w" v! v2 A# U' W0 v4 y  ]7 `        platform_device_unregister(&da850_evm_tl_leds_device);
& J% |) g  `5 b+ `' ^( O
- g+ C3 F' r0 |# M2 O3 q, i        printk(KERN_INFO "LED unregister!\n");" s& T; m+ P( y! t. L5 b( G' |
}+ H' s/ V% P" A3 Y0 d% R( [" Y

1 ?4 p, L& O1 v  c9 dmodule_init(led_platform_init);6 ^* t1 O+ a. T( Q5 c  L$ v' d
module_exit(led_platform_exit);2 a6 I) |8 L9 `# c3 F/ |1 L4 M
; c3 ^+ f1 @4 d' U
MODULE_DESCRIPTION("Led platform driver");
$ D9 n0 o5 b3 m* n7 m- V  EMODULE_AUTHOR("Tronlong");
7 B, f- B3 `4 z! x+ CMODULE_LICENSE("GPL");# T0 j; S6 ~1 Q* @# M3 N6 U; v

( G. V3 M3 g# e2 x1 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-8-19 23:16 , Processed in 0.048524 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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