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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' Z+ F# k$ ?  d
#include <linux/init.h>6 f7 H1 ~, r. b7 T* x1 E; K
#include <linux/module.h>
+ H. m& |" J( E0 P#include <linux/kernel.h>0 r- a, ^$ ]% W5 v: w0 K
#include <linux/types.h>
/ w9 }+ w( a1 N; w. a: p#include <linux/gpio.h>
9 Z8 K( g- l; `3 s; P) q#include <linux/leds.h>
. J' D" m1 Q5 a, ~# x& U#include <linux/platform_device.h>
$ Y  C) R5 e" b, ?+ n
" o' k" a/ T. O, S% D#include <asm/mach-types.h>2 `- Y" I4 J$ L& s2 g! ]
#include <asm/mach/arch.h>' }2 @$ i( W4 Z9 T5 [* s; K
#include <mach/da8xx.h>
% b5 q2 Y* ]$ H& \  e2 ~7 |( k#include <mach/mux.h>
/ h- {! r6 K8 r! A3 o7 U/ @. G, n0 Q5 p9 n5 J/ Q( e, \+ J
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 K. F& y( N% G' S/ y
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ N' `/ M3 d+ ]% O+ F/ A+ y
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% D! @# k3 C: Z8 b, {5 o#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ }7 @$ u5 _9 C7 O' m
! W; M$ T9 m+ K7 W4 u7 o" E
/* assign the tl som board LED-GPIOs*/
2 {; a$ D5 u" L* ]% y' ~( pstatic const short da850_evm_tl_user_led_pins[] = {
- Y7 l- A: J2 B% R" @; [        /* These pins are definition at <mach/mux.h> file */0 ?) Q( W" }9 w. K- {8 U
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% d0 n4 l" [* c4 j- ^, i- J
        -1
$ K* E7 O! U2 u; B: h1 V* ~. J};8 h, A; L3 B' O; e7 L, _: z
% y6 ]4 A: o' ~& S
static struct gpio_led da850_evm_tl_leds[] = {5 ]9 U$ a8 ?, d
        {
: G; o& Q" }! f0 w+ b8 f( f; }                .active_low = 0,
: ]( H: d/ k# H& I# N: C( h: f3 v) X; _                .gpio = DA850_USER_LED0,0 S. c' ?5 X# ]* d; m: b; H
                .name = "user_led0",- E/ A& }9 Z0 R# M' W
                .default_trigger = "default-on",) r  E) L, V' h/ g1 Z# R9 i4 b
        },. i, i3 w" j2 Z
        {
# Y; h( k; A! k/ X# o* A# l                .active_low = 0,) A+ p  V" g$ v7 _9 t$ R5 \2 a
                .gpio = DA850_USER_LED1,0 x( n( U5 W% H9 m& T
                .name = "user_led1",/ U! J! H( Z" f6 h4 Z( h
                .default_trigger = "default-on",
8 |- C# t7 F4 l        },( |( A5 d* S( ?
        {4 ]8 g8 J# z$ `  R0 O% H0 Q7 z
                .active_low = 0,; c& _+ o' q# r! X% C
                .gpio = DA850_USER_LED2,
/ b7 e" B, T/ ~1 K4 N                .name = "user_led2",9 H7 p+ u* U& Z5 b
                .default_trigger = "default-on",
& A" [0 B/ R4 Z  p( a/ x        },+ {2 M% P$ P  f1 q8 T3 X2 x( g
        {% a9 N# F7 e8 H/ H, I/ B, m4 s
                .active_low = 0,
& v% f# V) k# s$ `# S4 B                .gpio = DA850_USER_LED3,5 R4 e4 B9 L; |# }3 |) |
                .name = "user_led3",
6 X4 ^# x( Z" u1 g! }                .default_trigger = "default-on",# N8 Y7 k: z' _1 U+ P
        },
' d! t8 p1 K1 c- D};9 a" N( Q+ Q( M# V# k0 i8 @

; M0 Q1 s& q8 E8 q- Z' H, _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 m4 s, k4 i  f! T3 O
        .leds = da850_evm_tl_leds,
) ~6 Y4 L) @! g7 ]        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ ?3 K, I: j* \9 l};
3 q8 t1 k" O0 t. e, d! U/ ^( }' z) t: u# g
static void led_dev_release(struct device *dev)3 V+ Y  P. k( w: p1 x
{
/ \$ h' S4 |( w2 X( `};
8 K- s0 _0 m6 t7 o/ h& ~/ w" o/ w- x4 h3 `
static struct platform_device da850_evm_tl_leds_device = {4 [( O+ T. y/ S, M
        .name                = "leds-gpio",
4 J2 e2 W+ @5 A0 D2 U3 {; m        .id                = 1,
* g1 n) s! x7 _- M. Q        .dev = {: [' e1 m5 d" K( W) H+ k2 H' l2 j
                .platform_data = &da850_evm_tl_leds_pdata,: k# a2 p+ J0 d7 g2 c
                .release = led_dev_release,
3 D  V, D0 x* |7 w        }
- w! c9 T: S" d  o};2 d5 H/ W" O0 y3 |0 `) i
6 X8 B0 [+ B, x$ |
static int __init led_platform_init(void)1 X4 d* K2 R, N
{5 K  m1 Q! J) G- m5 t2 t% F
        int ret;
+ P6 D4 k* E% M1 C#if 01 r: R2 \% V4 P6 q: E& \
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ F% z$ ~! g  Q! ^" [5 F
        if (ret)
. E# T4 p. ^- f1 D& m- Y; s+ l, D                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" _1 ~/ A  G5 s+ m0 F+ P- D                                "%d\n", ret);
8 D' y9 @& ]" J2 P6 }8 t* D8 p#endif
: d" \) Z" [) e! E  m        ret = platform_device_register(&da850_evm_tl_leds_device);
5 s/ `  ~' v: y# i: ?        if (ret)
6 n' c6 F1 r. W% E' I) V                pr_warning("Could not register som GPIO expander LEDS");
  B' n* F/ Q' P# }. R        else: `5 D4 v: z8 D
                printk(KERN_INFO "LED register sucessful!\n");
/ Y  D' C) y+ L' q5 U+ \  j
# W: N, `. H7 o: G$ `6 b        return ret;
+ W; W) K! d6 |4 i6 M3 ?9 T}
3 C$ K0 |9 V! m; C  W1 G9 E' `, x5 U: ^1 h  ?) v0 o8 a% K
static void __exit led_platform_exit(void)
7 ]; I8 p* v- K' ?5 l; T) V- q{
6 S3 U( @5 @% }# x( o7 w+ y        platform_device_unregister(&da850_evm_tl_leds_device);8 a, Q* J( o& [! b( L

: S+ M: G# N/ I& l5 W- A        printk(KERN_INFO "LED unregister!\n");$ I2 }6 C9 K: `
}
4 O* O8 ]" P1 l. T
; Q  Z0 ]# P' C$ Gmodule_init(led_platform_init);
, V( R" P; ?/ g/ dmodule_exit(led_platform_exit);
* r$ I2 C' l( B$ ]' ~" A4 r, ~) c) m* V9 k' V
MODULE_DESCRIPTION("Led platform driver");% }8 A5 `+ E7 ?+ v% c, l' ~& X
MODULE_AUTHOR("Tronlong");( q4 z% Y/ P% v$ k5 U+ x% w3 x
MODULE_LICENSE("GPL");/ L! n  o0 z% ~" ^$ X
. Q) K$ E1 M& r2 y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-19 07:18 , Processed in 0.038963 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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