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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( L  j" B7 v2 y) Q* U! G2 ?, d$ @
#include <linux/init.h>
5 P" X' T' D  P! S5 A# p#include <linux/module.h>
; N3 a6 o. Z9 a8 h6 S#include <linux/kernel.h>. M& v6 J. c; y' V2 ]* b6 }& n
#include <linux/types.h>
3 k" L. ?! ?7 g, g: C#include <linux/gpio.h>
) o+ i9 S# T  M* a5 z9 q+ E# W# e2 Q#include <linux/leds.h>- z2 @5 K; H# z. o; W
#include <linux/platform_device.h>
) |% _. |: l. n& k4 ^, X  I8 a
4 ?# c& u7 F$ D' D, p#include <asm/mach-types.h>
& v& ~4 l) p, Y0 i! _- x$ f1 u#include <asm/mach/arch.h>
( r# i( M; B/ ?4 k& r" i#include <mach/da8xx.h>% a- F6 y2 d3 n1 l0 v5 O5 |" S
#include <mach/mux.h>
% g6 ^9 R9 }  v3 U/ k3 {6 ]
0 t- w6 n6 H; F1 T4 f% z" ~7 S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. G9 a: N0 C7 ~#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! ?6 Z! k4 c* _$ U8 t
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1), s# @7 F4 y) q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
- T+ M0 S/ T# j2 G
% x5 M* v, h2 ?/* assign the tl som board LED-GPIOs*/
4 J: Z1 M0 J1 h0 U# y& J* pstatic const short da850_evm_tl_user_led_pins[] = {. j) {3 T4 {" m4 l
        /* These pins are definition at <mach/mux.h> file */( s: _0 Q: y8 U: J1 R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ R) f1 h* w9 j* i% `- P+ y3 ^( P1 }        -1
* ?! Z4 J5 |2 V/ ~};
! L$ M# ^6 Y' F% V" R. c/ [6 O/ E" o
static struct gpio_led da850_evm_tl_leds[] = {
& v& I3 i# G% I0 W, i        {6 f9 l, U2 O3 C: l$ b! C
                .active_low = 0,
! y0 k& o$ n0 ]0 O, c& t3 e+ `                .gpio = DA850_USER_LED0,
% A5 Q7 c6 r% J  p$ B                .name = "user_led0",
* D6 g+ _; O! S$ g+ J5 s                .default_trigger = "default-on",- j, k  ~6 U0 U" X5 n9 r8 N
        },2 D9 C# s4 |" B: e* \
        {$ h6 F( _% h% ~& V1 M
                .active_low = 0,! f" y. D1 @3 Y! N  N; J
                .gpio = DA850_USER_LED1,
4 c% D2 E& P' j( ]0 q1 N+ k                .name = "user_led1",6 k$ m: ?9 f. K" K' e5 F- }6 m
                .default_trigger = "default-on",1 x2 \& F) h* I2 I( _
        },
