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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 {3 b1 S, J+ M. m* s#include <linux/init.h>- D7 m/ c0 D1 V9 n" G
#include <linux/module.h>  Z$ h7 F1 b: n* h' ^7 D
#include <linux/kernel.h>
2 @* U- i* \- _! Y% r#include <linux/types.h>
/ j; T0 q7 n6 j+ h* f% v( W8 @( I+ Z#include <linux/gpio.h>( q# }& T9 ~# K8 ^+ G
#include <linux/leds.h>
) m2 I" Z. L7 a+ W5 _; J$ A( b: V#include <linux/platform_device.h>* d3 l" f$ {/ y# \% Y
$ V( Z+ `- [& Y) j4 L2 [" L8 C
#include <asm/mach-types.h>% f; P! o7 O- G* w6 D3 F
#include <asm/mach/arch.h>; d% R5 ?( |; [$ K, U
#include <mach/da8xx.h>9 E' y: \5 p% d6 X. g  n- Z
#include <mach/mux.h>
' I  ~4 r/ i: x' F, C% J
0 ?# K% j& W/ i  G7 R#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, a- F0 Z1 i& h) l3 t2 y#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 V! ^$ d: z( v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' q# a) ^( b6 c- ^
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
( m6 Y( E2 T: w9 o7 j% ^/ R: S3 B6 v4 r6 D# @4 [" @0 z% s) Y
/* assign the tl som board LED-GPIOs*/; T  L7 K& Z+ f" [: O& N0 I
static const short da850_evm_tl_user_led_pins[] = {, J9 q9 E& ^5 t" E
        /* These pins are definition at <mach/mux.h> file */
3 Q8 w1 r, |/ ?: _. q        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ g, h5 W4 I& P4 J: r! V
        -1
5 e; O/ L9 t; }) n8 I8 K};
6 ]' w. l: Q8 J
+ h8 M4 S6 S; S- W# F. M- l3 Hstatic struct gpio_led da850_evm_tl_leds[] = {" _9 G) }" ~  p* K$ o
        {
3 p. o8 w' d8 v. U- A- @& e                .active_low = 0,
$ _  n2 ~: n- b; ]- Z+ f                .gpio = DA850_USER_LED0,; G; v) M* P) J# s2 k* ^0 g
                .name = "user_led0",
7 m3 }$ B6 D: K                .default_trigger = "default-on",) ]  G2 a" \1 p* Z8 I" ^5 c* t
        },2 Y  X. g0 E4 q8 F) M
        {9 D0 W- Q% p+ @2 b9 X$ {
                .active_low = 0,% w/ [8 T, P/ w, h$ N( D3 Y, \
                .gpio = DA850_USER_LED1,
1 X) e! c/ H) a                .name = "user_led1",
2 X' G3 N5 p0 d9 t' R+ J7 J                .default_trigger = "default-on",
7 m: ?# H! e- Q  H& b) r) ^) \" D        },0 e% c, [$ U0 J% b
        {& C- \- C" ?* s2 f# G( m: F
                .active_low = 0,5 i$ i% k. r: W* F' h
                .gpio = DA850_USER_LED2,9 E) [$ T) ^, b, l2 X: W
                .name = "user_led2",
' ?; n5 z% J7 H) i1 c3 T                .default_trigger = "default-on",' \" M0 z6 h& A" M' y' g
        },
" X& c3 a& ?7 d- P        {" q  q, O! a1 r
                .active_low = 0,
9 o# b3 |8 q. b1 d2 n                .gpio = DA850_USER_LED3,# A! \5 R; e& o
                .name = "user_led3",
7 p2 h3 o7 ]3 P$ v# d                .default_trigger = "default-on",' O, t# d6 G! B) J0 N$ x. h* S
        },  K% c! T8 ?7 G# C
};  x9 b* n& V( g& c

+ h- a, t! k& n9 {) pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. n, f; d8 {2 S% B! K2 H
        .leds = da850_evm_tl_leds,
0 }- F0 \/ V0 O. a3 O1 ~        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& l0 _# r2 U4 q& S};
5 x  C3 Q( H* R5 _4 t
: S6 ?  m; G- l5 k0 @) ostatic void led_dev_release(struct device *dev)8 a+ R0 C% A; n8 v2 H3 K
{- @5 @$ _8 {' `6 V2 q$ z
};
9 K; a. n& j$ n. ~6 g0 e
% c0 C6 G# Y9 Q8 [( w% I0 }/ sstatic struct platform_device da850_evm_tl_leds_device = {. |8 z0 {" F& K9 E9 W( x$ k
        .name                = "leds-gpio",
( L' @1 d; R" O( J        .id                = 1,
0 G0 n' a4 O" a2 W& u$ n1 b$ d        .dev = {3 K1 C( R) `; [
                .platform_data = &da850_evm_tl_leds_pdata,
, m/ {. b! z  b2 W! b9 s                .release = led_dev_release,
# B: E7 V5 A9 E; m0 o1 s        }
* ?  [' X+ y, s9 R* {};2 s2 X+ n3 B  s  s* r8 R
% X- X2 b0 W$ l% X  ~
static int __init led_platform_init(void)
1 W( c3 \3 Q1 w3 k{
! _( ]& @& {; t3 m        int ret;
- {9 m  z5 \, @2 R#if 0) x0 s0 N  @8 P- u% D  P
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: e3 h. W6 K) Z* {( C( ^
        if (ret)9 s) y; V2 h8 D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* |7 n1 b- E+ q7 t                                "%d\n", ret);2 J# c) B7 J6 {1 w( [' |
#endif5 a0 n0 X* l2 b# r, N
        ret = platform_device_register(&da850_evm_tl_leds_device);/ d% y/ j2 f- r3 D6 M
        if (ret)5 I/ |, p- V' h, H* w
                pr_warning("Could not register som GPIO expander LEDS");. U: {* b1 |% U  r0 I" e
        else* ?5 m+ X2 L: k
                printk(KERN_INFO "LED register sucessful!\n");! }( H6 F& U% p$ l& S% m% U* ?5 k- `

/ D! {+ N  b: p- Q        return ret;  M8 F8 t6 J1 }0 g% Q! A+ u
}7 X/ M3 E3 [4 t( C# K9 Q% v
2 n' E& ^# ]& L5 Y" H
static void __exit led_platform_exit(void)
) v5 \9 e3 ~( `) c1 S{
! ~+ f8 d& |1 g& R/ w+ p' Y        platform_device_unregister(&da850_evm_tl_leds_device);: g& i: R' p1 I$ L( u, L4 X
" U0 s& C; ~, j+ B8 b, J
        printk(KERN_INFO "LED unregister!\n");; @/ G9 n1 G2 F% X( H# _# X9 t
}
  H( x: g. _/ K" ~
8 X# R/ I; v" T6 G) N. t3 H& |module_init(led_platform_init);: R0 H1 j8 E- r( O7 H9 |
module_exit(led_platform_exit);. ~0 m$ W  C+ C" W/ s
9 j& s9 z, n+ f) m) V2 F7 N' h
MODULE_DESCRIPTION("Led platform driver");+ w" l; ~6 D/ n* n, M
MODULE_AUTHOR("Tronlong");6 n% z1 E$ `8 p& r, d1 X& u/ j' J
MODULE_LICENSE("GPL");
! |& ^1 P+ o7 k, \3 p
/ p: h, K8 A& e( I2 t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-12 20:29 , Processed in 0.039456 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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