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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( c8 }8 T! b  o! I8 Q
#include <linux/init.h>8 W+ n  h  n! D, B
#include <linux/module.h>  I: e1 u9 ~: c/ H  n) y5 Q$ Q& t- r
#include <linux/kernel.h>
9 J1 D: E( G( z( m( U( ^#include <linux/types.h>
$ n; X, o. e; m# ~( }# `% ]#include <linux/gpio.h>
. G5 N% F- k0 ~8 c6 c#include <linux/leds.h>
9 o7 \9 h2 v% S9 L- r; Q% a; U2 t#include <linux/platform_device.h>( m6 o4 f0 Z9 Q! p% c

: h* e9 j- x' [' e7 J2 R' I3 T#include <asm/mach-types.h>7 A1 H4 V- @: Z3 d
#include <asm/mach/arch.h>3 W" v# d. Y* p% ~: s' T# M
#include <mach/da8xx.h>
+ ~3 o# T2 o, T1 k0 b& N0 z5 X#include <mach/mux.h>5 p; c7 o$ J5 R5 ^
. \0 ~# \* P8 V) o" a- p+ Y! `
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 V0 \0 @3 e1 b# j1 H" a& {#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 W, k, ?7 B* _7 D8 C( M#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# D# j3 X0 z# ]" S6 l  q  N#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
: z' u+ _6 A1 N2 I9 h! u! i! h1 B+ U% l. R! Y  U+ E
/* assign the tl som board LED-GPIOs*/5 O( @3 x# n# n( f
static const short da850_evm_tl_user_led_pins[] = {% Y/ R9 r' d/ a5 x
        /* These pins are definition at <mach/mux.h> file */
! Q4 n* V) [5 f- J        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! B7 l7 m1 o6 Y  D        -1- X& O, M* A. q) C* p, |% D
};
6 q0 S" Y) R( L% q% e, G# G% g( A$ C& q" _" q' p* @, c  Z
static struct gpio_led da850_evm_tl_leds[] = {' b- f% f! `) z! e' M
        {% K6 v) g. i( e( Q7 `: f- Z/ c) h
                .active_low = 0,
4 q* h  P, P4 Z: X- h$ s                .gpio = DA850_USER_LED0,* l& Z- F. i$ n! t" a+ g
                .name = "user_led0",$ z. I( H' b; D, ^$ G) m
                .default_trigger = "default-on",& T% `& x3 a. o5 R8 N+ b$ g# u$ z
        },
) }' l% Q) F6 E        {
1 g" x9 a9 H1 T0 k/ z                .active_low = 0,& Z+ O  q7 m- D$ [  E8 n$ W2 V
                .gpio = DA850_USER_LED1,: i/ |# k# Y. G( C4 K9 @
                .name = "user_led1",* Y" x; c1 d  u/ F7 M$ G) M* r
                .default_trigger = "default-on",
4 H8 q3 P9 T/ E  S        },& g" r3 b$ y& U
        {1 s/ \- S/ F! h4 w
                .active_low = 0,
" L, q0 a4 y& f7 X! c                .gpio = DA850_USER_LED2,% G+ i; ~* p# p9 n7 o
                .name = "user_led2",# w0 @$ @' _/ S
                .default_trigger = "default-on",/ M+ A/ w3 y1 N* W. J2 Y' S
        },% J( |/ h, J3 \3 `" b# c
        {
( a  N# i7 B# ]+ F+ s; M- d                .active_low = 0,
# j3 p2 u+ ]* N& H9 S                .gpio = DA850_USER_LED3,5 C( \3 t2 Y0 m9 s2 \$ W
                .name = "user_led3",
' e1 T: L; ]- P. q* s                .default_trigger = "default-on",
) h7 U1 I4 y* v* B        },: |8 P  r+ B/ Y/ b3 |) D; u6 u3 L
};
; A+ C/ }! _- C, u8 [3 h: P+ c0 P, t8 ~9 R4 o( Y- c# `5 Y# A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' c" ^+ ^# V0 O3 H0 ]: \8 O/ `        .leds = da850_evm_tl_leds,  L4 u& Y2 _0 e+ [, K: d! c
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 {) J' c; Q( ^% E};  L0 d, u0 W3 @: G' D
: Z; g1 Q/ U+ v
static void led_dev_release(struct device *dev)
* K: F1 E3 j. m4 Y{9 g8 I4 W5 T2 W, V: B$ a5 L0 `
};1 L4 r. Y' V8 f4 u
+ o% o% D; y) Y* w4 p
static struct platform_device da850_evm_tl_leds_device = {
7 O" ~& H2 N6 F4 ?2 t& ]; w6 a# ~- S  `        .name                = "leds-gpio",
! F# m% W: ]2 g$ ~7 i        .id                = 1,3 x! r/ r! |7 d6 W
        .dev = {
; I7 N2 G9 |8 m& U$ B1 W. A. n                .platform_data = &da850_evm_tl_leds_pdata,. R# a) E! {! C* R5 X. k% `. |
                .release = led_dev_release,4 K/ q. T# U! W- A, `+ S" U
        }
: |- ^  N2 R9 o0 f9 b* S8 ]};
0 J$ x4 o0 `% F& U9 W! ?( s) `
: R' p3 B# A! J/ Q! i  q% Z& v' ustatic int __init led_platform_init(void)
$ G; a1 C8 w. {1 R! e2 I, P/ y1 [{
* j, c* g& D" H" F; j. J  s        int ret;0 E: V$ u0 J2 h: A3 t+ r# Y( w6 E# H
#if 08 Q0 W' b, n) x1 ^
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, H# a: w  w+ z# l, V' w0 y% `5 u        if (ret)6 d; q6 H7 J- i4 S2 r
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ D# t* r5 h" j9 ]) I
                                "%d\n", ret);
9 W+ ^* M/ }3 D; \0 L* [; n#endif) G! L+ h* r, c8 J# t0 S% m8 B
        ret = platform_device_register(&da850_evm_tl_leds_device);
4 p% W/ m: v- c2 t- }- ]. v        if (ret)
) x% ]. a* a! |1 _' C8 ~                pr_warning("Could not register som GPIO expander LEDS");
% J8 h) ^& C" C3 V        else
4 ?2 F+ g2 M0 h! S8 z                printk(KERN_INFO "LED register sucessful!\n");' x( R) c" q  m9 a; t+ z4 e* c) N
$ N1 e- }6 b' U4 P0 R( o5 _
        return ret;
