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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 s( a" S$ S0 D( s% L5 ^
#include <linux/init.h>
# Z7 f7 X6 m' m4 V6 Q+ k' {#include <linux/module.h>
; {3 V+ Y2 P9 a3 S4 I#include <linux/kernel.h>+ X2 \6 L  e& f. r) c
#include <linux/types.h>) V9 z+ ?4 p" ^7 s; \
#include <linux/gpio.h>8 k& ?6 J: X& @
#include <linux/leds.h>& U2 D% t5 h1 f- u& p$ c6 E( B5 x
#include <linux/platform_device.h>$ A+ s. T6 }) F5 o

( ^; g. b2 ?% T; |, X& Z#include <asm/mach-types.h>
& I, d- N/ b( |! X# N0 S#include <asm/mach/arch.h>1 ?  f, s) A& L  b% A% {" v, p* }+ M& m
#include <mach/da8xx.h>! V- d7 P& x% @4 z. n9 A7 ^
#include <mach/mux.h>0 C2 m+ v2 }5 J* ~6 i2 t9 z" G* N) T. L

4 d( I; Y$ r  S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 [- ?* V0 x: o#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 r- _7 N' ~( [; Q& v6 J4 L
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ J! e  e1 Z( W+ ~; P2 ^#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
4 m# w4 v+ J: B4 v4 `. o. ]5 ^( H. i" f/ |' S! r/ [0 U
/* assign the tl som board LED-GPIOs*/2 b) O) w" L' E# n" O; l( I
static const short da850_evm_tl_user_led_pins[] = {5 F5 b8 n5 [# c& s& A  I
        /* These pins are definition at <mach/mux.h> file *// [& S1 y. R0 w7 S* p( |: x
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 b# Q5 e( a; Y0 [& Z        -1/ M! W9 q2 u4 ^; ^5 f
};
# M, A- g7 e2 t3 ]0 H1 \" }; t6 e$ a- U, k/ G
static struct gpio_led da850_evm_tl_leds[] = {
! I6 R  Y  R1 v/ K. u! ~5 \& ]        {
" _& h0 W7 L, h) W                .active_low = 0,
+ [1 {9 ~# @  @, ]0 s& Y4 Y) ?                .gpio = DA850_USER_LED0,
: G8 l8 [- Q5 h) ^, v* V+ H; c                .name = "user_led0",
% K6 b8 }! Y2 X2 j9 _; ?                .default_trigger = "default-on",3 Y; o6 d! A2 E: f
        },
4 |( s, h  A3 r        {- R! n; N% q9 y$ p$ U4 D8 g
                .active_low = 0,
1 U( j6 l% n3 A# p                .gpio = DA850_USER_LED1,
/ V3 S2 p( ?# ^$ V* m$ X9 O' f                .name = "user_led1",
% Y9 X" d' r6 Z4 ?7 k                .default_trigger = "default-on",7 T2 O: S5 H) d4 H2 D* m$ Z0 t
        },$ K+ D1 y8 ]3 Q' O( z; b
        {" y6 K0 E0 b& u; M
                .active_low = 0,2 D2 o& H: \/ z  o* P
                .gpio = DA850_USER_LED2,; ^! V2 t: c2 c# Q; Y& T
                .name = "user_led2",
8 G$ W2 ?' w: N1 r) ]                .default_trigger = "default-on",
; X3 i, v2 q- o$ V/ m) r% b0 _        },9 J/ A4 I5 y( U6 w9 p
        {1 D, r! }8 e1 e$ K7 H+ D
                .active_low = 0,* o6 ^: }& n0 h9 A/ n, j
                .gpio = DA850_USER_LED3,2 l  K) a( L/ z8 H
                .name = "user_led3",, ^# \8 F' m" _) E) E
                .default_trigger = "default-on",
1 s4 z- a% n# P& z- t& M        },
& B  p# V2 B$ @' ^};! W+ n3 a  |$ V( r4 X7 o3 @
. c0 g  ?! M+ }. D6 T3 t5 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 i( Z; O+ }* l3 ]) E; U
        .leds = da850_evm_tl_leds,
+ v7 c/ J% c3 r; H$ d8 u+ G9 o        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! T3 k% }& k9 W0 I; u};% n7 I: U" V) ~
5 R/ w1 X0 Z3 J1 N1 O
static void led_dev_release(struct device *dev)
8 a! q% ^5 K$ s) J2 h, b# P7 j{
$ {- q" e: f+ O0 G: T) u};
9 O8 f6 u. y# Q$ u% x
& r5 x" k0 Q! ~# `' O2 s5 Estatic struct platform_device da850_evm_tl_leds_device = {6 p* c% }' I6 L! [+ u
        .name                = "leds-gpio",% L' s# W' r, y. |& ^
        .id                = 1,( o9 O# |$ L3 p$ C# B
        .dev = {
8 p" l" h6 Q% K, y                .platform_data = &da850_evm_tl_leds_pdata,' x& j" U$ X3 p& q9 v$ U
                .release = led_dev_release,& f5 S9 x$ c4 o& @" x+ y1 J
        }3 K$ I% P6 l; L
};
+ ~5 e' O& k: _7 _* j' k: u
. }9 n$ X! \  j0 a; z2 q& O. bstatic int __init led_platform_init(void)* D5 {/ i8 x/ ~4 a6 i. n# L, b
{  z8 f5 I" w: C1 ^
        int ret;& Z# i4 `' S! f2 x- f
#if 0
) f1 Y9 T' K+ z% e( W& k$ ~        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 \2 i2 {% ~, m9 b0 u, t        if (ret)
5 `" [; k8 Q) a: G6 a                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ S4 S0 @+ [2 j4 L: T4 g! K                                "%d\n", ret);
4 Q4 Q8 c. }1 r- Q9 _#endif$ f, P# l: o' v. ?1 e; n* `8 W
        ret = platform_device_register(&da850_evm_tl_leds_device);
' C$ T/ u$ k+ `9 s& h! i/ ~        if (ret)
: j- e; t: A) n                pr_warning("Could not register som GPIO expander LEDS");
. T2 `9 G/ Q# e* T& j: N        else
+ L: W( D1 ?4 i, N5 P3 t                printk(KERN_INFO "LED register sucessful!\n");
  H1 @: ^  c' W: {8 o
# f# [7 b/ q: c3 I        return ret;; G! g( M: y+ v7 w7 Y  A
}
$ ?* {; x. B) T9 a5 b( f* D# f" W
6 J8 r/ G9 W4 a2 b- i7 Bstatic void __exit led_platform_exit(void), r, r7 V3 V5 @2 t5 P/ U
{7 E3 E! K0 y) y' f
        platform_device_unregister(&da850_evm_tl_leds_device);
% p/ ^5 ~1 G7 N/ e9 V, P3 K+ _+ N: X& h! I8 V. |% G4 l9 }
        printk(KERN_INFO "LED unregister!\n");( @/ m* i) n( f. K
}
( w& }! S5 D% B" {' W9 {2 \- |# B3 S, ^- ~
module_init(led_platform_init);$ [1 q/ i  f5 b! D# z% f9 d. i
module_exit(led_platform_exit);
2 @+ u  r; u7 d( k2 L! p+ C
5 W1 |$ Q. K: f2 a7 D' d9 j% j; HMODULE_DESCRIPTION("Led platform driver");# e# z: M3 `; l( [; ?& r
MODULE_AUTHOR("Tronlong");" @! c* P1 R; X, S; U8 i
MODULE_LICENSE("GPL");
& F- \" Z9 e; f& d# Q0 E( I. y0 R  E9 D% A8 z! P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-12 13:09 , Processed in 0.040320 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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