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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) {) J, T5 y4 ^6 h5 Y1 Y# U; X( r#include <linux/init.h>
, H' K8 L3 V6 z2 a# E* I2 `5 J) g" e#include <linux/module.h>! {, C( D) b7 `) q
#include <linux/kernel.h># q: L9 A: M. S6 T: \4 G
#include <linux/types.h>& h- |$ K1 j7 V% t4 i1 U8 c( e
#include <linux/gpio.h>
. r+ Y/ ^; l8 S% G$ W% d6 G: T#include <linux/leds.h>2 K8 S+ A3 c8 K* j$ \! N
#include <linux/platform_device.h>1 N: h! u6 c' W8 m
' j3 ?. g$ f7 ]2 p# u4 @$ f
#include <asm/mach-types.h>
7 V2 `) T3 b: b* n6 _#include <asm/mach/arch.h>6 d' W, ]5 Z6 P, F0 V! f: C
#include <mach/da8xx.h>( V9 _3 L3 b  a6 J. C! v2 x  l
#include <mach/mux.h>5 Z  K; x( M4 k; o  O' i& @" z

  E- a. z9 b4 _0 ^* e8 j0 B#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)& l) ?" i, A$ H6 P  |
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" u& {. e$ J( f# g#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, y; z5 E4 Y7 R+ U4 ?#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# j- B) V! c& p7 r# u- J. Q, l$ |4 L; m
/* assign the tl som board LED-GPIOs*/* p- u% a7 o8 g' w) a: g3 y% _6 N
static const short da850_evm_tl_user_led_pins[] = {8 J* ^7 e( g4 n3 r! K- \
        /* These pins are definition at <mach/mux.h> file */: o, k, C: T# b; L' h
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! e8 c5 ^) r9 ]! G" V% O
        -1) m6 w0 q( h' r) [
};7 m2 o! a* U  U0 m
# e) Y9 n" a  j3 }2 C4 _
static struct gpio_led da850_evm_tl_leds[] = {* \3 V; d. X0 R/ F
        {
* G$ e& k& ?$ C- {; Q  [' R" t                .active_low = 0,+ [7 M8 o5 a$ @& r* l& G
                .gpio = DA850_USER_LED0,
: H, a3 e1 l- T8 k+ n                .name = "user_led0",
0 ^9 K. l8 {% \7 K* ^                .default_trigger = "default-on",
( T  }7 [6 K" p5 ~- ^3 `6 f        },
$ o  Y, j. Z8 C* d) c        {, K/ K! o* U. y& D2 b7 B
                .active_low = 0,
* D0 W- b2 l! Y1 U8 K                .gpio = DA850_USER_LED1,- C# u+ l/ i0 b* ]+ ?
                .name = "user_led1",
. m$ u/ s$ ?: o9 R( o8 Y                .default_trigger = "default-on",
4 p. A8 N1 {7 K* x        },1 X. C+ ^8 [; g  e! m7 [$ x
        {
$ I# C- S! T! H2 @: f                .active_low = 0,4 b9 T1 \" ~+ G
                .gpio = DA850_USER_LED2,
: e: \* a) Y% q% T                .name = "user_led2",
3 Z0 ]0 h+ t! O; M5 Q7 k0 F                .default_trigger = "default-on",5 h7 w7 u2 z$ w6 }$ K
        },
$ j- \( E1 c7 J8 ?% }        {
. m! C6 `' j0 w/ Z+ {. c, ]# K                .active_low = 0,# n& T1 ~# X. N* x
                .gpio = DA850_USER_LED3,
6 S+ D! V7 A- [3 D                .name = "user_led3",6 B' G! A3 {1 w% Q8 S- U' e/ D
                .default_trigger = "default-on",1 k% l8 v. B# g7 C2 U" o
        },
1 {: V+ O& W3 f* u+ D};% }/ a5 S& U! t% Y: G. z8 B
5 X6 m( x( P" m1 ^$ P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 ]6 g7 Z. W* U
        .leds = da850_evm_tl_leds,
; h) Z. r: I4 V& `        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, X$ n) @+ n0 W, L2 N7 d" v: X
};7 t5 v" n2 K. }, _% y

