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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 O: h% M/ B9 g" @7 K#include <linux/init.h>' V! h  j: Y; j
#include <linux/module.h>
/ x9 C3 a# T% K  o8 Z! M# ?& z#include <linux/kernel.h>
3 k9 g, @: r. z; S0 Y% R#include <linux/types.h>
) C" l1 H1 L9 n# z#include <linux/gpio.h>
" e- ^' s% U. b/ W! h( h#include <linux/leds.h>
3 E1 I0 m1 J% j1 @( ]#include <linux/platform_device.h>8 I/ h; U) C. [& J  a+ Y
1 t& T6 C1 X0 F0 I1 p
#include <asm/mach-types.h>
, L" ]( i, D! X/ m( S5 |' c#include <asm/mach/arch.h>$ `; U$ n7 F1 N; v) M: g( e
#include <mach/da8xx.h>( L  D% [+ H0 _  a4 d
#include <mach/mux.h>
: D5 s) [& T5 g' v# k6 }' x
4 A8 U* K/ ?; h) Z4 K$ Q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 r2 L7 p) t4 v/ H; h#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* R# N! b  }3 i8 U# h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
$ p1 x, R' Q6 p#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)8 j# y" j& X3 m" p) y

: \+ e: D8 W1 c9 d" A$ @/* assign the tl som board LED-GPIOs*/
$ j' G* m% Y5 Hstatic const short da850_evm_tl_user_led_pins[] = {
# v0 V% q5 v8 f        /* These pins are definition at <mach/mux.h> file */6 I0 V0 n* k8 W& I
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 h$ u9 [& N6 Y! R( @& D8 C        -1
" h# U6 d6 s2 x1 i$ R7 D};* a! N& J4 ^" k  z) K9 a

2 `2 P( h/ y3 b# Y, S6 Gstatic struct gpio_led da850_evm_tl_leds[] = {
2 Y/ L; K: c9 c; M5 H: i; x( n: w. p        {
' r, m0 y* J$ A& r" b( p                .active_low = 0,, I# x* P/ t; q
                .gpio = DA850_USER_LED0,; q* q0 G; q0 H  m! w2 l) n
                .name = "user_led0",# w& R# y" ^- q3 i+ t
                .default_trigger = "default-on",
% H: c3 A! k: d4 g        },. ?3 ^" C6 m. s" J& n+ q
        {
# Y' {; n4 N* {" D                .active_low = 0,
% T) f- i2 o' `1 z                .gpio = DA850_USER_LED1,
% L9 f( }4 t$ G6 f                .name = "user_led1",: c- Y0 l+ h0 }% u+ |; `
                .default_trigger = "default-on",
# o  y1 r4 K* \        },
3 o' }4 Z! c, w        {
$ G0 Z$ o) z! p& Z9 z  y& ]                .active_low = 0,; g. M; _! x* h; a
                .gpio = DA850_USER_LED2,
, {) r! ~( L; p- Y( c4 |! s. P                .name = "user_led2",
. z5 ~2 k2 \. U% D: O                .default_trigger = "default-on",
) r9 i: V; k5 t# P' O        },
, B9 }! ~4 s. ]. s0 e        {
* I. R) L5 y7 L# q& m                .active_low = 0,% ?/ |% f0 U: l$ d" `, z3 T
                .gpio = DA850_USER_LED3,- E+ [" |, J' n  T' b  ]
                .name = "user_led3",4 b9 |2 [9 k. O+ D
                .default_trigger = "default-on",
" c0 G- O2 S/ `* L' {        },+ @0 B2 k0 w) C. f
};9 c9 O- O- R) }) b& P
$ P: T# ~0 p, [. j6 H6 ~; M% E& \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 ?- h' P/ j" r" f2 u( z* n! O
        .leds = da850_evm_tl_leds,
1 D+ T# t. ?! \( j: O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! {# ]) D4 [" K9 \+ Y, m4 e3 v' v};
# ~8 ]' E7 Q* E3 M7 e
1 t# d% a) Y/ X! W3 w8 Estatic void led_dev_release(struct device *dev)* x& {. k& ?8 _$ J$ [
{- _0 {. q: `  F/ x1 P( s" f
};
1 n5 A+ q8 M5 M; m& i0 P; E5 H" [/ O5 ?- F0 k3 i
static struct platform_device da850_evm_tl_leds_device = {
2 f5 z4 A6 Y* M; G        .name                = "leds-gpio",* U# {! o# n: e& M# v& u# I6 [
        .id                = 1,$ E3 s% T- |8 Z# D/ q
        .dev = {
( ^; d, u. a5 @* p, c4 p4 p+ F: @                .platform_data = &da850_evm_tl_leds_pdata,# r/ h4 g: ?$ e. [( |1 @! G9 t
                .release = led_dev_release,
( [; C9 X. B* G, _        }& A; D4 v; [. X
};
3 b: H8 j; g+ I' q
1 |) Y3 e% R5 e4 b7 N8 Cstatic int __init led_platform_init(void)
6 r  o' `9 j6 m! P' X+ {{
' |; O- ]% A6 W        int ret;! W' C- G3 Q9 @! g1 |* f& o" E
#if 0, o7 d8 l; R: k- c2 f! B! k& n; ~
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' p1 @- V2 Q6 R& ]* J
        if (ret)
: w+ m) `# I# T$ S7 T4 ^# |6 L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 S+ @3 I$ U  o! x8 }  K( G" `
                                "%d\n", ret);8 L2 b, L3 q- q7 b
#endif1 N3 R+ O- Y) z# u& ?+ N& \2 D
        ret = platform_device_register(&da850_evm_tl_leds_device);; R2 K. y! ?' |# X) H+ O
        if (ret): E1 K( H  j5 C" I+ A5 ]- b0 s
                pr_warning("Could not register som GPIO expander LEDS");( x( @" k7 W) U# a8 ~$ Y. [
        else
7 C& z; i6 q5 d; L' p# L$ ?                printk(KERN_INFO "LED register sucessful!\n");
: _" V" G2 o3 ~$ v& P. |0 E& O9 a1 [* Y9 ]2 c/ w6 ]6 j
        return ret;* I1 T' D2 {2 H, ?% V# |
}6 e5 p& G7 \# t7 M" l- y- b" w
; I, S, U4 Y0 _4 C
static void __exit led_platform_exit(void)! [7 _7 D/ P: P2 }2 S. _- G
{6 Z5 j% J% w- k5 L% w; d
        platform_device_unregister(&da850_evm_tl_leds_device);  ~& {6 S6 u' m
$ k& z- Y+ T! X; d
        printk(KERN_INFO "LED unregister!\n");- \2 V. M6 }. H! v: n8 p& z
}
# u  ~* C9 X0 j! t  v5 B, x8 `9 P9 v* [5 j' d
module_init(led_platform_init);
) D8 @  K) j( p. m! R  O1 \module_exit(led_platform_exit);) F+ \. r6 a$ x; y9 s3 N* P
' R, o  l5 F1 [$ q+ G# w
MODULE_DESCRIPTION("Led platform driver");
0 x/ [* |. w2 A4 M8 A' j) n* @. MMODULE_AUTHOR("Tronlong");
) t  v" N0 F5 t: c, w3 vMODULE_LICENSE("GPL");' q0 g+ p$ m1 l, h
1 U7 Y& q- d' q& b# @! a. }! [) a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-12 13:48 , Processed in 0.038425 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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