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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 S% q0 z2 ?9 [1 G' ^- Q#include <linux/init.h>
& Y1 \: F# f( R3 l: K& w#include <linux/module.h>
0 i. V0 n% C5 C2 p6 R#include <linux/kernel.h>5 u: e8 O! ]* Y: ?7 r7 y6 F$ z
#include <linux/types.h>: U2 L' D+ C7 @+ U, f6 K
#include <linux/gpio.h>" i1 I: S" G7 m2 x
#include <linux/leds.h>) D8 U' b; @; r* ]  i
#include <linux/platform_device.h>
6 N6 X" G7 P  b. o% C  ?, e% i# P% V0 ?& q: z
#include <asm/mach-types.h>& p1 i" r! T* w4 {
#include <asm/mach/arch.h>% Q& p' |- D5 d# l# e6 e$ G9 x
#include <mach/da8xx.h>
( h' x8 \9 A4 n  D3 o5 g& r( N  `#include <mach/mux.h>
! L" ?( Y' M& E
+ j: C$ B5 R9 A: ~  H#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). ?4 Z" a7 N' c/ }
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ l- h9 h' J& L; D. |  V" M7 ]
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 R2 P3 Y( B+ g* ?4 D. A" e" Q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 L% b; V  J- o% K' U8 ]
( O5 b! }& p% |
/* assign the tl som board LED-GPIOs*/, I% v& P# [& |5 i, r3 I3 V
static const short da850_evm_tl_user_led_pins[] = {! b- Y. R7 k3 X, o7 w5 r
        /* These pins are definition at <mach/mux.h> file */
, ^8 s4 {8 j1 J0 Y# @% {  c3 l        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 ?; R" m+ f/ K0 M2 c8 F9 l
        -1% F6 S! q6 ^8 Q' V; J% d
};
$ o2 d2 f1 V. h# J9 L3 g$ {$ j- N$ \
static struct gpio_led da850_evm_tl_leds[] = {. A& h( ?7 @3 R
        {$ {- I+ t+ C6 V+ Q0 o
                .active_low = 0,
* ]; K8 }; T+ ~0 d' d0 r3 }; E                .gpio = DA850_USER_LED0,
0 m6 O; k" G# c1 j                .name = "user_led0",; C2 h7 ?$ F0 W
                .default_trigger = "default-on",
; k0 u0 ?* G: v5 e5 O, B) Z2 `        },8 r8 d$ ^1 f: L& g9 p+ R+ {
        {
/ U! ~: j4 U( \                .active_low = 0,+ T' ]$ a! y9 C! w
                .gpio = DA850_USER_LED1,
$ H/ w# D% j" O                .name = "user_led1",8 Q7 U0 I0 |  c& `1 c: `, C
                .default_trigger = "default-on",: A% \- ~; W: n
        },
$ O+ @5 o% A/ W8 \8 a# q        {
* N3 C( p0 o- _! s2 R                .active_low = 0,8 D/ q$ x) P: D$ d6 C) U
                .gpio = DA850_USER_LED2,
3 n' v0 m0 Z4 m* F' [                .name = "user_led2",! @: N( a) ]; Q/ a# ]
                .default_trigger = "default-on",
7 I$ x+ @  z) N( d- g. y4 \9 y        },
& k6 |& _2 J4 O! S; w2 ~: V9 m* @        {
; z# R( Z4 L5 d1 g                .active_low = 0,
* W8 n% b# p* u3 d- z' i                .gpio = DA850_USER_LED3,
9 l/ A$ ^$ i& k7 n4 Y* H                .name = "user_led3",( C) z+ a# ?0 l! ?# J  ?+ f
                .default_trigger = "default-on",/ U3 W1 ?* C  ?% `- K
        },9 d$ U3 A9 b; B5 P+ e: _9 [8 f
};7 r- i, e, l6 G: R. j
" ]' p* Q+ Q% v  d, x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% z4 r3 G) V& L( x( J5 u
        .leds = da850_evm_tl_leds,
, D. m" [: t; d        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 m1 N4 @/ ~# `: v1 z, D- `9 s};
$ ?% l/ u$ B: j6 T- u6 `- S- [7 I5 F
static void led_dev_release(struct device *dev), u# L4 w8 B2 m" W. W0 a# I
{" s+ O: `8 V8 U
};
$ I: ]( ]5 Q: p' B6 R* w6 B( x  |9 `3 h& r# y
static struct platform_device da850_evm_tl_leds_device = {# b* V& N% @) p# O. |8 j* T" t
        .name                = "leds-gpio",5 P, I1 O8 s6 r1 j% q
        .id                = 1,/ c# l5 X* s; J# p. S+ G& E
        .dev = {
' J- Z, d9 J1 D                .platform_data = &da850_evm_tl_leds_pdata,. A! k) m7 O6 D3 }: _
                .release = led_dev_release," r3 `7 S: e% s" |4 ?  e, h
        }
6 T+ s$ f9 ~- M4 a8 u2 Q" s2 N};3 `3 ?; W  D7 M: u

- `& Z/ F# l8 f5 B2 E$ f4 Ystatic int __init led_platform_init(void)
; ^% L* N$ w! `  Z$ k! n) F{
6 g2 Z; \2 t+ W        int ret;* D0 g$ j$ @7 z  s' i
#if 0
" v0 l) p, q+ J% m; [" Y        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  X) h4 q9 ^5 B# B0 `2 O7 u
        if (ret)+ k1 \- |4 t5 \
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 [* H! X6 u* l- f% |/ Y, z
                                "%d\n", ret);+ O9 w" k7 j' |
#endif
; O, ~, M3 q' l* ~$ }; B: E" i        ret = platform_device_register(&da850_evm_tl_leds_device);
2 L1 y6 v8 |$ c' |/ e' b        if (ret); Z! y$ m9 T8 O4 B) c6 Y  W
                pr_warning("Could not register som GPIO expander LEDS");) [. Y6 |% P+ R1 }
        else3 m8 N% g/ a' Z" U5 f2 }
                printk(KERN_INFO "LED register sucessful!\n");# y1 X2 u  j8 t! ]: c
8 i: K8 t9 H* ^" l6 M
        return ret;" J& J, p8 _  B+ H  f4 h+ I1 O
}: O  I7 k6 t  m4 ^# ]- z0 ^

% b/ |1 K1 ~  E) S: ~8 W# s' cstatic void __exit led_platform_exit(void)
1 X8 l: m/ p" q* \{' }: D% P2 ~# _* T$ a4 _
        platform_device_unregister(&da850_evm_tl_leds_device);
2 T  C) T1 Q; _
. b" E0 f  v* [        printk(KERN_INFO "LED unregister!\n");' r1 a2 C7 `. E0 s  d- c
}
; D  U& {5 ^/ V6 T0 U: F1 M
6 k- e7 `' O0 r# C$ ?module_init(led_platform_init);
3 o# t% `: ^, E& D! {; mmodule_exit(led_platform_exit);2 n+ ^$ v  P2 j& |
8 e3 [: i& U) ~
MODULE_DESCRIPTION("Led platform driver");: j/ @4 C3 X% ~% o9 u! ?' x
MODULE_AUTHOR("Tronlong");* `" \0 C8 d; ~6 Z3 g
MODULE_LICENSE("GPL");
" }( n) [0 t: V$ L) }+ u& ?8 v5 r$ `
" N9 [3 Z: d2 r% N! }; e5 W# z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-3 18:52 , Processed in 0.039425 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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