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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 B1 h( }  j" }3 T* [2 i1 {#include <linux/init.h>
' Z  o  f  y& |( J7 Z#include <linux/module.h>1 M! L% \6 i! @2 J% v2 s+ {. x: s: n
#include <linux/kernel.h>3 y5 ^& N4 X: I3 x) W
#include <linux/types.h>
; ~& x: m" c% w0 s/ O6 G#include <linux/gpio.h>* v: t5 G" [# F, M/ `: Q1 s
#include <linux/leds.h>% M, h6 v; u6 {7 s/ K
#include <linux/platform_device.h>
, I* F5 k* g" [9 J; q
; @. w* a* R- ?#include <asm/mach-types.h>
2 O, V, G* F4 T#include <asm/mach/arch.h>  U  v9 v1 |  f% l5 o3 f
#include <mach/da8xx.h>
7 R9 }& M! o5 ~) }( H#include <mach/mux.h>
, G# s2 l- s8 j# |; I9 d
2 Y, f( n6 \( O! p" i9 E6 Q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
1 [0 ~& _  r% ~; D  {; Q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)* u& z. b8 r! W5 t& D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! o: f' ~6 \2 G* `9 Q- O9 \
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
3 I7 i9 ?& K8 u% y2 k9 K% q+ B( {2 V% F
/* assign the tl som board LED-GPIOs*/" C8 a4 w% U/ J3 d1 T5 {
static const short da850_evm_tl_user_led_pins[] = {
. x  J+ V# S4 |  |1 M- e        /* These pins are definition at <mach/mux.h> file */2 f/ C2 i; \' J0 U- I8 W
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& N% Z3 s9 Y1 a- h        -1- L4 V- U% a6 B- O) g' b
};
8 |8 C. T6 ?" Q: a& ^: q: Y* s! P- y/ P- ~* u4 `7 x! N$ W4 ~- q
static struct gpio_led da850_evm_tl_leds[] = {" m- P. L% h2 E; I$ I
        {: |! t3 F6 }$ W1 U
                .active_low = 0,$ Z9 ^2 B# V3 B# r: x
                .gpio = DA850_USER_LED0,; m3 j* V  }! U9 [- ], |, M
                .name = "user_led0",: x6 m& ~2 W; u' }5 d
                .default_trigger = "default-on",
. T4 {- y! n4 t" r" Z& A        },3 A) z: D# r% W  l( p
        {
; A1 x5 |$ t3 K- c- s6 C3 o                .active_low = 0,
6 i3 g) O+ |' E2 F0 Q& G' O3 R                .gpio = DA850_USER_LED1,
" N8 H, S$ K* ]9 I                .name = "user_led1",
: e& X+ i: ~: ]* n+ s                .default_trigger = "default-on",
3 }- `! B# r& A! C        },$ `: Q4 v6 v+ N- q$ ]
        {3 r: m' [. U" N& B
                .active_low = 0,7 H  z$ ^: L+ f4 S9 Q- f3 d2 s
                .gpio = DA850_USER_LED2,
; O& Y+ I2 F8 M( \* d& C                .name = "user_led2",
0 k! |& q" W1 I9 v0 E- b3 j) r                .default_trigger = "default-on",
$ ~  Q% j, z+ z8 E9 `, W        },
1 C: ?6 Q- K$ D        {
1 W& U8 o# i9 u6 Y+ `( j                .active_low = 0,
: |: S- n% T8 U7 b                .gpio = DA850_USER_LED3,
4 e& b* o/ x9 F2 R0 I* W. U                .name = "user_led3",
7 \. ]2 g' |4 Z2 h                .default_trigger = "default-on",4 d7 B" l+ R6 _2 A2 i
        },1 Y4 t# L# `/ h8 I+ c, _6 w8 F+ U4 N# r
};
/ Q+ {. U0 {2 U
" ]& k# {1 N$ X. F: Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: ^4 t  z7 P" r* |; d6 R% N
        .leds = da850_evm_tl_leds,
" h: ^2 U- D) f8 \/ C0 ?0 j6 Y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) T, Q2 Z0 Y' q% K0 v
};
( q! s) k% h4 F" f0 P/ ^# k# S3 ^( ~5 L; x, d0 q
static void led_dev_release(struct device *dev)
+ C9 C. y- t6 |4 ]{
( U; b0 C: ]7 ^8 }. b* i1 P};' Q7 j5 L" }* D) i; I
/ ]! @! v% w& A6 y
static struct platform_device da850_evm_tl_leds_device = {
+ W3 m% P. D0 Y0 X9 R        .name                = "leds-gpio",
+ O, ~" O1 D) `" c* b        .id                = 1,
4 l% \) C1 i0 C8 W        .dev = {" Q0 n" H( g/ [
                .platform_data = &da850_evm_tl_leds_pdata,
2 C* v1 l& G" q7 \9 i                .release = led_dev_release,1 }8 G6 ?/ j- r% ?- K2 r1 B
        }
- c; {: u/ J3 R" u9 F$ v};
5 T9 z) C. h+ t) ]' i1 P. N& T7 [3 R& j( V5 O
static int __init led_platform_init(void)
/ T2 q5 j# d( K: V# u{
( u- A! [# W, s/ Z6 a        int ret;
) {/ j/ X! s9 G1 H7 y% f#if 0
  {) S% T% c' @, K* s" J        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 U: y9 F7 c9 G$ m, x        if (ret)
6 Y. o3 {7 Y' m/ M8 r; {. N                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ y1 G/ j. d% s( J4 @                                "%d\n", ret);5 ^7 Y2 p+ N/ U
#endif
' c1 Q; v2 p  `' S' b5 ?        ret = platform_device_register(&da850_evm_tl_leds_device);$ S( Y$ P( {8 G, L9 b5 b
        if (ret)7 }3 G3 T2 o( C0 l, s$ @
                pr_warning("Could not register som GPIO expander LEDS");
9 n; T0 \( e7 k( ], W        else0 D6 L& y; ^# C. m. I$ c9 k5 }
                printk(KERN_INFO "LED register sucessful!\n");
( o. v9 G& ?8 U9 X/ Z0 v: m" z& \9 [% F
        return ret;
4 C- c! f+ Y+ E4 \}
9 \( x0 J; d- w3 s+ Z- b" \* {# q8 U
static void __exit led_platform_exit(void)3 k  }  w1 i" F9 `% c/ w8 X
{
* w8 r  F; ]3 Q4 O$ J1 D        platform_device_unregister(&da850_evm_tl_leds_device);7 m) }# B. M* G! t/ U  I+ I

! V- A% [$ n+ L        printk(KERN_INFO "LED unregister!\n");
9 x; q9 t: ]* L: S/ w}  @/ @; z( R( L" d! q* n6 @
7 y. v! b/ Q0 Z+ I4 D4 O. G- E8 ^) ~
module_init(led_platform_init);9 m# F6 ]8 V( l$ [+ g1 K+ I
module_exit(led_platform_exit);
% \" F% w) m. A- q+ @. I3 F. C& i" }4 {4 R, n8 d" N0 Y8 B: |2 @
MODULE_DESCRIPTION("Led platform driver");
" y: m0 e: C; ^) J$ f! @5 O% `6 @MODULE_AUTHOR("Tronlong");
6 N- P+ |' w2 ?4 b2 X" P, e7 bMODULE_LICENSE("GPL");7 m7 I- E- m6 T
: d5 S  N! b1 J  ?# x- d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-13 23:56 , Processed in 0.035937 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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