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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" ^$ ^$ p" B: I% s#include <linux/init.h>
0 H3 G$ H. ~' E" [#include <linux/module.h>
  ?6 ]  T$ o  c( n) Z/ s4 `' J" Y* K- _#include <linux/kernel.h>
. K+ y4 m8 ^, b- F6 [+ v  {#include <linux/types.h>
* [& J* c7 N) J& g# X#include <linux/gpio.h>/ Y  a: O( Q( X* V
#include <linux/leds.h>9 S/ o/ Y' p4 L
#include <linux/platform_device.h>
2 b; P0 l  W; Y2 z" E0 b) X& Z+ m, h" c3 J$ k$ B$ x
#include <asm/mach-types.h>
# ], O, n5 |. [* {9 @# A#include <asm/mach/arch.h>" x! Y) y* k+ j
#include <mach/da8xx.h>
9 _# j6 F3 p5 s#include <mach/mux.h>
' K8 S6 J/ |! ^3 G0 \. p% z7 W( U# X4 M1 }# Y& T0 D" k
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 }. l+ V9 q5 d! u# |' u6 p: o
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ u% k. E, G$ h  S# A
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 `. ~$ g1 m, A' u* U
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
! t$ k$ f" @* W3 [5 E) r$ t( u5 ^8 n: l: Q
/* assign the tl som board LED-GPIOs*/. f) [: \# y3 k, g- J
static const short da850_evm_tl_user_led_pins[] = {
/ S) K- W2 q5 [: P  x* ^5 ?        /* These pins are definition at <mach/mux.h> file */
0 {/ `9 `9 n# _5 r) W        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 V. p$ D. b3 ~1 p/ G7 a7 _5 D3 _1 p  T
        -1+ G" G+ [  h& Q+ k" G# U" F
};8 E. U+ s' ?; F

) X+ B) ]* b0 y3 U7 }* P2 v+ s5 O  Qstatic struct gpio_led da850_evm_tl_leds[] = {
0 T, x7 J9 J, y, Q9 D, a5 k( B4 |" a        {9 D& C! j$ H. B- c" v
                .active_low = 0,
6 T% j" u6 D* O; s! H  L                .gpio = DA850_USER_LED0,4 f, H+ ^' p" K
                .name = "user_led0",
" A* ~1 C0 @) f0 E% |                .default_trigger = "default-on",4 v- _2 S$ B' F) Y( i$ Z" J! m& `
        },' u# z# e  J; g' j  o# }& p5 g+ a
        {: ~* I. t8 `2 h$ F! B1 ?
                .active_low = 0,$ s2 w) T" k/ Z6 m- Z, ~" o
                .gpio = DA850_USER_LED1,
2 S9 f* n. V" _. G) U  e5 ?                .name = "user_led1",2 ~1 x  u0 H. J9 C6 W$ m/ x
                .default_trigger = "default-on",
" ^& d0 x0 l8 i. J# E        },7 A) O/ d1 w( o* p/ a; w7 [
        {
9 l. A) m6 t( h                .active_low = 0,/ w# K* K5 n9 C4 A, V* y! d4 V; c
                .gpio = DA850_USER_LED2,9 z5 X# u2 [. h2 f& f$ }
                .name = "user_led2",
9 t" q- z: |" N2 m' B  A( [- b                .default_trigger = "default-on",3 H4 q9 O3 ~; v: F' `) F: q5 U3 q
        },
- E8 O  {+ {; n% d+ E        {
5 _: y* w( z) \! u' p                .active_low = 0,
8 V( t: i4 R! W2 A                .gpio = DA850_USER_LED3,
+ E% v! D8 z% u: {) ]) u. P& v                .name = "user_led3",+ R3 R% h6 O" b4 s7 F: p$ ?$ d
                .default_trigger = "default-on",7 O1 _: p1 J# I4 A* a$ ~
        },! V) k* ~+ P6 F; U* O3 `
};8 c  h5 ?1 n9 M" H3 l2 O& S1 B
. t: D, }- q$ q+ D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 ?, h9 C- L+ g
        .leds = da850_evm_tl_leds,) r( B# Q7 _. `  {! n1 ^7 G
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ?  s( Y$ Y! J! A};
9 {8 B! O) ]2 h, a; l  L4 S5 p
+ [8 L6 d7 i- q  fstatic void led_dev_release(struct device *dev)4 q/ Q0 N% Y6 u( `- D& b* |  N
{0 \3 c/ G/ q1 f+ ^
};
* u9 |6 i! F. V! s* H, j1 O% P9 H9 r: X5 {# P4 H1 Z7 R* d" ^1 y7 [) @
static struct platform_device da850_evm_tl_leds_device = {; f3 t$ v* ?( b  J; }$ d, t
        .name                = "leds-gpio",' D' l, O$ k: f- c( h1 H+ W5 O
        .id                = 1,
' v4 x1 o, j1 L' x        .dev = {
$ c4 D+ t! R) K+ @& X% r3 e6 ?: [                .platform_data = &da850_evm_tl_leds_pdata,
( C$ C& v/ u" O$ Z                .release = led_dev_release,
, X) H  q2 f1 j* ?( d- F' G        }
# O5 B" A4 y. s4 ]5 N};
0 z- ~: {2 ?1 H
: f% Q" v" o0 n* m$ {8 \7 X3 ~$ G+ tstatic int __init led_platform_init(void)9 x0 w* m. @1 D; q! x
{
% P3 e0 w! h3 K8 G( [- V6 B        int ret;
3 m' b" e9 R/ L1 n7 r8 m#if 07 N# A% ^2 H# H  R: f2 J. h" U
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ Q. s8 O) w4 D( m4 k, y+ A
        if (ret)
" {* t8 d) d' b$ K. |6 t                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  y# ]- e1 V/ w. Y+ d( h
                                "%d\n", ret);
: S  V( A) c; {9 {; F2 q5 Y2 [) H#endif
+ V* }: _: _/ [9 m$ v        ret = platform_device_register(&da850_evm_tl_leds_device);* @/ c6 p. `2 x/ V$ ?& ^, u9 y* p1 o; ]
        if (ret)
8 k4 {' ~( J( }5 |+ x5 Q0 D                pr_warning("Could not register som GPIO expander LEDS");& ?. X1 ~1 P1 J  \
        else& D# c. M/ V' g
                printk(KERN_INFO "LED register sucessful!\n");
8 z  u: c& h$ W0 y1 \& m4 |, m8 l
/ w$ @& O* b7 m* R' M$ u        return ret;- L% [6 G6 {; e& k1 q1 a5 ?' a
}
  R' F; b8 M7 X# d; _) u
- W6 M4 M6 d: S8 Rstatic void __exit led_platform_exit(void)3 C* w! P) t: s# `' ]# f1 K
{
1 n+ w* N. |7 u; l4 F        platform_device_unregister(&da850_evm_tl_leds_device);
% s* t6 R5 C$ B" l
6 K& Q2 I" {+ C8 c6 @7 ~8 j        printk(KERN_INFO "LED unregister!\n");
. r* C& ]! {/ y% Z/ C}
+ X/ S) V) `, y6 x* }# C6 R2 |
& Y' t: e2 v9 l% H6 Y4 |6 G2 xmodule_init(led_platform_init);
% ~$ s8 H3 \3 Omodule_exit(led_platform_exit);9 y( W) k% ]: O- c  L

- M8 f3 y! z0 M) `MODULE_DESCRIPTION("Led platform driver");/ V! d' w7 K9 n$ ?4 m
MODULE_AUTHOR("Tronlong");8 `" s1 N' B5 t
MODULE_LICENSE("GPL");
, G$ n* Q) G$ B' s& j" L2 C
# I; z9 e+ {5 ^" _, c7 x6 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-9 04:41 , Processed in 0.037719 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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