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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
+ u/ D' W& n9 a5 o7 b. f# L#include <linux/init.h>
' _1 z1 `% |5 A3 {# Y* R, r0 ]#include <linux/module.h>+ u% t( V  Q% r; |# |% i
#include <linux/kernel.h>
: Y3 G3 a" N: p+ @  s1 o6 }#include <linux/types.h>/ |% q% d) I0 U( c) m" A" S# z
#include <linux/gpio.h>
, a8 L0 r5 W# o4 E#include <linux/leds.h>, F5 B# s8 Q& {% _) Y4 t
#include <linux/platform_device.h>- |9 H& `" j" i+ }8 ^8 p
6 _5 E  I' ~" `+ x- q& v
#include <asm/mach-types.h>
% h  U8 Q; p+ P( }1 V/ _' }6 w#include <asm/mach/arch.h>: p% T, i) ~4 E3 s" r; B
#include <mach/da8xx.h>  M+ |6 ^  R& S3 u( `9 M
#include <mach/mux.h>
. N+ `. ^" ?7 P$ E# i
# h1 _( R# E4 h+ u- |1 o4 r# ?#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  Z; o  R+ s! i6 c#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 ]8 n* h9 _7 f8 k1 |" F: B) }9 R
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) I' p$ E1 S# L5 Q, O4 }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" |. M5 J, g7 J
* p; F% V* ]) ?+ z+ y' j0 n. Z/* assign the tl som board LED-GPIOs*/
! s' N  y/ k6 V$ I' _static const short da850_evm_tl_user_led_pins[] = {
6 X8 a: W3 z' h        /* These pins are definition at <mach/mux.h> file */' n" v7 P+ Y  f8 _; H- C1 p
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 Z$ V2 ^0 C# O0 c6 `$ b; u- q/ `        -1
9 C+ X# p, t4 ^6 c9 c! W" C+ D4 |};2 m, `& ^, i9 t: i$ {! t  \4 O) A
- x. X2 v+ D4 L, M% K0 h6 w! t
static struct gpio_led da850_evm_tl_leds[] = {3 M. N- D- m9 |3 l7 @- U
        {) `9 l  o$ g8 v7 A0 J) Z
                .active_low = 0,5 ]1 W* C0 E0 o  H8 X) A
                .gpio = DA850_USER_LED0,6 ?: w# d% S- e" i. ^
                .name = "user_led0",, P( Q# Y8 Y! R! {( L% B
                .default_trigger = "default-on",$ x) N1 h" Q- s; ~
        },& Y/ V! _1 a1 I5 E" O9 M+ s$ {3 ^
        {
& M. {+ {& s$ v" N( Q3 `' q& K                .active_low = 0,! K+ K+ d8 O1 D7 X' u% ]% i. ?4 l
                .gpio = DA850_USER_LED1,
$ j9 A# J/ r3 _* W                .name = "user_led1",
% t6 H1 N% D. k- w& n" ]8 D; r                .default_trigger = "default-on",2 ~- g3 ^/ p/ r
        },
