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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 q. Y; S# b6 T. x0 ~#include <linux/init.h>
4 a" H( ^- B8 @( U% r% k1 m! P  ^#include <linux/module.h>5 \/ g5 e# V/ o
#include <linux/kernel.h>$ M5 |& N8 s* }
#include <linux/types.h>" b5 [* T0 ~) c1 a$ T
#include <linux/gpio.h>
: A8 \$ C" S, @* s" X% {#include <linux/leds.h>. [. ?; D5 U, U* K7 ~7 n, C3 y
#include <linux/platform_device.h>
3 `! Z* o, G6 w2 l& L
* p0 p. i) K2 Y1 d9 i/ G2 X3 V#include <asm/mach-types.h>
+ {: L! t3 ]  x4 y0 a) {# I#include <asm/mach/arch.h>
: B. @( g* L2 B" v#include <mach/da8xx.h>
' m; m( v2 X+ Z5 a, R7 _9 l#include <mach/mux.h>' y8 J, l1 W- I8 `
! h: C  o. f* x8 g
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ B' Y% }, t, u
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 s( ^$ U7 V& j/ @% J1 Q! y
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: J6 ~9 [# F7 a* W; w) |( N#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& y, R( o' u( K! o% [
8 L# K- b8 J) @) \) j8 Z/* assign the tl som board LED-GPIOs*/! h5 @% i+ _- R* ^
static const short da850_evm_tl_user_led_pins[] = {9 @) r6 \, r0 h; ~5 z
        /* These pins are definition at <mach/mux.h> file */
4 A1 \8 B" P$ C7 C  w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 Y& g/ _$ ~5 j% L) j, L) R! H
        -1
! f5 |+ ~  Y# `. P: w" l# F};
$ G) p& w" n7 d( ?- j6 y" c5 I
  E  R1 y! c6 `static struct gpio_led da850_evm_tl_leds[] = {" t, U! Y5 M$ D  \( ?
        {; S) s3 j% Q, B7 T  y4 F
                .active_low = 0,
+ P; Y8 ]$ a+ m' J! n8 t                .gpio = DA850_USER_LED0,
0 }1 S3 b' E, w6 r& A                .name = "user_led0",6 M9 p  D' c, B+ Y
                .default_trigger = "default-on",9 \4 T. t! _  N' M7 m# w
        },
6 s9 n% Q* V8 k5 Y        {) Z5 b  F% u* j; t9 v
                .active_low = 0,
$ Z: Q  H) O: Q: J8 H                .gpio = DA850_USER_LED1,
  Z8 [! U  ]5 ]  x4 v( r9 [                .name = "user_led1",' g/ O0 M0 _+ A; J
                .default_trigger = "default-on",
7 X' L+ x$ t1 ~9 |+ a        },( F, r( L& y4 s( Z3 T+ K0 O2 U. G/ j0 U% m
        {
  P$ ~1 Q* K6 U# Z                .active_low = 0,! N# a9 [. T. a* W" w4 e, e+ a
                .gpio = DA850_USER_LED2,9 w$ ?2 d# C5 _1 B
                .name = "user_led2",
* U% d3 c- w8 q) f9 F                .default_trigger = "default-on",
" q- d5 w$ \, F0 s4 h" ^) J5 n        },
0 n- D1 t2 h; [# y& P4 @        {
# \, }9 b. F" n( l$ ^                .active_low = 0,
  k& R( w# Y% x- l                .gpio = DA850_USER_LED3,
, i$ _; q5 f" T2 s1 o" O                .name = "user_led3",% o8 w1 [' s" I$ g& `6 k: a
                .default_trigger = "default-on",
$ Y, i9 l: F1 _& h        },
% e% p7 j+ L0 w};
( N+ B& t$ ]! o. b  k% b9 O! L6 l2 H6 o9 u  ^8 N# R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ S- E* w: C: i% v6 M0 b" J! O) }$ X
        .leds = da850_evm_tl_leds,' r- ^* M3 u6 O4 f, b
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ @& e2 g& y1 S, }- A2 |+ S& x
};
: u( A3 q+ h* s# O6 v% d% c( P- E, A! T6 e* {4 ~3 r
static void led_dev_release(struct device *dev)
. r7 |& W. w6 @: x+ [- K3 N! W0 v{/ m" j1 Z! A- \: c7 }
};% y8 @- f+ ]8 S: {7 y7 L7 L

/ U* r+ k* O  \- V. zstatic struct platform_device da850_evm_tl_leds_device = {  h$ L+ ^$ H" B! T! n
        .name                = "leds-gpio",
: E& a1 n$ h2 g; c+ l        .id                = 1,+ ~: H) p9 n% c' a# Y2 ^
        .dev = {
1 p/ p) y2 W1 }! v4 o9 M( N                .platform_data = &da850_evm_tl_leds_pdata,+ G( B' U5 _7 u" P* Z$ Z1 F
                .release = led_dev_release,
. X$ K  [+ G0 X. d+ ~% S; L* O        }
0 Z3 u: |% O3 Q9 f8 ~7 W, h};0 w  }  U/ E5 E

1 M5 L& ~% v4 [: j* {# a' Vstatic int __init led_platform_init(void). [; m% w- r" R6 D) M% i; m$ Z
{: W" r/ k2 d# H7 Y5 i$ w8 O7 |
        int ret;& [* `) a( _9 b% k; G( w
#if 08 U5 R: ^1 E: |! C. s- G
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) `! F2 F8 a4 B( ?. t2 X1 \        if (ret)
- [7 [' s' `" s, p7 j6 x                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, {; L4 `. K6 h/ b! y% K$ G                                "%d\n", ret);
  j9 v2 S( i# d2 s6 I: N#endif
  n5 T8 q  j6 R* l5 {        ret = platform_device_register(&da850_evm_tl_leds_device);
' [# r' U- x) T& i* c, U- z3 k        if (ret)
2 F5 {8 {  G$ d2 D/ k7 V8 J                pr_warning("Could not register som GPIO expander LEDS");
: k8 n% ~" @2 j! C8 U; B8 d0 u& B        else
" J& A% W, c. Y. k# D                printk(KERN_INFO "LED register sucessful!\n");% D8 n. ^9 G) |" W" M: a
# R: e5 f4 E2 m. M9 I  ]
        return ret;' X2 A7 P' i% u  M; k
}
+ G% O2 D: b8 S- C
: \- I5 u6 M' U5 n# c5 |9 U; Wstatic void __exit led_platform_exit(void)+ p+ }8 Q/ B  t) A
{
6 G2 W- ?( \' P        platform_device_unregister(&da850_evm_tl_leds_device);
" Z0 ?5 b# F+ ]! K1 A* Q2 [0 N; c# k2 y+ ?/ P1 ~0 T- S
        printk(KERN_INFO "LED unregister!\n");
1 a: G  Z1 L: B/ h: y( E}, [5 N+ t: k, y0 i

: J" E2 o$ W% R) L& imodule_init(led_platform_init);
: l1 D' C% K( @/ }. Wmodule_exit(led_platform_exit);; H: J7 ~! F8 m$ a% Y
; j. B* h( E- I# ~
MODULE_DESCRIPTION("Led platform driver");
  A9 q- G# R! z9 ~9 R) ]MODULE_AUTHOR("Tronlong");! J' _2 r; g9 V" ~
MODULE_LICENSE("GPL");
6 s5 k$ r) _" c
1 u' T8 I& `! c: e2 z& T# z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-4 21:35 , Processed in 0.038890 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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