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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。5 p1 o) U3 M" @4 h" n1 P$ Q, e& X
#include <linux/init.h>
5 H7 O9 H! B, _- ]! q#include <linux/module.h>
: u1 q% l# G9 G- J' i; Q+ t#include <linux/kernel.h>5 ^3 `9 A$ e6 q
#include <linux/types.h>
0 M$ [% S( ^5 Y9 h  [8 n* R8 p, l#include <linux/gpio.h>- [: `: i9 E2 Y' Y+ J
#include <linux/leds.h>& y( @# C% u: _2 }6 s9 O
#include <linux/platform_device.h>0 y2 |6 e# [, v1 G3 s/ b
0 L" q2 m" J* c0 M
#include <asm/mach-types.h>7 r; m4 @, j( a  p5 w
#include <asm/mach/arch.h># R+ U: H, k1 U* R6 H( G, L
#include <mach/da8xx.h>
3 ], J' f+ a8 j* H% m2 z0 C#include <mach/mux.h>
/ i/ K7 c" r* _( s# o; \$ {' |* V, t7 F% |# }7 _1 O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: w. Q. _* v# I7 Y/ y4 \; |6 u#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 {/ O9 L! W! C7 a. M#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. s" l3 M1 ]" ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
8 o- m2 B$ v, Y, _* O7 n
/ D' c5 A3 O, `) I4 d/ w/* assign the tl som board LED-GPIOs*/
( o  V7 N- d" R( [static const short da850_evm_tl_user_led_pins[] = {) j2 V) s; H8 e' `2 I
        /* These pins are definition at <mach/mux.h> file */, G9 ^" e: H+ W; z: r; x
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  D6 ?4 r  C' o8 K4 \& l. n) c        -1* i' F4 B0 f5 S/ L0 v6 Q
};
; j2 t, k- t: V6 g: `* k2 h5 C8 I
: u: l/ N+ D# T. ystatic struct gpio_led da850_evm_tl_leds[] = {
$ n/ p4 X& H- W% ~, S4 U; ~- }        {2 Q: C0 T* _- Q. z. ?% a3 ^/ q
                .active_low = 0,
& ]( V0 ~+ B3 E! j                .gpio = DA850_USER_LED0,
3 W0 y6 J. y4 D                .name = "user_led0",
: G& B- N6 M: \7 }                .default_trigger = "default-on",, Q1 h6 I/ }5 v/ x
        },( C  V5 `+ [# O& v* @+ }3 ]9 g* [
        {1 [2 O) X" s$ E' R9 v: @
                .active_low = 0,
4 B# J1 t. X5 V                .gpio = DA850_USER_LED1,1 m3 Q  e' ]8 z1 [2 _2 y
                .name = "user_led1",
/ Q& T, x- d. x! M; x                .default_trigger = "default-on",
, T! [6 U, v; C6 h/ ~  U; J$ b& p        },
9 F* S; T! ~3 S# v9 s1 E        {
2 H7 h* `& U5 h! L                .active_low = 0,( h, E. P  m8 F2 s
                .gpio = DA850_USER_LED2,+ W6 C) z8 v, ]2 M, c9 A3 ^( R  J
                .name = "user_led2",
/ [0 p* j: C. |- T                .default_trigger = "default-on",5 ^) w0 w/ G5 f# e
        },) D4 s) L4 |) M0 u2 ^$ }
        {" h' j" o$ b# P0 F- D0 |; ?
                .active_low = 0,. n: }7 M/ L2 c$ ?) ~
                .gpio = DA850_USER_LED3,
  V% X% Z' R* N! ^# _+ o                .name = "user_led3",
% F* s, Z' r/ n8 I0 i6 l* x+ Q                .default_trigger = "default-on",
% c1 g2 r5 h! j1 |; R7 _        },% b+ R- T1 s3 h; p& |( ^* c3 S
};" _; l: Q1 m( |5 a* Q3 x

+ v# z7 b2 |% v* E+ r, K3 V6 Q2 C  sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 k- I4 ?! ^: ^8 U: U: J. o; I% _' u
        .leds = da850_evm_tl_leds,* E+ v# b+ i( `" w, }1 c2 v
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# W; Q5 P4 e7 a7 B7 T0 n  X( o};& N! Z( ?! Q6 J

3 S% r3 T6 U- w9 r2 Jstatic void led_dev_release(struct device *dev)/ e; ^' ^; |, k
{# h& U; P# D% g, s0 h5 `5 ^$ V! L
};
% V" o7 S) Q# ]" Z" p$ E$ T/ r! J# s
& Y4 |* p' g7 E; `static struct platform_device da850_evm_tl_leds_device = {
* `! t5 i4 H0 T: X3 l+ r( L        .name                = "leds-gpio",
. E4 i" w" T% D+ q1 O/ q        .id                = 1,
8 S% G% v1 d5 K% ~- s  c        .dev = {7 s, b3 h) q* q
                .platform_data = &da850_evm_tl_leds_pdata,; ^# p% `' q3 u4 a2 g
                .release = led_dev_release,- }. j+ e: N7 m( h
        }1 S# K7 ~1 b/ T( A% F( c
};( l1 `0 h% h' s  L8 j
3 L" }* |$ _* ]/ `& f
static int __init led_platform_init(void)4 r# G  g1 y  u9 @; |0 W
{
' o4 B1 y  s0 \        int ret;2 u4 \% V; l9 {" }
#if 0$ m& ~4 e; j+ |/ H3 g' O( H
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ h; b1 t* [7 E6 P. S        if (ret)# m) z6 j6 S9 W. @. U
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 J: y; ^: j. z1 Q4 p6 }
                                "%d\n", ret);
* T1 Y# v6 V: \4 W) b/ g, o1 Q#endif2 H! L& [. D: M" F6 X
        ret = platform_device_register(&da850_evm_tl_leds_device);
! R! S/ W2 e* L* s        if (ret)
0 w  r1 s/ D, S; Z                pr_warning("Could not register som GPIO expander LEDS");
0 d* ^3 e% o) w( h6 |        else! s' U# K5 G6 B6 a0 [/ e. ?! E0 k/ ^
                printk(KERN_INFO "LED register sucessful!\n");) l. I) O  b* w" W5 D- f9 ~

2 q- R  m3 |$ A        return ret;8 E% J0 a5 n' B1 U9 o" R# ~
}
* V. V! t$ p( h. e: X; ~( C4 {% t" d/ l* C0 c
static void __exit led_platform_exit(void)9 [! Q! u; `8 A+ @1 D# |
{8 u  H, i1 |2 J8 U
        platform_device_unregister(&da850_evm_tl_leds_device);
  U- l$ K4 |: x+ ~5 R
9 }; {6 D, J' P' ^! {3 `        printk(KERN_INFO "LED unregister!\n");
9 b5 I( o& \  W1 o) M}
" Z3 @. @( `: U* @% O' ~, o2 V, @
& E1 f0 {2 }. }: \6 \8 l/ X- ~# tmodule_init(led_platform_init);
$ ^3 p& A) l2 f7 pmodule_exit(led_platform_exit);, s6 F1 C' k' f" x
5 |0 z6 ~" \5 b) n" m
MODULE_DESCRIPTION("Led platform driver");' R9 K6 S$ h8 o  w. D$ b: W
MODULE_AUTHOR("Tronlong");
' E# G7 m# K: E8 h$ p* hMODULE_LICENSE("GPL");
. X( ?# t- x& t) f1 ^& P: l- V
$ I/ _0 a0 z5 y) ^( \
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-20 08:53 , Processed in 0.039516 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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