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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% x9 p, ?2 J: b$ \& l
#include <linux/init.h>
# j6 k' F1 O6 V4 M/ }1 z5 H#include <linux/module.h>9 D* g8 Y9 T/ o+ _" f4 z
#include <linux/kernel.h>
' U/ g% C+ ?, E#include <linux/types.h>
' k# f9 s4 n, t6 ^: A5 |) N#include <linux/gpio.h>4 l8 {" }; O# a) R5 F
#include <linux/leds.h>
4 u2 p9 h4 [. i" }5 b/ a0 c#include <linux/platform_device.h>
; Y$ H- V0 [( E  @3 {! a
& a: _, O. u9 X+ w% `! l6 M0 e#include <asm/mach-types.h>: E. v" b7 \$ p* N0 N
#include <asm/mach/arch.h>  c! X3 x" k& R, t
#include <mach/da8xx.h>+ S* T) P5 g9 M
#include <mach/mux.h>3 l! B  G* e8 v6 k5 h* h9 S
* K: m7 w1 J9 |8 B
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 i; R- e& v' a0 N#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 ^! [# F- }0 \7 h4 f" D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)$ K, B& ^  V" ?; I  b$ Q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
- U5 a: S1 s. x. W9 V- x- r( I0 u5 p  b& m
/* assign the tl som board LED-GPIOs*/
- f9 X+ G8 h) u# i5 g7 Ustatic const short da850_evm_tl_user_led_pins[] = {6 m8 F8 e+ `1 n" Z/ g
        /* These pins are definition at <mach/mux.h> file */# ?4 ^7 A0 t$ l
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' I6 D8 M6 f" d; U" b        -1
% u6 ]9 j  K' I3 r- m* e! g};: r7 O/ o! ]8 e9 B4 ?+ ~8 L& X
2 d- Y* y4 R9 _4 ~3 ?/ c) }
static struct gpio_led da850_evm_tl_leds[] = {
6 z6 m1 q/ ]( @: C' N3 ^* d        {
+ u+ k/ c$ t. }' X& h6 n                .active_low = 0,. a0 {8 s2 N9 o; E& Q1 J
                .gpio = DA850_USER_LED0,3 Y( `, L. w, d! |( S
                .name = "user_led0",8 m) |/ N/ E8 L/ o( G3 t) O) u
                .default_trigger = "default-on",
9 [) h5 U7 c# M% ]        },
! [" l% `; A: }. n% Q) c        {
5 b( |! v. ~9 r: @: D' o' d) k                .active_low = 0,
5 r' T- n, W9 w0 c                .gpio = DA850_USER_LED1,! d4 r9 _* Q2 J% |0 G7 g/ D! C! R
                .name = "user_led1",* q! C. l  X/ t
                .default_trigger = "default-on",
7 ], s, f' A# K, e! r        },$ E9 M/ T) q, d
        {
( j. g. Y# J7 S# q                .active_low = 0,* C7 f, T; s9 X3 C: \2 I
                .gpio = DA850_USER_LED2,
* o0 Q4 E! c9 I+ c                .name = "user_led2",1 [1 h+ s% l( c$ m
                .default_trigger = "default-on",& p. S7 U8 r6 c+ r8 ], h+ x
        },2 [7 C( l2 k8 {4 j4 c; ^2 l: ~: [
        {
5 W* h  g* T, d! b+ `" t                .active_low = 0,; {  o  F! T/ q/ U
                .gpio = DA850_USER_LED3,, m+ l1 Z, Z6 M
                .name = "user_led3",
  f# A. d0 `8 {3 Z4 H0 ?                .default_trigger = "default-on",
* B& v, Y! c3 s, Y. H4 M3 R        },/ ~. I+ ~& d4 x4 Z6 @) v) H7 `
};4 ~2 y& U% _! R9 ~  e5 I; L

3 q3 k; `8 X+ o2 @4 Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& M* ~3 M/ d9 x" U# z        .leds = da850_evm_tl_leds,
4 w$ _/ y4 d, L7 g% y5 |        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( B7 S0 `/ w) H3 A
};
3 O, b, m' ~/ L+ r% M8 O
! D$ F# U* E3 `static void led_dev_release(struct device *dev): z% p/ z4 g! A  A+ T. K5 o
{( ?( d% N' ?8 O5 E5 T& S7 B
};
. i1 E3 M. h& {1 \* G. _! q4 [  \9 J- @; f9 ^  S
static struct platform_device da850_evm_tl_leds_device = {
* c$ T+ b8 L( K& U/ x  b' E        .name                = "leds-gpio",
8 Z* U1 d5 \% `: M; A/ ]! q        .id                = 1," Y& e! P+ p! j6 P0 b
        .dev = {
& Q  m: W/ p9 n                .platform_data = &da850_evm_tl_leds_pdata," Q% k- X( N! @! \) T4 U
                .release = led_dev_release,
/ J2 \: B' t; S) }        }+ K2 n. [( i. R: [; a1 Y% Z
};1 K/ l9 m3 H: U* {3 J

- \: I% L( J5 ?. {  M, {" Qstatic int __init led_platform_init(void)
3 z$ g, l% i. I, K2 f{8 Q5 C+ u- |' _
        int ret;9 M, O; T2 R( `7 g
#if 0
/ c3 k) t! h1 G, F' U        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& z! }! B2 H/ k6 k  R; p
        if (ret)
; _# Z) p6 _; ]  w0 L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" e0 |: k) J  c' F- t' \/ P                                "%d\n", ret);5 \+ D4 s% K4 {+ h/ e
#endif( c+ z* A# p+ \) l# [" }
        ret = platform_device_register(&da850_evm_tl_leds_device);
  b4 U7 b5 p3 F5 x        if (ret)) ~. h' U% e" o5 P7 x
                pr_warning("Could not register som GPIO expander LEDS");
: l8 r" ?7 |5 w: [/ Q        else$ c- N/ T" U$ @
                printk(KERN_INFO "LED register sucessful!\n");$ {! C! y7 H3 H( B" a* _: t
6 R; F. x" l) h
        return ret;6 X1 b) f3 z$ Z. W: f6 K; x! H
}  I0 e$ b: }% ?
: [" H8 O" N" C& e  f" l$ h% |
static void __exit led_platform_exit(void)
; b% q6 z% C9 Y{
# k1 L7 r, e- ^6 L, d1 ~% u        platform_device_unregister(&da850_evm_tl_leds_device);
8 A7 g1 C$ o( f) v! |& y. m/ U, p: G0 O: `2 H
        printk(KERN_INFO "LED unregister!\n");8 |8 A$ t: s* X; N8 e
}; f0 r0 ]' W  X/ y. S
( u# p1 v7 B2 @) l, x* l
module_init(led_platform_init);5 X. q, ^: p# W" n0 V& O3 O7 h
module_exit(led_platform_exit);
2 L1 `; _8 Z. e+ Y4 W* G+ N
- m- b  g* s) l- ~3 R/ \MODULE_DESCRIPTION("Led platform driver");9 I( l- N1 C$ N3 g: e) V
MODULE_AUTHOR("Tronlong");
0 h7 _2 ~; S8 e1 h# J+ ?# f# I9 z" b  DMODULE_LICENSE("GPL");1 H' y1 |. R+ d, ]. S

) O, f$ s/ R9 Y" t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-7-27 17:51 , Processed in 0.042053 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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