3 r- k! K/ X2 T. r        {
: R, Z2 @9 Z* v2 v: I( x% p4 t* d                .active_low = 0,. h5 w1 g! E1 f( e
                .gpio = DA850_USER_LED2,
# ~# I: R$ |  I! a# y                .name = "user_led2",* a7 O& Q1 w6 \0 R; G
                .default_trigger = "default-on",7 ~+ c& S4 w8 ~' Q
        },4 u3 t  ~6 ~/ x0 B  u
        {. w& W% s1 ~. ?$ {
                .active_low = 0,( i6 r( h; J4 |$ C' H
                .gpio = DA850_USER_LED3,* J8 N4 g) @- Q$ N) K3 u8 Q5 |! C
                .name = "user_led3",8 \& o* [9 O. b: T
                .default_trigger = "default-on",
4 w6 D* H5 b! D2 {% O5 d        },4 K) l# |% D1 p: \
};
& m  z2 \; D2 C- U+ n; |. d) [
! P! A, c. a; N* z: o6 `, n0 gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ i4 d* d$ t% S2 W7 M: E
        .leds = da850_evm_tl_leds,1 z* d- m% [+ b0 ^
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 P2 }& z4 |, r" I2 |& H, ^' F/ A8 a4 v};' g  F$ d) Q3 }# i% p, Y2 F6 F; C
9 J7 ]2 O8 J( ?% y
static void led_dev_release(struct device *dev)
5 `1 ]0 |$ _5 A! a/ ~{5 n1 |% U( z! \7 c1 E
};
0 G4 c1 S% E" X& R) @# ?* D
. j, y6 u6 P9 z# b3 Estatic struct platform_device da850_evm_tl_leds_device = {
5 L% Y! I3 B7 K7 R        .name                = "leds-gpio",
* O2 Q, G( w* w5 p        .id                = 1,4 h5 ]6 f4 s" B2 p0 E
        .dev = {$ x$ `% H" I$ W, C* l% R7 T
                .platform_data = &da850_evm_tl_leds_pdata,9 i& M3 a! Y! m( d3 e8 \
                .release = led_dev_release,; u3 Z9 ~! h8 q3 l2 b
        }
5 i& v3 w* H  p9 L- j) P0 i. P};
/ D: Q( |; d9 ]3 |7 v, k$ K1 E& \" W; j- M" c
static int __init led_platform_init(void)
: {  g& y! `4 J, B1 y# E& K{
) S& ~( z# w7 d1 u$ {3 K        int ret;5 N# A" P) J  T, x. u2 q" m$ _
#if 0; Z& b& U5 f3 Y4 p
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ g1 Q1 s2 S9 J        if (ret)
) U$ L+ q9 H2 X4 F* s2 S! z* K3 ^                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 w1 o7 D1 a; }' b' }- k
                                "%d\n", ret);( u! Y' U+ S. a& x4 K) T2 w- y
#endif! G8 a+ g; |# I" r
        ret = platform_device_register(&da850_evm_tl_leds_device);( x. }  U" ^& f# i' B
        if (ret)
- \) \$ Z4 A; L, s0 [! j" s* \                pr_warning("Could not register som GPIO expander LEDS");; m) U5 w' Z- x
        else
/ {# _6 j" K3 `" O$ H                printk(KERN_INFO "LED register sucessful!\n");: b$ ?0 ]+ G* Y3 W

2 o) Z/ a, e: T        return ret;# n  f# K) f+ m# Q  Q# m6 b% s% t
}# {) Q6 c8 K8 @5 i: W

3 H+ u# e+ f* d& K. Lstatic void __exit led_platform_exit(void)4 v' Q$ {) \, E' H2 r# L" M1 t
{, i" t6 j( @4 J5 J5 W. |8 n% B$ L
        platform_device_unregister(&da850_evm_tl_leds_device);
. k- a; ?6 y! c. p; U
) [! d7 G7 o" m# B, p        printk(KERN_INFO "LED unregister!\n");
/ T: }0 s1 O3 u% ^}6 ^( ~% L. }. r& E1 V1 h

4 V/ t) _1 l/ T5 x" ~# F7 `: dmodule_init(led_platform_init);/ b% |( l% Z8 |; |
module_exit(led_platform_exit);
4 L7 q! o& x& N% U0 C$ n- V) _3 X/ T; G7 F, a0 v
MODULE_DESCRIPTION("Led platform driver");
% C" y! @6 f+ O1 ]; GMODULE_AUTHOR("Tronlong");9 y2 y4 C" `5 p+ q5 N2 s
MODULE_LICENSE("GPL");
# f6 L0 K/ t2 ~) K& k7 F$ ]  z) F
- ~9 d% i5 U3 ^! g6 |2 c! k! p
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-16 01:38 , Processed in 0.044400 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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