程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ K) z" l: X- e+ q3 T/ L& J#include <linux/init.h>$ ]4 C9 \( [' Z, _* I0 O* K
#include <linux/module.h>7 p* s: T* W1 f; E1 N
#include <linux/kernel.h>
$ H  I# f2 m  H3 p3 k9 X#include <linux/types.h>, m/ Y! ?, U; ]2 k
#include <linux/gpio.h>! Q9 A1 w" ?: e' A
#include <linux/leds.h>- O' @' X& A' w) T5 t
#include <linux/platform_device.h>: H  U) e- g5 {
/ n4 I6 T, `( B) Q
#include <asm/mach-types.h>
$ l) ^# {; m; K4 e  s. q#include <asm/mach/arch.h>
) I" D- E4 S# u: ^) Z3 l#include <mach/da8xx.h>' m2 R  t, {- S- Y$ z: C
#include <mach/mux.h>
' L5 h; X5 g4 e+ a, ?1 V" Y, X* ~* p: ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ \; A& c( r, n
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). [. w$ t% M7 M' P
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); w- l, n7 _: `  A: ]
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
8 L  m, M' P+ y/ b, P
+ d, p2 q+ @, b# o' c) j/* assign the tl som board LED-GPIOs*/$ [: d9 E) C2 p, \
static const short da850_evm_tl_user_led_pins[] = {: L; k+ E7 w. D/ N
        /* These pins are definition at <mach/mux.h> file */
' ?' W8 o. d: U+ H        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' Y+ c/ ]9 V0 I$ l. Z) l        -11 y. H; |8 k% e5 q6 Q
};
1 |. e, t) A& c
% P) S1 K; e3 m: |! Q4 J, [static struct gpio_led da850_evm_tl_leds[] = {
  s  x8 @6 q0 G- S0 q; M        {
$ ]' F. i2 W0 A( N4 ]6 U4 L3 ~                .active_low = 0,
+ ?! e- z" g' j                .gpio = DA850_USER_LED0,# }* |! s/ B0 P
                .name = "user_led0",7 u& T9 ^" j( j' L5 @7 n8 v  v
                .default_trigger = "default-on",  V/ {% A+ V. {: V
        },
( V  O8 _( }* f& D( D& v5 I        {
7 S& o. N4 R/ Z0 r6 }5 k                .active_low = 0,
" F- ]( x* }+ {                .gpio = DA850_USER_LED1,
" |& ~- C* s$ C  v0 d4 A: a1 w                .name = "user_led1",2 ?! i* r9 p1 F) r7 _. }) F" E; R
                .default_trigger = "default-on"," y3 v, B: i& i2 |
        },$ t- q) v' O% b" m
        {8 t2 y, T# d' ]) \4 P. X+ t
                .active_low = 0,* k# P% z0 o' W
                .gpio = DA850_USER_LED2,
( Y" r" r6 S% h4 b+ S, F                .name = "user_led2",
/ g7 s1 s1 x7 n8 |. c                .default_trigger = "default-on",8 g3 Z, o; ]$ @' ~' Q; B7 I
        },
7 Q. @5 x9 q1 Z* Z+ z: T" {+ c        {
# }7 W* e! u5 Z+ I9 x: D                .active_low = 0,4 l! l! }7 D) c; L/ j7 p( c
                .gpio = DA850_USER_LED3,
! r0 s6 o* _$ P# x                .name = "user_led3",
, m) I9 m1 s1 C                .default_trigger = "default-on",6 ?% y* K& \2 w5 J, \) k
        },
' Y- t( Q/ o* W! Y7 l2 ?# J};# Y* R6 |: {3 l  G

. Y* R: r9 w5 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ ~! g& s3 t. ]6 `( B        .leds = da850_evm_tl_leds,
, P/ V% u# Z- M8 n$ h; d% Y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. l/ a$ B& m) E4 H& U& P  \};
6 |' `7 H% y# z( x
" p% l. Q( I- m' [' fstatic void led_dev_release(struct device *dev)+ B1 G; k" J) u
{  G: J3 p$ m4 [- V
};
3 t9 @5 p1 N) @
4 M- H: i) D6 k- t- Ystatic struct platform_device da850_evm_tl_leds_device = {
  X: X; W6 Q5 {8 g        .name                = "leds-gpio",
# M: D& p) N8 I  o5 H5 p: U8 X        .id                = 1,# h4 f  A1 D+ G& i/ b; I
        .dev = {5 |, H) E3 m' e
                .platform_data = &da850_evm_tl_leds_pdata,
* `( Q1 Y( v5 v  ]) L# K6 z                .release = led_dev_release,
, \; N) E/ I$ `8 {6 J! ?        }$ s' u& ?/ f. Z- e  M3 Y
};
2 ?9 b! X- s# B8 k, x
7 o/ L8 w) Z5 |8 ]static int __init led_platform_init(void)/ Q/ f4 W) r2 x% \5 ~7 P1 V
{( h# g4 v, K% _/ R
        int ret;% Q2 m3 k( E4 o5 D4 F2 |" V$ e
#if 0
+ F$ @0 e/ ^7 q5 t* I  w4 ?, L  t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ ^9 {, u/ z* R! _0 R/ h5 `# \& K        if (ret)- `' Q: M4 L/ Q' N- n# \- `
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* |! ~, u: `) z2 T8 w                                "%d\n", ret);
/ D5 J& B& ^% S  d& u! m' d#endif- `1 ]4 Z7 o3 s- O0 h4 D' B; z. c
        ret = platform_device_register(&da850_evm_tl_leds_device);
" ]" x/ k. b( Q' m        if (ret)
2 f# A6 F, E. F4 I, u1 k                pr_warning("Could not register som GPIO expander LEDS");8 W3 ~0 z1 G! a" @% N7 S
        else; W8 K8 c: n/ u8 Q' ?$ L* Y$ `
                printk(KERN_INFO "LED register sucessful!\n");
- T5 \. Z$ P0 C3 B6 ]( C7 S
( R( q7 @8 Z# H) N        return ret;
9 U, B0 u# s5 Q1 q}
" S( k: s$ a6 P. F
+ ~! ]* A6 H2 Y, D4 C- ]static void __exit led_platform_exit(void)% V- l+ z8 ?1 t- b0 @4 M
{
# |. j& Q) y0 p        platform_device_unregister(&da850_evm_tl_leds_device);
" m3 x9 K# ]$ R1 R% I1 E, L4 a9 i) ]0 I
        printk(KERN_INFO "LED unregister!\n");
2 E/ b5 h2 d9 _9 j}0 o3 D( J+ a$ I- x/ ]

4 ~0 O" M/ T! {$ y: q) D, Pmodule_init(led_platform_init);) E$ Y8 Y2 O: i8 T/ O' {
module_exit(led_platform_exit);( ?' X' G* E% d1 C) ]

* o9 q1 y: }- f) L$ a/ cMODULE_DESCRIPTION("Led platform driver");
- z' l+ H( K! s) eMODULE_AUTHOR("Tronlong");
1 s2 J9 [& l/ H8 b4 T" r% C7 j- \) SMODULE_LICENSE("GPL");6 [: M* i: b( M

6 o; g# ~0 w9 R1 H" M3 m
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-10 00:29 , Processed in 0.037423 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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