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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 _7 e+ ~9 P8 U: |5 U
#include <linux/init.h>  m9 Z) g# n0 R+ u6 C. K8 e. I
#include <linux/module.h>2 z: }1 m1 p1 y/ I
#include <linux/kernel.h>
9 J8 C( u2 y+ N: ^: @0 x#include <linux/types.h>* R/ q% `& B2 @0 \; I
#include <linux/gpio.h>9 l' |1 Y/ o# g7 m9 t
#include <linux/leds.h>
' _; w& K: G  x- v  `+ Z' v0 ?#include <linux/platform_device.h>3 U2 v  S: |, K0 h! S; x/ k
8 ^+ q1 Q& \2 b$ X2 u0 R- a
#include <asm/mach-types.h>
- \$ T8 Y0 ?$ u# q! u#include <asm/mach/arch.h>
$ B% g7 U- r( O! e" P/ N#include <mach/da8xx.h>
3 |6 L7 Q* \% W% D5 [#include <mach/mux.h>
  w# R2 t( g' b, s1 g8 a9 e" [
& u7 Q; H6 y5 X0 M4 ]#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ K- m5 t; ^+ Y" E7 B& C0 R& D1 H#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). s! K6 c5 Q  G7 Q4 E
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 ]3 I$ J) L7 o* X
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 x9 u5 \2 z1 B+ O' Z) H3 \
. I  F5 p! D* t( j
/* assign the tl som board LED-GPIOs*/
, o: o& J9 f& ^3 s& u: N; ?static const short da850_evm_tl_user_led_pins[] = {. v% e0 r! @, k( |+ W( I
        /* These pins are definition at <mach/mux.h> file */( j* }) E) A8 Y6 y+ ]
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 I% N/ w/ \5 G8 g* H7 Z* Z. M        -1
' a6 x# x$ a1 y0 ?( S1 Y};
, |2 x8 ]1 `+ ~
, a' u: g7 l$ j* n5 j* c& wstatic struct gpio_led da850_evm_tl_leds[] = {" I1 Q5 h* T/ w$ u
        {- w6 }# A8 y, H
                .active_low = 0,% h- [, [' u3 X" g
                .gpio = DA850_USER_LED0,. y; f) \; N) Q) \1 ]( n
                .name = "user_led0",
  q) M9 Z0 X+ \) o4 o- X% X                .default_trigger = "default-on",7 u$ L( [; H: i0 b  c
        },
% ^( T. o/ g  b. F1 e        {7 k. d2 B! j1 X+ _" }9 X  i
                .active_low = 0,
) C' d/ G  m  S- N& P: S                .gpio = DA850_USER_LED1,6 }! E2 y  s* K3 v/ y* D, K, ~
                .name = "user_led1",, M3 `( q; A5 U$ D8 g) D
                .default_trigger = "default-on",& @; I3 X2 K! C, M
        },
