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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
; P5 i  L2 M8 U0 B  M#include <linux/init.h>9 V0 n6 [& m. F  C; s5 J
#include <linux/module.h>
' g: `4 g# O% S; h- n) ~#include <linux/kernel.h>
* g) g* P3 W: S#include <linux/types.h>
" q; F, I8 ]$ f9 p#include <linux/gpio.h>  K6 t+ Y. Z0 J! o& e
#include <linux/leds.h>+ O# f$ q8 u/ X3 v. x+ b
#include <linux/platform_device.h>) _' ]; X" Q4 F1 H6 T

! v: e1 V: l+ a2 X#include <asm/mach-types.h>  @% f+ y- ^! u7 P
#include <asm/mach/arch.h>$ Z9 t: v& L% V0 K# A# ^3 ?! W; ~% Q9 ~8 @
#include <mach/da8xx.h>( x/ D; [2 M7 Q7 X
#include <mach/mux.h>
* i# Z! A0 H! M0 p# l  R9 N  f% F  d$ W3 k, w
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# w5 r, G; O4 U) L* C9 s" C$ O
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 Z6 W( E+ J# V' N+ \! n
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1), b+ L. c/ o3 j5 Q" R# W
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
2 Z5 _( K" m' L/ n1 r( i
! @; r7 [- P; K& b& M/ z, J' o/* assign the tl som board LED-GPIOs*/
" g. I. Y& m' R! Ystatic const short da850_evm_tl_user_led_pins[] = {" I) }9 [% I1 E" T& K9 l: o- L' C
        /* These pins are definition at <mach/mux.h> file */
8 a& M, U; b- H6 \! |. G        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 I4 Z7 ~% {1 i0 w
        -1
1 Y  m( }% v+ |7 g/ H+ R' ^: c# ]};
: \6 A2 g+ E# K9 _9 a) \1 _
1 r+ ^( U" E; f2 R0 c9 hstatic struct gpio_led da850_evm_tl_leds[] = {; Q# b; D" w( _$ r
        {) i2 j8 v. C: _' d+ Q9 K) V
                .active_low = 0,
# ^& R- Z- y: Y& A" q5 E& w, k. }                .gpio = DA850_USER_LED0,
. B3 K! P" N) R# w! @6 b0 O' U) s                .name = "user_led0",
0 D- v7 p9 G! |                .default_trigger = "default-on",
! V* z" G, v. G; t: Q8 |; Q/ l        },) K" ~, [) f$ h0 D+ ^
        {3 {2 v/ c; A4 e$ C$ H* x& U
                .active_low = 0,; [: ?/ e1 k& e/ r6 f4 }6 s1 D
                .gpio = DA850_USER_LED1,2 B# {. G9 a: `5 }2 a
                .name = "user_led1",
8 J& }7 D1 K' U; m                .default_trigger = "default-on",1 h. j* y' R! `8 y' n: g) z
        },
! s$ B+ |: ?6 y! o4 C        {
, X! f2 |% c/ Y                .active_low = 0,
% J( |! \- k+ L" c                .gpio = DA850_USER_LED2,
. ~/ \. K1 Z0 B4 V! A5 I. J% z                .name = "user_led2",
( [5 J& `4 y- h& t8 O0 D                .default_trigger = "default-on",' H1 H/ S8 }* \% h
        },1 Y' `% E& y8 p* `) j* m. z
        {
" u% \/ x) Y% {- ]5 S0 P& X3 X8 s                .active_low = 0,( M5 T6 g, M" G+ d8 n! K
                .gpio = DA850_USER_LED3,
* q; L" d. P/ R4 H; A* Y& C                .name = "user_led3",
* M1 n3 u8 {+ f. d2 A! P$ y7 H                .default_trigger = "default-on",0 S7 H  C' t& s) i: P! U
        },
) Q9 n3 {$ R- ^" w) ]1 W7 m0 y};
/ }4 Y. z* |5 M0 q& A: v+ d7 \2 v
6 \8 X8 p! K) t8 Y- k$ N, `# kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" `# k/ a) ]; x- n' D: F
        .leds = da850_evm_tl_leds,
1 C9 }% [' N) Q) A2 Z7 D* V* l        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) ]' {$ O7 n  y0 p( a
};& ^* q/ ^: J! [8 R" b* g

+ j2 U8 k7 }3 J% s$ |! ustatic void led_dev_release(struct device *dev)
" e0 `  I; L, v8 [, y) k/ A* F2 {) I{) a3 y, F  R3 |, A9 B
};
; B% t: U$ l5 k- P$ F- R& j
  g; k2 f* r8 d4 }, g! Z3 hstatic struct platform_device da850_evm_tl_leds_device = {% T! R, w- Y  a' U- I# p2 [) C
        .name                = "leds-gpio",' r$ D3 @6 S: U+ O4 M
        .id                = 1,
) v6 X- A1 r* I8 X4 ?        .dev = {
9 M$ _5 j8 x( ?7 V                .platform_data = &da850_evm_tl_leds_pdata,
8 r2 ?: `, |2 v8 ?- R7 M; s                .release = led_dev_release,
' t* V. m; |% E$ I1 w' {* G4 c        }
% I2 [$ B3 O! r  U6 J7 B};
2 j0 I; Y9 w. c$ L, L" C- F
% V0 d) ~. J. I+ \" G; r3 Qstatic int __init led_platform_init(void)
1 w2 ~4 [4 b9 U& x3 P{% O( c4 P- k. T2 Y2 }( E
        int ret;6 I9 X, t( Y& i6 D' N' B
#if 0
& U9 X+ X% ?$ h/ Q1 L        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' ~; K. h0 q! v. d, m        if (ret)
7 D8 Y) c3 Q8 x, ^                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 G- w3 [7 Q% J* V3 X5 d
                                "%d\n", ret);& K+ O2 j) L+ c$ s, m, l
#endif
  Z) q5 P* g' k4 h        ret = platform_device_register(&da850_evm_tl_leds_device);1 h2 R$ G( W# ]( }* D
        if (ret)4 e. T4 K, _/ b* D, V$ g7 \7 l) i
                pr_warning("Could not register som GPIO expander LEDS");! w: ^0 s9 {& s! t! S4 b* s
        else
' i9 l% M/ v) I+ d4 k5 f& C$ O                printk(KERN_INFO "LED register sucessful!\n");) Y" y6 S6 X" |( w7 @, t
+ q! @( ^; m0 m6 F# A7 c
        return ret;
' k5 ?1 {# N- O7 S& G}. S5 C2 j1 g) J3 }( V7 h

2 }/ \0 _8 A8 \+ f. j  nstatic void __exit led_platform_exit(void). X# s8 {: w6 A) D8 V$ P7 X/ e
{! b; P6 h% i5 _
        platform_device_unregister(&da850_evm_tl_leds_device);
9 A+ ^, l. ~  P6 t5 |5 L+ Q/ @6 v5 T2 a, h: n' o( c1 t
        printk(KERN_INFO "LED unregister!\n");3 l5 }$ S" l! f) b' @8 y: X  `
}2 p6 G9 c# k4 Y( w7 J* X& M7 w
+ K* g2 G7 s/ b- @( J
module_init(led_platform_init);
: X! Q1 t% |9 _* w& d- T9 Nmodule_exit(led_platform_exit);6 X# v3 T7 z& x

/ v& ?; d4 T; o/ p* s3 B, hMODULE_DESCRIPTION("Led platform driver");, Q& r- S0 n) p; J" j/ x
MODULE_AUTHOR("Tronlong");( ^: T. N- v6 G4 y: L, T
MODULE_LICENSE("GPL");
! Z$ p+ v! ^; s  R: R1 @1 N& }7 [, l; c$ K# ?- c. H
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-10 10:59 , Processed in 0.039421 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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