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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
/ x4 }% x: a: r' y# I7 t#include <linux/init.h>
; Z: o3 m! T4 P! W$ P#include <linux/module.h>
# N8 q7 Z/ P; k9 t- g#include <linux/kernel.h>" Z8 [5 C/ }8 L5 j- X) k
#include <linux/types.h>8 Q% \$ I% ^3 e6 N+ g7 `
#include <linux/gpio.h>
0 n9 K. ^; P3 }: b/ s, p#include <linux/leds.h>+ G5 F2 o- m) b: m+ A* s* x, \
#include <linux/platform_device.h>
) \2 {$ j" p' f( v0 g  \) h: M! ]8 c# y; m8 W4 K
#include <asm/mach-types.h>- l" F" q5 F; r' T
#include <asm/mach/arch.h>
7 ~0 J' f6 @2 Q4 U. k& a#include <mach/da8xx.h>( ?5 W3 v) e/ U% n
#include <mach/mux.h>4 E1 V% o; J" \- @" A; r
+ S7 J; `. _" Q
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' y: G' q2 M0 U+ w) S5 f% I#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
/ o9 R  h3 h; j#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): l4 d: K  T' O( z. N5 [/ n
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 V! F3 Q* R$ k2 J+ ]
* z# v3 R6 Q' R  M
/* assign the tl som board LED-GPIOs*/7 E5 z; F7 S- x( p: T- z4 h
static const short da850_evm_tl_user_led_pins[] = {' g$ }( D7 {+ w' m. r( }, M
        /* These pins are definition at <mach/mux.h> file */" L6 M5 ?$ C  Q) J+ d- l) f1 q  b
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* e- ^' E. J, D! [. U$ `5 \
        -1' ~, j3 V$ T$ p3 H7 o- s+ P
};
# D, A  o0 I3 b, G0 p& v( y6 U' `6 K# G/ A
static struct gpio_led da850_evm_tl_leds[] = {
" z& K' u) G' b8 T        {
' l/ F' `7 O& H( _8 t8 V& Q                .active_low = 0,' ?$ p/ s. r) r' n
                .gpio = DA850_USER_LED0,1 I3 A% ~- X" F* Y
                .name = "user_led0",4 I/ s7 Z8 C+ F6 \& C' h" }2 `
                .default_trigger = "default-on",1 i; i* U1 \" m/ C" D5 y& @7 j
        },# u7 o* U3 v& B" ^+ N( O& C
        {3 L( Y' C( r$ u; y7 d# B! s: x
                .active_low = 0,
2 m4 N' x/ U- j6 M2 i8 I. `                .gpio = DA850_USER_LED1,
* Z3 J) C, N) {4 t                .name = "user_led1",6 F' H* p) h$ S+ o
                .default_trigger = "default-on",
" h( I( U, L; y& X        },( l, @+ f4 i, ?9 t/ F4 U6 k$ h# O! u$ H
        {
' B1 M, B7 S' J$ N6 Z" D; n# _                .active_low = 0,0 `8 O! a7 ?6 ^- ?7 `1 {& ~3 z
                .gpio = DA850_USER_LED2,, S; i0 Q2 D* V$ ]: _1 d2 \
                .name = "user_led2",
0 C' v  Q9 d. T5 s# j' G                .default_trigger = "default-on",
' o' H+ `& z! n7 `, H1 L/ q% T        },
# ]  W- C0 l% h* P" n/ R7 X        {
6 {5 ^# [, @; C                .active_low = 0,
3 _) D, l9 Q: t8 ?2 |                .gpio = DA850_USER_LED3,; v. P, L6 K, P: y3 A+ M
                .name = "user_led3",
6 l( H* Q5 S9 K' p9 B* A: S# M                .default_trigger = "default-on",
) G5 M% u/ Y! U5 D        },! y) x; P7 ?% [8 {6 |7 [# ]% o* |( ?2 h
};
! n1 y. d8 T+ \% J! m8 ^; L, N
8 ~/ d: P& D( rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 d6 p, i0 z; H: f$ K9 z5 z        .leds = da850_evm_tl_leds,
' M; H" ^7 `7 Y) c. Z% ~1 O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# e- V/ X" o& e) n, x& C: O+ K
};
, S  t3 d$ l# D: A% d! E2 J4 Z3 u) U3 a3 ^  y
static void led_dev_release(struct device *dev)
' x; P0 V- |, @# }9 e1 l- b3 y{
% l- r, \9 d% w/ S  \};9 z6 L5 E9 q5 d: a8 f' i( A

9 |- X* n! Q. Jstatic struct platform_device da850_evm_tl_leds_device = {/ A# @" k" f) t. i5 Y: J4 h
        .name                = "leds-gpio",/ B, O3 _' I1 l# R9 G) |- @
        .id                = 1,
% h3 @; I# I% S        .dev = {
$ j7 X) g% j& F- }7 A7 F                .platform_data = &da850_evm_tl_leds_pdata,
: r. r/ O- y+ a0 q0 V) c. x! F. T                .release = led_dev_release,' X. \2 J- d4 w5 H5 ]7 K
        }
2 Y8 C  y1 M( w' C) m7 S* B};
! F! p! r/ \) s; e$ b9 N) G( i5 V+ |6 q$ }' I& C% S
static int __init led_platform_init(void)
7 [! Y8 ~/ }$ K. i{
! o& z1 A& M, C  S        int ret;4 s3 O  s7 s* {8 t" G9 P# `# l8 K
#if 0
+ {0 ?5 `* }2 _- W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) z2 e/ ?2 ^% f+ ?, }' Q% n( z
        if (ret)
. r! M! p- o5 f0 s                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( N( }: l6 F# X% b: J' [                                "%d\n", ret);( g2 }  Q- x' a( n9 V9 s
#endif
  }8 L9 ~+ m& W        ret = platform_device_register(&da850_evm_tl_leds_device);
5 u1 M& [& M" W1 k        if (ret)# X' c" c: j# v9 `) c* M: q
                pr_warning("Could not register som GPIO expander LEDS");( l' z% r' Y8 H4 m( Q* U
        else
2 Z. e6 Y7 e$ T& N) S                printk(KERN_INFO "LED register sucessful!\n");! P! X1 Q- j/ o3 x
* K7 t: N* |, m4 `: a
        return ret;# Z3 S4 U2 W) `6 E! u1 i4 T- O
}
: _) T: E7 a* [5 |3 s# g* |" G( r* S( G) Q  N; i! ]
static void __exit led_platform_exit(void)
& W1 K. Y; M6 S5 g{" _" W% x; I' a9 k! a4 j0 E
        platform_device_unregister(&da850_evm_tl_leds_device);# w/ z0 b! J) s! H, ^  }, ^
# ^5 g. M. n: H0 d( @
        printk(KERN_INFO "LED unregister!\n");' Q* l# k3 m; A+ @/ J7 m9 m* Y6 I
}1 C$ M* [* a' J# n! B5 Y) [
+ u) s7 y6 @7 {2 \
module_init(led_platform_init);. O& i% R: j: x- J: d$ K
module_exit(led_platform_exit);
: o0 U! Z" z/ N) A# T0 E0 ?( g8 [
% d0 }' J) d' K  l- f* TMODULE_DESCRIPTION("Led platform driver");
( W0 ^2 q. x; I( GMODULE_AUTHOR("Tronlong");
; X. K  J3 e6 w$ {6 vMODULE_LICENSE("GPL");0 u1 Z$ z3 O  b0 l3 m

( Y8 x8 v4 G  g/ H8 E3 n( @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 04:25 , Processed in 0.038955 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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