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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 i0 Y6 {6 R. W' y& F# I
#include <linux/init.h>
- E) Q6 n. @+ [( D0 w- O#include <linux/module.h>; n( N, H1 D# }: k# D: E" F
#include <linux/kernel.h>3 q/ \( A; y( ]+ `
#include <linux/types.h>. }' ]$ s' ^5 i9 c6 h8 j1 g/ Z
#include <linux/gpio.h>) r4 W4 J3 `( q9 h/ t
#include <linux/leds.h>
0 Y8 Z- j5 w2 z( A* R8 b#include <linux/platform_device.h>
9 _' M" N5 W# @- Y+ r* J+ Y% w
" a/ R8 L; t4 c& B#include <asm/mach-types.h>- Z9 l7 c# a5 P% j+ \
#include <asm/mach/arch.h>& f( V8 ~' F$ F2 c' i3 o6 ~& p
#include <mach/da8xx.h>
" o  b  x. B8 e#include <mach/mux.h>) i! F# V6 I! T$ x  Z
: q$ }+ ?( ]9 M
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 `% J! B& N* E/ i. D( y#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  R6 N. t3 _2 s" a; x- d& Z
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 d% b- D& B! c. i& Y( I
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& ?) @' W4 x! O3 B( J/ F5 \8 v, j$ D( p$ s3 Q) Y; m2 N- o8 i7 E9 m
/* assign the tl som board LED-GPIOs*/
6 p$ @9 ~1 V. t8 q, istatic const short da850_evm_tl_user_led_pins[] = {
, J5 P8 a, g/ r: q$ y' z+ _5 w        /* These pins are definition at <mach/mux.h> file */. `! f& m1 v. y8 I  \
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 Y6 C" _% r( y, X: ^% O        -1
8 l7 e- n- M2 F0 o) ^! X, M, l};
: Z8 q6 m3 J  Y' v! V6 C/ c. C+ C# U) p' ]+ ?# u
static struct gpio_led da850_evm_tl_leds[] = {
9 d6 Y$ k0 |/ A/ t        {
5 G' }9 E5 t. e; t7 H# F                .active_low = 0,
5 R$ @5 ~5 n1 m$ D                .gpio = DA850_USER_LED0,
6 w& _7 M% O  p5 @7 q                .name = "user_led0",2 z( Q9 L5 ]) z9 E" T/ \
                .default_trigger = "default-on",+ u, ^- U* ~5 q9 ?& Q
        },' l( S+ ~$ i% ]9 o
        {( w5 Z/ U9 ]4 w: R4 C% b
                .active_low = 0,; S3 ?% A7 r% y5 U$ a) e
                .gpio = DA850_USER_LED1,
. `+ V4 j% R# n0 O& ?                .name = "user_led1",
2 _; V# ]0 R5 u, @  f6 g" D1 Q2 f                .default_trigger = "default-on",0 E* k# Q6 W8 A+ c2 M' ]8 q
        },3 ~- u$ e4 J% \
        {/ l& E% b" ?" B' T" Z* |
                .active_low = 0,
8 H5 _! Y! g/ Z* Y' P! `                .gpio = DA850_USER_LED2,
: X2 t/ k4 r6 p5 ?) s! J( u                .name = "user_led2",; w7 p& ~, U8 q( r4 q, x
                .default_trigger = "default-on",8 B5 C& K5 V1 Z. A
        },
0 g8 R- P0 l1 S$ U+ |9 s        {( }$ q# P! p. \, a& _
                .active_low = 0,0 s; g) i- c. d' D9 r
                .gpio = DA850_USER_LED3,
' m9 _' u+ S$ |" P. I% _5 ]+ x/ Z$ U                .name = "user_led3",
: b. V$ F- M6 M9 x' Q* T$ c$ q                .default_trigger = "default-on",
5 O' f& c* l, ?  o5 ?! Z        },
( E& v0 y5 l( G: o9 C};
+ j/ l7 s$ W. i+ D+ D5 [6 Z  e" G; S! }" E7 q: h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: H% C' I# @& O$ t7 f. y
        .leds = da850_evm_tl_leds,0 R8 b+ Q% {; ?0 C5 a+ f: C- ~# O0 [
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& j8 L$ C! u* i( t; ], E
};
+ H5 b5 Z/ H6 u% B0 b& W2 l3 t; D9 i3 y# x
static void led_dev_release(struct device *dev)) _7 {* ]) l' C- I& o) X1 |- m
{
( P9 U) Q/ @+ w" j2 B' C2 H};. P7 Q. T2 ~- {, d
# k6 @3 b. o9 @1 r
static struct platform_device da850_evm_tl_leds_device = {; q6 G& F0 l; R' m1 U( }; l' U
        .name                = "leds-gpio",
1 _% e' j3 E! ]2 _        .id                = 1,7 W" o1 s& K. a% p$ ?- H0 A* @
        .dev = {! }0 S5 B! ]8 K' @# E
                .platform_data = &da850_evm_tl_leds_pdata,
' Q7 s* a9 t: x3 {  |1 K! ^                .release = led_dev_release,
3 o. O, J2 L- V        }
$ H: S- V$ p2 ?* E: `};" \  Z7 \# q& t- J% d# V+ v
9 C& ^9 Z0 Y" |% z6 b  P" r
static int __init led_platform_init(void)
$ f2 d6 O6 w2 F! h3 u; i% W{
) |: l  S, X7 L: L! I        int ret;
/ e! H8 t( |: l0 p4 b- P#if 00 e- w2 d6 z8 a* V' H3 J. R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 }6 e9 w# j$ X% L/ B# S        if (ret)- V5 G$ n2 `& `0 a3 Z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ i2 z, V0 \7 e  h7 z                                "%d\n", ret);
7 j% v, v+ @# a2 f#endif# `/ e4 k5 a( s. y2 C
        ret = platform_device_register(&da850_evm_tl_leds_device);
; H9 U1 w) H1 D; C  P- X4 y; J7 p        if (ret)
7 t% o) r/ t8 e* [# Z7 }                pr_warning("Could not register som GPIO expander LEDS");% [( c- o3 q7 f( o* A
        else
8 I+ x3 p& x1 |9 F                printk(KERN_INFO "LED register sucessful!\n");( A5 P+ f; T! d& t* Z2 [7 n
) }) E5 g) h9 [- H
        return ret;
8 N% X* F* k: f+ S/ F" O. I}- v; T9 |2 s. y
6 K9 K! _8 S  L! K- q0 f; G" \( W
static void __exit led_platform_exit(void)
* P( m3 v$ G" D! z7 F( S$ s{, X4 {8 r& Z2 y0 V
        platform_device_unregister(&da850_evm_tl_leds_device);
' ^7 D* E; F4 o" y2 C9 s; f
8 H. o) E4 X8 H, h        printk(KERN_INFO "LED unregister!\n");
5 p" i+ W7 i6 K5 L& o, S5 i}: U  C4 \3 w: C0 e' ?: Z: C

6 z( Z+ F$ b* |  wmodule_init(led_platform_init);' o( _8 R+ Q8 y. C  p
module_exit(led_platform_exit);+ V3 t7 |- [! y! a

: t5 U% d9 {2 ^5 N7 _% h' J+ |MODULE_DESCRIPTION("Led platform driver");
% t5 i* u8 e5 W7 T$ N4 I* s3 ~- KMODULE_AUTHOR("Tronlong");
7 d9 ]+ z1 B( [MODULE_LICENSE("GPL");6 w: x! Y+ y, g8 B! g& _& W

- e- R( r1 U$ ~6 o8 o2 B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-6 16:50 , Processed in 0.039265 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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