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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" K+ g% S( M5 {2 s; S#include <linux/init.h>
; j. @9 _$ ~2 R. ~( k#include <linux/module.h>
) B# n' V* D  z! n#include <linux/kernel.h>
/ H  q# x  W" ^9 l#include <linux/types.h>
2 X0 ~* f) ^2 Q+ l- V/ ^#include <linux/gpio.h>
+ T9 _1 L/ ]) r1 [0 @1 Q#include <linux/leds.h>8 E9 M+ D" @6 Q
#include <linux/platform_device.h>4 z; W+ r5 n( T$ {
' z! G: @3 _5 G6 J
#include <asm/mach-types.h>4 Q4 }7 T3 s5 U7 Z; V4 q" _
#include <asm/mach/arch.h>
5 W* n: @4 [/ p( t$ ?' y#include <mach/da8xx.h>7 A" T0 l/ g* {
#include <mach/mux.h>" x5 l( X+ {$ K5 [( D5 q

" h4 q% v, e+ c#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: K  S5 m; x( ]+ `#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" [0 p1 Y5 T5 r3 h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& ]% ^/ q  t( d  Y" ^' k
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ Q; P% {# t! j& W5 n6 i5 _: u& i1 ]- `) k
/* assign the tl som board LED-GPIOs*/( w2 k4 |7 A6 N% y9 I
static const short da850_evm_tl_user_led_pins[] = {
( Q& M  \. ]5 g        /* These pins are definition at <mach/mux.h> file */
9 t- o4 J% O5 m. M# W        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* m( w9 Q, _% V4 H1 c6 j7 H8 }5 |- X        -1  `1 N/ B: l/ V: c1 V6 U( y2 l
};
  b. \1 J4 c5 P% E6 A
3 t0 W! n0 h3 @9 S0 ?static struct gpio_led da850_evm_tl_leds[] = {3 J8 O3 @% G0 \2 @% }; Y; ?; j
        {8 n7 n9 o; H! v% _  U+ O2 Y9 b6 U
                .active_low = 0,- @" q/ m5 s! J3 ?4 L" C
                .gpio = DA850_USER_LED0,. f9 X* H# r1 R3 q# }( z
                .name = "user_led0",/ {2 c/ ]- B; }4 d+ y
                .default_trigger = "default-on",
2 f' ?$ }( }* v5 P2 ?! L9 |/ B        },
' l$ @9 o! u2 m3 A4 w        {
+ {4 q3 B; F1 K" |, {) i                .active_low = 0,/ w9 A9 Q, y. n! E2 L' y
                .gpio = DA850_USER_LED1,3 ~; X3 u- T  U
                .name = "user_led1",
; y7 L2 |; W& F/ W7 V8 u8 X                .default_trigger = "default-on",$ V: }) m% S2 a6 S" J& j  k5 z
        },
. F& N3 x0 W& P* b6 f+ n8 ]        {, A9 i/ P( c0 Y
                .active_low = 0,: g! Z* H" O6 V( _
                .gpio = DA850_USER_LED2,/ e' d; j/ T) X& p# q
                .name = "user_led2",& w( {& m  _7 i
                .default_trigger = "default-on",
& a3 M) \! ]8 W" i# C4 D        },
, F9 J" |8 U( Y5 d/ `0 D        {+ o! B2 r2 `+ \+ J6 V( [& D6 u  I
                .active_low = 0,6 B; A2 @. ]  ]* |5 }' ?
                .gpio = DA850_USER_LED3,7 N1 d  |1 h  K* Z% ^; Y
                .name = "user_led3",
: T& d5 Z8 |$ j) o9 J/ p  s                .default_trigger = "default-on",
* I" a5 B3 [8 m        },3 Z% M$ t, ~: O% F( U
};
: X' m% V- R& N) X0 s" V3 V/ b  b4 q. x5 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 M* C9 o0 U3 c8 Q0 ]% J7 o
        .leds = da850_evm_tl_leds,
4 P: a( ^- j- y4 g4 U1 H- b        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& `5 s0 {6 y6 I4 Z! {1 n' D
};6 Y! J6 P0 R7 N3 C
6 F' G9 j5 w; E& H) K) w% T
static void led_dev_release(struct device *dev)
& v# a/ ?# _3 Y0 c{( ~& m7 F, q" N/ M' K) N: s
};' G" |# Y1 J) ?6 c0 T
6 T& n1 F- p7 d0 {# I' }+ f
static struct platform_device da850_evm_tl_leds_device = {
) Y! Q% q; c4 n% @, d/ W        .name                = "leds-gpio",
* T  I  s* t% D5 d        .id                = 1,# v9 |' D+ X5 |) r$ S/ Y
        .dev = {
1 c. I( C2 m3 B- Z3 r% f2 a                .platform_data = &da850_evm_tl_leds_pdata,
& E9 P! U# q5 @1 T                .release = led_dev_release,
- b. E; D# z+ b        }& [/ G5 y5 f2 \
};! Q8 u% Q# ~4 H

, R' I) q6 G/ K6 H) O! Q8 [static int __init led_platform_init(void)
" e' W5 ?0 a/ v5 P# Z" j7 Y{& f" ^* w6 {) y" Q
        int ret;
1 k3 W9 ?; @( _#if 0
4 S, k& c+ [0 z) F2 k$ Y9 c' p( l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 o" V0 m3 q0 k9 ~) ~        if (ret)
+ A* F6 v2 l8 O. ~3 m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' p) }2 h! a8 u& k- v
                                "%d\n", ret);
6 T; q% D1 i+ H  h- y#endif
; u& u3 G9 `5 Y        ret = platform_device_register(&da850_evm_tl_leds_device);$ H8 p9 l; p! a! k8 y$ Z
        if (ret)" [; r% @  d5 m
                pr_warning("Could not register som GPIO expander LEDS");
" e7 j+ {3 i+ }; ?% Q( U* u3 C  M        else
( N& I; ]$ r4 F+ S1 a                printk(KERN_INFO "LED register sucessful!\n");# R/ U' Z6 I0 w( T2 X: B7 i
9 h1 J8 E! @/ i  k* k9 X1 s* l! \
        return ret;( z! V  X" |3 l- E, M7 ]3 y
}4 H( M+ ?7 [: W! N/ }; _

5 w1 e- c( M$ Cstatic void __exit led_platform_exit(void); s. X( z5 ?8 Z! X! b' a1 ]3 z
{2 \& A/ e" u* @4 p
        platform_device_unregister(&da850_evm_tl_leds_device);( u7 p+ b. s, h$ K2 s

0 Y' I1 j' N8 m; E& b& C/ k        printk(KERN_INFO "LED unregister!\n");1 O$ ^$ v) x" F; r, d5 a
}- Q/ \+ e3 P; o- H

. U7 W8 S+ l9 L4 ^1 X: Tmodule_init(led_platform_init);
6 y3 P9 C2 e7 S5 X& D) Bmodule_exit(led_platform_exit);
0 `; t( _4 G$ Z! J" O- O( X; u7 t- o0 T0 l: ^1 H7 q
MODULE_DESCRIPTION("Led platform driver");
$ m0 Z( q, K' S9 F9 OMODULE_AUTHOR("Tronlong");8 z  X! j' d) p! T
MODULE_LICENSE("GPL");4 L7 |& t" b6 H- t0 V7 \3 O  r

  b/ w8 q3 @2 n: A2 N7 r* s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-15 08:58 , Processed in 0.040030 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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