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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% N( K8 c; j; q
#include <linux/init.h>
" l0 L* D4 ?5 b+ J$ r, O7 b& W% J#include <linux/module.h>$ \2 F; B0 h1 `+ R+ l
#include <linux/kernel.h>$ ]* e( m$ |- D% e' u! P( L
#include <linux/types.h>
4 H. h6 U6 T$ M6 o/ c. H) @#include <linux/gpio.h>* h% i5 b' Y/ F- Q% \" `$ s
#include <linux/leds.h>
: Z8 l5 Y7 l' Q7 D/ P# {) j#include <linux/platform_device.h>
" g$ s8 k8 Z& s) q$ Y! l
, p9 b: w, d& O: j4 @$ B# Q9 y* A#include <asm/mach-types.h>
+ Z0 g' ^4 X9 _( [9 G8 k#include <asm/mach/arch.h>
) p3 Y5 e3 j4 A1 `! _& Y' _#include <mach/da8xx.h>
, S3 o9 g, r$ H- m8 A4 \' }#include <mach/mux.h>
+ e3 r4 M8 I0 \5 O3 ?$ b
: ^& w& t5 j: x2 j# d. K#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)* E- R7 d' h/ d4 ~. k1 E& F
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% u2 u5 |% K( m9 K' P
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
6 F: P3 q: D1 w#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" d6 k# }+ S$ n
) ]0 g" k: b! I' \7 C0 w4 @% |
/* assign the tl som board LED-GPIOs*/
% c3 u* d  c; T6 H! [: _static const short da850_evm_tl_user_led_pins[] = {
3 a! O& p9 z' w& L2 N: C' m        /* These pins are definition at <mach/mux.h> file */! f2 H4 J$ V5 u  k/ I3 K
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ `: A# }6 K+ \( z) ^: u        -1' A3 k/ ?0 A& q* ^
};
+ K( G& ~" M9 _2 E' ~3 c
" i8 [4 h* U. U! H0 V& ^static struct gpio_led da850_evm_tl_leds[] = {
  E* X; ]3 x6 X  Z8 B+ J/ U        {2 Z1 C; a: |% {- e& J
                .active_low = 0,
/ e1 \; @1 e' H) t' A6 k                .gpio = DA850_USER_LED0,- Z' o: }4 X" m6 L" L  H/ q
                .name = "user_led0",
  p# N$ A' J- ^+ K+ d0 s, x% h                .default_trigger = "default-on",8 W5 [& b0 n& b$ C4 ]
        },; _3 D  N2 [0 K( h3 G
        {
) g3 }& B8 ~) H                .active_low = 0,
" [: O4 k; Q" q+ U9 E6 ~                .gpio = DA850_USER_LED1,
. G8 `* g, [) K7 y& j% _) ]                .name = "user_led1",2 T" ]( s; Y7 }, w- N1 b& R
                .default_trigger = "default-on",3 D  E3 ?+ b! V4 |4 _5 y' o: [* ~7 K
        },6 G+ u* f3 @: d4 w, [2 \
        {
' @7 p; |) t$ Z) J                .active_low = 0,$ n& g# }- ^+ q8 a* G  O
                .gpio = DA850_USER_LED2,. D6 h# j  v3 Q2 I  `. e
                .name = "user_led2",  I* N, z: O! w6 T' r+ ^
                .default_trigger = "default-on",/ }" Z3 I) |; v# l* ?
        },
