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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ S" V8 D3 U4 l3 S1 J#include <linux/init.h>0 W; @. J/ }: U( w* V3 i2 }
#include <linux/module.h>
2 l; n# E# c* J6 n* ~; H#include <linux/kernel.h>6 Q# T+ l" S/ m3 w% i6 O5 e1 \) \7 }* c
#include <linux/types.h>
) v$ [! A- C! A! T# ?2 ~! d#include <linux/gpio.h>
/ s- B" \) A9 T#include <linux/leds.h>
* ]6 n7 l* L0 Q#include <linux/platform_device.h>& Y; g' J- `3 n3 p- O
% o! O4 e  J% E7 H& Q$ D
#include <asm/mach-types.h>; L7 n) a% f1 t) T; X8 g
#include <asm/mach/arch.h>: x1 E4 @/ w( d
#include <mach/da8xx.h>
- l7 T3 \& m6 z8 L* ~3 j8 x* ]! O7 v& x+ w#include <mach/mux.h>2 L8 x. n/ P7 k' f- d6 \0 {

$ K  t& S9 z% D& F. r0 k% R7 P" ]- \! B#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* u+ f8 n( V1 }6 N$ t# `#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! I8 b' _( Z$ w
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 P( [  b8 D5 d0 x7 W: M' h2 l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 R# b1 q4 c, \7 l: m, `

1 x  z. ~# i" p0 O5 p* h% o/* assign the tl som board LED-GPIOs*/
* s* R' N' R4 f  Q, E7 d9 \+ Hstatic const short da850_evm_tl_user_led_pins[] = {
! T7 u2 p9 a& t1 c0 J+ N" }$ i        /* These pins are definition at <mach/mux.h> file */$ Q" C9 u, e# O8 d$ Q9 \
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 w: r: H3 V1 X' F- Q0 f) \4 D' L1 y
        -13 ~3 \5 a! L- P
};# M" r+ [/ F+ W; l& j

0 m' R* U7 g/ |7 lstatic struct gpio_led da850_evm_tl_leds[] = {
# l0 y( o, `8 K. k        {0 R( ?0 t0 [; b  {
                .active_low = 0,
5 N' d' ]8 _7 f2 k                .gpio = DA850_USER_LED0,
. {4 C! H& b' `; G  |                .name = "user_led0",
' p: |; p/ R0 C                .default_trigger = "default-on",
2 Q9 L) h( w4 ~5 H* v        },0 q5 j' l6 u4 y  ~
        {
& ]6 U# ]# ?+ p! \: |3 C                .active_low = 0,+ Q$ b+ J0 }$ n) m6 W5 J+ z% _: X
                .gpio = DA850_USER_LED1,% ?7 J& G9 z; f! n
                .name = "user_led1",
; {$ _( i# A" f. p4 m. O                .default_trigger = "default-on",* s/ i- o' d: Y7 x
        },) J: B% Z! |: t5 R2 Q4 [' i
        {
! A1 X  y7 p7 n8 {9 |9 x                .active_low = 0," K2 Z( R: V; s, q9 T
                .gpio = DA850_USER_LED2,0 m0 P# v& E; b- z8 n9 J1 e
                .name = "user_led2",
, e: v* w3 c- b, u% P: E                .default_trigger = "default-on",
8 w- {6 P2 Z. X" o        },
8 B" _0 I7 \0 V( {4 Z" C$ U" L. y        {8 ^  J6 ?; E4 P3 H, l2 r
                .active_low = 0,
5 x# B1 N( X: Y                .gpio = DA850_USER_LED3,
4 y  A5 G1 x6 x0 \. v2 ]- o                .name = "user_led3",
$ |9 A2 e" x. |5 K/ M# V7 ~1 ^                .default_trigger = "default-on",
/ w' m& G! ]3 O) ]        },. K+ s' A- j! N" V) K, ?
};3 \- i0 ^, M& O

' l- I) A: X: H: _. t: W& m8 L1 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ l% i: s- w, o- V/ `        .leds = da850_evm_tl_leds,: t+ g9 U- s1 S  z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# Y, z9 h" @6 Q" e' p; j) S};
$ ^$ u; A$ s; |/ _! s  {2 a0 N# H+ A8 t7 O/ f
static void led_dev_release(struct device *dev)+ z& K8 |& L' s, P2 `$ [
{
( A4 Q( P4 i* C1 D5 r};
0 i7 j+ c' b! J  o5 d
3 u2 K: z) w# S! Y' P% B  `static struct platform_device da850_evm_tl_leds_device = {
. a+ k+ H% w) ]        .name                = "leds-gpio",
, m: p) z6 n6 s, E* A# {1 p: U  e6 x        .id                = 1,$ c* ?* M+ a7 r6 Y  @/ n+ I
        .dev = {+ k* X/ g7 x$ E0 k
                .platform_data = &da850_evm_tl_leds_pdata,4 ]: e8 ~. g2 W! J
                .release = led_dev_release,4 y! Q) B: G% L) g8 B% l% Q
        }. C( z" u# q7 i2 N
};
9 f  ?/ n5 j0 ~, K5 x  |  z3 x; I3 T3 d. {
static int __init led_platform_init(void)
+ @6 u1 d7 |: y* b{5 E/ G5 \$ l7 X% Z2 \& R; r
        int ret;
( `$ [$ V; V& B& y, a#if 0. _8 i: ~5 n/ x5 D8 O( u' f. j8 R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ {) h4 ^7 U: ?0 s9 [& ?5 S        if (ret)
/ Y1 C) I, [1 b                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 q5 M) D/ F9 T! g
                                "%d\n", ret);. ]( i0 T, S2 R9 d
#endif9 `, q5 ~3 }& ?+ F3 J
        ret = platform_device_register(&da850_evm_tl_leds_device);2 v; M2 a: W3 W/ C
        if (ret)
9 D% r+ k# M% u9 O                pr_warning("Could not register som GPIO expander LEDS");
+ x9 c* I1 F) J1 y  _  c  l$ g( e3 a        else
" N) f* n# H2 {/ W$ k                printk(KERN_INFO "LED register sucessful!\n");3 U8 |. S4 O6 w8 |4 B  d& E
3 ?" u5 K. r! g+ E1 J) f1 m
        return ret;
" \8 L" N. g9 D$ W+ i- C( n}- e5 x0 a* j, J: n# _# d4 o
8 f1 J$ Y6 f; u& P3 S: J
static void __exit led_platform_exit(void)
: d. |% h7 ?8 z. ^6 H- s{& @/ s; o5 p  |4 G' \, r7 M
        platform_device_unregister(&da850_evm_tl_leds_device);6 L" A; V1 k% V$ S& J
, ~# j$ l" ?+ A) t2 B: E* p
        printk(KERN_INFO "LED unregister!\n");- r" O' [( |, H) n9 @$ d9 R' k
}
+ F8 O5 D$ \5 Z+ t1 l$ g$ N: t8 _: d" d: }5 N0 [$ }$ [
module_init(led_platform_init);% j5 p, _) w3 R# a
module_exit(led_platform_exit);
/ b: H- I5 n' |' q; d, T0 u  ]5 {  W3 A& z* C2 ^
MODULE_DESCRIPTION("Led platform driver");
( l  }4 H5 N7 N: b- P! P$ N7 W6 {MODULE_AUTHOR("Tronlong");% L4 F- n  y. U4 t6 h
MODULE_LICENSE("GPL");
# b! P: o& C, J' l- W! x# [8 S, n# }6 @7 c' k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-11-7 22:13 , Processed in 0.040405 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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