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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* f& C: w7 Z% {9 ~
#include <linux/init.h>; Z5 v2 I# t9 R3 p
#include <linux/module.h>
9 N  r$ G, \+ w3 k; y" |4 b( h! C- r#include <linux/kernel.h>( x. p5 P( H9 s6 H$ X& ~# v- z  E
#include <linux/types.h>4 o( E+ O( H% T# R! M
#include <linux/gpio.h>
, s6 X0 C! T/ }! I0 L6 o5 L#include <linux/leds.h>6 L' q) G! ]* O  r( q5 k9 P7 E
#include <linux/platform_device.h>
) D3 A" T: a* r$ c+ N4 q2 \: R& m8 m/ _* R: q
#include <asm/mach-types.h>
! V3 `( x6 M1 o' h/ D0 z- l#include <asm/mach/arch.h>
5 B$ f2 t; \% F: w#include <mach/da8xx.h>
, W" ]) \5 ?/ \0 G; w6 s#include <mach/mux.h>
+ X& E2 n# P" N  e( s
8 l& C9 m. z- ~2 \5 t# g#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) O8 v0 U; C" o6 h( U$ s#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& b5 F2 u  l" |+ w; M0 a% w
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)  f. J% l- D0 y' F
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 X2 I+ n4 O+ t+ M4 L: O( l
9 G) z- f. Q5 }4 k9 w5 S% {/ C
/* assign the tl som board LED-GPIOs*/6 r$ v" ]  u$ H* L9 I( ~( _
static const short da850_evm_tl_user_led_pins[] = {
' e) V) x. Z5 @5 _        /* These pins are definition at <mach/mux.h> file */
; z% o: b) C$ x, z. ?* H        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 {. e; m/ z+ z2 f( J$ P' Y
        -1/ U/ c/ Y% V+ t
};
2 s4 l) k# ]2 k5 W* B* W9 n+ L) U7 b( C2 l1 x( A4 X, b8 A0 X
static struct gpio_led da850_evm_tl_leds[] = {/ o# b) \) C5 x& W
        {5 Y9 O* C2 H0 s" t. @
                .active_low = 0,
* U% K0 ?, _9 \" ?" s7 B; w; O                .gpio = DA850_USER_LED0,
! l, F* h8 l2 c* d" q                .name = "user_led0",, {2 G) y& I' Q8 [* N9 a4 q2 T) u
                .default_trigger = "default-on",1 @; G6 n  k, |  U' r; H
        },; H9 p, a/ W  A7 z) k3 }5 U( y5 B
        {5 m9 D* T2 y% Y6 @0 W* }1 F
                .active_low = 0,- [3 i2 W$ F& k2 x+ ]2 s4 A* h
                .gpio = DA850_USER_LED1,; c* I. \4 q' N; m: ^
                .name = "user_led1",
* Y+ H6 W& ?1 q                .default_trigger = "default-on",
8 ]$ @2 F, d( \% s" v- S        },' X' r+ P# P1 C* G$ f3 g
        {9 f8 y) b0 w, I3 E; H' _7 S
                .active_low = 0,
. g9 f  G- u% o' i2 Z3 E% I                .gpio = DA850_USER_LED2,
, g0 }( l+ a1 p                .name = "user_led2",, }$ ~7 \8 B8 `9 G$ m
                .default_trigger = "default-on",
- U5 B( s: U8 U- q9 R! |, V' w9 s        },) x& b' O/ z! O/ |) g9 ?* N
        {, Q. ]  w" k" Z& q+ @7 D
                .active_low = 0,' h6 D: R4 \) s- W2 g" |" s7 K, X
                .gpio = DA850_USER_LED3,# k/ d  E& Z' t) `$ a. s
                .name = "user_led3",
