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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. ?. R3 |! w9 ]9 r. A& U
#include <linux/init.h>
- q; X4 L$ c- T9 u#include <linux/module.h>
2 W7 }! P% ^) c8 B% |; ~#include <linux/kernel.h>$ W" x  v) G9 ]$ }$ T
#include <linux/types.h>) t: }9 r0 X, i) |8 C
#include <linux/gpio.h>7 k% v; O- q4 h8 M, y) j% O
#include <linux/leds.h>
/ j  {; t& ~/ S; i4 h2 Z#include <linux/platform_device.h>0 t5 a" o1 b2 |( V. I3 ]3 u# m

' b: t2 U! X$ j1 J  m4 c; _7 E#include <asm/mach-types.h>
& H4 l; a0 Z: g* E#include <asm/mach/arch.h>0 W9 g3 |8 U. l/ L( @) g
#include <mach/da8xx.h>' B5 C* X: }  |, R$ W5 d/ u
#include <mach/mux.h>1 d) z" z, k/ d0 n+ t' j

5 e( L* N. j+ c#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ `5 E7 S* ^1 M  C1 z, ~#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)+ G) W- I" ~7 o' b, g
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! c& |% F( l- F#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). h0 h$ H* Y9 Y3 C6 y

5 ?1 g1 d5 |* \" N  C1 M: N/* assign the tl som board LED-GPIOs*/' }7 o6 a/ A0 C
static const short da850_evm_tl_user_led_pins[] = {5 E7 M  O4 V& H% |1 s
        /* These pins are definition at <mach/mux.h> file */0 G6 [; N8 F9 X# C# N( T# M' a
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. I% F6 ?* N( @: G# [
        -1
- G2 v' i3 ?; m( R- R};4 _7 ^% G2 z* a+ H) \
3 e! ]1 F/ z  T. u4 g" ]
static struct gpio_led da850_evm_tl_leds[] = {
& J. J9 l6 H' i9 i) V        {
9 G) s) q: E) ^8 }' b$ r1 v                .active_low = 0,( [, v. l0 c; x
                .gpio = DA850_USER_LED0,
  h; j) W6 Q& X/ a* ~' t  [                .name = "user_led0",
3 S( w  L- g6 q$ {2 `                .default_trigger = "default-on",
, [0 j' ~1 l7 w        },
) I) @0 Z* G8 [$ L        {
/ C4 @+ x5 [' e: j7 _                .active_low = 0,5 ~( y& R( T1 h7 M
                .gpio = DA850_USER_LED1,
  d2 A4 W( V0 b; B                .name = "user_led1",* k+ D5 L/ {; R( y, V# o
                .default_trigger = "default-on",
/ J9 V: x! y" v        },' ^& l. @. m% f$ |5 O
        {
  c& J0 M: w% J                .active_low = 0,
- U& W* N5 _1 \( h- J& C                .gpio = DA850_USER_LED2,1 N+ l$ T6 K% Q8 R- s7 i3 j
                .name = "user_led2",7 `# p& w% T5 {2 S
                .default_trigger = "default-on",
* `9 k2 m1 p5 w2 ]' V$ y9 B! [) v, q        },6 Z. |* ]5 F* Q, V8 o  @
        {
; V" A9 f* \8 N                .active_low = 0,
  g5 r$ L' G4 ~; p( G, w                .gpio = DA850_USER_LED3,- y# _1 q. b$ |
                .name = "user_led3",
- s/ m2 @1 E9 k; m3 V                .default_trigger = "default-on",
! |4 x1 \! s  u* h6 S) i1 A, m        },5 w  j7 B3 R. d* u
};
# R* Z- ?- L3 I" F7 `6 G
9 |+ t- Z: L/ L+ Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' ^4 }7 Z+ J0 ~4 c/ |        .leds = da850_evm_tl_leds,5 o( L3 W3 ?& o3 m
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 _+ N: {, V1 k4 V) C  {( B& w# u% {
};/ J6 n6 R! a# s, ^2 c

/ ?# I7 n$ O8 z) V5 k  U& v: Ostatic void led_dev_release(struct device *dev)) s% w" B( Q8 ]0 @6 e/ _* j
{. A4 [& [$ y4 N: B2 N
};
  F# S8 r: D$ B& o. K$ M4 v' N9 R/ J/ u0 b  g
static struct platform_device da850_evm_tl_leds_device = {
( a% l3 t: |* `* {        .name                = "leds-gpio",
( x6 @0 `% o) J: ^        .id                = 1,
6 V' ~. `# }9 [  d        .dev = {
0 ?; N) e& N( l6 c. J                .platform_data = &da850_evm_tl_leds_pdata,0 U$ v* C+ [. o4 K# ~5 C
                .release = led_dev_release,5 A- u/ J; \2 y& S9 ]* F4 A& F8 j! L
        }; V+ [& Y# ^# k& O0 p7 M' }6 {
};
1 {/ ~7 a& J  ~$ R+ Z5 s' w7 Y) f' S9 k
static int __init led_platform_init(void)
+ @0 v9 |' i4 h{
: B, z5 }6 `0 O7 m        int ret;5 d$ Z, k& n! A' G) f2 f
#if 0: f. P/ q6 X9 F& M! V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 E3 M. w8 f1 ?) u- N4 |7 {; ?        if (ret)( L8 h1 d; b; A  B; ~: q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; a) V8 f8 i0 R% \: z) S) p                                "%d\n", ret);
5 Y, @+ [5 n% @! ]; U#endif
7 w: Z5 D' w2 u6 r* W6 B        ret = platform_device_register(&da850_evm_tl_leds_device);' Q( F- Z3 ~, ?+ N- t! k
        if (ret)9 O3 E6 h( b9 X. D- R
                pr_warning("Could not register som GPIO expander LEDS");; y0 V5 g$ q3 m! H: q
        else3 X$ x, ~" C& d2 Q! B3 ?
                printk(KERN_INFO "LED register sucessful!\n");
3 M/ R2 n3 Y3 h/ P4 R( Z
/ o3 w5 ]2 S  V/ i' P$ \- e- c5 D6 n        return ret;) {8 \, @8 g9 T# b' T) b
}* e/ ?. K* U- U) K
) d! p4 v/ [" ~  \
static void __exit led_platform_exit(void). v* v' l7 Z7 b
{, o0 ]0 `/ p. ]% P1 Z1 R% T1 w. x/ ?
        platform_device_unregister(&da850_evm_tl_leds_device);- F+ v# h, z2 s; z9 T: x5 F9 \" k

( U1 |! l6 N4 Q1 ]: r        printk(KERN_INFO "LED unregister!\n");
$ C( a% s5 f* B, O+ W3 N* a}1 e" P- X1 J* h7 P" T7 w0 s0 p  S& `

: h2 t: M7 h$ J! ]( [% t/ M* {8 qmodule_init(led_platform_init);$ I  D  I  c7 w& j
module_exit(led_platform_exit);
2 z; h9 _8 _! s" G% X5 J% D1 _: N0 T" H2 R3 C% ]
MODULE_DESCRIPTION("Led platform driver");# z% ~5 ]& q  ~& [4 b
MODULE_AUTHOR("Tronlong");; _! f) G+ _* {0 w9 @/ N
MODULE_LICENSE("GPL");1 m, T) F2 o: w$ H0 y; U
- t- u1 J! j- R5 Y- Y  {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-5 02:25 , Processed in 0.040004 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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