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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- i8 B+ l$ p6 K, I4 H
#include <linux/init.h>' |, b+ F1 a4 b$ U- E) U9 z) V
#include <linux/module.h>% ~  g0 O( V- T6 H1 b7 [
#include <linux/kernel.h>
: F$ `3 a/ j6 l& k: Y6 f3 V#include <linux/types.h>+ B# w) _  H' Z
#include <linux/gpio.h>
: v  W* [2 M. }#include <linux/leds.h>- i  N) Q# T& v' C
#include <linux/platform_device.h>6 e1 X) e# b" y6 B# O+ v7 G: c" Z
0 B( b# C  @; K4 F- C2 N
#include <asm/mach-types.h>% e3 G4 F9 C) o( Y
#include <asm/mach/arch.h>1 }4 U" c. j8 H3 }8 N
#include <mach/da8xx.h>' r' b6 q' ?. O* J+ p3 |' S; |
#include <mach/mux.h>  }: k0 G0 y0 y4 ^0 R1 ?
9 b: G, x% e2 f( P* g& W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)* z" i5 L# }2 v$ [+ x7 U
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' v# B1 x7 Y' L0 T' @  Z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 a% r- P  v6 W4 B( F0 v1 a9 a1 {#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)! A# n& a( r3 F  I+ x' ~' d
% d8 {; P7 M& b1 N- [
/* assign the tl som board LED-GPIOs*/- x) M1 ]8 q/ C# \. _' o
static const short da850_evm_tl_user_led_pins[] = {& N* h9 i" b/ D* U
        /* These pins are definition at <mach/mux.h> file */
( H# Z  C  c9 I2 `7 V        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# q7 k2 a$ Q' p: @- |
        -1
' b4 c9 o5 V9 I+ `};, y5 M6 v8 ^7 ^  o3 g; E

1 Z! q# c3 K! R7 i2 S3 mstatic struct gpio_led da850_evm_tl_leds[] = {
8 k* ]: v2 z" M& `' m; s' i9 f        {
  d! q  u* \5 y) M! }6 t$ b                .active_low = 0,$ M7 G0 m" l, a& v/ n! g2 e
                .gpio = DA850_USER_LED0,
* I; ^4 e7 v1 t2 f                .name = "user_led0",
; c+ l: x( q: b' n                .default_trigger = "default-on",, z9 P7 e6 j" B$ u
        },
$ \* p# c4 H% y( G9 s$ V3 N5 V        {+ [) F" x7 R/ \! G: |6 p
                .active_low = 0,
# [: V7 o4 p" f. Z4 s8 U                .gpio = DA850_USER_LED1,
" }* v7 f% |+ n  k2 V# ~1 r0 e                .name = "user_led1",
7 U" Q$ \2 r3 w3 R- i                .default_trigger = "default-on",
6 k' h  f/ F5 y7 u        },& k, q6 }' y# n4 j$ ~
        {# S$ z' d  t' m4 L
                .active_low = 0,
9 [/ @7 W0 F. I% z9 [6 G                .gpio = DA850_USER_LED2,
5 B: Q- T. |; v1 I" A7 r) b                .name = "user_led2",
* Y. E' N' a. x! q; K; R. t! ]                .default_trigger = "default-on",
+ t3 v- R8 d6 ?. R+ I        },  @7 \8 }" X* X7 v6 @* \* p% P0 G& I
        {
" {6 U# |1 H( o5 V+ i5 M- m                .active_low = 0,1 N" B5 B* q7 w/ a8 V
                .gpio = DA850_USER_LED3," F5 O' t( w2 F/ w" J+ g7 ~
                .name = "user_led3",
$ C1 u7 z; N& V4 R8 m                .default_trigger = "default-on",' x: ]' v# i# b
        },
: `- N( E3 j9 d/ v& d};
: B1 f! C' ]) |, ?/ N
; w  Z  j! ~) jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ H2 v, |/ a/ C1 @
        .leds = da850_evm_tl_leds,, G0 H* V7 s5 ]/ p8 b4 d
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; ^2 |* M! m) z' i6 E3 o
};
( y6 Q/ \$ B2 L$ P; [0 [
6 c( S6 I7 a4 j! Jstatic void led_dev_release(struct device *dev)+ j4 y* M! {  b8 D7 w: W- q8 S
{4 H) @( o' E* _% Z2 J# z' x
};
5 [# D0 f" k7 y: ~* n$ J. [/ R
& X& V" \) b4 R( E$ L9 k# }* K$ zstatic struct platform_device da850_evm_tl_leds_device = {" c2 w" C9 }) b
        .name                = "leds-gpio",' \# l9 ?$ L5 @  j$ }2 q
        .id                = 1,
1 c! [4 R6 {5 x- d        .dev = {
) c2 d( M; K' k; S, t; ~                .platform_data = &da850_evm_tl_leds_pdata,, {+ W1 G) y* a$ l: _
                .release = led_dev_release,5 I7 O' ]) z( L6 h
        }5 i/ T% z, d5 u" n# A5 B6 R
};; m% @" `  D8 V$ z$ D( ~

& g5 y$ A: I) ?6 ]) [static int __init led_platform_init(void)
+ \8 U1 y) M4 {; z) w{
; V, M5 p. S% i7 Z0 c5 m" V        int ret;$ A. S8 W' W- T# Q4 A% c
#if 05 b! f  D/ a1 K! t" u) J
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 w+ o6 u  f9 b! q1 L) i        if (ret)
( I0 ?8 H* h3 q: v8 |                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" w7 p5 s2 h  u. a1 F
                                "%d\n", ret);' g1 E, w1 s" |  [0 H
#endif' R4 S6 U" C; m7 r& J
        ret = platform_device_register(&da850_evm_tl_leds_device);
& h9 o: ?$ P2 P7 K3 p, W5 t, C* o! i        if (ret)/ {9 o5 n/ ^& N. s0 }
                pr_warning("Could not register som GPIO expander LEDS");5 |2 @0 X& A9 y7 ]6 {! f
        else
0 Z8 P# ?& R5 t% p# s; E                printk(KERN_INFO "LED register sucessful!\n");. l% P  ~1 Y% e$ E8 i

/ h  K% g8 [; k        return ret;
) W& @6 V2 J9 K5 ~" d7 W}: c; d- E$ R/ a& O

- A: w* a) n$ A! ?) j8 A2 sstatic void __exit led_platform_exit(void)9 C. q; L2 I. C9 t& ?  U
{0 w" ^3 h3 e/ t
        platform_device_unregister(&da850_evm_tl_leds_device);
7 s1 X/ j7 }- Y. o6 q9 W3 {6 _6 n8 l* a8 ^% P
        printk(KERN_INFO "LED unregister!\n");
1 `/ A% r7 d+ L  a8 W8 O}
% C- m% P% F2 c3 V4 f) p+ l# `+ z5 A1 w5 j
module_init(led_platform_init);
- e, {" c" _, D. a  ~$ Pmodule_exit(led_platform_exit);5 m# \. t: b% I: V' c

- m0 v7 Y: I9 e' t7 o; ZMODULE_DESCRIPTION("Led platform driver");
7 M) m: j; k& d9 _, o: v) Z* a! PMODULE_AUTHOR("Tronlong");
, f, B; h6 [/ h9 _' a/ JMODULE_LICENSE("GPL");
/ I/ ~: u+ M: C# L
. Y; |$ v& d/ f3 k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-26 00:15 , Processed in 0.038804 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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