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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. s" R6 M9 r3 ?; ]2 E#include <linux/init.h>7 o. u" g0 U3 h
#include <linux/module.h>
* W# U' j; w5 V! u5 N0 I: L! h' p#include <linux/kernel.h>
( `. n/ ~1 L1 s9 R1 [, M#include <linux/types.h>
9 ?. E6 P4 C8 C/ z#include <linux/gpio.h>
: j( P4 v0 g* R4 C0 R5 H3 F$ r#include <linux/leds.h>8 o8 _' V$ s9 q* I" b, V7 l
#include <linux/platform_device.h>9 Z) _' y0 b0 R1 {5 X( r2 C9 Z
" [1 F5 n. d# C, `
#include <asm/mach-types.h>
. ]* g2 a8 k9 v" v2 Q/ E#include <asm/mach/arch.h>
% t9 R  y+ D4 ]/ C! n1 q4 P4 ^( m#include <mach/da8xx.h>
5 `- w" }  R1 j4 a#include <mach/mux.h>
! g6 p$ P9 T: H. _6 B% P% |
) U7 U. M# P! w2 I#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! G- N8 f9 R8 [; D( L8 K: T
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 v$ W8 d# Y/ h0 `
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 c$ a; P3 ^% [) \/ o
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)0 |; N  `$ n( E  p

  g8 t- {, o7 A. S# k4 Q+ I/* assign the tl som board LED-GPIOs*/7 l/ L7 [4 y( i, P9 c* g
static const short da850_evm_tl_user_led_pins[] = {
3 n8 z. C1 F) T/ [' r! C/ M; m        /* These pins are definition at <mach/mux.h> file */9 |, O8 k9 p9 f. \; Z' |1 g
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" s9 ^- x- Y8 R% ?        -1/ w0 p3 ]3 d) X% q
};( B, a" b( H: ]' h, s6 q7 o

, z2 b' N) x% K) Wstatic struct gpio_led da850_evm_tl_leds[] = {
. L! X0 T) ?( |& b" h        {, |' _" d$ d. d
                .active_low = 0,
  z0 U* H. z  M5 n" O% ?                .gpio = DA850_USER_LED0,: J! S, y! f* q$ n
                .name = "user_led0",
) |/ q2 u7 D+ H' U% ], Z; A9 R* w                .default_trigger = "default-on",
) H- w$ n% G- l9 o, Q1 e1 C        },
. M" |4 T1 q- c9 `        {: I( t- ^4 |; p( @* }+ G( ~5 J
                .active_low = 0,
  I/ `% ~/ K4 k. |* l5 D+ z4 ^                .gpio = DA850_USER_LED1,1 Y4 Q8 x! c  L9 U3 O2 C& C; C
                .name = "user_led1",9 a& w6 V' t2 E* E8 {- ^
                .default_trigger = "default-on",7 F( b) x  h5 ?- _
        },; [! n! j0 M! X
        {, p  r1 Z0 _) ^
                .active_low = 0,
, |, ?# V; q: t6 ]! k7 @5 T; J                .gpio = DA850_USER_LED2,- T3 v4 Q8 c4 p
                .name = "user_led2",9 g' d0 Z/ a% Y) r5 m
                .default_trigger = "default-on",
$ ^4 y) z# c: L. S* k% B        },; f, [# a: T+ b: x
        {9 \0 u. e9 ]) d9 E
                .active_low = 0,6 H! f7 c% Z. K1 K  p: E
                .gpio = DA850_USER_LED3,2 g' X9 i* A. Y  m3 H. G8 t
                .name = "user_led3",5 h( j) x9 {- m
                .default_trigger = "default-on",! F) ]7 i7 G& S1 K. @4 c6 e
        },
$ e1 v- y. Z0 `" D- ?  d};5 _/ ~8 d( y* `

+ ^5 d  N) j7 N5 t& bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ C+ f+ r- \1 K9 t3 B7 q0 T2 a/ i  W        .leds = da850_evm_tl_leds,* Q) b8 b6 Y2 |: O- t% s7 c
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ c" r' o1 ]6 ~' M1 _$ w) f};
% p9 p) ?# ]! d8 o
4 j1 ]! }7 L" G, q0 C9 wstatic void led_dev_release(struct device *dev)
6 f' d# x5 h. p5 `1 N8 Z{, a, S, n* O9 M" |7 M, Y. \; G
};
( B$ C& \% H! Y+ `7 S9 H0 h1 n+ S' o9 `% z' E9 Z( B
static struct platform_device da850_evm_tl_leds_device = {
+ L+ r* w% Z$ Y5 [        .name                = "leds-gpio",
' ?- D+ e6 {! n' Q3 @" Q# E        .id                = 1,
; E- f9 F, Q6 e" |, c& a( S* e+ o        .dev = {2 j: W' T1 O# \- G
                .platform_data = &da850_evm_tl_leds_pdata,
3 U4 B/ D  E) S( C& Y3 T                .release = led_dev_release,
0 V% l5 J5 O  _- h        }0 B% f$ `( X$ R: W$ ]% w
};
; d) j  U3 W' \6 P# B0 o& W. Z+ v9 e% o) r
static int __init led_platform_init(void)
! n3 T2 `' ]! y6 U1 Z4 K+ R$ @{
: |/ s+ N8 t* A% W8 F, R        int ret;
, T6 w) m1 s; b1 {7 R+ X) M#if 0& T0 D; f6 U# C4 v' }' {) N
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: _/ M( u0 Q; `2 \, V' h1 k5 I
        if (ret)7 d& ?4 l0 _6 I  U- R
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
  j- U) n6 ~! s+ Z                                "%d\n", ret);
& Z: R. X6 F/ e#endif' L* y7 G; _' I9 Z( i. \- o
        ret = platform_device_register(&da850_evm_tl_leds_device);
4 H: x8 Z6 y- e7 v5 f( j        if (ret)
* v8 z5 l3 C3 p1 _* b) P8 X8 `                pr_warning("Could not register som GPIO expander LEDS");
+ J+ x7 c) s" z* {# B        else
; d4 a& l! W( {% G+ g$ v/ `6 {1 ?3 a                printk(KERN_INFO "LED register sucessful!\n");7 `* ]* G$ C/ B

" @; f8 {0 z- B        return ret;% ~- U4 a- j+ i6 t! w9 G
}( w  X* q7 m) ^1 G' t  f: V$ `
( E: s/ _% T9 u, c
static void __exit led_platform_exit(void)  e0 m' v5 ]( F8 ]/ |
{
; y7 e/ X. |) r        platform_device_unregister(&da850_evm_tl_leds_device);  U2 i0 [: t& J4 N; M5 I4 a

- N# |* x0 Y* }3 c        printk(KERN_INFO "LED unregister!\n");
" L( ?9 d; @& P}
" v0 C; t, l7 x: P  [/ }+ ?" S# h9 M: u$ _
module_init(led_platform_init);+ N; V+ H! q% O  ~' ~( H7 A% u' T
module_exit(led_platform_exit);
( r4 k% c; b. w1 u. ~
7 F5 ^- P. u2 t, Z$ H7 }6 I! h3 B: wMODULE_DESCRIPTION("Led platform driver");
& f9 O8 m1 Y# {8 u% y% K% w0 S( RMODULE_AUTHOR("Tronlong");
5 L3 T: W7 F, w7 l3 FMODULE_LICENSE("GPL");
: _8 q0 `( O0 T$ W4 e% D0 ~: [+ A% c( F: M* F
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-9 07:41 , Processed in 0.040577 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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