- p- h! J8 t  u. a" p" ?        {
( }7 }1 T, Q, D( x' n) L4 m- Z                .active_low = 0,
6 X9 M# m9 \9 V6 R& s                .gpio = DA850_USER_LED2,/ W2 \9 Q7 t. ^% k3 p
                .name = "user_led2",- ?1 S3 T- z/ A* O! Y* C
                .default_trigger = "default-on",
" A2 B/ U6 P& O0 t/ e        },9 l3 [. O- x9 b% W% w" y( a* F( Z
        {
4 S& h& W1 T6 U3 R/ R8 X                .active_low = 0,
2 j3 [& _; U+ W3 u: z2 G% C7 X                .gpio = DA850_USER_LED3,9 J% g$ a, M+ ]* b
                .name = "user_led3",# K4 Z) z" A& a7 i0 ~; W' f! z
                .default_trigger = "default-on",; J, B( t6 r) T/ N4 b% J
        },
) X% }8 O- e% w# d  N};
. s: g( w1 z3 q8 ?
9 @2 m, e1 x1 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  g+ w7 s  ~; X* r3 N3 L0 C% |
        .leds = da850_evm_tl_leds,2 k0 \2 N+ Y" k& P% j) s* w: x; t$ l
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! I3 Z( D+ S4 p0 D# b/ k, v/ f9 Q
};; j' H( F+ e' ], [6 @7 @3 `
  O  \6 _! {) a3 r" Y9 l, ^& I/ H
static void led_dev_release(struct device *dev)
$ b+ J8 B5 L5 W! {) Z" \{$ t2 m- P  B3 O+ |& W
};
: x7 e: M* N( K! N" n( C* S* i( i/ n0 N$ |* i
static struct platform_device da850_evm_tl_leds_device = {5 f+ S! S$ u& I, O
        .name                = "leds-gpio",+ g2 h0 N( E' o0 ^% B
        .id                = 1,) m( c2 |* {" [
        .dev = {# h2 E  G; G7 C2 F9 b& \% \
                .platform_data = &da850_evm_tl_leds_pdata,
2 r9 d0 O) O/ ^  W" O7 L9 H1 V2 k                .release = led_dev_release,- d/ z4 ^' T& b9 R" _
        }$ R/ W; Y% d$ }1 r) Q# D+ W# ]8 O
};
1 Q, q+ m& W. ^
* f, A8 A8 q; ^0 Vstatic int __init led_platform_init(void), B: K4 ^& P! ]9 O3 e# }: h
{4 J0 C+ x, u5 a9 Y7 q' R+ J. u
        int ret;0 Y$ k+ N" \2 x0 o7 S& p+ p. U
#if 0
. }/ a& e: M/ n6 U) S2 E7 R        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 F1 J2 c7 N& Y. n: y8 M
        if (ret)/ ~6 |. E0 Z/ \8 P  ?' F+ \! c" z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 y, S# U7 h& J* t7 {2 @5 `, B
                                "%d\n", ret);
! @/ V/ M. L2 m# J+ K#endif" N8 i" k- k5 C5 d: y( A' M+ {
        ret = platform_device_register(&da850_evm_tl_leds_device);
/ X. D2 _$ @  R1 y1 Y2 l$ ^        if (ret)
" B  D9 l0 }; u% w' V( x* P                pr_warning("Could not register som GPIO expander LEDS");5 S( o$ S3 D; o1 r9 G7 X' o
        else7 P1 B2 r' j8 U* @- R
                printk(KERN_INFO "LED register sucessful!\n");
% Y$ n7 k- n4 i2 ]$ A9 W. a
! T5 `% H# n. ~7 w5 q/ s/ A        return ret;' s0 C/ P* Q1 P( w( }! |
}
' y0 Q; O$ f" w- _
& _; D- H3 n; U9 q8 sstatic void __exit led_platform_exit(void)1 v) ?6 V7 Q! \, n! O- L
{+ R+ b1 ?: ~4 k& \$ Z( R
        platform_device_unregister(&da850_evm_tl_leds_device);/ K; F, ^4 ]; m5 s( a; V2 S. }5 O
, X" k0 a$ j, w; w# k
        printk(KERN_INFO "LED unregister!\n");' l$ E( L. R. T
}5 w9 c- J$ B4 a: D2 Z
2 r. E) R9 J0 z
module_init(led_platform_init);
8 z. @( K1 D1 P  f5 [. U& j) Dmodule_exit(led_platform_exit);
3 G1 s5 a; R) L; a2 I) u; S# j& e( v' r( W' f3 h7 t* H! g0 T& d
MODULE_DESCRIPTION("Led platform driver");  x) Z6 C6 x/ y1 O) v% W/ ]
MODULE_AUTHOR("Tronlong");
7 }9 E) W8 S8 w+ B3 NMODULE_LICENSE("GPL");
  y0 Q, j4 |9 [$ b2 r/ X/ [) B6 B; J, L) U8 R8 Y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-26 21:05 , Processed in 0.038207 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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