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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 u( W! O( v- Z+ c" f; @
#include <linux/init.h>$ l7 ]+ _- P* H/ V2 v1 c0 V$ Q
#include <linux/module.h>
9 e, E, J5 `0 V#include <linux/kernel.h>
! l- h) c& T8 m+ m1 g) I#include <linux/types.h>9 `+ l  m8 N5 o
#include <linux/gpio.h>
0 n2 u, E& Z9 G" h" c#include <linux/leds.h>
4 g2 q$ @2 w/ W6 w! C4 p#include <linux/platform_device.h>
4 }5 I* x9 ?0 V' I' ]4 k5 j# s  M# M6 `/ D
#include <asm/mach-types.h>
0 j$ S8 c' i- ^4 C( x#include <asm/mach/arch.h>3 t. j+ q5 [3 l% O
#include <mach/da8xx.h>) U+ }; r9 V/ H6 a/ K
#include <mach/mux.h>/ [% I( @1 p* d$ k- V/ d8 R( {

0 h. Z+ A. W6 Y" u( G3 h2 d* O' z% x#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; n: j4 g  b, N  K1 U9 H& L#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% K5 s  o; p2 @1 i: @/ Q, ^
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)  g; C: {/ k) }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 u5 a9 x- N" S! V( B$ P; [9 q' S/ Q! c9 i
/* assign the tl som board LED-GPIOs*/  l% W$ S# }* R
static const short da850_evm_tl_user_led_pins[] = {- ]1 C1 d( j# w, c$ I5 L
        /* These pins are definition at <mach/mux.h> file */- a+ J" l3 H0 e5 f
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  c# W# S" ]1 L: L        -1
) @5 R& I* u2 J& l};6 ^+ b; e" ^- E- V" ?8 R' I

, W' w, z# b7 ~5 T3 {# n; pstatic struct gpio_led da850_evm_tl_leds[] = {
# z9 y) N) U6 Q* z" @4 I        {3 h1 i2 L3 y' s0 R0 z7 C/ b& `
                .active_low = 0,
: J! b( W. q2 Y/ S' Z, ]/ ?5 U                .gpio = DA850_USER_LED0,0 P( [, p, }  F6 W6 s5 a6 X: G
                .name = "user_led0",
+ a$ C# i! B; n( d' U# y6 Z" ?- I                .default_trigger = "default-on"," T, o) D8 W6 W- n7 u
        },9 O. G5 x# v1 |/ d1 D- ~
        {2 y2 k. H( E' S, g( m
                .active_low = 0,
" ^! t, S1 q3 F6 C+ k9 n' R9 W                .gpio = DA850_USER_LED1,
. K0 M  i- M: i2 O' N8 _: g- J                .name = "user_led1",
- l( J3 }" K* M                .default_trigger = "default-on",
/ T8 M( w# N" g2 M7 s        },9 }! `5 e8 A( q! ^/ G
        {# ?1 |* O7 M  k: R
                .active_low = 0,
* |( D& v3 }! d" L* \5 K/ j* q                .gpio = DA850_USER_LED2,3 f3 s) U% s3 F
                .name = "user_led2",- @: O1 {8 t! |5 Z$ B/ R
                .default_trigger = "default-on",+ J& U' a1 w; _8 H; D6 G9 Z
        },, O% i2 N4 M2 {
        {' ]. w. \" v$ y
                .active_low = 0,
8 `  y7 e% i6 u. d* u1 w                .gpio = DA850_USER_LED3,/ F* m! K+ r( J$ H) H6 w
                .name = "user_led3",
+ ~# q6 I/ x, h, F% M                .default_trigger = "default-on",
. J& l9 y2 M6 t+ {+ d        },% s8 _' E7 I4 }7 Q& i2 X
};; Z- ^4 k- }( f3 }' C. H
' j4 m2 x" H8 r' Z8 ]% d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! t5 e* N8 l. d; U$ e* S        .leds = da850_evm_tl_leds,
* @' ?' d# o+ y% b        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ Y" ^4 ?* d2 }7 a9 s/ w};4 |# j, a. v6 H
. y& F3 e" d2 i. w
static void led_dev_release(struct device *dev)" V5 U6 o: g8 r1 n& m; f& Z7 Z6 Z
{9 h# y- ~7 t, E% c! [8 B
};
7 @, q. E  A8 ~7 _0 s: }# q; ]8 M7 |: |; g2 W
static struct platform_device da850_evm_tl_leds_device = {, w6 q' H! H$ v5 \8 Z. b2 w
        .name                = "leds-gpio",. T  z, g; x- \0 ^, p$ t# L
        .id                = 1,# A; T3 U+ x. M- a: b4 c% n% F
        .dev = {6 ^0 q  X; p* a0 P3 h. g
                .platform_data = &da850_evm_tl_leds_pdata,
' W; ?0 n3 K  ^, }                .release = led_dev_release,2 R) @. S7 P5 v; k5 w3 A8 J2 B9 z  |
        }
: @6 U+ Y0 [" u4 m};
" E0 Q$ D# E" \0 I( K/ |6 d; ]' N, u
static int __init led_platform_init(void)
9 `( E* ~0 q7 }# }1 D+ }( f{
5 c. y; c( ?: U: x! [3 n2 C) I. I$ z        int ret;
1 o7 c. x) e2 ?; ]/ p9 n! [#if 0
1 c( F7 R5 R/ l) M) ]; c: Z$ `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  p4 N! Y7 m" T# \. I9 ~# y
        if (ret)
9 e8 h1 z2 l% O9 j4 Z/ c                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! B2 P* h7 m5 d( b5 v# d/ \( e                                "%d\n", ret);
' E- L" @9 s" F#endif! }. E: Y0 s' f! ]- d
        ret = platform_device_register(&da850_evm_tl_leds_device);
# T3 w8 O4 ~. l3 ^2 A4 G+ a. j) s        if (ret)4 r9 Y' ]* z2 h, |3 i
                pr_warning("Could not register som GPIO expander LEDS");; H; Y, W/ W* v1 ~3 m" J) O; `
        else$ f+ ]$ ^! k; U
                printk(KERN_INFO "LED register sucessful!\n");. j, v4 w  a2 N( p* E, u3 ~  d
2 z- W- I- |9 T2 y
        return ret;
9 B" u" _( x& c3 m; |/ F9 Y}
9 ~# @+ y) n5 d3 o% M8 h2 m, h7 l3 N; y; f
static void __exit led_platform_exit(void)3 c7 s3 }7 v# N) v
{7 a5 d1 H2 f4 P' F+ ^- D7 b9 R. i0 y
        platform_device_unregister(&da850_evm_tl_leds_device);
+ h- B& ?3 @& N& N' \' g' x" Z5 O' I  o- i
        printk(KERN_INFO "LED unregister!\n");
; O6 Y* l9 _& V0 W}
8 |% R. V+ N& d3 q9 a
5 ~& a9 }1 e" Y" P) E% }module_init(led_platform_init);
3 r+ \/ D/ }5 y( mmodule_exit(led_platform_exit);
8 k/ @; X, |* J! j* {( z( [6 }2 }
MODULE_DESCRIPTION("Led platform driver");) H1 w. G( ?0 ^
MODULE_AUTHOR("Tronlong");
4 t1 g( f' i3 l. L) n3 f" dMODULE_LICENSE("GPL");
* L- q; K6 W2 T7 |  ^$ s+ L5 H0 V$ S# `+ q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-25 01:46 , Processed in 0.035853 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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