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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 E% E. Q! A/ X, ?! @#include <linux/init.h>
$ w% ]! v3 d; d7 ?8 `5 K#include <linux/module.h>) n& {3 L/ m% c! i6 \
#include <linux/kernel.h>
0 m3 E5 W5 |! r) s6 L% W#include <linux/types.h>+ l/ x" v0 L1 A7 ^- c6 i
#include <linux/gpio.h>
9 R7 O2 k8 _# J% {& ~" B( w' S#include <linux/leds.h>
1 H& C) C! t8 L' O: ?/ F#include <linux/platform_device.h>
* r  C0 h$ _; s6 c. z$ B' W! _, ~6 V+ @* L5 O! Y; F
#include <asm/mach-types.h>( |0 H4 g  N' D
#include <asm/mach/arch.h>5 t0 S1 k) K/ i7 J. k
#include <mach/da8xx.h>0 b4 W$ I. |! q2 a
#include <mach/mux.h>
1 Z; e# X2 p3 h5 k  f# g; k9 V! Y
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' U! i" t9 M& P  M* X* m
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( a( j4 O  i5 t4 U0 n#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
1 m2 E/ u5 p9 I+ _" E#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" j; o+ l0 M% }; t

$ s1 M1 s/ M9 l3 s: z/* assign the tl som board LED-GPIOs*/
0 }0 ?0 F3 v7 w; Kstatic const short da850_evm_tl_user_led_pins[] = {6 W! c! f& Z+ l- [
        /* These pins are definition at <mach/mux.h> file */( e& T. ~, b; M2 r* N
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 F' R0 J% L* H8 t
        -1; |" c; R- h" ], y# G5 a( j
};
% ?8 ]: t+ e8 S% z1 |& V& p( j- f  U, L; e# Q
static struct gpio_led da850_evm_tl_leds[] = {
- J6 b, s, i5 R8 v7 O! g4 {* M        {3 |1 b0 s7 ]& K
                .active_low = 0,) k0 V4 f3 U# g, A2 ]+ R
                .gpio = DA850_USER_LED0,
/ ^1 K. _) K4 O) L& A/ K                .name = "user_led0",+ O, N0 _3 j$ I$ }, f
                .default_trigger = "default-on",) q9 F' m! Y, ^+ m. }- h; d
        },, M6 w$ a  X+ C, z/ w$ ?
        {
# W& o/ a. Q$ \5 {7 s6 s( `                .active_low = 0,+ E" e1 v9 B% a6 [! h, {$ C4 J) I
                .gpio = DA850_USER_LED1,
  N. w5 R  p8 y9 G2 \( i                .name = "user_led1",
. n3 M4 v9 P: J% c9 D1 g# _6 G                .default_trigger = "default-on",
3 n7 o5 V  }) z        },
- w# i9 D! |( K4 y4 e        {# ~/ D3 Q/ ^, ?" U* y7 Q
                .active_low = 0,! _. T# K$ r8 M' |; [+ r9 ^
                .gpio = DA850_USER_LED2,
* v% h6 Y# ?: }; T/ D$ U5 |                .name = "user_led2",( u4 H1 ?; S, T
                .default_trigger = "default-on",
