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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 s) m8 s8 _0 T/ H- F# h
#include <linux/init.h>
2 N/ U9 }" W6 g* w9 s' _#include <linux/module.h>7 w7 }: ^2 g% q/ B
#include <linux/kernel.h>
8 Y; d) i" Q% a  ~& Z#include <linux/types.h>6 z. H8 l5 J" A  ~& G6 \% {( P3 I
#include <linux/gpio.h>6 A  J( d# t7 n1 ~2 D
#include <linux/leds.h>  [* ]: o2 R$ p: R" j
#include <linux/platform_device.h>
+ H, g# _6 B- G! c, b: L& ?# D! E8 c5 m
#include <asm/mach-types.h>0 ~9 |5 X- u0 a" T
#include <asm/mach/arch.h>7 s, Z( y# u. u" @
#include <mach/da8xx.h>% k( a$ P. B" r! A; O& b* @
#include <mach/mux.h>
7 z3 ]4 t- \4 E( p
: |. `! b  r8 B" {  g#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 i/ x) o& H: P! u#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 q+ ?% ^5 w; Z: g#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ H1 q3 l1 c) V( P- i7 o9 E
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ I9 s. [' o1 O- W

: Y( y1 m' p7 A0 E- r7 o/* assign the tl som board LED-GPIOs*/- A" |2 @# l  v  a& u4 c4 w2 D( Y7 O
static const short da850_evm_tl_user_led_pins[] = {
/ A5 I9 x) ?( a! L* w# S7 _% d+ }! ?        /* These pins are definition at <mach/mux.h> file */
( a( V) Q& x: ^) C/ T        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& p2 |8 ]' S: y: t
        -1
: L+ [9 s1 _0 s+ T; M# {};
. `( r3 V' z) m% |3 `& _3 N9 S/ v' ^" O! y0 ]' s
static struct gpio_led da850_evm_tl_leds[] = {  i$ z6 n# C9 g- U
        {. `" t, i& ?/ j: @3 t
                .active_low = 0,! O* c4 L2 X6 P  |% V; p
                .gpio = DA850_USER_LED0,( ^; ?* Z# i* j( p
                .name = "user_led0",: n; B9 ]9 j# E7 F" G& z9 {
                .default_trigger = "default-on",! R6 e7 h7 ?4 O6 u- c# ^
        },# n2 T. k. v: b  M" {6 n
        {. a* N2 O. R- {* o, e$ V- M7 ^" o
                .active_low = 0,
( e. b! U- O4 g) ?; }7 Z. K- I                .gpio = DA850_USER_LED1,! g7 \& ?" g1 Z! T( W# p
                .name = "user_led1",
7 n; T/ _8 Y& E7 d                .default_trigger = "default-on",
; }/ S$ N9 {" K0 }        },
' n! H# b6 {1 d2 R        {( m9 S2 f  m" f* M2 B- W/ s- I
                .active_low = 0,
  Y4 Y0 j/ r2 Q9 I' U, w, r  _                .gpio = DA850_USER_LED2,7 G3 |& N0 N8 T! x- Z( x# Z; c  J
                .name = "user_led2",
/ D4 w6 y6 l- f8 @2 N: }6 F1 M* ]                .default_trigger = "default-on",
$ G2 r. g/ @+ H0 t. r( ^        },
; z% O: ^; d/ o0 W8 U3 o8 ^        {
; Q+ ~0 }4 K% ~& m                .active_low = 0,
! |2 L6 M; U, j# E                .gpio = DA850_USER_LED3,
2 ~- }- a- D7 f                .name = "user_led3",- \8 G/ J+ Z; E9 l
                .default_trigger = "default-on",/ z' z2 N' g) J1 \
        },2 a! a9 ]1 \- O  ^7 p8 ~
};
7 T6 Y3 D' d: {: |
- ~. a6 s( p3 a+ O* Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ j( q+ o& K. o" A( H$ @
        .leds = da850_evm_tl_leds,2 x; N& i8 f4 U
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& p& a/ m9 Z8 M3 R
};
( w" k9 k( @( }/ P, T, a, @: c1 Y% r! L
static void led_dev_release(struct device *dev)
; k/ ~$ x% i2 t5 a4 `{$ d3 Y9 z' D' ?+ T% `) w7 W
};
( G( r5 Y( _; [  c; J* B' l/ w$ k- v& p' a
static struct platform_device da850_evm_tl_leds_device = {7 G4 P7 M& f5 c' k
        .name                = "leds-gpio",8 ^; ~$ \( y; n; D
        .id                = 1,8 u1 r+ L; S  f1 O
        .dev = {
+ T; l% c) U. U. K1 W% a                .platform_data = &da850_evm_tl_leds_pdata,
0 Z! u- @& C1 W4 g. @5 O" `                .release = led_dev_release,- T9 V0 e1 O0 x! y! L' ]
        }
* P6 S7 T7 ]9 X5 H% i4 Q};
+ |' n7 Z2 `8 T, e' @' m$ x) t5 @6 Y* i2 B: T
static int __init led_platform_init(void)
+ l* E+ u# f: k0 z; E( V{2 ~. `" i/ p9 y; Z! V
        int ret;: }/ a9 @7 ]. y
#if 0, K1 @" Y% l; F" T$ L4 K7 |3 t
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 H- X6 R" l" q* o& B+ |" n2 q        if (ret)
# V5 K2 h9 t/ K5 U" H                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") W$ f0 C- }2 l3 {  M
                                "%d\n", ret);" s/ D3 F( j! ~. \2 w/ P. N, `
#endif
: e" f8 ?) n3 E1 ~0 G        ret = platform_device_register(&da850_evm_tl_leds_device);
, ^9 ]6 t( k2 T  o, w% u! w) }        if (ret)$ v. C# c8 B$ P
                pr_warning("Could not register som GPIO expander LEDS");
* A. |, H' _7 Z4 w, f, P' \% M! q+ C        else
0 m! }( k  A4 L$ e/ C: D                printk(KERN_INFO "LED register sucessful!\n");4 J% l! p8 @2 R. g5 T+ ^5 L
" {# _3 @, n: h7 N& l6 J
        return ret;
1 |" @9 K# P$ H$ P, }# k}
: A; I) O2 S* p; p3 I$ f5 J- ^5 O3 y! s9 M- D1 j
static void __exit led_platform_exit(void)9 |& ~5 i$ H  T2 L
{" ?0 ^) e. O+ S7 v1 {
        platform_device_unregister(&da850_evm_tl_leds_device);8 }0 U& Q9 G4 Z1 X

1 u( D$ \6 [$ L. O4 V6 V! F        printk(KERN_INFO "LED unregister!\n");
: d! U/ l$ m! X- @4 g}
9 ?! m* _. A) S* {9 f+ P7 K. W6 ~4 U6 I; @
module_init(led_platform_init);
' f8 K7 t( J1 ]/ Z( }module_exit(led_platform_exit);; H4 b3 v" f" ?1 R
5 ?; y, M. i6 W0 I
MODULE_DESCRIPTION("Led platform driver");
5 G2 s/ @1 u/ `2 x  G6 D7 y7 E1 TMODULE_AUTHOR("Tronlong");  P. L, r( O- b& g# j; u. J+ O
MODULE_LICENSE("GPL");
' r2 a: u- M  q, ~# O0 T& c) c4 c, w$ K: S& w3 L- b9 O2 z0 |/ R
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-20 03:54 , Processed in 0.039439 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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