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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
! g4 f+ M5 x$ j# v. B#include <linux/init.h>* j4 S2 L6 h3 f4 U8 T6 |/ I5 y: t
#include <linux/module.h>
) f; l. ^8 k; K) V#include <linux/kernel.h>
6 T3 e% o1 s  M: ?, y#include <linux/types.h>
6 t4 h9 R* `: o$ i9 j$ X#include <linux/gpio.h>
% v! f8 @- X: Z+ p: N) X: e#include <linux/leds.h>
) n; R, i; l7 m7 }! \4 U2 e* D#include <linux/platform_device.h>' `. }- n$ U1 A4 T2 @3 u

2 f0 C9 m' ^' |  S& g#include <asm/mach-types.h>
3 Q" A" m% V# ?$ k#include <asm/mach/arch.h>+ n& I/ F0 I9 F! I8 @4 P& [
#include <mach/da8xx.h>6 q& k. B& y5 X' q% A" v% S
#include <mach/mux.h>
) E4 w! k  }, Q% E7 G$ I
) n7 J% g# d7 @5 Z" h#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); i) o! M. I# S. F2 h
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ @5 N6 T5 Z0 o9 R; J#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' [$ e; @; {' n. e- _' w- y#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). V# c* j4 a% `3 k4 k# w6 R
. Z% b' ~. W2 ^$ H' k
/* assign the tl som board LED-GPIOs*/' W2 n* f5 U* b5 C! r, w
static const short da850_evm_tl_user_led_pins[] = {* C0 V% e: z: D5 k4 F. S: n/ `
        /* These pins are definition at <mach/mux.h> file */3 O1 t6 U( G* G( V; }
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 g4 p$ {7 ~) S& R( _
        -1! ?7 J( J; E5 c0 r) E" T
};
5 T* E5 v, h7 j* J
$ F' s6 \) x3 T5 O: z5 Estatic struct gpio_led da850_evm_tl_leds[] = {
; c5 G1 C/ @' J$ L        {5 d" B, x" D% I+ E3 ?
                .active_low = 0,5 k4 \4 i& J/ t; c( W) }4 _
                .gpio = DA850_USER_LED0,
7 f0 o, ?5 a% D2 P                .name = "user_led0",
& O0 S! s5 n& }5 f                .default_trigger = "default-on",/ K1 V0 B! r8 o" M
        },3 N' Y: }: g& Q+ }6 Z# g1 }
        {8 ]& I* B& J! }
                .active_low = 0,! U4 b9 V# n1 u5 I
                .gpio = DA850_USER_LED1,
$ r  I- n# @, w% K( L9 M                .name = "user_led1",
: b) H+ \0 q& a: r& p5 E                .default_trigger = "default-on",
% p. }) e. W: R0 g- X  Q8 y* D+ l        },
& D: z9 n% S: Z) y: G6 c        {. E3 {- i$ ?+ p  W6 F6 E; ^* o
                .active_low = 0,9 o7 o, K% I2 p) o, g3 Y1 A# f
                .gpio = DA850_USER_LED2,
9 Y! l* f9 B# W+ U( Q2 a6 Q                .name = "user_led2",
! t8 ?  G3 z$ u' H6 q                .default_trigger = "default-on",- D5 T- T' V9 J* ~7 X
        },3 |7 F- ]. c9 b# J% j  N
        {
  U( s* V1 y( S& k2 x                .active_low = 0,
* J6 u3 p5 E; f6 a0 ~                .gpio = DA850_USER_LED3,
# N2 [/ k/ n# J; s                .name = "user_led3",3 J8 W1 M! g+ h
                .default_trigger = "default-on",
1 A5 S1 q7 C3 P9 |1 C" K        },) b9 i7 o" X7 k. C  `
};! [! I  r- R, O4 a: U$ r8 i5 b

7 I! j& I1 v0 N% @7 w/ Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! o; V+ b1 _* A# w5 G6 q! ^
        .leds = da850_evm_tl_leds,
1 w. `4 h! |$ d* o' R, @' ]. n        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 L2 c7 B6 V+ {. u};
* ~' y. h$ {" c4 B- F+ M+ x6 w5 w/ A) I  H
static void led_dev_release(struct device *dev)) P/ x7 b" z( N
{, o, b& B$ l6 q# T3 c: S5 l
};
3 I9 ]: X8 ?9 n+ z9 B2 V7 `! o# G9 H. X  O
static struct platform_device da850_evm_tl_leds_device = {+ e9 i; D, P& l& U: J" u/ j+ M
        .name                = "leds-gpio",
% F; ^' K% ~9 \        .id                = 1,3 v: i% o& c' D/ O5 A* ?6 E0 j
        .dev = {
# h% P/ A# G: n/ T0 d- r* }                .platform_data = &da850_evm_tl_leds_pdata,- H! q5 E( G; I6 g6 R! c
                .release = led_dev_release,
6 w! w7 j. q0 O7 m        }2 e9 e& H% ^" p5 }& E: Z( F
};
/ i' r4 g) A8 v+ @6 U6 d0 X2 |
static int __init led_platform_init(void)
& F# f% x7 l9 B{* D, Y; I# P, c+ z4 U: r# b
        int ret;
; f3 G( \1 B, a#if 0
3 b9 ~% ^( `  f3 ?- ~% W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# h6 r8 M) d! J* x( [/ j% j: y0 K        if (ret)
3 K3 c! W0 |# Y' o/ y9 N0 Y. @                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ ^; A, b6 |  k( Y0 P# q
                                "%d\n", ret);( k2 _  N0 f4 p8 i9 Y
#endif2 _( e5 Q- O+ `, `
        ret = platform_device_register(&da850_evm_tl_leds_device);9 Y  I) Q4 i/ w5 Z! L$ t  a6 i
        if (ret)
; A: q$ X; j- x. i1 r7 j                pr_warning("Could not register som GPIO expander LEDS");: f6 \; f8 o# Y" {7 F$ L
        else
7 B0 ^# q: V2 t3 G5 A" Q8 S  k  t; [                printk(KERN_INFO "LED register sucessful!\n");, U/ {" p1 \% W5 l4 ?
( o9 p, A! H# \% R+ A: ?' h/ i
        return ret;
) C) F9 J0 U& y& d: Y3 @) z! `}
; |' J  b" B; v! u: b( z/ d0 x! y6 z3 o: ]0 `
static void __exit led_platform_exit(void): B( O$ \0 a& i! y  @  s
{
/ A  w2 K9 k: |: {& f        platform_device_unregister(&da850_evm_tl_leds_device);
" f; X2 Z0 F# s6 P
/ i) Y. D3 U) e7 q8 m7 z        printk(KERN_INFO "LED unregister!\n");% g) K' ]! b& Z: a" J9 Z
}  {/ f5 X) E' _( T, |0 h
" f$ n0 ^$ |" X$ }0 n7 i8 f
module_init(led_platform_init);
- \; Z! R4 i4 omodule_exit(led_platform_exit);) p$ J/ m4 m' X7 a9 B& H
" f; W' f0 D2 K( J/ V3 E. A9 `/ H) n
MODULE_DESCRIPTION("Led platform driver");
( R- H* t9 q/ V/ c% a7 b5 z3 XMODULE_AUTHOR("Tronlong");( x) l9 y! P2 z
MODULE_LICENSE("GPL");* v$ {8 y' B. M( z$ {4 P5 K9 _

9 T5 m1 c1 h0 k/ P4 A$ W* g0 r3 G
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-9 10:04 , Processed in 0.038980 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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