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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。/ r3 v$ r8 U( h
#include <linux/init.h>. l, K, U) W; U) L" R3 ^% h8 m
#include <linux/module.h>' ^  d% F1 W& k/ m- F
#include <linux/kernel.h>
# U" N" O# c; Z' w#include <linux/types.h>
' ~4 v* ]  @( t5 ?#include <linux/gpio.h>
% F- Z$ l, T5 `  ~) H# b5 J#include <linux/leds.h>% L6 x) r6 m4 l4 u7 V
#include <linux/platform_device.h>
, @) K6 N6 _6 w6 w' E" Q2 N  P: m4 j4 S( T' a" o) ^! C
#include <asm/mach-types.h>
: I' d; @6 V; ^: L- o#include <asm/mach/arch.h>6 W" n: w5 f+ l, f6 P3 v) y
#include <mach/da8xx.h>
9 c! D9 n  Z" Z, l6 h; N+ l  I#include <mach/mux.h>: U1 Q# x& x7 t% ~+ @* Z, }7 @
: A9 Z6 F. b3 Q5 K$ P; E
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  O/ s9 z" j' [& s2 {2 G' n#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 g7 l; g+ a! N" p( f
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 y8 F" k# }( M$ y' b; o
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
7 V7 ^8 v* V* y/ o# K$ z* r4 V- }) U9 g. B
/* assign the tl som board LED-GPIOs*/  J3 x% k" D$ v! e% s5 a
static const short da850_evm_tl_user_led_pins[] = {. ~( s$ w! [! k; o9 t7 o
        /* These pins are definition at <mach/mux.h> file */
# B3 ]6 J/ N  U& F# k3 p* o        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# }0 K" B7 f1 Y; Y% u        -1' g, j! ?1 ~  J2 R4 m/ X  k$ n
};
$ n4 a4 n: y0 k$ g6 d" @4 m, M: v+ O( r2 A9 z" ~/ Y8 F
static struct gpio_led da850_evm_tl_leds[] = {9 t/ L# [2 T+ e" I
        {
1 y8 A5 A( A8 H8 p                .active_low = 0,6 G& d1 ~8 }) F; M) a
                .gpio = DA850_USER_LED0,8 X* J, J, A2 M% R. Y% f7 Q5 l
                .name = "user_led0",
0 k3 d5 j  z* {2 _+ B0 A                .default_trigger = "default-on",
5 Y" ]8 r/ R. e6 j. ?4 C8 v        },
+ A# S& l% V" d2 n        {# y5 T1 f5 [' {* ?* T, k) G% [' V7 R
                .active_low = 0,
+ w* N: w* e4 ~1 L1 l% d                .gpio = DA850_USER_LED1,
. {/ c$ Z$ r) F! T; M5 @# i. D                .name = "user_led1",
: Z/ I& I& w. H- M/ e/ _                .default_trigger = "default-on",
1 c" b# H0 [* t; H% @# @3 P        },
" I" j3 B+ Y# A4 }/ s- l        {& U9 {; f8 J7 h# M3 Q6 J! J
                .active_low = 0,
% A' Y8 {+ g3 m" N                .gpio = DA850_USER_LED2,
& F; w5 h; M* k4 _2 }) @) P                .name = "user_led2",, e: `( s6 S3 D! _
                .default_trigger = "default-on",$ Y! h$ M- `0 A( c% K: L% u
        },
  p( i% j: b( A! z3 B6 s        {8 @/ K- [' s* f8 Q
                .active_low = 0,
/ n% n+ z3 c! |0 q3 n4 b                .gpio = DA850_USER_LED3,
* E* k* f  v% L4 f; W                .name = "user_led3",& Y. O6 s. Q* p" @6 h
                .default_trigger = "default-on",
/ ]/ q0 u( U8 c9 t4 H3 ?        },# ~/ J: Q1 ~% }- l
};
& H% h( ^/ R9 g$ X. v: U" K) w" m" u; D6 j3 r0 R( Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ S* @  X! K$ O+ r: U3 j9 X        .leds = da850_evm_tl_leds,
8 T5 G- u+ [4 @! n7 S9 |6 E4 y3 I        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" t! J% x: L4 B( K# F};
. H! V# [3 {+ I* `  s2 k6 W' Y; d/ m2 p7 e7 Z% k4 z( b
static void led_dev_release(struct device *dev)
( B% g9 _( H. ~$ o: T4 a; t{4 f, \1 c4 _" j8 c' e: Z# z
};! C9 G. s6 m' s' o' T7 i

* w4 M+ r  f' b+ u# p7 U1 ^$ Q. Dstatic struct platform_device da850_evm_tl_leds_device = {
& p1 g8 j1 j: O9 G: m2 |  a3 A        .name                = "leds-gpio",; C9 W, `5 ]$ g1 c
        .id                = 1,# Z4 P; t5 F+ Y8 V' c
        .dev = {4 J' ]  }% I; t: o+ g
                .platform_data = &da850_evm_tl_leds_pdata,
1 s* L5 I; M8 ?, k1 d                .release = led_dev_release,
) @& B) T8 A+ Z0 m/ a/ s# T- I" D        }) U7 u' S, ^2 y/ ^: g. T0 p
};) P' U. m$ Q  Q$ J* v$ |* g; m  G  @

( `8 s1 E& ^0 \. d# vstatic int __init led_platform_init(void)
# }" b- |5 l* a. x{
: c; s3 u- k8 s        int ret;
; h) \. Q" L6 G5 F5 J#if 0; X% n  S: q6 ?% J. |8 h+ Y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 W5 U2 _+ `  m, `: E" i8 d9 Q        if (ret)
9 w* d8 Z! Q5 O9 O- {; F                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% m) q+ I( H( a8 r, @. K0 z
                                "%d\n", ret);5 M1 D+ H" y. L! W/ g2 F
#endif/ m5 G6 r0 ~# s  b
        ret = platform_device_register(&da850_evm_tl_leds_device);
% _2 P- @  Z9 x1 m        if (ret)4 K/ Z# C+ n3 J8 c* }& d
                pr_warning("Could not register som GPIO expander LEDS");
' ^, s" [4 T/ h! i" R- M8 G# U' b# l        else. V6 t) U" M* r* d$ ~
                printk(KERN_INFO "LED register sucessful!\n");  p9 g  u* x1 @- Q7 O

! k/ T" U3 ]; G8 y" o8 i9 Z        return ret;
" u& n: w3 y, X5 E. J}9 D/ g; [; b  e4 P4 M) G

5 h1 b/ E/ W' c: y$ I0 ?4 Gstatic void __exit led_platform_exit(void): l. c9 Y+ J5 N7 w' B7 l0 R
{* D7 ^; K/ c  o0 U) S
        platform_device_unregister(&da850_evm_tl_leds_device);
, o  K' ~# e! B/ P4 y) b
! ]3 z7 z. C9 q9 J. Y" e. f        printk(KERN_INFO "LED unregister!\n");! f5 Q, Q8 L. c) Y% P5 v
}
# R# r* G* u! a* @' \- `* V3 f0 l" U* O% P
module_init(led_platform_init);
5 e$ S2 J& p4 |+ d% d; ?module_exit(led_platform_exit);
! J4 e) R" [& M7 f
: {* F& X* k5 J5 S3 ]MODULE_DESCRIPTION("Led platform driver");
7 k! t0 p) G2 F5 Z4 [MODULE_AUTHOR("Tronlong");' U+ N+ h3 [& B7 N/ k
MODULE_LICENSE("GPL");! o8 N0 I7 S5 s: ^. q$ V( P$ F: b

$ ]& W5 {7 Z1 b7 Q' `+ S" t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-11-17 12:42 , Processed in 0.039620 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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