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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ p" r* `, d* n3 r+ p8 [2 u#include <linux/init.h>. Z. R/ l, ]- g
#include <linux/module.h>
$ X! ^7 V) g6 s* M6 t#include <linux/kernel.h>
- ?! A  B8 x! f: d0 y; U- x( O#include <linux/types.h>$ c! u7 p; S$ H  I$ T' R) j
#include <linux/gpio.h>
- r; M2 y7 q! h" J7 U% z#include <linux/leds.h>) f0 `8 y+ l4 m' `7 @( f- B" O
#include <linux/platform_device.h># @0 A$ w' R1 u# b$ `1 k3 A% L& w9 _, |

5 ?$ D, Y. w" i' g( _% {2 Y. D+ b#include <asm/mach-types.h>
0 ^: f& K7 ~9 F* u! G4 H#include <asm/mach/arch.h># F- q' L( S' S' e6 V
#include <mach/da8xx.h>, D9 Y* U" C' x8 O: e9 m
#include <mach/mux.h>
! A4 P( Y( }% e; _( ~4 I8 [  }1 d; o
6 l' n0 `3 N3 i! K#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), Y8 J3 I* S/ x- c6 q' q( W9 j
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 ~  B) `5 E2 T
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
1 A9 v% v. U$ B. l( m3 N#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 q* E9 ^5 ^2 W  n
2 l: P- `, a& J, X& m. s
/* assign the tl som board LED-GPIOs*/7 X2 k. o: Z4 D9 c& u
static const short da850_evm_tl_user_led_pins[] = {
# q% e6 q: V. J        /* These pins are definition at <mach/mux.h> file *// m, v' r9 ^0 U2 L" i9 T8 F* m
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; |: X- {1 F9 G        -1- r/ i& u$ X# g4 c9 q
};. f( ]4 L/ H! p$ N; l. E% J( p+ H
# W9 j: A4 a6 Y" E2 m! N
static struct gpio_led da850_evm_tl_leds[] = {, I+ p+ D$ j' ?, h
        {
; g7 S7 x5 R! z: Z                .active_low = 0,
2 [* q& j  d' n& i! V  v, y                .gpio = DA850_USER_LED0,
' {; D. u2 p3 `9 ~                .name = "user_led0",3 ?" ^* G/ M7 K7 {, ~
                .default_trigger = "default-on",+ }- S* [: N( _" P+ F0 m
        },
: t" P/ U1 R1 m; r  u  q        {
( V! U& H9 [7 E7 |3 _: D$ ]1 {: D( I                .active_low = 0,3 O8 v2 R7 ?  y. j! j% K: y: x
                .gpio = DA850_USER_LED1,! `0 d+ A# d0 h
                .name = "user_led1",
3 P% g! c+ z! T- C- {                .default_trigger = "default-on",+ p- F( _$ }# Y! \1 |: `
        },
3 z  }$ o4 L; o! _" V" l        {) w3 o7 @" _4 e- P
                .active_low = 0,
2 A* \0 F9 P5 @8 X! S                .gpio = DA850_USER_LED2,& P/ w7 A5 v2 u6 b8 ?6 W8 J+ v1 E
                .name = "user_led2"," `5 \7 @5 A: y( u+ f5 y
                .default_trigger = "default-on",
- _: B8 E* C; Y' E0 c        },6 K! V' K1 v  m" o- w
        {- L8 n5 J3 P* G/ d4 Y
                .active_low = 0,
- Y/ i: F0 o1 `9 D1 I0 P0 u                .gpio = DA850_USER_LED3,; d) \6 z+ \& o9 Q
                .name = "user_led3",
3 }( z7 U1 u# M1 `6 }5 }                .default_trigger = "default-on",
! ]: p1 ?6 G0 Y8 \5 [1 y6 W        },
5 @! X# k2 y3 h& @) X- |};
6 h% Y( a% u1 U/ R6 y% d
0 U5 b' g/ W, z& @9 E  K0 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 ^) _& w2 Y! j6 J7 w" o6 C5 C  l
        .leds = da850_evm_tl_leds,
1 b3 |2 J5 \2 t# E3 w1 b' E5 R        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ V2 }7 h7 l  G/ b' G4 w
};
9 T9 H$ Q5 s' i7 |3 C' \  x0 N
' N( g0 ?0 o* Estatic void led_dev_release(struct device *dev)" s- X2 w' Z* v. f' K0 C" e
{
$ t: `' L$ t: K  Z1 z' }: L( B};0 ^1 ?4 g9 q4 w3 l4 c# k

( g3 k! n1 Z  ~+ Cstatic struct platform_device da850_evm_tl_leds_device = {
- v: [/ F, v7 d) @7 E4 m9 _* W        .name                = "leds-gpio",
* `, H- `) n, k        .id                = 1,4 y; Z  D* O; X1 E0 g) i* n
        .dev = {
9 B9 x) ]" K- w- t4 R7 Z                .platform_data = &da850_evm_tl_leds_pdata,& }, v1 b. M! L1 d" `
                .release = led_dev_release,
/ s" f2 \9 G# x. o1 f# h9 _7 p        }
: S( h# E) x6 e' D) P! O# p# L};) H- T, w- k. T. A
" r% ]! |  ?% N( @
static int __init led_platform_init(void)9 i1 ~0 z; h1 R5 k5 G. H
{0 P* I* o1 t* W: V6 G6 D
        int ret;# ], [) {! @$ s  k$ t3 D7 B
#if 00 Z" m# s6 V# i0 q! }( E
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ t' d$ Q  K3 `& [2 G+ E7 o
        if (ret)
* \( n; O& S4 Y" d                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* c2 J# f) s& ~( W1 _  b! u
                                "%d\n", ret);2 o7 f  |' f$ P  K  r" a) P% c
#endif) ]  V) V: P+ x  f
        ret = platform_device_register(&da850_evm_tl_leds_device);8 e9 T% y5 ^2 o5 s) L6 I
        if (ret)" A( e, x! b. S! N3 G% g
                pr_warning("Could not register som GPIO expander LEDS");
5 f$ A; _( z( O0 W        else- O3 S# G) ?% E9 n" D2 I3 ?" s
                printk(KERN_INFO "LED register sucessful!\n");' ^8 V, w) `+ ^3 p( k

$ q/ E5 p: j2 q$ N( C8 q) Y3 M        return ret;3 I) m7 U. X0 q& ~
}
+ k3 `9 [; n) F) A7 o, E  v2 O) D6 g( w6 M* F% F6 g5 n
static void __exit led_platform_exit(void)
. p: Y! V) x9 {4 \' @& y& }{8 _3 {" g  H- z5 e; x' P9 C
        platform_device_unregister(&da850_evm_tl_leds_device);
: y1 x5 E3 J7 L. W9 c: n+ }3 `4 V0 v. L7 A' N3 O% e( H
        printk(KERN_INFO "LED unregister!\n");
( B) ?% e# N* |% ?; j5 C9 a# T}
8 W: s* v8 w# M3 h8 X% s1 c# K" c
# x' E0 D! s& P4 M! u& O8 A' Vmodule_init(led_platform_init);
1 b. ]) d: M3 O( v7 w+ [module_exit(led_platform_exit);
- N& h3 J7 j0 {2 `
; d4 `+ U' |3 _3 vMODULE_DESCRIPTION("Led platform driver");) Y7 T* L2 R1 `" p. i% b
MODULE_AUTHOR("Tronlong");
$ E; s, P2 @  G8 ]MODULE_LICENSE("GPL");
. ^$ t9 i3 K) q3 e
0 F: N/ A+ o9 v0 @' M$ i8 G
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-30 06:56 , Processed in 0.035546 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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