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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。, j5 h1 e7 V  Y: R0 B+ s
#include <linux/init.h>
' r& O$ e( V+ O3 `#include <linux/module.h>& S7 U( W9 ^9 f* ~! k
#include <linux/kernel.h>
9 u5 Z* G0 [1 `1 R8 @#include <linux/types.h>3 B8 i! M; a; S) F
#include <linux/gpio.h>+ h2 A& H" K* w3 ?1 m$ ^
#include <linux/leds.h>
1 A' t+ |- E, |8 N1 F, M% c1 Z#include <linux/platform_device.h>! ^8 E1 G9 f2 i- X
8 s2 L1 U  n6 M; h9 Z4 O& m: h
#include <asm/mach-types.h>
/ r1 \3 |0 J. j& ]6 L#include <asm/mach/arch.h>9 E, @2 ^4 V) Y$ h( o; H
#include <mach/da8xx.h>! Y& N. Q9 K4 d9 ~/ M( U7 h0 h5 l
#include <mach/mux.h>
, ]$ ?1 C4 J* _0 L$ v! J& e0 X  N: z8 f
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 p" M3 f$ i  L+ L+ y! j+ a
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 v' l, o# A$ e$ [8 O#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
) I3 b. o" Z( j! }/ i#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" _4 e; V0 ?6 F5 P. s% Y) N) f6 H, R

& K7 C0 @, [" k+ W7 \0 w( }/* assign the tl som board LED-GPIOs*/
4 W* j: _2 U2 G& Y7 P* ^static const short da850_evm_tl_user_led_pins[] = {  P$ i0 i7 ^$ l, i4 |1 q
        /* These pins are definition at <mach/mux.h> file */4 b" b+ e" x1 S) R! U/ C6 C% X
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 x2 B* `5 I* v5 N6 b8 _$ d        -1: d* i- h, i4 I7 [/ s( {& f
};& }8 J: n' t4 J$ q! f5 ?& o

( ^; [/ h" e4 \( f, Kstatic struct gpio_led da850_evm_tl_leds[] = {
# F0 A' x/ f6 ~1 I0 Y1 _        {( K$ S6 m! |; R( y5 ?
                .active_low = 0,# y1 I6 W0 j! s5 g6 ?& V
                .gpio = DA850_USER_LED0,# a- S7 ^! d: h  U" Z+ u# N" M
                .name = "user_led0",- B) z& T+ A$ I
                .default_trigger = "default-on",
7 @- R8 n& m* o        },3 w  L8 {# [& h& S6 g4 b! g
        {/ j/ h# B# j; Z. V$ F5 ~* L
                .active_low = 0,; v5 S7 h% Q, ?6 W
                .gpio = DA850_USER_LED1,
7 E/ m' N8 c% B/ b# k8 j$ ~                .name = "user_led1",
; f3 z5 k( ?1 ~' ^6 Z                .default_trigger = "default-on",
4 Q( D) G  I' e$ T8 Y        },* D) D2 U' ]8 [: o
        {
- q# K6 U# Z1 B4 E  b" S& q% M                .active_low = 0,, k! K  M2 F  d) G
                .gpio = DA850_USER_LED2,
0 K" ?1 j9 ~0 P# d9 L' z9 @# ~/ [                .name = "user_led2",
. N& p" o; J# Z. k                .default_trigger = "default-on",
  G6 h$ t8 i) F) [        },
& |# U( w- `0 w* _; \        {
- L" V3 T7 `! G                .active_low = 0," w8 I# z, r$ T1 G
                .gpio = DA850_USER_LED3,* N, a/ m4 h; |9 n
                .name = "user_led3",
; N9 S" I, |0 d2 e                .default_trigger = "default-on",
2 y# Q. T! X: c' y/ f        },
1 }4 o& n, g0 p};
: t, [; \4 R3 Z% J: f, Z. Q+ E7 {3 `: N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 u5 u4 t5 u- e- {3 Z- G        .leds = da850_evm_tl_leds,
( M+ Q( z+ ]9 m+ B: Y' N& e        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 q2 O* i9 f! ^3 F1 D
};
( a- C4 q7 @, c" p( V" i) v1 w5 s/ z4 }4 Z
static void led_dev_release(struct device *dev), j9 i: k; f! z6 I
{
, F$ c, c8 ?6 a2 z* ~, Y% z};
  O* I( Q5 X) ?
! _5 ?! `- m0 @static struct platform_device da850_evm_tl_leds_device = {2 r/ d$ w# I  ^1 E3 U
        .name                = "leds-gpio",
) w, Y& ]3 d: u# l& @% f        .id                = 1,# a9 O% Z9 J/ L
        .dev = {
2 G4 _* ?2 W' d$ P4 U& ~. a                .platform_data = &da850_evm_tl_leds_pdata,
; ]- ^! |$ Q) ^                .release = led_dev_release,$ J3 o+ a: U' H  d
        }
  p' g: T- p# q; T% p% R$ i};
$ @* X6 g: s* ?. Y: A5 s4 s
5 D$ J$ z* r  L  Tstatic int __init led_platform_init(void)) I5 w* W1 o" v# Y, V# q
{
6 k' p4 U  n3 [; T        int ret;3 j! h1 d9 p' T2 d$ A) q. z
#if 0, i4 o4 @$ \' ^) P( e
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 P# @0 d, F; Q( j* Y  Y/ I3 O
        if (ret)
7 I2 r  X, j" E                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 t( V" X8 \4 q$ Q
                                "%d\n", ret);
7 V6 G7 m- {  S' x$ b% \#endif
9 D' i2 U" c# U0 J3 g7 B' I        ret = platform_device_register(&da850_evm_tl_leds_device);9 Q) I9 s! G. M. T! D/ k: F
        if (ret)
* k( y( n2 [/ \9 Q0 {6 r                pr_warning("Could not register som GPIO expander LEDS");& ~: z7 s! J6 i, E
        else
3 |  E, y# |4 _9 Y0 ^                printk(KERN_INFO "LED register sucessful!\n");
1 _( W5 |& Y- G" I+ Z  I7 {. w" Y# y) T; Z
        return ret;* y/ g3 @( W9 B% x$ u
}
. O5 o& E4 d& _; A8 ?, X5 ~
  Y9 T2 _: O) W, }' N7 I% i  Hstatic void __exit led_platform_exit(void)6 w( R$ a. }: `, L$ D% c. z
{& d1 [: S7 m: L& e1 x" i0 V
        platform_device_unregister(&da850_evm_tl_leds_device);) }3 M, n! U+ c8 H9 ~4 d

/ G. o# _3 s; _3 S) A! `2 p        printk(KERN_INFO "LED unregister!\n");9 o/ R$ |; c3 M; V0 V
}' S, X# j* {- ~9 P( ^/ W* {1 y( c: N

$ W; Y  L! ^/ x3 xmodule_init(led_platform_init);
9 u( S. z2 Z- g) T! a+ Y8 zmodule_exit(led_platform_exit);
* n- _' {1 U( g- x3 D! P$ I
4 D. _5 u8 u1 O- a6 M1 tMODULE_DESCRIPTION("Led platform driver");& c! }$ L# s. ]6 W1 ?( ?) _) ]
MODULE_AUTHOR("Tronlong");" b6 x$ H# z: D) b9 n3 `1 o
MODULE_LICENSE("GPL");* ?& u, q* X3 ^5 T
* Y0 B" a' v& W+ L& m5 i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-13 09:31 , Processed in 0.042135 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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