程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
+ z$ h  r! _" _# R" J! g#include <linux/init.h>; K  S1 V( z( _* m: C
#include <linux/module.h>$ ?: R: m% `& Q$ e
#include <linux/kernel.h>  t; z; p4 s& v3 `+ z/ `( S7 V
#include <linux/types.h>8 t+ V! @! _" ?% \! T
#include <linux/gpio.h>6 ~7 B5 _( ^* a! b2 o
#include <linux/leds.h>- p3 N$ p0 _, ]! U; s
#include <linux/platform_device.h>
- V' M0 x; `# j4 P. y& d& \) a% n( l8 e& `
#include <asm/mach-types.h>. f9 h: O5 J. m3 a) p4 U
#include <asm/mach/arch.h>3 o: g$ g7 z# x. S. B" Y, g
#include <mach/da8xx.h>
6 O8 s9 G! i: e#include <mach/mux.h>
' ?4 k# L; r4 Q. m
% ^1 [1 }+ w" [! Q& o#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). Q1 Z" _9 N5 ]) e& f
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, D% Z8 }) I' A4 E5 R3 v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 d- q, b+ n# X9 S5 B7 N5 K
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); X( V* P/ r( P6 Z! w/ R6 S/ V
. u/ ?; u: e6 e- c' p
/* assign the tl som board LED-GPIOs*/
; |2 p+ N; s- g( O, Kstatic const short da850_evm_tl_user_led_pins[] = {
0 d& V( a8 N9 A3 S        /* These pins are definition at <mach/mux.h> file */& P: H/ i0 f4 E( F9 I- U
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! {1 z/ k: h  D' l  R5 |) s; f        -1
$ e7 n! v9 B# f/ R3 n};* N% M; n- I, x5 ~% s& l/ b
  T# c/ R  {3 l! W) g4 k
static struct gpio_led da850_evm_tl_leds[] = {
* T" a' u* \  l; C1 w+ O# q# B* a        {: `/ g! Q' v1 D' f# x4 Z8 [
                .active_low = 0,6 E+ h! W# Z8 |/ R2 m/ r6 E
                .gpio = DA850_USER_LED0,+ d7 }8 A: d2 U
                .name = "user_led0",
! b1 n. |2 E, O* h0 h/ {+ c" m/ j                .default_trigger = "default-on"," k% s6 H9 V% L* n; T
        },, y6 q# M8 B, M0 A1 N- F
        {% i6 c( M  |; ?/ c
                .active_low = 0,) R* l$ G: s0 ]
                .gpio = DA850_USER_LED1,
& S! N6 V6 z& V/ z( m0 Q                .name = "user_led1",
9 e5 h. V$ c2 a: ]8 w# _" e                .default_trigger = "default-on",/ ]+ v1 x  t: H7 M# D
        },
' T; z8 D0 A1 C1 q        {5 q7 T  d- z" x* |1 |& k% k
                .active_low = 0,. J' b2 \# T! j$ x
                .gpio = DA850_USER_LED2,8 b6 g/ I' _( ^% R
                .name = "user_led2",; b* b- d5 n  ?* D
                .default_trigger = "default-on",; R' N* K& o0 _5 f2 P/ b
        },
3 ^8 U5 `0 }& a4 e" ^. i+ g        {
+ R/ t0 x4 n9 Q! [/ m                .active_low = 0,- P% Z3 O8 Y2 k# T
                .gpio = DA850_USER_LED3,& o+ F6 q$ v4 l; A: f4 k1 ?' s" V
                .name = "user_led3",
5 F4 `  H5 q- {* a3 \  t* [/ O                .default_trigger = "default-on",% e# z- f3 _8 w- T5 w# ~. i  I1 f
        },4 {6 {% M1 W' X; y4 V4 b4 Z
};# Z7 h; ]1 n' h

  S1 `9 F5 Z: z; i1 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; K6 `: d; P0 Y        .leds = da850_evm_tl_leds,* M: @7 k1 C% q. x, M; z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 Q' ~; R, z2 [% Y: t# f- n
};
& q% W! i8 L  I$ x9 h0 z1 O/ Z- v- k. n! G. R" L
static void led_dev_release(struct device *dev)6 J) r2 ^+ l  j& Z0 ~. P
{  T( ?# p- v) j/ m7 s% k
};
" [# L' j3 M- D  n* {, u! O8 `3 `! G3 c+ q
static struct platform_device da850_evm_tl_leds_device = {
- |# p# |6 h/ V        .name                = "leds-gpio",
: c! q2 ?8 E" Y5 U* i        .id                = 1,4 P3 k+ i7 B# A2 `
        .dev = {! ^8 c: _2 J/ ~. S4 s7 G  O
                .platform_data = &da850_evm_tl_leds_pdata,7 C' y# R+ Z1 X, J2 H% E
                .release = led_dev_release,
4 g9 j5 n  D' [' j        }: T3 o% ~! Z! S5 o
};$ [: I7 _; V' H
5 I' l7 _( |$ _) a. _0 t: n. {
static int __init led_platform_init(void), z) g- b$ A, E  C) e
{
% F8 R& f- r7 [9 x        int ret;
  C' c, C2 [2 U% V3 _* E5 `#if 0! b0 o4 E) c6 k, Y! U& A
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: s. S) Q: U3 Y4 a
        if (ret)5 Q0 J6 `  y& U5 W  m% V( F' y
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 ^# ]' s7 X- U, |$ q! [: O                                "%d\n", ret);
; S7 j1 Z4 G5 W' D$ e' s; A* V4 n#endif
. p; X5 M8 A- D+ r1 b2 E5 q        ret = platform_device_register(&da850_evm_tl_leds_device);
* Q  P$ q3 v- C8 k2 Q        if (ret)
4 [5 s3 B( M, |; Z/ ~5 O9 L                pr_warning("Could not register som GPIO expander LEDS");2 ^1 K1 x$ [5 m+ L# m' ]
        else
; d. s+ R& a$ Q4 r5 R8 _4 s! m                printk(KERN_INFO "LED register sucessful!\n");
4 E5 N- a6 ^' u# Z' |# g
2 W0 ]8 @  o- v1 r2 A/ i; y        return ret;
& k+ ^: Y6 }- O; P}" o  s. F' b2 ?4 @

& p2 ~4 W  v4 S* O# Z/ y* F2 V9 lstatic void __exit led_platform_exit(void)8 n5 W! y3 b. C- E* u' p
{5 @6 k; {* V9 k, O3 _
        platform_device_unregister(&da850_evm_tl_leds_device);- j: K: B5 H# a: t9 ~7 B4 V  o

+ `1 K* Q6 Y9 `2 u9 H0 N, s        printk(KERN_INFO "LED unregister!\n");6 x* O& F( w1 `, d' Z3 q
}$ i# `% A+ a( }
0 L' C5 W0 f3 C  c: z4 E
module_init(led_platform_init);& j6 f2 \+ K8 ]8 M/ n- h! _
module_exit(led_platform_exit);5 h' W) d- J5 b2 M8 o9 i

8 J3 l% B. ?$ t6 X( \/ X* WMODULE_DESCRIPTION("Led platform driver");
: N4 U6 }6 }" P% U+ Q# EMODULE_AUTHOR("Tronlong");
7 F& p7 Y/ n( Q6 n/ aMODULE_LICENSE("GPL");
* o& y0 u: f: Q" d1 g, a. k4 s
( f/ k; X6 B6 H$ ]  p1 I# X, w
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-4 10:16 , Processed in 0.034429 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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