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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 S0 \; _2 ^/ L1 A. x& G#include <linux/init.h>
7 A# L1 K$ G; [#include <linux/module.h>! c3 ?9 \1 v$ W: V
#include <linux/kernel.h>
- Z. H# ]+ ]! e) q2 e! B/ Q#include <linux/types.h>
" p2 b2 G3 n* h  R; b# h2 z#include <linux/gpio.h>2 c2 R) s4 ~) D& L
#include <linux/leds.h>
- M: S( h6 q2 C2 D, o#include <linux/platform_device.h>
) c8 x3 @% P6 n6 f1 {4 S. N9 r% W! G. g% c5 Z* {
#include <asm/mach-types.h>7 p: a6 ^1 C, ~
#include <asm/mach/arch.h>! c( S2 N- F' F4 z* s% |! A/ |
#include <mach/da8xx.h>; E+ }- h; ?! F: V0 n/ H& j9 D, ]
#include <mach/mux.h>( |6 y" q2 T  u

  u( w! E: d& I( o1 G#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; \0 h- C1 a( z3 l: o; l3 s#define DA850_USER_LED1        GPIO_TO_PIN(0, 5), h+ k& L6 j6 C! l5 ^+ x5 z5 Y- G7 H
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 N2 c, t  V% M( B; |4 n#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 V$ v6 i( s/ A# i* F/ M

: j+ ^' Q0 f+ w: O/* assign the tl som board LED-GPIOs*/
/ @/ N7 `6 ?5 m6 j9 |9 Ostatic const short da850_evm_tl_user_led_pins[] = {9 r# P4 p, z. e: y
        /* These pins are definition at <mach/mux.h> file */
4 g5 ~( i& ?0 _: S" r        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) h, l+ n9 V: Y- ?: c        -10 Z# e" ?$ [9 @
};
" [2 a/ b' K  h% |( R
% u( i* ]! p) A$ E; ^0 Mstatic struct gpio_led da850_evm_tl_leds[] = {
, O* o- _: P6 X( z. _        {) V) o, r/ x% P: Z+ e
                .active_low = 0,
, C+ z2 w2 O/ t) }+ u! G, t; b7 N6 Z6 l                .gpio = DA850_USER_LED0,/ M6 ~3 {) l( t# J, F& ?
                .name = "user_led0",
+ B1 g+ P9 b. k                .default_trigger = "default-on",
: y, u* R' r# E8 P$ g$ X        },) T; C  u! z) }$ a
        {9 I3 ^: Y& M, X
                .active_low = 0,1 @+ \6 ]" `- q. _
                .gpio = DA850_USER_LED1,6 B5 m5 ]& }& F
                .name = "user_led1",
+ A8 D" z8 U4 C3 `                .default_trigger = "default-on",! C$ ~( g* V' A6 @) L& L
        },6 N" ]7 F! p& Y( [: U
        {5 [, W# {! @0 ]
                .active_low = 0,
" I$ c# k" V7 O                .gpio = DA850_USER_LED2,/ B- V! t8 o+ D1 t0 G
                .name = "user_led2",2 h6 x, E! X) N# _/ \# p
                .default_trigger = "default-on",0 L0 s) p0 w2 l0 ?2 o) F3 }5 S! d$ Y
        },
( k9 |( F6 X+ F) z5 x- T8 s5 _+ ^        {
0 u1 B# q2 W: n  |4 g. Y/ j                .active_low = 0,
! L. L' X! k; A: M+ u$ [" B                .gpio = DA850_USER_LED3,
' ~1 A+ s7 C1 g% N                .name = "user_led3",
1 `$ q9 O4 y9 r: L% x+ ~+ c                .default_trigger = "default-on",
; I3 Z, }5 z  i& B; P1 D        },3 v7 q9 V, Y+ o3 W& T
};
2 T3 g' [6 o% I) }# M  z0 Y/ O" g4 L% {: K$ a% T- h/ K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! ]+ @% B* W: O( \3 f/ J
        .leds = da850_evm_tl_leds,
4 l* m0 @6 C- p7 W7 n' Z* e8 W' N        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 o% w; }. a0 z: {' y4 N
};
: B7 i& M  X# [. s: j+ l
% P9 o3 {! l3 u7 F6 Gstatic void led_dev_release(struct device *dev)
1 J9 Q( f; K; D( }$ ]9 {{
* h; |3 ?+ ]& {" @% n};7 {) _; N4 v6 o+ G3 d5 U
8 ~6 F  U$ |+ s! z9 V7 O8 d" U
static struct platform_device da850_evm_tl_leds_device = {4 ]% J, F( o7 J$ @; }* k
        .name                = "leds-gpio",
! b  q9 }$ y- U& {0 R        .id                = 1,
6 q# z9 q' ^) e4 S        .dev = {3 _% y1 k0 b; k
                .platform_data = &da850_evm_tl_leds_pdata,. b2 q: C8 s: ?- V! W# [
                .release = led_dev_release,8 E1 _. e6 H# f0 Y: ?% Y, u
        }
0 S& f9 A, L9 }6 m# n};4 @7 z' V0 v4 [2 |8 T# d

# r' \% Q/ }; }; J/ ]0 W* ystatic int __init led_platform_init(void)5 D$ |. e3 n9 c) ~+ c  q6 U$ r
{
) z, m0 Q" v. c, {2 I        int ret;
- j/ I) y5 l7 t# k" c$ i1 Y1 m#if 00 w, O1 G4 W1 H9 o& ]
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 t8 f4 m4 h9 W        if (ret)! H5 z1 @- f1 z, c: L; H& k
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 C( E4 a( B+ Q! ]8 F
                                "%d\n", ret);
  `5 L$ g. s0 Y9 `3 {- O5 @6 V#endif9 d, h4 v, f. u' V
        ret = platform_device_register(&da850_evm_tl_leds_device);
; N1 T( c1 x6 ]8 m) O# _$ k        if (ret)
; ?3 d& g" ?6 d                pr_warning("Could not register som GPIO expander LEDS");
0 `' Y& }% |+ Z0 C        else
$ Z' a1 a& k! o" t% e+ j/ n0 M4 e/ i                printk(KERN_INFO "LED register sucessful!\n");4 l9 s! O. H0 n. x

7 t8 [/ q/ S* S, N3 R+ N        return ret;1 Z9 S) W" E3 j* v& T0 f
}" R8 b; ~3 u9 a; g8 _! N
5 A! _3 i( [2 m
static void __exit led_platform_exit(void)" w8 E8 N  y" o/ L+ v/ j
{& |" j8 ?+ f" [3 w+ ^+ ?6 X  z5 _
        platform_device_unregister(&da850_evm_tl_leds_device);
, R* u2 N& c, E+ z9 i; H: r3 A: [$ ]/ A; l: O8 f# v) f
        printk(KERN_INFO "LED unregister!\n");1 k% l4 V, O6 c
}
" @$ E* ?+ R) s6 G1 |) J6 v4 B& ]2 @9 S1 I
module_init(led_platform_init);: b+ H7 Y6 c; V/ i" x- d; i
module_exit(led_platform_exit);
1 w" N" Q- H! p0 A% Q) n
; j, V1 x+ W0 EMODULE_DESCRIPTION("Led platform driver");8 g! Y  [* R' C! O, k
MODULE_AUTHOR("Tronlong");, R% l: U9 A9 |5 u7 K
MODULE_LICENSE("GPL");
+ ~+ m- P0 o: b+ y  H- d) q& x5 E8 @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-24 20:07 , Processed in 0.040702 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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