3 R9 k7 [! Q( V3 ?% N5 X6 e' \; o: Y/ ~static void led_dev_release(struct device *dev)
$ Y( O/ n8 ]1 x# s* @7 Z{* j  Y) R. J. p. ^. p- J/ b9 S& l3 v; c
};
/ s  m$ }: z2 s7 G* Q3 Y7 Z$ z7 m' o1 l' k& f7 b9 d
static struct platform_device da850_evm_tl_leds_device = {
: |- T5 F5 P1 k: l0 w+ z        .name                = "leds-gpio",
+ \: u, v7 D3 {- ~) Q0 w1 O0 p        .id                = 1,
7 }, M8 D$ G) N0 m& @7 l4 I        .dev = {
) v3 {" D8 C1 k+ }                .platform_data = &da850_evm_tl_leds_pdata,
1 @( f# x2 a) {* |4 c                .release = led_dev_release,; f+ s6 b+ J- R* y! z! O! h* `
        }$ d" ~7 S: ^0 y5 Y# ?
};& h1 O# y( K& A/ t% C2 B

3 E) p: b6 {% |static int __init led_platform_init(void)5 {' h1 O; F* x" @5 H
{. v" ]# z: L) {+ W, {; d; D
        int ret;
- `3 k2 o+ p4 R# \0 |* C1 K% ~1 j, w8 `% r#if 0
: C( b" ?* q. ?- a1 `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ ~4 D4 O' [. m/ @4 U+ s- i- A
        if (ret)
, q+ a; f" U" ?: v! h                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 _0 _- v  b( q7 j; D% M5 p                                "%d\n", ret);
# @# k0 R' h7 Y, R#endif
, Y/ w! [, C* T8 S4 I! E. H        ret = platform_device_register(&da850_evm_tl_leds_device);" p8 ^: N5 x" v" [8 A
        if (ret)
# X6 q; v' h6 B( V: V4 B  S                pr_warning("Could not register som GPIO expander LEDS");
( n, J) {5 f7 u3 @1 a" r5 B        else) @% q- j$ n( ?. s7 _( z
                printk(KERN_INFO "LED register sucessful!\n");, e: p) C5 V( i; B; S' f
& t  i& c: I- M1 {& E# w- ?' F3 E' E
        return ret;( k. k0 J2 G3 _( F, V2 {5 I
}/ L, f: s+ z) P0 ?
- D* _. q: R  v2 `! V% r" i+ `4 N
static void __exit led_platform_exit(void)
5 O5 c$ a8 u' V: n5 N* V{
7 Q) A/ [) y! D. f5 F$ L! w/ c        platform_device_unregister(&da850_evm_tl_leds_device);
- J6 X; a7 {. |# ?9 K" W6 [! w! q6 c+ U8 _3 i6 I# z3 J1 ~* V8 j
        printk(KERN_INFO "LED unregister!\n");2 F2 D; ^( Y9 w/ F0 K0 }
}% H% }- ~2 m9 p7 m9 \7 |$ C

% y9 a, h! t! q1 W$ l8 g' omodule_init(led_platform_init);
, N# I7 x( e2 F+ z0 rmodule_exit(led_platform_exit);" g5 P/ s. o3 k

, F/ G- J8 n( X/ ZMODULE_DESCRIPTION("Led platform driver");
4 f1 G- L- v( l1 iMODULE_AUTHOR("Tronlong");
2 ^, u8 D+ B, A! `8 K4 `" }+ YMODULE_LICENSE("GPL");
: b$ {, \) k- U, _
( y1 L" j' ^( }6 E" O
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-3 05:27 , Processed in 0.042360 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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