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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ |2 v" |' Z# c
#include <linux/init.h>
: l! W, g% n* J* Y2 ?#include <linux/module.h>
7 t7 v; w( A+ `$ m$ Q6 `#include <linux/kernel.h>
& q& n# f- V- c$ h#include <linux/types.h>- a& g8 e0 Z; Y% d
#include <linux/gpio.h>
* G# A8 s- h  F" N- ?) S, s#include <linux/leds.h>) [8 C0 t0 c9 h( J% G& ^) z3 G
#include <linux/platform_device.h>
+ ~8 Q4 B6 ]7 Q+ \! T1 Z; c
7 [( _6 X* O3 u  S( v#include <asm/mach-types.h>' F8 S7 t% l, r0 u) x0 A8 i
#include <asm/mach/arch.h>
. \* p! H3 q# Z#include <mach/da8xx.h>5 W$ S. ^+ @2 g; |4 @& Y, N
#include <mach/mux.h>% w* g5 l* C: Q8 H4 s# t5 b

8 r! Q; d4 y! C#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' h6 K) y5 |0 f# T& r#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)' Y3 K% Z6 ~9 ~& l
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): P( u% i$ y$ C! U6 D3 L* {
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" v1 `* [9 b# ?3 m2 k
# N# m: s" q( G/ v9 j0 Y3 U% N
/* assign the tl som board LED-GPIOs*/
9 V& `, r9 k+ R! t# _static const short da850_evm_tl_user_led_pins[] = {
( {( X- Q; d) q0 M6 ?        /* These pins are definition at <mach/mux.h> file */9 T( X: T- k" h: R( J, L; ~
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# D3 ?  M; d6 h+ _' T, f        -1
! Z) b, X, S) \2 F& ?9 U, E% K% x};  c' [- [6 H" r  z8 b
6 Q+ q; Z3 |" w# [
static struct gpio_led da850_evm_tl_leds[] = {
  J: J# ~: `1 M, v. Q9 `        {9 j* U/ D6 N& ~4 l) e6 E" O% u
                .active_low = 0,6 Y+ R; T2 \$ ^0 D3 i8 ]
                .gpio = DA850_USER_LED0,, V, O' h- z/ U7 \- T8 C/ d  `& c
                .name = "user_led0",
4 y  _+ H) o* b$ w. s                .default_trigger = "default-on"," j& X  K9 a% U; J$ z/ d
        },# v& D; B) y* T: \$ h. e% f
        {1 ~: {7 h; [/ f; K3 Q2 X( Z0 Z
                .active_low = 0,8 w% r* k" H# ~5 a3 t
                .gpio = DA850_USER_LED1,- n$ p* ]; c' D* ?/ ~  M
                .name = "user_led1",! k/ X. z& e4 k' B- v: z4 K
                .default_trigger = "default-on",
' a6 ?* t3 E7 ^1 W0 K+ f        },# l8 l+ I$ b9 M, o' @& Y
        {+ t6 A* A7 Z, j2 T3 c
                .active_low = 0,
. H5 A  G& u2 r7 }  ?5 ~3 T+ _                .gpio = DA850_USER_LED2,
0 c; X9 D0 a$ u; i                .name = "user_led2",
" h5 J' O, G" d2 N) R                .default_trigger = "default-on",
2 e$ W  [( a- J3 U        },
' q1 [1 U9 f0 m- Z' Z- n. u        {3 H- I# O# z+ W3 B+ J, j" b
                .active_low = 0,+ S' M, _' e  y3 U( b# L8 A
                .gpio = DA850_USER_LED3,: g* O: {5 a; S0 {' ~8 N: C: _& L7 |
                .name = "user_led3",' u( x0 ~; s- n+ l, h) x: m; Z
                .default_trigger = "default-on",
& ]& d) p5 `. ~" g& y9 ?        },
! ^9 c8 X7 u, ~};% |$ Q. j8 b$ x- r" w
; k. p0 ~5 a0 M! L. P2 f; F' W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 T; s0 h# u; G* z. i4 k' d
        .leds = da850_evm_tl_leds,$ H9 b! e0 I/ O$ I+ w- A
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ ~  i( m9 K( F5 b: X- P
};/ \% e$ P! k4 f/ ]! Y( @$ X6 D: W$ A

( t4 Y* @9 K6 M! \  A2 V- Mstatic void led_dev_release(struct device *dev)
+ j( U1 v9 k% d$ S) D/ V  [{& G8 \8 U0 a) e6 t6 I. J" s( X
};
0 Z5 |" |1 y7 }+ a- r! g4 z% z; R( H2 t# i2 {) c# @
static struct platform_device da850_evm_tl_leds_device = {5 Q; Y) c* i( J$ S
        .name                = "leds-gpio",2 S$ G$ j5 c! S. Z" _
        .id                = 1,# ?# E. q& P$ F% N# h2 ?  ~; _
        .dev = {6 {$ |8 @! a! m6 Y& T
                .platform_data = &da850_evm_tl_leds_pdata,
( }9 E' f' }  B# J1 {+ W                .release = led_dev_release,
( {  _' V; f- G( W        }( X8 T7 n6 I, G/ \) Z
};
4 X" U* }/ I! q# r
" L0 \7 u" E" ~" M9 r2 {0 V% J) |static int __init led_platform_init(void)
9 O' b8 P& V9 E. W. x& V{  w* ?$ k. s. s" {
        int ret;
1 K1 U9 [" f4 p#if 0* H/ W! j5 J; A. M9 N0 N# b
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! c( p* S# f/ w0 H$ f8 |
        if (ret)
: O. @; C0 ?( A+ g9 L0 j                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ Q" h  Q! c. Y, C* C1 K                                "%d\n", ret);3 A! q; z! B5 w" V7 Q2 h0 A% b
#endif
1 t3 S! S: H$ b        ret = platform_device_register(&da850_evm_tl_leds_device);
+ `) d; O6 |2 [4 x0 \/ l* X5 t" Q        if (ret)
. `7 K& l; l" ?+ p0 x" n                pr_warning("Could not register som GPIO expander LEDS");4 _: }( a6 `# O2 k
        else
1 S- {, Q) g2 `9 `& Y( D                printk(KERN_INFO "LED register sucessful!\n");* Q! r9 G+ h8 j- o( t+ N
) G* T4 E& _9 z& T) ~) c, d
        return ret;& D3 }& \9 N. \
}
% _# \; f! V. D( a9 o* h8 i+ o" Y) l% ]$ o% O: `7 Q1 s
static void __exit led_platform_exit(void)+ J) O& W! ~( w9 Y
{
" T2 `* e5 T( l$ ?" {: T! Z4 Y) o        platform_device_unregister(&da850_evm_tl_leds_device);
6 t% L) w) U/ t2 x0 l$ v! D
# M* {5 E3 ?9 K( J" {% a        printk(KERN_INFO "LED unregister!\n");
$ W/ V7 T. b9 {2 d; ]4 I' p6 U}
/ _, a' X$ K* Y, [. e! H
$ P* U/ z3 e, }1 s4 y8 ~module_init(led_platform_init);
4 r7 ]* L# c1 s* v1 |! dmodule_exit(led_platform_exit);
+ V; i3 q7 t) f$ \
4 h& c" L- L: G0 A$ {MODULE_DESCRIPTION("Led platform driver");$ M+ q! n! ?+ X) q" A  y- `
MODULE_AUTHOR("Tronlong");9 E  Y; R' ?/ x: L
MODULE_LICENSE("GPL");
: T+ O/ q/ v' A, X3 |3 p9 [% Q5 ?% B+ t2 T  {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-2 19:59 , Processed in 0.039273 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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