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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* Z# F  D, ^- V6 O- N0 @& ?
#include <linux/init.h>+ C  g: A: F" v" q+ S0 d: L
#include <linux/module.h>; T0 i. z6 B/ h+ v# _* y8 H
#include <linux/kernel.h>
9 d3 J, F2 b. C2 r- x. E$ J# K; y#include <linux/types.h>
: o/ C) @( N( [. q% L#include <linux/gpio.h>
8 |' q) r# h; ]" j+ ~; k#include <linux/leds.h>
5 N1 n8 _3 n9 |. M+ T#include <linux/platform_device.h>, ^5 j1 Y: E7 @5 I! G% K2 M
5 Y. L5 X( Q5 e; ]
#include <asm/mach-types.h>
2 [+ U) E7 H" x; N2 Y2 [#include <asm/mach/arch.h>, ?3 \: H/ T5 U! u9 O8 ^: \
#include <mach/da8xx.h>. a& ^2 O2 `9 ~$ Y; r' d3 ]
#include <mach/mux.h>) ]7 t& z% e5 q+ ~# S

9 ^0 `/ {1 O& G. R6 z1 p#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 j4 d: l" p4 u4 W2 k#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)" \: G/ W& J9 R
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 D! {* K$ d9 I& E#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). B/ O! s! G" R$ R' o

% Z2 V& K- E% I( R7 g/* assign the tl som board LED-GPIOs*/# U) W, O+ x4 q# }/ Q( L
static const short da850_evm_tl_user_led_pins[] = {
3 S( P( r/ e- H( }# ]9 K* R        /* These pins are definition at <mach/mux.h> file */
4 v1 y4 g. m! s  t. D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 u- J3 k, _' y" y( h
        -1
0 _9 m, C& X! M/ j8 P  ~};, k" H, c, \9 k4 [) B
9 d& X  N& J. h/ i: W: R6 k
static struct gpio_led da850_evm_tl_leds[] = {" ]; j- A3 Q' h. M
        {
% X, W& g) |8 |& @/ ~                .active_low = 0,
* ]' M0 @" {0 B2 q& c4 j                .gpio = DA850_USER_LED0,! @9 d9 e% p8 ^) ~
                .name = "user_led0",
* O) R; K9 l& v" x! A* {                .default_trigger = "default-on",
9 T/ U9 s" M+ l- V% ~        },7 Q# d6 S- m: S+ Q6 f. w) ?6 h* \% u( I
        {' S% s2 g9 z: G2 X5 J; F# x0 P
                .active_low = 0,9 R* k: A1 S2 r( C
                .gpio = DA850_USER_LED1,
/ F5 E, o& [/ v  }5 S                .name = "user_led1",
& F  ^. I) }: ]# U/ m/ r4 I6 [                .default_trigger = "default-on",) f2 [$ F' {. f
        },
4 E9 b' {/ O+ F( R        {
, I' O6 b4 E6 V! v                .active_low = 0,( J: \1 Q' I( ~: K2 L; o* e0 A
                .gpio = DA850_USER_LED2,
6 }) S5 _6 ?$ V4 p8 y                .name = "user_led2",
: c+ N' j/ O! B9 h1 a                .default_trigger = "default-on",
  K# F$ V* C3 M8 J9 C        },
- @1 y, v2 n1 ~/ b1 Q3 S+ _! n1 u3 J        {" x, v0 t8 Z# \0 ]% y2 Y
                .active_low = 0,' a/ Q! ?; B: G- j- G
                .gpio = DA850_USER_LED3," k% Z, o/ X, b5 h. N% _
                .name = "user_led3"," n& u) N$ j' P6 \2 x) K
                .default_trigger = "default-on",
7 R* J- }5 s. @& J! U! s        },0 l: s$ O5 w4 b
};8 }& s! _0 }) X/ m, I
* o( W: m0 u9 R8 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# d7 O& a! H: E/ s3 p        .leds = da850_evm_tl_leds,$ ~8 Q9 f7 Z+ q+ Z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, i, a) }% o6 @
};9 M( K; }, i' L6 B; {6 H

3 b1 Z2 V0 r* w6 rstatic void led_dev_release(struct device *dev)
) ]" F' E# b8 y{9 |1 z5 H( f: P9 [0 ~9 C' ~* N
};' l/ M7 o, C) r
4 x% P8 V+ H6 W  F. G9 i
static struct platform_device da850_evm_tl_leds_device = {) z; }+ r, b; R6 w- G; x- v
        .name                = "leds-gpio",
4 J, H$ m( O* l) y4 ?- S  P        .id                = 1,
1 q: B# M+ N$ n9 f- _+ @" T. @        .dev = {- ]; q/ V( |2 E- V% V% h1 F
                .platform_data = &da850_evm_tl_leds_pdata,
. K0 c8 B# B3 _                .release = led_dev_release,
+ V! T& n5 e4 [        }
# C; _3 s1 J/ I" y" l; m};! M( K# i! L! I& A, |  e

$ y3 i9 j6 P0 n0 A# nstatic int __init led_platform_init(void)
( J9 c  Y5 o, p/ `$ s7 t{- P1 W0 C: }$ M% I+ Q
        int ret;
3 `. N, h! R) O5 }#if 0  |! F# T2 v, t5 K) G4 R* }" t
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 K! Z1 i: g- D6 I# q+ U% s7 d        if (ret)
" `5 H+ i+ y  v9 S                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 ^, S, T- ?2 s0 K                                "%d\n", ret);
" \, Y% G+ r1 Y! d) d5 f3 y#endif* `. D+ I. P5 A; Q4 F8 O
        ret = platform_device_register(&da850_evm_tl_leds_device);
2 T5 O6 |5 I* O7 P# W        if (ret)
  z6 i7 k6 ?/ {( m  R                pr_warning("Could not register som GPIO expander LEDS");: o6 p3 D7 a% _+ v
        else6 X1 r9 g7 {" _' p5 H8 t! R7 g
                printk(KERN_INFO "LED register sucessful!\n");+ i7 \! a9 }0 y3 }6 ~  Z. s

. \; j9 k% d' b; D- \        return ret;
0 S2 v2 i3 i6 y9 h+ |2 p. e}
. c3 @8 a( ?* w( U' I, e7 j
8 c2 a6 W6 w/ e6 T- M' g8 q9 b0 |static void __exit led_platform_exit(void); J( _3 w/ X6 l0 W
{
- Y1 h+ [" _. Y8 ^! n: s; u        platform_device_unregister(&da850_evm_tl_leds_device);
2 c% R/ e: y9 ]& _  Z' Q8 h
, ^& O2 f& z% c* L        printk(KERN_INFO "LED unregister!\n");3 M" f' U: a/ ]: q* \
}$ h" r# d, Z3 ]) F5 n" q3 j

6 o! \: y% x! I5 y2 F0 {) ]module_init(led_platform_init);
* J: o$ o( `$ T  C0 F9 ~8 gmodule_exit(led_platform_exit);
' E' f& Y2 M2 m  I! q. K+ H+ R
+ P7 I$ ?5 A; \6 r1 JMODULE_DESCRIPTION("Led platform driver");- t  f" y: u; N3 h8 f' m& q8 Q
MODULE_AUTHOR("Tronlong");4 X* w1 E; [1 W6 [) z7 ]5 z7 n. e
MODULE_LICENSE("GPL");
2 g* J! O$ Q' t- z3 `: q$ _7 O$ X! k8 l  j: P/ J% _
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-10 10:04 , Processed in 0.037966 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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