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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. g! A3 @% o/ y' C6 s7 w1 Z6 S! j4 F8 @#include <linux/init.h>
3 b- o4 }; S+ a2 D- m$ v#include <linux/module.h>2 ]% ^5 b0 ~5 i
#include <linux/kernel.h>. I5 v' Q% J/ B) G
#include <linux/types.h>
+ ]/ ^# Q# @$ C; q9 \9 E3 O#include <linux/gpio.h>
& I* I6 R- m2 {) z#include <linux/leds.h>6 A2 Y% t. G* x3 y2 P$ [
#include <linux/platform_device.h>
# e! {& b+ n' I6 y: x: {7 ]
& ?8 ^, n% _8 p! d1 x#include <asm/mach-types.h>
7 f* X' J0 s  j, L! @$ h. l) l#include <asm/mach/arch.h>5 R2 }- V2 T7 {. p. ~+ Q
#include <mach/da8xx.h>1 q, o8 C# |7 O$ [
#include <mach/mux.h>
& r- j" }4 u& x% {% d. U/ A! p! i. P# b( n- J: X  I. ?
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 e5 s( X6 C/ \0 j) h6 d; U9 C#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)) P* T' B% ~+ t
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# g0 T0 b& ?7 i/ @$ \% U6 I5 I7 e#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( V$ o* D9 D( `- C# m* ^% |
) B4 g# K! i/ i! _6 m) d
/* assign the tl som board LED-GPIOs*/# g9 k( y/ I0 H$ i3 ~2 T
static const short da850_evm_tl_user_led_pins[] = {- B9 k, ^  O6 B* m
        /* These pins are definition at <mach/mux.h> file */
' K6 ~0 f0 g! E# v. E& P. U$ d7 H+ `1 z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! a0 a$ L( E7 a0 r6 u& f' S
        -10 F) m) V0 d0 z6 Z% G% l
};
8 a5 W: ?0 R0 b6 a
7 I/ l) J  ^4 _& F' x' wstatic struct gpio_led da850_evm_tl_leds[] = {
" ]3 g: X5 p( a* \( R        {* ?% I3 z" a. c* N* W
                .active_low = 0,
# C) z% P3 C- y" K$ u' n5 q                .gpio = DA850_USER_LED0,
7 o# S& \  Q5 \, C6 A# E0 Q                .name = "user_led0",/ k0 C( }" M% t5 e' L" Q
                .default_trigger = "default-on",! b$ i; n" R" d3 b+ w9 o( @
        },
- I- w! _9 ]4 s6 y. B& F# K5 O        {
* n8 d- [/ e7 C                .active_low = 0,/ t/ L0 B8 a  O& M5 G) P
                .gpio = DA850_USER_LED1,
) {+ W; ?' l- z2 P) E! F                .name = "user_led1",% m8 c) [& j, Q( |3 b+ U
                .default_trigger = "default-on",
( |* q: F  }! I0 }6 X) ^        },
: c6 _6 s7 |4 c1 c* f4 U0 `        {9 f, k, S6 H% |1 \
                .active_low = 0,. Y) \" R# w5 W8 q
                .gpio = DA850_USER_LED2,
# I9 s* _2 A& `' e2 G' w( c                .name = "user_led2",2 V) Q* }+ e$ Q) ~! q
                .default_trigger = "default-on",
& i) y! P$ H& F* U. f" P/ H3 ]        },) @3 f  u+ n; S
        {' m: x4 l/ p3 Q! i) z
                .active_low = 0,0 s/ T" p. k, [) {) E# M
                .gpio = DA850_USER_LED3,
- M/ q1 O6 N" x  a5 t' @, [                .name = "user_led3",
, \2 y* F9 M& }8 _                .default_trigger = "default-on",
4 V/ W  {! ^4 w+ r, D( @* J        },
2 p$ B: k8 n1 q+ |5 o};+ P; |  h8 I) C. o6 A! B

9 R" }1 u& D( g, S# ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 n7 C3 f3 Z- W% p
        .leds = da850_evm_tl_leds,
( ?5 u7 }- r4 `7 N1 O1 A        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ ^4 q! F  |' P4 ~  q};2 y( V. ^2 G  o3 H
3 a- M/ y  }5 e! u' l
static void led_dev_release(struct device *dev)
  x/ }7 L! n) O- X{5 ?5 r7 H) H( ~* i- K7 z9 v
};5 h+ f, u8 Q9 a. U
+ Y; I. B: {! K2 w& w) _- N) T. N
static struct platform_device da850_evm_tl_leds_device = {2 P% [8 y7 c9 x5 Y: ]7 c+ Y/ {
        .name                = "leds-gpio",
. E7 g6 o% K8 {$ \/ n+ O        .id                = 1,
" j3 ~8 [* U; r4 Q; ?        .dev = {1 ~  F$ T9 J+ C* r
                .platform_data = &da850_evm_tl_leds_pdata,2 S% _( z2 I1 x- `& _# U4 d
                .release = led_dev_release,
. C8 d  j+ l0 m) |& ?2 J        }
3 A; M4 s7 s6 ~9 i; W};
8 o# d+ q1 y: G+ R0 o
& e& p* F( X5 E0 hstatic int __init led_platform_init(void)+ {' b2 s" P& f; g# y8 D, C8 d4 W
{0 D6 a/ u1 E- W7 u0 g0 T: T
        int ret;3 w+ {9 g- a. P7 g" k* w8 @' I% Q
#if 0
1 l' @0 _# e' y        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ @  K. @3 i. h8 I  y) n
        if (ret)* f( f2 k! r: d1 b  x* f) y, V
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ U! z+ i( S, F, \' Y                                "%d\n", ret);
# h' [8 e7 O6 q5 z#endif  b; {6 I. G, f4 r# I( q+ w* S. w8 Q
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ ^9 ]. F) d7 `& g7 K( G        if (ret)3 V7 D8 J# D5 n' K/ e
                pr_warning("Could not register som GPIO expander LEDS");. R2 q5 c3 a( S
        else. m* d  a# k. i% n' ?( v# @
                printk(KERN_INFO "LED register sucessful!\n");) b/ M) g  P; u. _

! b) u* a5 r) ~9 M        return ret;
, J& S& \. G3 t3 |( Q4 A* @0 S}
* d; ]) g- Z( B4 P) z/ c* K% |
9 f: k3 p; s+ k1 D6 cstatic void __exit led_platform_exit(void)
1 [% `  {" `3 M, o9 T# {. s{0 ~$ A8 A* N* v
        platform_device_unregister(&da850_evm_tl_leds_device);
1 m/ n2 m0 s/ A, B2 C6 g0 n: N9 `/ u5 t
        printk(KERN_INFO "LED unregister!\n");
' C) j  t* J* V2 o}9 A' \+ d7 x- ]

1 q/ ^8 h$ H& ~1 L4 O3 j' pmodule_init(led_platform_init);: S6 |; @* j; J. C; e
module_exit(led_platform_exit);
5 ]2 _, g; Y7 r( k) }
7 W$ h2 L8 r9 i  I4 ZMODULE_DESCRIPTION("Led platform driver");
  j& A  D2 o1 L  j& [MODULE_AUTHOR("Tronlong");# d  O' |- R: e
MODULE_LICENSE("GPL");
! g: [2 X, }/ A" L9 w& F4 L% F& h4 {- M9 [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-22 11:39 , Processed in 0.041620 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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