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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
; y; J4 _% W  s5 a#include <linux/init.h>& n) l4 L6 @" ~6 a* K% u
#include <linux/module.h>5 {, J# c5 R! m( G( [3 s( ~
#include <linux/kernel.h>: m$ Q. o. x" e
#include <linux/types.h>. ~  j. K1 Z! ?/ K9 y% N% G& j
#include <linux/gpio.h>, i+ |, @# v3 G9 `( K
#include <linux/leds.h># E1 o/ |& T% k0 N, K5 ?- V
#include <linux/platform_device.h>7 m% c3 A- l/ A. k* y' h+ b# W$ C4 H
4 E+ e; b& E, D3 ^
#include <asm/mach-types.h>
( {# g# k6 {4 a4 F( `4 h#include <asm/mach/arch.h>
  F5 _- o7 g- W: p( h#include <mach/da8xx.h>5 K: L) ^$ y, V2 ~- L5 R8 F* X' A
#include <mach/mux.h>
) Q9 O0 o, C1 k- ^/ Q1 ]6 {# I9 }, [* R2 L3 t5 ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 [/ M1 a4 G+ M! i
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: |. l1 f- Q& @8 T% m#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% N* g3 O( |& |* J( C
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ [. u2 A+ ~0 _
( V/ S! F/ E( C5 a, y3 C6 x
/* assign the tl som board LED-GPIOs*/5 E2 w5 E/ h% t
static const short da850_evm_tl_user_led_pins[] = {1 m- r0 B/ T( e
        /* These pins are definition at <mach/mux.h> file */
5 X( J6 @3 F$ ?7 D" P) R3 s        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: ~* w! N2 L8 H) k9 s! K& t
        -1
( `8 B! k9 p& H( O};
. _& `" Q8 l, H  Y# o, h9 Z/ w9 z, w
8 e% v' M3 p1 R/ s0 N. ?9 [% {static struct gpio_led da850_evm_tl_leds[] = {
9 O$ W& P! l) P        {
: U* U3 Q7 ?4 t8 Y                .active_low = 0,* p% h6 ]7 P: A) S- {2 g" q* h
                .gpio = DA850_USER_LED0,- a: {; R! }) c6 K1 a
                .name = "user_led0",1 D/ h8 `. f$ a0 B8 A
                .default_trigger = "default-on",# b8 e, o  S# D* Y
        },
1 F' e) {1 u+ p( l        {
% g3 k# ?# e% a. {- o- q6 v. S                .active_low = 0,
, W3 W9 f% a, T5 a                .gpio = DA850_USER_LED1,
5 v6 C9 K- d1 P/ p" Q2 T                .name = "user_led1",. y5 M- D9 J) o# u+ W
                .default_trigger = "default-on",: r5 r. b0 F! i; O
        },6 i' y. }, A+ |, G# h8 X" j
        {/ Z+ z6 d& B. h( m+ H
                .active_low = 0,/ |! M7 k- k6 p' Q; @8 n& O
                .gpio = DA850_USER_LED2,
# c; R3 y9 m; B. F                .name = "user_led2",
. w+ A+ v: |( p& l                .default_trigger = "default-on",7 X! b; O0 z0 D- o5 H% G
        },3 P$ h. ]3 F' [
        {
# h/ g  o/ W0 C& I# w- I                .active_low = 0,
" R/ G* x, |+ g! d                .gpio = DA850_USER_LED3,- c; Y2 {6 Z# K' U  b
                .name = "user_led3",
% F, d$ r* j/ e                .default_trigger = "default-on",$ W: K* k! _6 T; c" @* B
        },: y' K3 n8 V/ R9 y$ w  J( A
};
# w% s/ K4 U1 Z, B& E
4 S- H8 r# o/ N. k, r- astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 T" Q' O7 k& E
        .leds = da850_evm_tl_leds,% B8 C$ O3 [: S+ w
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 e" @0 N& ]4 c0 a3 Z! W
};7 d  `5 {* P. V, L" v$ k  W% o
; r6 A+ l  K4 b* O/ x
static void led_dev_release(struct device *dev)+ r+ E9 y/ M! o* Y
{
" N% L  i+ ^- a; S- b. g};# U! h8 g$ Z) _. F6 f5 M

& D6 v7 n) U9 M. ^static struct platform_device da850_evm_tl_leds_device = {6 q/ p$ [3 z6 \  Q6 z2 s9 o1 Z
        .name                = "leds-gpio",
  x' L. U5 G2 h8 I, U" j! x" |        .id                = 1,  [" D) m& J/ `0 ^
        .dev = {
- W# t3 w$ i0 O; V: r                .platform_data = &da850_evm_tl_leds_pdata,: X8 m8 Q, m; v; N4 l
                .release = led_dev_release,
+ P# V6 `( J" e        }1 R1 W0 l7 m, q
};$ P  J8 @0 t4 F+ Q( T

' O: `* N6 B4 D( ?% @static int __init led_platform_init(void)
! P3 q& P: X5 `1 k9 ~# b& N. {{
$ N" E( g7 @) b6 Q        int ret;* g* H1 P1 g3 G$ ~9 @8 Y- I6 P
#if 0* ?+ c( K- I4 w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ \6 `$ u3 k  V
        if (ret)
/ g5 y# H$ g" c2 V                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* Q* j  b" v% T                                "%d\n", ret);
- T2 K4 w7 W5 C+ C#endif
1 h* X7 I( x7 X7 q        ret = platform_device_register(&da850_evm_tl_leds_device);
# m/ l6 y& U2 q; ^# H        if (ret): ]- k: ~4 |: @) @9 n8 s
                pr_warning("Could not register som GPIO expander LEDS");
& q6 Q$ w! E8 D( S  |        else+ W* r7 B8 U  p, |1 E
                printk(KERN_INFO "LED register sucessful!\n");
* @: Q( v1 k' h. j
+ V" N# g: Y+ o$ P, Y9 U, I- y        return ret;
1 ?4 I( ]+ f8 M# q}: q5 J6 g& [! h8 K, t
& C- M! t. [: }( v% _* g9 E; y! u2 K
static void __exit led_platform_exit(void)
) }% @( @5 q& a" n{: R! f& v0 a! Y1 `. k
        platform_device_unregister(&da850_evm_tl_leds_device);4 o& t3 ~" }' _) }) W, k1 B. v+ g

5 _# E: t! F! w% H        printk(KERN_INFO "LED unregister!\n");/ O, J; u/ R/ Q: R& a
}
- A: D" K" Z8 \: r* _. Q8 x: L% }! w' x! E: I! I9 J# T& h
module_init(led_platform_init);, Z" W8 j3 T0 K2 ?9 N2 K% @, e
module_exit(led_platform_exit);$ `. y' r! F& Q
6 s# r% w- G4 p+ R
MODULE_DESCRIPTION("Led platform driver");" o! k; k$ k4 |3 F
MODULE_AUTHOR("Tronlong");- J) r! c$ l* h5 P( p0 i
MODULE_LICENSE("GPL");: w. t8 v/ |# r& I
6 T7 v" b; `& i, Q' Y5 E
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-8 02:49 , Processed in 0.034881 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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