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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! W" C( i+ e4 Q% Q. i
#include <linux/init.h>
% H: T9 h# f& ]' p  C#include <linux/module.h>
% N" h3 y% U" ]8 N4 p: \#include <linux/kernel.h>
" o9 R; L' G  D3 V4 _#include <linux/types.h>$ ~  [# n0 z5 [
#include <linux/gpio.h>
% o8 I# ]6 h# ~1 n: p* r#include <linux/leds.h>- p6 j, V; j& W! N& D
#include <linux/platform_device.h>
/ @; Y' H& h3 S4 P3 ]2 e  n& K" p% h9 V8 k
#include <asm/mach-types.h>
0 b2 z; m+ ]) {$ N/ `#include <asm/mach/arch.h>
% A" }, f& f; I% C#include <mach/da8xx.h>+ Y7 w  y0 J- \  Q
#include <mach/mux.h>
! X6 X$ }2 B3 W) V+ q/ q7 Q- P0 {; r9 L& K, t
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; [# `9 f( e3 y3 t8 q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
/ e+ c: a% c5 u" M, ^: q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ J% K6 f! A  e* R1 C! }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# s0 K4 L5 n: b2 v* Y6 {& ^

4 j1 A* P) ?( @1 ^5 U1 m/* assign the tl som board LED-GPIOs*/
) h7 T- N. ?4 w1 }static const short da850_evm_tl_user_led_pins[] = {! W! ]* c" @  I+ m5 C
        /* These pins are definition at <mach/mux.h> file */
3 V: q7 U* u, N) t; q; t        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ ~5 k. K" j0 a7 N# K! n0 O# o- D; l
        -10 ?9 I" f& u+ e# z8 i& D
};
; s) B9 ?' C8 _' [' Y2 o" P' }+ D5 Q5 Q, F7 G* L- R7 Q
static struct gpio_led da850_evm_tl_leds[] = {
' y2 _! O0 q  |) l        {( W, z2 {! t5 H* S$ V# S3 y7 T
                .active_low = 0,
: a: k! U# }$ z! D                .gpio = DA850_USER_LED0,! j* T  i7 D- n( n
                .name = "user_led0",0 Y! |/ M) I, M0 x8 M
                .default_trigger = "default-on",
