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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。+ x. K# w0 ?6 |' v! U
#include <linux/init.h>4 e# o  X+ ^7 A' }" N) {; U# I
#include <linux/module.h># E, S' J  h7 c1 m0 {% v, _6 U
#include <linux/kernel.h>" @+ B) X! W# |+ G& r: _
#include <linux/types.h>8 n9 p5 o0 c7 b( }: S) V5 v5 {
#include <linux/gpio.h>
1 N# Q! u. ^+ T5 \- _5 O$ i' B#include <linux/leds.h>7 B' k. `6 l/ p
#include <linux/platform_device.h>
! T5 s8 ~6 t+ ^8 ^0 |3 e( Y
2 w: x- }7 z3 B8 F% E8 ?& {#include <asm/mach-types.h>7 n' `2 C- ~% [" N" M1 B
#include <asm/mach/arch.h>
  F7 s* Y/ ^; B! s; P) _#include <mach/da8xx.h>, G- ?, [3 @6 a- |+ K5 ]7 R5 i
#include <mach/mux.h>* P) i3 @8 @0 p( n( h. U0 o2 G

% ^) S$ v8 V. N, }# ~4 j$ N0 `#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" r  G' C0 w8 C#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  l5 u: ~# G8 Y( g( G& z
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)  @' J" d: i5 b, q  U/ z3 g
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
3 F+ u/ p9 U: h0 y
5 w  |: T9 v7 q: B/* assign the tl som board LED-GPIOs*/
- \% ?+ d+ O0 Fstatic const short da850_evm_tl_user_led_pins[] = {/ j2 }% \+ z' [! I3 L
        /* These pins are definition at <mach/mux.h> file */
% [1 O7 @6 x3 K. B        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. M& f( h/ G4 L# u
        -1) @  i* c0 o% x7 H2 _" q- S* D
};. d2 {: d5 b# s0 b
" F6 S9 _- t4 z1 X9 ~& `& t
static struct gpio_led da850_evm_tl_leds[] = {1 y. i& a% c! }" z1 x3 O
        {0 ]' H  H1 ~5 H# K+ ~2 E! l
                .active_low = 0,
. ~8 M3 r4 e8 O                .gpio = DA850_USER_LED0,8 M2 B# ?3 s2 D8 B* L$ ^7 Q
                .name = "user_led0",
/ t2 G; ~4 C5 x+ y) }' Z; b                .default_trigger = "default-on",
6 V0 n5 O. |) ?) C        },
" N' ^& {4 n; \. G3 w        {
2 _7 P$ e# d* b9 y& t8 ^  g  d5 y                .active_low = 0,! o  G9 {4 l9 `. I
                .gpio = DA850_USER_LED1,
5 `5 g+ V1 I6 s% ], k6 ~8 N                .name = "user_led1",
* Z( W( {( \( ?" c) o/ p# V                .default_trigger = "default-on",
+ e" J1 Z7 U* D, W- W- d  v        },, J$ Z: G8 r" L  w0 b: b
        {
3 F# h! j& |- X' m! G% n                .active_low = 0,/ }, q8 l+ u: S; `3 ~- o
                .gpio = DA850_USER_LED2,7 d9 [0 ?; c1 `2 X0 J7 n6 u
                .name = "user_led2",% J4 D, f' v/ U$ i3 n7 Y* q
                .default_trigger = "default-on",
) X% e  A) x2 ?) Z8 ^        },6 u5 Y2 e! t' d. n) Q, Z
        {
" y4 _0 E& j4 D8 ^                .active_low = 0,! z/ {8 D- C' A  J- |7 o1 [4 ]8 X
                .gpio = DA850_USER_LED3,
7 @  A" N; ^, g# Y. R                .name = "user_led3",' Q" F4 [, ^; {5 a
                .default_trigger = "default-on",5 n6 K% m" L! H- l
        },
: y  d% B( Y% M2 `4 u};
" {* D! p; H9 I' G% s
/ z7 h" j1 K# @0 i0 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( k& N: V8 P/ k- v9 @" _
        .leds = da850_evm_tl_leds,
% S& w, X1 j! ]- W$ M4 p' f        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. Q% x- s5 c0 k% ?% V9 b0 a
};! `8 m$ ]9 N. p9 ]* ]
: \. V6 u1 p2 `2 P
static void led_dev_release(struct device *dev)6 A  I/ y- _! v9 M5 W+ `% \  e. i
{6 q/ d" U1 L; e2 S
};5 b6 Q/ O! \, H9 Q1 k

9 M. T- |7 {! u# Ostatic struct platform_device da850_evm_tl_leds_device = {
8 W* E" @% c9 i# ~& F  X, }1 Y' C        .name                = "leds-gpio",: O( E6 H- K7 Z3 }0 {
        .id                = 1,
8 m( i, W  j( |' Z9 ^' m        .dev = {
! i- r- D5 E+ }1 K                .platform_data = &da850_evm_tl_leds_pdata,% P. k6 w/ [! R  r' {+ x% c
                .release = led_dev_release,
3 n& {1 ~8 I* B/ {+ h# }; r        }
4 p( m. f: ]  k4 i6 b7 b6 g};
0 @+ x1 P/ X/ F" F* A
' Y& b/ N# A' ^- Z4 v& dstatic int __init led_platform_init(void)
9 ~/ u& L/ C$ M{
7 l! G* V2 @4 ~' Z        int ret;  k% D& o; f* I5 r
#if 0; u7 }% n; o0 W: f, Y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# u) L  m5 E2 E/ ?* l5 Y1 {& G        if (ret)& d- ]! O" R( [. p
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' i; n8 d) v! D) J: m+ k
                                "%d\n", ret);, g1 n$ @* s+ k- s5 S' q' O
#endif
& I0 N7 P( L, _# r- [        ret = platform_device_register(&da850_evm_tl_leds_device);( c' i( `+ h+ S! `* H
        if (ret)
5 {5 f7 E) o2 A( Y                pr_warning("Could not register som GPIO expander LEDS");, q. `3 X: Y5 E; Z
        else
2 O! O' [* i, f" S) }- [                printk(KERN_INFO "LED register sucessful!\n");3 G; a8 w  {$ ?; S" l

5 q0 k- R8 w6 O# e& D        return ret;
' E" V# R. L: J  j" Z' N1 B! Y}
, x' i* m5 i3 r7 a0 e  }
$ u' }7 y! S+ x% w8 _static void __exit led_platform_exit(void)
5 o: u5 u$ K% Q8 @3 X{
" m# l$ @% E- ^5 `# G        platform_device_unregister(&da850_evm_tl_leds_device);% u: I5 k7 ?; p, E9 p0 R+ z( j
9 M, ?- n* z* f1 q) n3 T
        printk(KERN_INFO "LED unregister!\n");& M- t' d  G' R6 N4 r$ u3 @& W/ I
}
3 i! o, n, v& e9 H# a* }* l3 }
module_init(led_platform_init);& s$ ^& A" I7 l, D& i! o, q
module_exit(led_platform_exit);& r1 u3 _3 ?1 m6 v9 z
9 X  U/ f. u# o& p
MODULE_DESCRIPTION("Led platform driver");
# G. _+ D- g5 F  A  DMODULE_AUTHOR("Tronlong");
4 x! P. _# _1 yMODULE_LICENSE("GPL");
- [9 {/ Z7 ^! R! G6 }! O! W0 W  W# `6 J2 s1 J3 R' l+ D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-31 18:25 , Processed in 0.038775 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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