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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 Y; v9 G8 i6 L! U' M9 K
#include <linux/init.h>
; h6 c( n# Q  o, a7 b#include <linux/module.h>
6 S0 ^: `6 C1 L/ s#include <linux/kernel.h># U, F- Q/ N. R$ n  I" S
#include <linux/types.h>
) u% z6 E5 ^! S1 l" `) d#include <linux/gpio.h>
9 @. i& \$ |8 u* G. Z* I6 d#include <linux/leds.h>
) l" R; T/ a! A8 T2 d& \$ ?#include <linux/platform_device.h>
- Z; ^4 U6 H3 L" N( e% P  l. H& W* c. o: D4 d- d
#include <asm/mach-types.h>
1 C5 Q$ \  k6 v3 s7 X+ o#include <asm/mach/arch.h>
8 O8 k' P% H. m/ i/ @; d5 M) g#include <mach/da8xx.h>% A. f2 D6 S) l, z$ G8 K4 n- b: U  ]6 c
#include <mach/mux.h>
5 i# {1 f7 c! t7 n5 V' H$ R* s
$ N' v0 t/ X8 g" ]7 s#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 }% _6 p$ S. `& A! d' ]
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) ?5 `2 A; {4 ^5 k! I#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 H$ _8 V8 }( I, i3 ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), \1 x; k' b* z  g9 [! g

- c" ?2 m% \6 R7 P/* assign the tl som board LED-GPIOs*/
5 ^5 ^) A# [- d: |# t& Vstatic const short da850_evm_tl_user_led_pins[] = {
  P  o4 y) t. F) H; e6 ?2 B; z        /* These pins are definition at <mach/mux.h> file */
2 G# \/ a9 N- x        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 C( S* p$ c8 e6 L$ K        -1
4 [5 \9 ~, b, }% V1 ]: ~};/ b8 {% i" c& j# i( Y# u1 j# y
6 j7 E% {( t$ ~# ^9 @/ K
static struct gpio_led da850_evm_tl_leds[] = {+ l/ x9 s+ l& e% J6 f; P3 y
        {
$ o0 f/ J# R8 L- X) n                .active_low = 0,  n/ p7 k5 [/ R  e8 g) `8 Z' x
                .gpio = DA850_USER_LED0,' @8 b3 g! r# i
                .name = "user_led0",' Y$ e6 T- S- m7 h! e4 l% [
                .default_trigger = "default-on",& w1 ^3 w/ y( N! P! e" J3 W! a/ F$ V  f
        },- s, X3 G6 ~: N8 j% L
        {0 [# o, {( Q% I% _% d/ C$ M
                .active_low = 0,% D4 p$ h7 T' V% Y
                .gpio = DA850_USER_LED1,: _+ i% w1 ^+ B  ~5 f8 r" K
                .name = "user_led1",- I, a! h  P* m7 _5 H
                .default_trigger = "default-on",
% B' e, D1 M$ }. G, A- j        },
1 X0 w% m9 p, ~8 g        {+ i9 O% f- U  P. b! B
                .active_low = 0,
! c# K' W* O0 |1 T                .gpio = DA850_USER_LED2," ?/ W$ x7 O; w/ j9 Y
                .name = "user_led2",8 ?. j2 b- B/ r6 N
                .default_trigger = "default-on",3 p9 O) Q$ Z- [. d
        },
( U. Y1 q/ i: K) m        {+ G6 l/ n( U! u
                .active_low = 0,
4 V* M; P9 ~* Z+ M, l) U" s% \                .gpio = DA850_USER_LED3,
0 X6 }; X3 x) w5 \/ t! J# v                .name = "user_led3",
! D. a3 e! Y* F. r% }9 O$ K                .default_trigger = "default-on",& Z1 {  W& D* f6 a* K) F
        },+ b* u3 `# a& A& A8 H) R. b2 [0 j# k$ a
};/ o# E$ ?7 h& P* D. {7 t
0 l' b: x7 ]- g. W& c, N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& v" b7 o- m: h& |
        .leds = da850_evm_tl_leds,/ y/ W5 W' ]- }) U" a8 C5 i" G
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 k" H. @) v0 K5 t};, }/ I3 h! p$ i1 N, D

; D4 Q2 `- q1 q: O& \static void led_dev_release(struct device *dev)- @$ l9 K/ @4 V' F0 u! S
{7 r& l" B& C% s. U6 t
};4 n% |1 r  f& s1 i

! I4 G- K( U# f: Y9 @9 ~/ G8 }static struct platform_device da850_evm_tl_leds_device = {
1 U; M+ N  ?7 A3 q: Q( n  V+ G        .name                = "leds-gpio",
% P- r1 P  ~; Z* N        .id                = 1,  F2 Z3 @& c, g* H3 r4 I3 x
        .dev = {. E5 B2 H+ O& @2 H
                .platform_data = &da850_evm_tl_leds_pdata,
. H9 q* e. p( b2 q+ A" |8 ]                .release = led_dev_release,; m: B3 c# e: h
        }* `+ X4 w! w3 f( v
};
. _* J# K# s, e. i( t. J: p& F
" d; n1 _# P, Y  P8 I7 h* e9 vstatic int __init led_platform_init(void)
$ {0 v" ^) p) K! b% f! t* C. c& U{% k# p' R- {) m- ~
        int ret;
2 B( i0 L3 s9 v#if 0  V. {9 n/ n7 P' M: R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( u; r" W1 u1 l) J2 c! o
        if (ret)
" x$ L- p! n* d! F                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& `/ U; @* m0 x8 B. s
                                "%d\n", ret);
' D, p2 M6 x, F8 r& z6 N6 c+ q#endif
  R* ^$ J: |0 N8 M/ \! ?5 t! [        ret = platform_device_register(&da850_evm_tl_leds_device);
! Q7 U1 k% Y/ d8 S" v0 }4 a0 y        if (ret)
. G) O- c( X' I+ M8 V                pr_warning("Could not register som GPIO expander LEDS");
# X, i+ `: d, h0 v4 E- ?$ z0 H        else
; ]7 x3 S6 }+ M$ ?& s                printk(KERN_INFO "LED register sucessful!\n");# v/ x6 Z$ g3 o
& F+ [* J1 N- N/ t& r  `  z; a
        return ret;8 g: H" t/ G! W( _2 G2 ~) Q
}
9 k$ y7 u* r) T4 J5 B
3 g) I! k# b, ^+ Wstatic void __exit led_platform_exit(void): G( B% i' m& M9 ?. ?3 y7 Z) B
{
4 u  t& _3 e/ g9 K0 e* B        platform_device_unregister(&da850_evm_tl_leds_device);& a7 e0 ?" j' Y
* k' P# w7 o6 h% f4 D. A  Z
        printk(KERN_INFO "LED unregister!\n");
' i* V: G( c% D! k/ M! e  k; L}4 x1 K. b5 H' h* z+ `* j0 k: _
2 t+ ?$ m* A( `+ `" i2 Y! ^
module_init(led_platform_init);+ O: ~) L2 X- s) E; k: r+ _
module_exit(led_platform_exit);1 l  b6 c6 K& N+ r/ x: o. W1 x- d

0 @9 h5 S  M( u  c6 g8 ]* [) ~5 zMODULE_DESCRIPTION("Led platform driver");) R/ X1 z2 P1 ]! `
MODULE_AUTHOR("Tronlong");
4 G3 U% T9 O& |0 e2 e7 _# ~  tMODULE_LICENSE("GPL");! N; U# U7 b+ ~2 d. U: i8 c
1 G9 p. |! p  Q. l( v$ C
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-10 17:44 , Processed in 0.039622 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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