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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: V, U* q- q; y" Z2 Z! c! H#include <linux/init.h>
6 Z; V* S9 W7 ~) e. S#include <linux/module.h>
  C. O; c7 \. t- |5 _1 [#include <linux/kernel.h>6 d/ R% R) ?, `4 ~" U" Y- i: U
#include <linux/types.h>( t. J6 v) B& i6 i6 K1 ?) c
#include <linux/gpio.h>
7 Q) j5 p' `( v+ t( s#include <linux/leds.h>
2 n5 T3 c- h8 V9 ^' s8 e#include <linux/platform_device.h>4 J  s, v$ m% I( S
/ B/ d' _" _' I1 j9 J7 i; |3 B
#include <asm/mach-types.h>
$ b% S( F" W1 w; F( W+ C8 }6 x#include <asm/mach/arch.h>
8 _  K0 [' u& `2 O" _4 s+ Z#include <mach/da8xx.h>4 S; t) p; d( d' \8 v
#include <mach/mux.h>
* W& o0 u9 q' Z* }" X* N
) Z" U# p- P# [) r1 V. F/ O# P#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 H$ E$ u" G* ?( e& N( N#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): _% x/ |4 f" A  e
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 T: b) r/ Y7 L8 Q, P, f#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ a2 G- p; M$ O. Q

2 C" h+ B  e; Z) u/* assign the tl som board LED-GPIOs*/
' T; t4 Q1 q9 X& {: h0 Qstatic const short da850_evm_tl_user_led_pins[] = {
& ]: i- K8 s+ C6 [+ X" U6 ~( I; D        /* These pins are definition at <mach/mux.h> file */4 E* X1 q- `( M! Z' `- }
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: `* U6 |, |- e* q
        -1! a! R" ~' ~- y  X
};
* d% ~# x+ j9 l) k. Z) Y
1 Q. e% }& r& M) v2 T. d+ mstatic struct gpio_led da850_evm_tl_leds[] = {
7 S: x1 ?8 D, N2 \        {
+ N1 m! A/ d& h. {2 ?                .active_low = 0,
0 K) M) W$ E$ a0 r, B                .gpio = DA850_USER_LED0,3 P% W0 y. O" k
                .name = "user_led0",
, T. J  _3 `8 g7 U! t/ g                .default_trigger = "default-on",
" G$ i% r  g- a' ^% ^# l        },
  o: k; P: B. i* _        {; J3 {0 Y4 _4 x. ?6 W( L
                .active_low = 0,/ g# A, k0 v, s( e. n
                .gpio = DA850_USER_LED1,/ Z6 }$ Q9 k" `
                .name = "user_led1",
) |* b7 b. k9 }0 k* r                .default_trigger = "default-on",5 L9 q, d( B0 q* J0 V' P
        },& C" Z8 b8 v$ _5 ?8 {; |
        {
& q% ?% V: ^9 D9 Y; ~$ T, g                .active_low = 0,. ~, S+ B0 L: P2 n/ C/ n6 U5 ^
                .gpio = DA850_USER_LED2,% C2 E/ {7 t7 r# n" e, L1 J
                .name = "user_led2",
) C# @8 T! R% t                .default_trigger = "default-on",5 j' u& F  s3 c2 i6 g8 g' o
        },
, G) J$ E$ V1 a2 N. f- C, f- t+ d        {: \* v/ w  a' s) e  v& u
                .active_low = 0,
' m: Y! u* ]/ @* N# B) ^, L' _7 J                .gpio = DA850_USER_LED3,
; ~9 Z: A5 E' ]7 ?0 n: i                .name = "user_led3",
# K) x% [1 {" l  y( q                .default_trigger = "default-on",( P6 \% O% M  x9 @
        },# Q, g- o2 N* `6 r9 {
};
% z7 ?( V/ B2 z0 j  g3 J' i) |, K5 ?5 n$ K& j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 x! R6 h  @% x1 k$ w4 |2 J
        .leds = da850_evm_tl_leds,* D" B" A6 @; S; t# Y/ C
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% k: U0 y5 x% K$ A1 r
};* ^, H1 x# Y" r5 x7 Z/ P7 [; K
) l2 o$ m6 I/ h4 ?8 p) w- ~0 n
static void led_dev_release(struct device *dev)
! e. R9 y6 @& a9 x: n+ K{6 P1 S! W' T" S3 E2 x
};) t0 v* y" a6 d; k+ w% O+ t

3 `% P" q# J6 `* ]static struct platform_device da850_evm_tl_leds_device = {
) \" B3 ]) R# }7 [        .name                = "leds-gpio",! b( Q* w3 o; I# E1 y* m1 O+ Y9 _/ j
        .id                = 1,
3 q9 R6 [9 C$ D! B! M: ]. Z% t        .dev = {
( y* P# }+ |5 E, o7 y6 e  @6 R# L                .platform_data = &da850_evm_tl_leds_pdata,& u7 _% l3 D4 q: J1 d* }
                .release = led_dev_release,
. w3 k. i% f5 k0 L  {        }
/ Q( Y2 @' o, v: r$ a% T$ N};; s* f4 d+ y) v0 T

" L1 B' l* O8 P) ?5 `static int __init led_platform_init(void)
2 R' Y. A4 W( _9 g7 V! v! X{
7 V2 I: ^: W) z1 K! `+ I- C  q; z        int ret;: A8 v9 }# C4 K
#if 0! \" l4 A, O6 x% Z' }- T4 J
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* d/ n4 ]+ ?$ M. V$ e; ?) A4 N
        if (ret)
- H' X: d3 A+ {, }7 k" r1 l. k                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ U0 r* {, C! R4 g- q! J
                                "%d\n", ret);
3 ^# Z, L/ D* @9 z( [) _#endif9 Z3 N1 U7 a% a4 I' d% K$ ?8 X
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ h( `' N; b1 S* l$ J) R        if (ret)6 o0 b( f. v+ ]7 \$ m1 S" R
                pr_warning("Could not register som GPIO expander LEDS");
& m5 g5 L" g+ e+ p# T7 w9 Y        else" J( f& [) S6 k8 ?& |
                printk(KERN_INFO "LED register sucessful!\n");
& x/ I/ \, D8 i" p- m% d( v
3 R; ?5 ?' G7 ?& ]9 Y$ R        return ret;
: k# h% U8 ^0 X) T/ L9 h}
! B0 D" U) O: X  P6 X* h
: v# E2 E& L7 i; Y; Pstatic void __exit led_platform_exit(void)1 b( y7 k) }- n6 b! N6 Z& K0 F
{
. S; |$ x2 H1 m5 F, s        platform_device_unregister(&da850_evm_tl_leds_device);
3 ~3 W& c' T- @1 h6 L( G5 f
" d* E! D) |( X* c        printk(KERN_INFO "LED unregister!\n");7 d# |9 _0 d$ |' X
}
+ s* \+ c$ Z+ G- s# B) ^1 z) k7 l$ `4 G
module_init(led_platform_init);5 o) V9 G, f  j
module_exit(led_platform_exit);
: F7 D0 ~5 a, S. k* ?7 n, w* m6 W. {) n& M& P3 x2 K: A
MODULE_DESCRIPTION("Led platform driver");# W+ L; G7 u% G* {
MODULE_AUTHOR("Tronlong");9 R7 K4 `5 C7 K) ~; @
MODULE_LICENSE("GPL");
8 a, D0 L: A# y! v( Q' M
) e3 h4 ]1 ~8 o, B& s  [/ I0 J! I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-11 06:43 , Processed in 0.043691 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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