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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
0 ^) r- {9 |2 V4 Z  e1 d#include <linux/init.h>
" x" q7 Q+ B2 s  e#include <linux/module.h>2 ~. p  _" `* [& l' T% V  r
#include <linux/kernel.h>$ l$ X5 ~' C: M
#include <linux/types.h>. i: B. l& t) g) m6 p1 b8 V
#include <linux/gpio.h>% J' g7 ~! W0 V+ o
#include <linux/leds.h>
# a3 a; x: v) I6 k7 R, y#include <linux/platform_device.h>/ W$ v% |$ \- i' O8 d
+ u0 i/ \+ Q0 t' B- I- V2 L4 W
#include <asm/mach-types.h>
( v7 C9 D  R8 Y2 G" W+ s: T  R#include <asm/mach/arch.h>
- }3 }% ]( n' J7 H2 p% W! f7 V#include <mach/da8xx.h>0 R2 D6 i. I5 ?$ X9 ]; D
#include <mach/mux.h>! g9 z+ W# {. c& b" |3 R9 Z& i
3 s$ F5 N0 m0 S* M/ A- r5 r8 @( S! V
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" o7 T# p1 J6 l/ w3 V+ X; K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 d1 a7 c- V; {& c/ M#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). @# r6 D5 p7 |1 h
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 g: ~; H* J4 H7 x, ]8 {# p
( n7 B1 e) f0 x6 n5 ~& F
/* assign the tl som board LED-GPIOs*/
  n7 k1 ?3 ]; e2 ?  p4 Wstatic const short da850_evm_tl_user_led_pins[] = {
' r) i6 ~( I  I2 f1 T        /* These pins are definition at <mach/mux.h> file */: D7 H' l* ^' U
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ F4 S0 k- S$ f0 P) J$ c6 \6 R        -1
1 b# g0 m5 X  {# @) _! @1 Q};
: V( g! g# f6 {1 \) N  B- D6 O' k8 F
- b! r8 g2 H" l* k. i$ u) Rstatic struct gpio_led da850_evm_tl_leds[] = {% b8 d$ T% f, i+ k
        {4 q' S- a! R$ @6 J5 c; f. D
                .active_low = 0,8 T1 r/ a5 \) d# A$ M- x
                .gpio = DA850_USER_LED0,
" c% \2 q: A+ k) D* b$ v                .name = "user_led0",
- w; {$ d8 ~. M3 {  Q                .default_trigger = "default-on",
4 t: K* Y, m( f! r5 y) x        },# T( W% e) ~1 Q" T
        {
9 m! v) _5 K- A" o8 F                .active_low = 0,
; D6 [1 S3 p/ b                .gpio = DA850_USER_LED1,2 a3 S  ^( ~3 u1 [% Q% {& ?5 D
                .name = "user_led1",
3 e" F2 a+ z; f; r, n. T) q/ f                .default_trigger = "default-on",) H; }$ m, P' h6 f
        },
: J5 C- s  J  ?3 ~6 z& ~* t3 m        {
; H0 a: Z* Y! G: w# H+ K                .active_low = 0,
. X, R- |9 ?  {" V$ M                .gpio = DA850_USER_LED2,
) P/ X" d# G0 X9 @3 s                .name = "user_led2",: K$ h- x2 R: \" O# L% m8 h5 ~, J
                .default_trigger = "default-on",
/ ^5 z9 K7 [4 r+ L" i. K9 y        },& w& m* H8 z; q' D) K8 Q" a3 v
        {
0 b9 x. \  d- i                .active_low = 0,
3 o$ b5 W1 `! i8 Y' Q% m6 [  C                .gpio = DA850_USER_LED3,4 `( t' t5 B6 o6 @2 ?$ V
                .name = "user_led3",
3 N9 x# f& U0 p' _                .default_trigger = "default-on",
+ j( s) U1 ]) K- W4 b# p1 w. M        },; J2 h( q9 e% z; x2 i
};
5 P2 w4 z/ Y' g: l9 f% ^. M1 Z6 N" [% n9 V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' L5 h7 _' X, j1 I/ w
        .leds = da850_evm_tl_leds,1 d* u- p. e4 c
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 r2 B6 D+ J' m* B. Q};0 n8 z: o. ]* j" h4 U

0 |9 V3 s8 V- {3 g% I9 pstatic void led_dev_release(struct device *dev)8 R- M0 h# l* Y: e  q
{
% |: ^# a2 `& F* y7 O8 R) x9 I};  z2 m3 P8 Q. k3 v: E+ v
: J( k4 e' p# Q/ N
static struct platform_device da850_evm_tl_leds_device = {/ ]1 w& N+ w* [
        .name                = "leds-gpio",
& i. U) w7 J* v% Q# ]2 N2 O5 }        .id                = 1,
9 s- w/ o4 _' n        .dev = {. i1 M. v! y5 Q. Z- `) J
                .platform_data = &da850_evm_tl_leds_pdata,
% [0 ?+ _1 E% j- J4 g! z                .release = led_dev_release,7 y  D+ j% m, S2 [8 i! t
        }
* K* Q# e% d1 H};
6 H+ }/ s" z+ [1 T. e! M4 o
7 o) o/ ^1 c: S4 G- z: z5 hstatic int __init led_platform_init(void)
! d# X" A- j1 ]% f{3 W: ~1 L3 `% Z0 C8 J
        int ret;$ F( I7 _3 s. v0 }/ |0 N) C# _
#if 0
/ W/ N: L# Q; [7 c        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" K/ W& l9 f$ e        if (ret)
! Z' R8 x. J. ]9 \( I                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# R  e9 W# a- \6 g! e9 H
                                "%d\n", ret);
& M$ H+ I9 A$ j! I7 q* C#endif5 J/ t4 }! J+ j8 o% B
        ret = platform_device_register(&da850_evm_tl_leds_device);8 \5 ?( k/ W- ^6 I1 G
        if (ret)
! T, x, |' M  S  w0 V; M5 S                pr_warning("Could not register som GPIO expander LEDS");
9 u2 t1 M- R, E- R. _2 C9 n        else: @1 _6 k1 U, F- W
                printk(KERN_INFO "LED register sucessful!\n");% s4 T% \% K3 E! X# A) K( @
* ]1 O) h7 O/ J4 `' K
        return ret;6 d$ p) B( k, U. g9 J
}; P& z' w3 D4 B
# A7 B6 y5 U; s2 o& Y
static void __exit led_platform_exit(void)1 X( h2 N0 d, z. F
{1 ?0 C: G& H: e% Z4 E, W6 d
        platform_device_unregister(&da850_evm_tl_leds_device);2 M8 D' o$ v+ N6 s. `8 X5 o. Q
0 f; Q3 \9 x+ S" x3 H- N0 \6 A: ^3 ^
        printk(KERN_INFO "LED unregister!\n");
( h/ \2 e, V1 U# @# b}
, k5 L( h  U+ x- n2 v
' V) D! Y. C  G# X% smodule_init(led_platform_init);% @+ O/ n, c+ B/ |+ l- K
module_exit(led_platform_exit);1 c. ]" |' ]) Q

3 `2 g# M& k: SMODULE_DESCRIPTION("Led platform driver");$ _) O8 Q' B. {# {) [- t: l! `
MODULE_AUTHOR("Tronlong");
7 {2 Z9 g- G: x! U8 R* m! f* \MODULE_LICENSE("GPL");1 C& I2 K# ^$ p( `6 c! }- I, `
# x& `* C/ y) W$ K; X
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-15 08:14 , Processed in 0.037782 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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