+ A9 w0 a& G6 E/ h        },  n  u1 b+ W' e& K2 Y5 s3 m# s
        {
7 H7 x! W; y8 o; B* R                .active_low = 0,% r2 v* C- {' x/ k- ^! I
                .gpio = DA850_USER_LED1,5 q" |$ n8 R- |& t# V+ p" R$ ?0 |* a. E' k" U
                .name = "user_led1",
$ ~" g! y- v; _/ Y! @' p1 [/ F                .default_trigger = "default-on",9 ^9 e0 g3 m; C0 Y+ _$ J7 S8 t! F
        },; ?8 e/ a% Q7 q2 X, E# a2 z
        {
, g* F6 v3 z. N" w8 w; i                .active_low = 0,! B% C* Z- Z% O5 ]( `1 b
                .gpio = DA850_USER_LED2,9 k$ u5 ?' ~, `1 d3 y/ w% D
                .name = "user_led2",- K" F7 f# W6 `& K* \. f) I: ^! }( N3 }
                .default_trigger = "default-on",
9 b5 j6 p# ]% r3 W9 d2 t6 i( P2 s        },7 c2 J; \+ A2 G/ b3 M* [1 f0 c' Q
        {, {* m" v  H7 v( k1 }' }
                .active_low = 0,
+ s1 d  p: E, f& k9 A: J                .gpio = DA850_USER_LED3,
9 E2 ]( d$ x% N9 Z                .name = "user_led3",: w6 h; u- J5 M4 ^( h
                .default_trigger = "default-on",$ _2 h* p7 }. G9 Z
        },& _; P/ ]1 U* y) n4 y: @2 B) W
};
) n1 S7 {2 ~- R0 G+ c6 Y# I; l4 l7 k+ P- [3 _/ w+ y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; A4 }( Z# y& g7 K2 A. @        .leds = da850_evm_tl_leds,
4 c6 q% L  {1 y+ K        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. c1 {& J4 w* M. \( H: @};
! Q" _. F, |6 c' q4 L+ @0 @& A& H$ Z9 ^9 F
static void led_dev_release(struct device *dev)
2 p9 Y2 W2 H& i5 J{6 w% P8 n, b. X* p* W; D4 F$ x
};4 \1 c- K) u) Z0 I' S; @
6 ]1 @( |  s3 Y
static struct platform_device da850_evm_tl_leds_device = {; k+ L1 O2 {8 T( ]+ _1 t# p
        .name                = "leds-gpio",+ x% w  ]7 k: Q9 h
        .id                = 1,
- m; D. a' }: i7 |$ w+ F3 q4 ]! ?8 P0 ^        .dev = {
5 t5 c; S* K+ F' t: ]" ~                .platform_data = &da850_evm_tl_leds_pdata,
6 X4 v1 |5 a: v( r                .release = led_dev_release,/ l  s/ V9 {8 p: @) L1 K  Z
        }) S. \& p3 [# |; x( i0 L
};
. g* F9 f% g6 V( ]1 a! ]9 t6 M2 ]: e) L5 I0 T3 w
static int __init led_platform_init(void)9 V/ N. p- u$ D: c: z
{4 p1 Y$ A6 H0 Q4 L4 B
        int ret;
5 y) k+ |6 G. p5 p#if 0
* l) n+ B. E& h! p        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 \% l- U3 a& d! T; w5 {* o        if (ret)
" r9 ?  [, `* O3 ^+ @! j! X                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", l  P. |+ t0 j3 F+ p% }
                                "%d\n", ret);" u3 a6 ]2 Q4 I# O$ ?, O7 k
#endif- m' ~; a% z& Y. P, x
        ret = platform_device_register(&da850_evm_tl_leds_device);- g8 C8 D! R9 m+ Y. f4 f
        if (ret)
3 v* F, `) N* ^$ o                pr_warning("Could not register som GPIO expander LEDS");7 s* y: e* m- M% e
        else+ [1 |+ e6 f+ L% R" `, I* o. Z
                printk(KERN_INFO "LED register sucessful!\n");) S  \4 J0 q5 ?
; I/ s- V: a. b# S" l$ L1 d, T
        return ret;4 T9 A( J% h& A4 Y1 w
}1 p& B" f; J  x) o8 n2 d' {8 |2 F0 j

! x+ t9 }5 }0 |! \5 X* [) [0 K; Cstatic void __exit led_platform_exit(void)
- r1 a# f8 @0 V2 B" G  D- e$ w, G8 O{
5 J8 c  y4 l9 g. h. p        platform_device_unregister(&da850_evm_tl_leds_device);
# T' s; ~( t2 W, g! M! [
" b+ _! \6 c0 S" A8 y  s        printk(KERN_INFO "LED unregister!\n");
! r/ S3 t4 s5 U}* }* m+ y* x' K% n

, _/ p7 r: \, V+ S) ]& }, R9 s4 \module_init(led_platform_init);2 J( g! }4 l1 w# t/ H9 O6 A  K
module_exit(led_platform_exit);6 E; o+ P$ K3 q; q+ `+ @

* W2 @+ c0 W" n) N3 L! A. _; N; i7 @MODULE_DESCRIPTION("Led platform driver");
9 Q! k* o3 X+ i3 T+ G6 c; IMODULE_AUTHOR("Tronlong");
% B, t, A. a* i0 f2 K7 eMODULE_LICENSE("GPL");
0 e# _9 a, i+ }. T0 ^( E! E
8 e3 z3 C% R7 ?" @4 K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-7 06:17 , Processed in 0.040467 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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