: r/ B8 U* {* o* Y% E. H0 m+ D5 D: A        },/ F. _3 v. q# w$ R+ n
        {1 i) p6 Q) q, n$ E
                .active_low = 0,) l" u* p; d, I( C- ^- j6 H
                .gpio = DA850_USER_LED3,+ Q9 `1 Y4 ]7 B6 o" B, K3 ]
                .name = "user_led3",
7 U* ^( H: A  Z+ m- K8 o                .default_trigger = "default-on",
/ M' C  v4 d6 w: k. G6 _+ B3 x; T, W+ Y        },
6 _7 n/ ^, P6 q0 ]* j/ F};9 `; g7 m6 F  Z& R
1 d8 V0 l1 M* \) q$ h6 _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 _3 c( e( F( X: z8 D* i        .leds = da850_evm_tl_leds,: b6 |* ^* e# R  D; |
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' c: c' B$ D" r* @; I8 b
};8 o) _/ \' r! \5 o( T/ ]1 {, ~
8 n7 }1 ]5 `8 a/ A
static void led_dev_release(struct device *dev)
2 V( ~" S' ^* ^) u! C( a{2 w3 G) J7 j+ H' _( Y
};
  f* E9 j! e; ~9 h3 j7 e4 s
* V9 g6 q; t+ ]9 U7 l6 _! i; `static struct platform_device da850_evm_tl_leds_device = {' c  @, ]+ G% z' ^/ e1 l
        .name                = "leds-gpio",- G! O/ V& j! i$ A, s" S! C
        .id                = 1,
# ?4 F# W) v$ ]& }, q2 A        .dev = {/ T' v4 m0 I" Y( J# [, c
                .platform_data = &da850_evm_tl_leds_pdata,/ n/ y5 J, G1 j9 X& Y. D* h/ |
                .release = led_dev_release,7 u5 e. M3 H  E4 F
        }! s; s1 H7 C: J( @6 ?* j6 b! T: p+ P
};
1 w" }7 A2 l1 j6 C. q. @
. A" y: Y% n4 ustatic int __init led_platform_init(void)8 }% g0 U& F7 b
{9 D$ E6 d/ u. k4 W' P( O) l' b3 Y
        int ret;( y( H; n! h! Y7 Q; l! l
#if 0! ?9 r4 j* X$ _" y/ g/ j4 B" l. r
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! W- |1 p; p6 T6 M9 ~  A+ D        if (ret)
% q4 ?6 }! ?( k3 R# y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. Q1 F! w( ^* ]& L* ^, f( U% j, j. u+ X                                "%d\n", ret);. C4 ?) g& B8 K2 p4 D, G
#endif0 [* d- F! k2 U1 c- F% k  ^+ g, m4 J
        ret = platform_device_register(&da850_evm_tl_leds_device);9 q1 r6 v* @7 O+ x. O
        if (ret)
4 g5 u; A$ F" P9 ?. B- m0 S% K3 E                pr_warning("Could not register som GPIO expander LEDS");* o: Z0 s5 l' W* k; ~) f) @
        else; w9 w% j, t# Q
                printk(KERN_INFO "LED register sucessful!\n");
8 T! f6 c/ R4 t
, B3 ]. ^3 H& u4 h8 J/ w        return ret;3 m: T  b2 i* v7 l, j9 z
}
& B% \' H$ Q5 q' G6 ^- e
8 \4 K& l( l) E0 [5 W* n* _6 Qstatic void __exit led_platform_exit(void)/ B9 b9 P1 ]. N8 E6 T  }4 e
{( i# @, w8 P* h
        platform_device_unregister(&da850_evm_tl_leds_device);+ _) z) e3 K6 [4 H
0 Y# z. \' R$ O- j3 S+ k
        printk(KERN_INFO "LED unregister!\n");
" o. M4 }- y) l, J2 ]}
0 ?9 I* b% d7 D0 R. k/ ^: ~' c  _" T& I# Z* y. f) I) ^# S, Z
module_init(led_platform_init);
4 u, {/ o  K& j4 Y7 `module_exit(led_platform_exit);! p0 B; J# k. |4 `/ B5 G6 W0 M. O

* d) W! l! Z; ^9 _1 J6 _* CMODULE_DESCRIPTION("Led platform driver");
, \; b% Z3 |* eMODULE_AUTHOR("Tronlong");4 f' n# R( k6 Y# J- ]
MODULE_LICENSE("GPL");
: Q) M' b! J! ^/ q
2 k. w3 l' V8 e! H/ A: }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-4 16:29 , Processed in 0.044684 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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