& r) L) H8 n9 K  E8 Q1 t$ ^}3 G. K  q: l- m9 d
' l% J4 N5 `! h; l( L
static void __exit led_platform_exit(void)( K+ f/ T* `6 S' G
{
6 t& R: b, B# h6 V& z2 h* H        platform_device_unregister(&da850_evm_tl_leds_device);0 z. I/ }6 P6 p$ k$ ~

, Z& p; w) I4 W8 f6 }        printk(KERN_INFO "LED unregister!\n");6 _, K' \( U1 V: B4 E& B) \8 p2 V! A
}- t7 x4 y2 G: E% b" Q; X

. z- k4 a& h" h4 a( y4 N- U$ `& vmodule_init(led_platform_init);* |- Z) y, a: I6 J* q9 j
module_exit(led_platform_exit);6 C, W- C" G# t  e( `8 j5 h4 ?$ e' }
5 B6 w( i, d' @, M: E$ Y% O
MODULE_DESCRIPTION("Led platform driver");9 ?, \, w+ A% E; S( p7 N
MODULE_AUTHOR("Tronlong");& ^8 J9 }4 O4 I5 \; P/ r
MODULE_LICENSE("GPL");; M/ j0 N. b) N* B8 S3 v

' Q; x1 }$ z) g& }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-3 12:21 , Processed in 0.037880 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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