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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; z  s$ V0 i$ W2 ^( z( G
#include <linux/init.h>
7 t, y- P9 _) a; q#include <linux/module.h>
; R; q: j( A; r$ w6 u#include <linux/kernel.h>, u' f# \5 t! D. e  ]6 F
#include <linux/types.h>$ B9 p7 j) k6 w- f, h; U  r
#include <linux/gpio.h>
4 y+ t4 u( A8 V! ?4 Z#include <linux/leds.h>; n" h. Y$ _4 o/ E; x# q
#include <linux/platform_device.h>5 M) X! a- d! M. P4 u; T0 n' ?. t

" ]: Y+ [1 t8 P# ?- Z8 _+ B#include <asm/mach-types.h>" _$ a. i/ T: c0 n% u8 B
#include <asm/mach/arch.h>
9 J% b- {0 f8 l2 m#include <mach/da8xx.h>
) L( f6 p' I  l& w#include <mach/mux.h>2 P2 L+ n  \* ~- a1 v: s

/ X6 K: z. d/ s3 H6 M#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)& O+ ?% m2 n7 F' O& J
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, ^# K3 o7 y  m- x#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)# ~  h2 w) ]: {5 I/ m
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 |3 c4 ^* Y1 l0 X- a  E
! D8 W0 g/ Y) B$ y* x9 s; x0 J4 D
/* assign the tl som board LED-GPIOs*/
2 `) S! I9 z6 T# k$ N! ~) }static const short da850_evm_tl_user_led_pins[] = {- k1 u' F" Z. C8 x2 D- }
        /* These pins are definition at <mach/mux.h> file */3 \! A% ]# D2 M% q
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# e! v* \& O  w6 J# n6 I8 V. ?        -1* ]0 `) d% S( O3 s
};
& X" m" c  V# e- {9 G* H' L
- M6 @; q; L3 }static struct gpio_led da850_evm_tl_leds[] = {. a. l" b0 d, }" Y) ~; |
        {1 G  f. z8 u' F( n# M" j
                .active_low = 0,
6 S4 J& u' x& L3 U$ c" A7 m4 T1 w                .gpio = DA850_USER_LED0,
( x& O% q8 }& ?  ]# u                .name = "user_led0",0 k& p# D2 i* C5 b$ ^2 U+ [
                .default_trigger = "default-on",4 a! j1 S8 z$ s: k. C' R' q9 r
        },
( s5 q' t4 V! `; p        {
# d/ ~6 r- q  n' Y                .active_low = 0,
4 y; i6 t1 H. g                .gpio = DA850_USER_LED1,
- T9 E# Y) b7 P6 w% T                .name = "user_led1",( `8 U7 p# b2 o! V* `$ C4 ^7 G
                .default_trigger = "default-on",
. x% @" \$ S" p& m  [! U        },
: w& W. _$ i  z        {
$ @+ t4 K% Q* H( ]- @% C7 d( U6 F                .active_low = 0,
0 m4 ~) z" N2 k) G$ v                .gpio = DA850_USER_LED2,
% K6 E, g, a/ O: G* W* O$ c) B, B                .name = "user_led2",
  ?1 s5 {2 U( Z+ b& T. ?                .default_trigger = "default-on",' d8 f" P2 \1 I1 J+ p" v
        },
8 s3 z( i6 u* `1 `# c" f7 b$ ~        {* Z) y, ]5 u0 W+ i, u* K: z
                .active_low = 0,
" ~7 Y- X& }% V) G7 h8 W; o  v                .gpio = DA850_USER_LED3,8 Q0 \  ?: }  y6 }3 H- y  U  _" x* s
                .name = "user_led3",# @) d1 E6 m- f" Y. h4 L
                .default_trigger = "default-on",
  J/ ~5 e  O0 f% @: u        },9 Z0 \3 d& }& J0 O( k
};4 R! i7 r* }" u2 Y4 |' g

8 O! \& z" o+ t2 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" s, x  w& J$ G9 v$ T1 o- h        .leds = da850_evm_tl_leds,
% R! V/ V+ ~8 `- `" O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! z' ^& r4 [5 \$ U1 C};5 R. W9 u* e: m# I2 Q( h: b
: E) w- g% v' o: f, C
static void led_dev_release(struct device *dev)
7 h' d+ V4 b/ V# E% ?% g/ H{
( Y7 N5 u6 @6 h3 B4 I};
! [/ C, Y2 |& l" v3 L5 H0 f( w
$ L( V: @/ [4 Y# K2 Y- c* Gstatic struct platform_device da850_evm_tl_leds_device = {& V$ j" t! D" p* [/ D1 v5 r
        .name                = "leds-gpio",6 S9 q: m! ~: @
        .id                = 1,
8 @9 j) N8 }3 \- q        .dev = {! F" V; I# l5 H
                .platform_data = &da850_evm_tl_leds_pdata,0 R& g  ^6 r5 h
                .release = led_dev_release,
) S8 n( G# Q0 ^- @/ H# j7 g        }
' f3 r$ V6 g5 p, k2 x7 n$ o. N2 ~7 g};/ f0 Q$ O. Q4 b$ J) {& u3 y5 c. F

9 T1 O- S' ?9 C$ F+ ystatic int __init led_platform_init(void)/ i, U3 A' Q$ {& G. L, f6 J6 t
{, m6 d6 I' U$ e% W$ z' O
        int ret;! _8 N! ]- ]! b: F% t/ T
#if 0
9 P: J# w1 t; g% C        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* B; `  b% \4 K5 `  p        if (ret)
( H- V6 G3 M0 D) g                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
  L( S, U  X" c$ t; |                                "%d\n", ret);
, F, b$ Y, K% `#endif' c, s4 R0 ]1 N2 K: j) G" f& d
        ret = platform_device_register(&da850_evm_tl_leds_device);0 k9 H4 S$ H6 b* f
        if (ret)
5 U+ s) i$ Z. B9 G8 t6 m( g                pr_warning("Could not register som GPIO expander LEDS");+ r# ~9 z& e+ J% S$ t
        else
  \7 p- k/ s2 j; r1 V                printk(KERN_INFO "LED register sucessful!\n");
$ _2 o# L1 Y  I' U9 x7 G1 C
1 _  Z) k! L2 g  U        return ret;
1 q+ c4 t7 [+ S}
( h" m+ E: h( |
- c9 {4 W! ~5 Q' M( m3 Cstatic void __exit led_platform_exit(void)
+ ^. ^$ ]% t  a$ D{
  L+ e. X- W5 V+ _- ?9 l2 b        platform_device_unregister(&da850_evm_tl_leds_device);+ o8 R  F; L" {/ K$ h1 N, M

% e& [( v. d- g/ Y3 b* h& c        printk(KERN_INFO "LED unregister!\n");
  K) h/ l* P9 V}5 _# W8 c6 o& k) ?$ C  d

! s* Y. Z1 q4 D7 r) Gmodule_init(led_platform_init);9 k! [& P: i' T6 r; H- s9 M* W9 U+ d! }
module_exit(led_platform_exit);
$ V( Q9 j1 R4 @& \8 S9 I5 C$ v
1 w. p) x3 S; d+ M6 TMODULE_DESCRIPTION("Led platform driver");1 [1 i1 Y# @8 _; |3 d/ d( M
MODULE_AUTHOR("Tronlong");7 ~' O( k8 s# C
MODULE_LICENSE("GPL");
. a: \/ n4 u5 y3 }5 [$ v& R
0 V  z4 ^" F: s  s. V) i$ X+ I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-21 22:05 , Processed in 0.038872 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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