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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 b4 [8 D2 p3 {+ F
#include <linux/init.h>. w. m8 \0 h& @
#include <linux/module.h>
6 W/ B. q! h& Y- i) o#include <linux/kernel.h>
( g  L) f9 e2 G4 O( f& Q# m9 `#include <linux/types.h>
3 J7 K+ P. x& C$ W) C" B, }#include <linux/gpio.h>
  {9 d2 `' X9 G* K. p#include <linux/leds.h>
' L$ x" Z0 I! M5 N! c& ?# d2 p3 ~#include <linux/platform_device.h>7 E0 [- M, i9 C1 ^8 S
( [' t) h8 o# ~$ l
#include <asm/mach-types.h>! F8 U) Y; b3 T6 a) V% j
#include <asm/mach/arch.h>
( f% `" V2 G. d9 Z0 F% S: C#include <mach/da8xx.h>  b: I+ M1 v1 c4 W3 R: R+ ]
#include <mach/mux.h>7 u! [1 V3 d- n/ W+ |6 a% _5 T
/ [' Y# A6 c, M' |! ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 J3 ?! A% X8 r5 A1 n- [) e
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 j0 ], p1 o. d% d' s4 s
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) p+ ~3 E0 O: e7 S
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ H$ G4 L* p1 B2 N" m

* H' N' @) G( j8 B) p+ J/* assign the tl som board LED-GPIOs*/
/ y' x. m4 i, e! tstatic const short da850_evm_tl_user_led_pins[] = {
1 r( w; y+ ]% G0 S# t        /* These pins are definition at <mach/mux.h> file */
1 N) c  `% y# p6 Y% `! a        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 \5 R5 y6 S3 {7 W* e        -1
9 g& H5 i2 a% O8 h' u};4 m" _: Z2 O' {! X/ ]/ g5 b' V
7 r7 }' d% G& @
static struct gpio_led da850_evm_tl_leds[] = {
& N7 z- K* y9 U; s        {6 h; a. x$ G; a0 p% j7 E- z! c
                .active_low = 0,
0 z5 }1 t. d; z; F/ m( ]# I! w                .gpio = DA850_USER_LED0,) r: `7 ~# d" P- O' [6 [
                .name = "user_led0",
" [: k) p- t0 n5 x) w' M( h                .default_trigger = "default-on",/ S, O+ @5 U4 [9 H- ~! a/ O/ k
        },% ]* ]2 K8 s% c2 {% J0 |6 m
        {
$ ^. Q0 R, f# Z. ?1 k                .active_low = 0,$ R( s( ~2 |/ j
                .gpio = DA850_USER_LED1,
- o' t4 [0 l1 n2 p0 K3 z4 l                .name = "user_led1",* N7 _6 [8 y: T
                .default_trigger = "default-on",) ^1 j5 Y% X$ `" g
        },
2 [0 _' S+ {& V2 c        {1 r+ ?" T' ?3 @! q3 o  T& B/ y) `/ O
                .active_low = 0,
2 c: s9 d/ ?" q+ t                .gpio = DA850_USER_LED2,3 F6 _# I1 C  w
                .name = "user_led2",
" a6 A# h$ f3 K9 I4 w2 z6 j                .default_trigger = "default-on",! a8 @; \& b' o, M, W" }
        },& d- x) _3 E3 c5 \
        {& R0 n' f% y9 R( Y
                .active_low = 0,
& \' C7 C3 h. U- F' [                .gpio = DA850_USER_LED3,
; k! K0 h* Q3 k+ @. a/ |3 o                .name = "user_led3",3 x9 Q" L2 L5 {" M
                .default_trigger = "default-on",
0 g) E. C& N0 P$ C" \# `! B        },
2 \2 m, J% P& M0 M5 ]};
  K# c4 ^& d+ y5 z8 _5 y
. R% ?" A. R' Z' ^8 L; Y3 B' Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. ?3 S/ P' L( G8 B  n( U4 i
        .leds = da850_evm_tl_leds,0 L4 O  `3 K# O% `7 b- l1 p5 N
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 E4 i1 E4 b0 y+ V. s7 x1 U+ u& p! A
};6 ~+ A. U; b: B8 S

- C! ?$ Y5 C4 H/ s/ `static void led_dev_release(struct device *dev)% X2 e. M2 J- `1 ^
{9 x& V) j( I* W7 x/ v2 \1 K/ `
};. O/ H! t8 R# _* E& l
" m3 m2 t3 J  D$ i- |  L
static struct platform_device da850_evm_tl_leds_device = {/ d* L. U0 p; w) D* [" k" v% {: M
        .name                = "leds-gpio",
* M* A  i  I2 _) O$ E        .id                = 1,
4 Z6 d' U8 u9 M* }; _) ^, i3 {8 h        .dev = {
) j9 E2 ?5 ?  p8 Y                .platform_data = &da850_evm_tl_leds_pdata,
, ?! A& F& r( K3 ~- Q                .release = led_dev_release,
. s1 W9 e# A. k9 x  t3 b+ B        }6 k4 _  A9 e! F: z0 a: R0 Q
};
; V  k5 R: `, T1 c, |# e/ x2 a  ?" Z2 J/ x0 B
static int __init led_platform_init(void)
2 N. g* ?! f6 ^{
; Z- r' }% j1 ^0 U7 ^& }" D' [1 d/ L        int ret;: I/ J. R! q+ Q
#if 0- `3 _1 v- O" b3 G# M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 Y' Q; {$ @+ S- N. D        if (ret)" o% ~6 c# `, Q+ K
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- G- g0 L' u) S! l- E                                "%d\n", ret);
4 ^3 A  Z# ?# n3 d( O3 e#endif
/ M7 z5 O0 P* o+ o        ret = platform_device_register(&da850_evm_tl_leds_device);+ F; O! W! @! B0 K& m
        if (ret)- G2 E# d  H% S' s  s. k5 O
                pr_warning("Could not register som GPIO expander LEDS");) m' C9 c' V) N1 b) J% G
        else$ H+ x4 l0 k8 o2 H" a0 X% }
                printk(KERN_INFO "LED register sucessful!\n");
9 q- T( m$ ]) _, B% Y2 K* Z9 t
        return ret;9 s2 p0 Q1 F. a0 x2 n" B+ z1 f
}2 z4 `) s* j* B; ~
( M& h% U# H& {* U& m
static void __exit led_platform_exit(void)
- `" F# h3 Z* A& r! p- ~0 C{
0 C% m% u3 e. h8 b+ v        platform_device_unregister(&da850_evm_tl_leds_device);
9 I0 _: h4 A6 K( k; s7 y  C' R
& t" Z/ T& u. d% L) V" U: n        printk(KERN_INFO "LED unregister!\n");
) D8 @6 G  ~& ?" `. T$ r/ O0 C}7 _# a. Z8 _' ?

) E' a2 v( F8 P% w2 ^module_init(led_platform_init);
+ P3 d3 o) S# i. l& q# omodule_exit(led_platform_exit);
) i" @9 V1 _: ^+ Q1 N
9 C) i- u" I; l1 {' i) O6 g8 u. cMODULE_DESCRIPTION("Led platform driver");2 V! R0 _% |6 W! U* g
MODULE_AUTHOR("Tronlong");1 a) _; Q* }, y) u' d" x4 q+ L
MODULE_LICENSE("GPL");. |( m2 j" c2 o1 N3 Q- s  M- i! }
6 X& m  H. H8 [" n' @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-7 12:55 , Processed in 0.038124 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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