9 N. E1 |( L1 h* B. u( @' b" d' J: n: L                .default_trigger = "default-on",. P' `0 X  X' a! M8 O5 P6 E7 e( n: P
        },
, O6 m* X( D  }};/ |% L* c# ~3 F, A8 f

1 W! ^; ^" x+ P/ @5 X8 M& |5 G& Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) N  n3 W0 h# _2 n0 j- b, S* [& t0 c1 e        .leds = da850_evm_tl_leds,
8 \+ A) g2 V+ L9 ?* {, l        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ m# L# P& ^2 K- p# d};
) w1 q! z" j& B) Y8 X
, L: e& G4 K- K7 Z+ Fstatic void led_dev_release(struct device *dev)
! ?6 P  O* g0 D* J  A' C# O{: V* h% O2 b( A  q( n  k
};6 T& ?/ ?' h, V) P7 q' Q

0 R9 g" f2 d, {6 R* {  I0 Jstatic struct platform_device da850_evm_tl_leds_device = {& H+ Y+ {% l8 t- ]& I9 n
        .name                = "leds-gpio",' |( ]; {6 w' W/ _2 `2 |/ a% A
        .id                = 1,8 j) {$ [9 ^8 f, e- ?
        .dev = {
' I! R8 _- d% ?( B" |                .platform_data = &da850_evm_tl_leds_pdata,
+ m4 V6 Q$ p- V8 \" A                .release = led_dev_release,& I/ T" D% i2 ?1 C2 R, s0 \# Y9 e0 [
        }
* Y' f( \9 g/ m( C};1 X% a1 j) R2 E0 {0 j
' r3 t+ g) }. B! ?% q( C0 A1 w% K
static int __init led_platform_init(void)
9 f* K6 Y0 E  Q3 Q, s7 p{
. R1 i9 l8 }7 S1 l) c. b! l        int ret;
; @6 }& I  Z9 K" p) e3 C#if 0% b% U, ~; e4 ]! I8 f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 X, O/ G# R- `. r* m1 C
        if (ret)
7 k9 I$ X- W+ u) N) [) R1 r! t                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: g; \) |! k- w- g) P2 @# o                                "%d\n", ret);; X# |( l" e( n9 S- }5 e  B
#endif4 u' ?% x$ _6 e) l- A9 T7 c+ W
        ret = platform_device_register(&da850_evm_tl_leds_device);& [9 e4 K) ]5 Z3 R
        if (ret)4 F- n5 u% Y* D& {( \  j1 ]* o
                pr_warning("Could not register som GPIO expander LEDS");; z0 y" S! V% L
        else
$ f* }1 l3 {! Q, V1 l$ v                printk(KERN_INFO "LED register sucessful!\n");
& v2 \3 b2 C9 j8 r, b
1 h  |4 \! o/ c+ t        return ret;
% A% D5 Q+ v" K}
2 m$ e& y, j3 O2 p7 ?+ |
( |; Z0 m$ X  O, x9 V. {static void __exit led_platform_exit(void)2 V( x  @$ p3 v+ I8 L/ n7 Q
{
' y& \8 E) L& ~& @$ p" o! j9 ]        platform_device_unregister(&da850_evm_tl_leds_device);" c7 G2 f( P1 O: _" d: }

6 B+ K1 @( k- ?( P& E5 _4 j# O        printk(KERN_INFO "LED unregister!\n");' D' S& M+ O% n, ?
}% q/ o, z7 I1 i; a8 c* b# {7 m- I
* i! p. v9 E  }
module_init(led_platform_init);
/ a& D! k! @4 n' @) A3 M* _module_exit(led_platform_exit);
  f8 p9 |  }" G* M) ~2 A. S0 b2 C# S1 C5 J9 p  t
MODULE_DESCRIPTION("Led platform driver");, k- V' B% G3 `8 x1 J2 \! u
MODULE_AUTHOR("Tronlong");6 Z% p7 S5 l0 a/ U: R
MODULE_LICENSE("GPL");: R" `) U( M6 Z# e
! ]$ g) }7 i+ c# Y6 x/ e; {# r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-30 11:06 , Processed in 0.041807 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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