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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。7 u6 v* P: }9 a$ D# Q/ ]8 N! F0 I: P# i
#include <linux/init.h>
: S" _1 M1 |+ V#include <linux/module.h>
9 f5 J* ~; `0 i! I+ T#include <linux/kernel.h>
6 ?* j7 B, D# E# k  o  W#include <linux/types.h>- G' ?2 q" n+ _
#include <linux/gpio.h>8 e2 [: A7 I* ]- P$ @- o# k% ^$ y
#include <linux/leds.h>
3 R: @- \) w0 T6 |+ P: a/ \#include <linux/platform_device.h>
& L# \/ E# k7 @6 M, f# w) l
- l, S2 c1 G4 S  Q* x/ h5 Y#include <asm/mach-types.h>" E4 T2 ~( @& L: x& o
#include <asm/mach/arch.h>
% \  h& R) A( I# R5 Y#include <mach/da8xx.h>
4 [4 Z% Z/ B7 w6 B' V" f#include <mach/mux.h># x" g5 Y; V, z# ?& V- @4 U

% h' n% N1 ~) o. _6 M#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 A* q; o3 }- r: u8 E3 }( i" F) X#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) x% [. j$ b4 K& {3 O#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ t' K' c  N. A' a1 V% w, _#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ r( p9 b- P. C. G; H. I
2 V9 ^4 j" G7 L" D3 K: x3 A" x/* assign the tl som board LED-GPIOs*/
+ b- A7 {2 q  astatic const short da850_evm_tl_user_led_pins[] = {' t4 {' q7 h& b, i
        /* These pins are definition at <mach/mux.h> file */  r% z& @1 c, z$ `( E: C
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ `( ?) g4 ?) M- \( ~
        -1
1 Z. ~9 ?# z, ?6 x};
# f& i, W" }- o6 @& q+ p0 r
) X4 J. u7 d. A) x+ f$ \static struct gpio_led da850_evm_tl_leds[] = {
- ^, d5 Y0 H6 m' G* W        {
  K9 k/ N! L' a7 L7 y                .active_low = 0,
+ C, ^2 E9 f& H' w3 y                .gpio = DA850_USER_LED0,4 |' ?3 \; l; ]! o' j9 N7 S0 Y
                .name = "user_led0",
2 ?: L: \) u+ c7 ~: e! \5 W0 q0 o                .default_trigger = "default-on",$ ^$ C0 T* R( t2 s1 f# m( Q' W
        },
% W: O! K& ~& N2 k  f        {
) Z! [0 M* U+ ^% m& \2 f                .active_low = 0,3 `  h( s2 a& F
                .gpio = DA850_USER_LED1,! T1 E4 b/ \! G& U% a
                .name = "user_led1",+ ]. O6 U1 w, b" q; k! K' }
                .default_trigger = "default-on",
% j; q9 }9 I0 l0 r9 G0 w        },
1 a4 D3 G- Q6 a8 J) ^/ V' u' s& B! J        {3 m1 ~" S- \+ {1 j
                .active_low = 0,
8 B! o8 e5 p( Y2 q0 v                .gpio = DA850_USER_LED2,9 y; x; }6 R1 T! [
                .name = "user_led2",9 ~; D/ ?" O: u  @% G% M! }
                .default_trigger = "default-on",
; u9 Y2 l9 ~8 c1 r( ?1 a6 j        },
, w4 |  m  ~! A- y1 H! e        {& d: [. k  o+ ]+ c- t! l, s4 l% v
                .active_low = 0,
$ L- o4 ?+ s( q" d, N" W  f' V- A' b                .gpio = DA850_USER_LED3,
# o+ k' S* Z% m$ Y                .name = "user_led3",  J8 W1 b* I1 m+ H* T
                .default_trigger = "default-on",
' \1 p! [, d7 a6 |( F        },! A$ b/ T: C9 s- [+ p- m
};
. [8 A, S/ N) o( C) a8 a; X
; w* a" ]  ^" _4 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ c! [* T$ q! J, Z        .leds = da850_evm_tl_leds,
& w- W- ^) B3 a! n' R        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! W' e2 ?, J0 G
};
1 f3 C$ B" p& m- M7 M8 K4 a, n% T; O7 R! O
static void led_dev_release(struct device *dev)
% A  R  E7 P/ w$ ], M7 G1 X{
- t' j& N0 c# h5 r: D! a/ p};
' ?9 d) Q5 ^8 E6 N# S$ G2 n' v8 d. O3 D: {
static struct platform_device da850_evm_tl_leds_device = {" X: |6 U7 Q# h4 k
        .name                = "leds-gpio",: K+ B$ {, f: J# R/ w$ j
        .id                = 1,
6 w6 D8 F) ?" X1 b        .dev = {9 J( M0 Q8 l# D% ^+ s0 Y
                .platform_data = &da850_evm_tl_leds_pdata,
9 ^& I" [  h# q                .release = led_dev_release,: O- j% R* M7 y* a
        }: z: W( c& O9 c; t9 O
};
; \; X6 I* ^- Z+ y. r/ D9 \1 ^( C$ d6 W
static int __init led_platform_init(void)
& Q. s  h9 v! M0 O{
2 Y0 R8 S7 i# l  |) {( e/ R        int ret;
+ Y8 F0 j5 k3 s& E: r+ [& S! y#if 0
+ L: j' k% ~3 n+ G        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, t, E( N" K7 d5 F; [
        if (ret)
" g7 m+ {4 @6 M- L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, ^/ E/ o( m$ M# V                                "%d\n", ret);$ V# M5 {8 F3 y/ C1 E0 C
#endif
: k3 M' B2 d4 T* p5 W        ret = platform_device_register(&da850_evm_tl_leds_device);
7 h8 c" k5 P0 I0 n' G5 r. C        if (ret)
( ^& t" ?+ }! U+ X  ~                pr_warning("Could not register som GPIO expander LEDS");4 |7 x6 R( _! H' t* q& K& `0 |
        else$ ~- w. I4 A8 J
                printk(KERN_INFO "LED register sucessful!\n");7 I* K0 K! p; \: a/ `+ s, B
  j; g" k! L& a# D- _( d
        return ret;) {+ u* T) H8 t5 H# R7 `3 o
}
" U* h4 H5 l8 W5 A9 Z# w/ V7 K+ A$ c' L/ q
static void __exit led_platform_exit(void)( k9 v5 c9 ^4 w% f- L3 ^
{
/ }4 [, [) H; Q% Q, f8 J9 G. V        platform_device_unregister(&da850_evm_tl_leds_device);7 I. \$ w9 L+ y

# m- n, s! D- J0 o/ S4 F" F        printk(KERN_INFO "LED unregister!\n");5 n- E4 D! a1 C
}9 @5 ?" N2 p' o

0 B& P- C1 q* P9 Z9 ]module_init(led_platform_init);7 ?- v9 R% ]5 i( _; q1 @$ n
module_exit(led_platform_exit);6 @, R  L: |( H) {$ ~! K

" D0 r8 |) I1 ^7 F" |2 FMODULE_DESCRIPTION("Led platform driver");9 x& A1 E  q+ ]
MODULE_AUTHOR("Tronlong");
( O( a$ f& ]* ?  U# m! {MODULE_LICENSE("GPL");5 o: y' y4 ~" j+ V+ V6 X
$ _9 b. V3 i8 d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-28 23:34 , Processed in 0.038263 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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