& w. @" r* w# e1 D        {
0 w1 W; s1 X; J+ r6 {                .active_low = 0,
  Y: V  ~# R" o2 }+ a3 G* O" Y                .gpio = DA850_USER_LED2,
, y2 i5 P) ]3 I- x, h* m1 y* Q                .name = "user_led2",
' R& d2 L, k( n. Z3 _  K5 I                .default_trigger = "default-on",
9 [4 U' l7 L: v. m: e% Z% ^        },9 Q+ R5 i$ m" f2 t/ N
        {+ Q0 u  x* o# C- {% S0 C
                .active_low = 0,3 [  `$ I. f5 S' l. v
                .gpio = DA850_USER_LED3,
; t. [) J, Q( @6 z7 f                .name = "user_led3",
: V6 k; J8 A' ?  U5 Z                .default_trigger = "default-on",* Y9 r' K) ^" U% M( ^, q
        },
5 J- z; h! G9 L( |2 z};
" E; y. v7 }7 L% D4 g7 V9 h1 V7 {, |7 G$ q$ d8 Q, L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ j4 [/ L0 R. z
        .leds = da850_evm_tl_leds,8 |5 n4 ~0 j% n0 }  q3 v
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, k' L& n: M9 @( U
};! Q( L& e) Y: K8 }
- ^. _$ b3 T: H! p, s
static void led_dev_release(struct device *dev)) c2 U) I  z* C& |% t, W
{, k9 O& H5 f3 A" u; {" Z4 |$ W
};
4 @! G) @; [; s0 y# t- k* J8 ?
/ m$ P$ c( j, V# B" g1 y1 Fstatic struct platform_device da850_evm_tl_leds_device = {- O: _' C- X; ^( i# C* R0 b
        .name                = "leds-gpio",1 E5 X1 d  D0 I/ V( L- y8 j, S
        .id                = 1,
& O' p& K  `; F; P, f4 f        .dev = {
4 L+ @! _* ]) D; f: n' h6 F                .platform_data = &da850_evm_tl_leds_pdata,$ ]5 m1 K' V! u1 }
                .release = led_dev_release,
1 [8 P1 z1 e7 m/ }" g- u        }
8 E7 w" I! B6 S* z* q) n1 ]: t};: }4 G% m% u9 Q# D

9 P$ J! G% O  L6 |" }: f/ G  Zstatic int __init led_platform_init(void)$ T6 f/ u8 P  J- E$ J
{. p  B3 I  D; X, q; T6 d$ ]
        int ret;
3 e# H3 C% B4 _+ j! ]3 o#if 0. T# l: e3 g, y) T$ S8 g3 }5 T3 b
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 Q3 k4 u5 D% L' A: u; T/ K7 h& p
        if (ret)  _' K$ O) D' k' x6 K+ j- \' I7 R
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: |9 i  G. B) E6 h7 x. {5 V                                "%d\n", ret);
) }. ^( x9 }" H/ A3 S#endif) p, \9 y8 w$ v8 x7 b& O  \
        ret = platform_device_register(&da850_evm_tl_leds_device);
( m, h  d% y! r! D1 @5 q: m3 s3 E& U0 S        if (ret)$ B4 Q5 T. _6 A1 L/ P1 H
                pr_warning("Could not register som GPIO expander LEDS");
$ @6 N* o( j$ ?. @0 x: E$ m" C        else* u4 c( y+ j/ ]) a- W
                printk(KERN_INFO "LED register sucessful!\n");
" D/ O0 o" o1 V8 g3 `
3 {1 Z) [9 F2 K: _8 O        return ret;( ]- Q# K+ f; j& P3 ?/ ^% j; w% N
}
. V" H6 Z0 `* |! c1 a( N1 i5 W! O' M( a1 c, N; }2 W: @0 u& y
static void __exit led_platform_exit(void)
4 }5 c. Q5 @( i: [; L{
2 X) \. |  G# v9 [* G: P        platform_device_unregister(&da850_evm_tl_leds_device);" w# l$ T8 ^  S0 t" [% K; w; o( |# I
) q# V2 m; x0 M; i1 P$ q4 _! w9 W
        printk(KERN_INFO "LED unregister!\n");
; X7 Q' b, @' s- ^, }! H}
0 f5 m* {% e5 o2 n# G' g4 O7 m4 M& e2 _3 N: ~2 t
module_init(led_platform_init);
) v! J. L5 U; l; L4 [5 Y0 vmodule_exit(led_platform_exit);/ X" k' w- p; u
" l  k8 d3 c0 j, N: M4 I$ b8 O
MODULE_DESCRIPTION("Led platform driver");& R# E: P( H1 z$ R
MODULE_AUTHOR("Tronlong");
/ a. p  U, i( oMODULE_LICENSE("GPL");: s4 y. b- X& u* }9 v0 A4 K* \

6 E8 U: O+ D( e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-10 23:03 , Processed in 0.036929 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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