- g" L) s1 f8 C# K2 l( i$ c        {
2 M# Z& w8 s8 ?( E% ?                .active_low = 0,; i7 q6 D2 u! F$ U
                .gpio = DA850_USER_LED3,6 M' {+ X' s- T* K
                .name = "user_led3",7 {/ y& ~( r( j
                .default_trigger = "default-on",% e/ e2 s* X9 u5 ~8 |! d2 O- H$ V9 _- O2 S
        },
& r6 j" \2 n. U  Q};
3 O& p9 v1 ?+ }3 @3 v/ w6 P
" J& i! |6 @5 G8 f) d* Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 L! K% [6 I2 Y0 I" f4 Y        .leds = da850_evm_tl_leds,
* K+ i# M( c/ i1 w  T        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) q) n/ S( \8 B2 u
};
% z# ]) ^9 X' T0 y$ n. |: I6 E+ ]7 p) z* [6 v. g- D% p
static void led_dev_release(struct device *dev)/ v# U6 q" n$ p. \: X
{
; @6 C# K2 {/ G. k1 x0 h};
2 X3 v! I: s4 j$ b: Z, u
" a  v+ Y( z- K% h# b% pstatic struct platform_device da850_evm_tl_leds_device = {( Y) M/ e6 v) H, }2 h" Y
        .name                = "leds-gpio",
% n% s  Q1 @' v2 p$ \5 G        .id                = 1,
# L7 i4 c) \0 |" ?  s        .dev = {
7 Q+ C/ W0 v  t; i  Z6 m% n6 e                .platform_data = &da850_evm_tl_leds_pdata,7 g, @5 W& m+ y+ V. e, B) {0 G; e* ^
                .release = led_dev_release,
& ~! e- F- c* w        }
( M8 [+ X7 R5 @+ M};
4 V( F% F: J6 u3 D+ n7 @8 v, z
' e# j/ f- R& ?+ Fstatic int __init led_platform_init(void)* L7 a4 A' t8 w! E
{: \  C( i" ]& m. C4 u
        int ret;$ g  p! T9 {( ^6 [* w0 [
#if 05 \/ ~  x6 a( b% s" C
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ ~, v2 U% K. r" q$ y( L
        if (ret): P, V' @- o6 }2 L; k
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 U$ _: x, P5 H$ V( L4 z
                                "%d\n", ret);5 R3 @: y/ L+ v$ ~- ]
#endif& `) `5 M" a0 k
        ret = platform_device_register(&da850_evm_tl_leds_device);8 L0 g6 }: [; O  u' E* d6 ^# N
        if (ret). E$ ^# m& r& i  e# f: {% d
                pr_warning("Could not register som GPIO expander LEDS");
6 K" o/ R. s  z6 Z        else
0 G6 W+ J/ w: _. V' O                printk(KERN_INFO "LED register sucessful!\n");
  a1 b5 H6 D% w1 e6 R# R' v3 n/ l5 Y) @
1 h0 l& \0 k9 W( N        return ret;
4 A! h* k, n7 N  H}
. Q- L: S" ~, y# r3 l& t1 P# ^
( s& e9 Z1 C8 o. E4 x4 b+ Nstatic void __exit led_platform_exit(void)8 `) h- s- v/ l9 F' k- l& L
{
- X+ ^1 I" u9 ?& `/ Z9 f: H0 w        platform_device_unregister(&da850_evm_tl_leds_device);
' S. k5 K( q3 C; T5 T, o5 K  Q" j/ M' C' k, T* e; E5 Q. ]3 L' a
        printk(KERN_INFO "LED unregister!\n");! ?$ l. l( S) \' E% t% [( O
}9 L& E) x9 {8 |8 I4 X) `' z4 L0 d

4 F; t) U4 {9 A9 E. z$ omodule_init(led_platform_init);
% M& O& X+ V* C0 x6 U8 p5 F; ?; X+ nmodule_exit(led_platform_exit);
5 k9 F2 U$ \7 l) f) f  D! m  w! Y7 h& c, E1 `; ^- v
MODULE_DESCRIPTION("Led platform driver");  m6 G: _  _8 S) `' h+ C
MODULE_AUTHOR("Tronlong");5 N# l- S0 q/ U# d; f! e! w
MODULE_LICENSE("GPL");
2 x# d% h% K6 D' [6 ?9 u6 ^- ^( n3 Z, z0 q! V
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-27 15:30 , Processed in 0.038556 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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