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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
0 Z9 [& h( Y5 Q8 e#include <linux/init.h>- [& @' _1 f: F1 C" j6 @7 w
#include <linux/module.h>
4 ]3 O- P- m  a; E0 e1 X, z#include <linux/kernel.h>7 |; {. c+ W0 N! i
#include <linux/types.h>0 b, d$ ~9 N. U
#include <linux/gpio.h>
+ W: W# s9 g& m% [7 X" a#include <linux/leds.h>: }" a0 p" g+ T) e7 U6 S
#include <linux/platform_device.h>
" u/ P  S* H' `( K) F" X8 Y' J0 M5 Y$ S7 S# R/ `2 V
#include <asm/mach-types.h>- l. m$ y1 m; M9 [
#include <asm/mach/arch.h>
. f9 e: W" t" H; A- V+ z3 I#include <mach/da8xx.h>& _0 ]* ~5 I) w
#include <mach/mux.h>9 ?& G  r( _; x  S; i
3 m  p* G6 Z0 F$ o7 W# J1 E
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! ?- b8 x9 M( R) T+ d
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! M, Y; k8 c3 W  W- o" n  m+ w: ~' {
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 Q) N  F8 g* q- K- m( @
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 Z& A/ {# D8 i( z% E6 J
0 ?1 X( G" a. h( f% K
/* assign the tl som board LED-GPIOs*/
/ C. c4 m9 ]8 N5 Ystatic const short da850_evm_tl_user_led_pins[] = {* z. D: I, P1 R9 }4 K
        /* These pins are definition at <mach/mux.h> file */
6 q% r. E  ~6 l        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. g3 q7 S) _# n0 j/ `2 B
        -1
3 g- P) R  A  n# {% o' p};
# h9 }  N; S* P1 U1 }$ g* t% `$ ?, B2 G4 Z- U* ?; D2 N* n8 }
static struct gpio_led da850_evm_tl_leds[] = {
+ w" _0 @" D$ }3 G  ?( U2 |        {
; d( O( E9 ?! X3 |6 P                .active_low = 0,
9 `/ Q; c& W% ]: }8 c/ X6 x8 v: T5 P                .gpio = DA850_USER_LED0," B2 X) G8 x' D/ P
                .name = "user_led0",
! f. f8 T  X% @% E1 n! s                .default_trigger = "default-on",
# w" \1 n& J1 X7 h8 }8 O& q        },  R" a( s9 Z: ^5 l' v
        {5 v4 G6 v, |3 w/ h/ l
                .active_low = 0,
- U8 f4 X3 a# i0 B) y                .gpio = DA850_USER_LED1,& S: }5 l9 U1 i3 N3 x
                .name = "user_led1",; B9 \9 ?( Z( ?$ ^6 x$ Y- c
                .default_trigger = "default-on",
+ w( G5 [+ w3 p  I; A& a5 A  L        },
9 x3 c: a# i. {$ {* r        {
) }6 [$ T0 `- L9 X                .active_low = 0,
$ Z. u0 M+ C" C' W3 b% G% v                .gpio = DA850_USER_LED2,- D! N. @  B7 k& n4 T
                .name = "user_led2",  `! Z" n4 ~: }, |( G: b# |8 X
                .default_trigger = "default-on",
2 Y/ o" Z7 k2 M, k        },5 q  @0 v* @6 K, E! L( Z% A6 }
        {3 ?6 q% Z9 D5 E, S3 n) T1 `
                .active_low = 0,
, z7 F2 k* d; l/ @                .gpio = DA850_USER_LED3,
. g; m6 U% _3 x* d9 [                .name = "user_led3",
) \9 X. w# T* u( Y                .default_trigger = "default-on",
/ u  E/ s" n" A( N0 Y$ g  |        },: f* m& |$ G% s- E1 d
};- Z2 V. z4 x0 h7 q! S" s; j
3 X& t$ P3 \3 k. I% G$ w2 x% _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* k1 w/ z: J' F! d8 T' j# j. Y1 C2 {8 K        .leds = da850_evm_tl_leds,4 U1 t3 r" h$ }0 i! M
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 H3 l, e0 j5 ?" {5 O5 R, ?/ Z7 w5 ~};' g$ c8 x6 R- d$ A+ ^& k

3 U& n: ^. d: A) Zstatic void led_dev_release(struct device *dev)
8 e2 t  o  T% p, p{: V/ F2 y# V! Y/ S' Z. W+ q
};
2 d0 W3 J6 \+ n8 q. j8 }1 A4 c' U" f  X
static struct platform_device da850_evm_tl_leds_device = {; U, ?5 V4 f4 z( @# d
        .name                = "leds-gpio",
# {8 P* z1 ]* _        .id                = 1,
  n; Q+ W% q1 Q! j1 g        .dev = {: c7 K/ E! K+ r* \
                .platform_data = &da850_evm_tl_leds_pdata,1 k3 L/ v) H5 v% h+ s! @
                .release = led_dev_release,5 K2 d: X# w2 u9 {, \: |6 x: M+ ]
        }
4 b8 G! @2 l5 I};- z3 ^' X" N2 |: _  ?, A7 j
* c& K0 W% P  w8 X2 ^- x; r! U! @
static int __init led_platform_init(void)
0 M& J) {; f' E7 W4 g{1 Y# I$ R* n3 r3 ?& G( u8 H
        int ret;
5 a  \+ T9 y* X$ M) L0 k4 D#if 0* }( H% d, Q* j. [' f' b& E
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* E/ I( P. w. ]4 r/ g4 ~. X        if (ret)- Q; f. J9 |" `% e4 H
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- t9 R1 i6 n" c0 Z1 S' T1 X                                "%d\n", ret);
* O! c, T; Z% R9 b- H6 Z! P6 z$ `#endif
) _1 p* v5 K; \8 s% V1 w        ret = platform_device_register(&da850_evm_tl_leds_device);
: g, ]& Q! x1 i" t4 x+ ]* I        if (ret)5 i* n. w  ~* ]8 n
                pr_warning("Could not register som GPIO expander LEDS");
" j+ b/ h& }* A7 o8 b: b        else
8 Q/ m+ X) S6 d8 t" R                printk(KERN_INFO "LED register sucessful!\n");0 E" Q8 A3 O9 i0 U$ }- C' X) @
" E# A/ r; I% I! \. {: J. l
        return ret;
* x9 n, ]: r# m& L}
5 [  y; v9 P( Y! m/ F7 p
  ]# d: X% G% e& Ystatic void __exit led_platform_exit(void)
$ R3 d8 V* y6 Y{
" L4 @" }: v; s: a7 M- h3 y        platform_device_unregister(&da850_evm_tl_leds_device);4 I/ g1 A& ~' C  i6 z9 |
( p6 Q5 {# t8 d, v  |: e
        printk(KERN_INFO "LED unregister!\n");$ \) k( |- `- ^0 C% @' \8 d
}! M  p3 s+ g6 n4 g
3 B1 }: i6 K3 ~  F
module_init(led_platform_init);* F1 m* k2 i; _( W  L; M
module_exit(led_platform_exit);6 u9 \; j& b. O5 M; U" c

2 d9 S6 D+ ^* D2 IMODULE_DESCRIPTION("Led platform driver");
0 s, q! B. O# @- t9 kMODULE_AUTHOR("Tronlong");
) `& t1 E5 Z5 ?. n4 ~MODULE_LICENSE("GPL");
  O  l/ u; L" Z3 x0 w+ j
; [( f  m& ]" W" y3 }% T
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-7 07:15 , Processed in 0.037428 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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