程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 O0 j$ {$ p; N: `6 b; F#include <linux/init.h>$ z1 e- L9 `$ Q! ]
#include <linux/module.h>
7 K! o$ ?0 g1 I/ n5 c% C#include <linux/kernel.h>4 x* H2 O4 ?  k
#include <linux/types.h>
, ^# V! I7 L; ]* |( W4 W1 B+ \#include <linux/gpio.h>3 R8 o/ \! p1 Y
#include <linux/leds.h>
" D2 A! |4 d8 [' o$ G+ ^#include <linux/platform_device.h>
) o$ N' R; S6 G; H' q* {/ k# @5 U
# u9 ^) j% s$ V3 Q! M#include <asm/mach-types.h>
% b$ p& E4 {; O$ N' r/ f$ ]#include <asm/mach/arch.h>
; I% P9 c8 p, e  ]" Y) _' x/ ]#include <mach/da8xx.h>
0 Q& b3 t' O  a0 q#include <mach/mux.h>, T# ^& A8 P3 P( s! m- {) |

, A% y" u- V; j& k* \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); ?" y/ Y( f8 Z2 ~0 i, x& x/ p
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 I9 q" [" T2 L5 K8 I) S
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: K! S5 W  e* r( M#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
2 O8 ]. a+ v4 E0 l7 k
0 A% Z1 a* a0 Y) g1 C/* assign the tl som board LED-GPIOs*/( x# N* l3 T: l4 A( ^
static const short da850_evm_tl_user_led_pins[] = {
) J2 @$ C9 `. U% L/ t' c        /* These pins are definition at <mach/mux.h> file */. \! a% ?8 W1 I) Z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 K7 z3 C' b$ u! P( a
        -1
, v, W2 d1 N$ E" j};; z, H6 G# t- G
# ^' l' C1 }5 I; A! e' d
static struct gpio_led da850_evm_tl_leds[] = {! @# w; A4 ~0 w9 k, s
        {
  w7 u  ?$ ~: @! u                .active_low = 0,
( q# X; G) [! p3 r$ e1 k                .gpio = DA850_USER_LED0,3 a1 j$ S& T3 ~0 Z; S0 Z7 q0 F
                .name = "user_led0",5 p: ]/ @/ c. B( V8 n
                .default_trigger = "default-on",
# u6 }5 B5 u) _; i; Y! x. |        },
6 ?0 H! g. l7 u9 ^# L. [        {1 d1 p! w1 y& r+ E; H' n7 F
                .active_low = 0,
5 N# v& Y6 i0 g. Z! [* p9 J                .gpio = DA850_USER_LED1,
6 K% d/ J5 h9 z7 E* p4 j8 O3 B                .name = "user_led1",- @0 o, [& j( z8 G
                .default_trigger = "default-on",0 O) b. `4 K- D) `* _& D
        },
" z& m$ G9 X* F        {
; g5 T6 e/ `  n1 p% R                .active_low = 0,
2 O! p' a% A3 i0 o0 }% ?) H( o                .gpio = DA850_USER_LED2,# \' E) k. i8 ?6 W
                .name = "user_led2",
7 ]; }3 Y' l. {* h  ]- o) K                .default_trigger = "default-on",
; j( N; C, K1 U2 U( a4 Q  a3 S5 ?        },& E8 \2 b: i" E6 v' A; g
        {
1 E" ^! R5 [1 C                .active_low = 0,
+ x& {$ e& ~, t                .gpio = DA850_USER_LED3,
4 T, W- x8 T7 _4 i  L                .name = "user_led3",
9 N9 Z) y' T8 ?/ z6 O5 q                .default_trigger = "default-on",; j8 d+ d/ b; q9 O/ k# y
        },
* r- ]+ g+ V, @: p' ?0 t};
+ z" U% G1 q* B% ?3 C
( O* [" G9 l9 g6 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& h7 R& V4 V1 h# O( _" k+ F        .leds = da850_evm_tl_leds,
' F5 P3 h" d* q  ~, N& h        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ F. r5 S6 e+ [' U& E};
! W" G7 X, a. O4 p5 _! s6 X
, L. x9 Q6 u. Q, |" |# {9 ostatic void led_dev_release(struct device *dev)6 E4 D3 W( f5 k# m
{
9 c) M1 B0 x) t0 y3 h( ^};0 k2 o% s9 S: e' ^
3 Q. q3 E3 Q% R% H: v3 f. m
static struct platform_device da850_evm_tl_leds_device = {% r7 M( ?! d5 F; n  `
        .name                = "leds-gpio",7 ]* C. h  s# N" ]
        .id                = 1,
$ ^  K% T; Y7 K        .dev = {" {8 Y7 r6 a/ Z) D. ]/ I" S
                .platform_data = &da850_evm_tl_leds_pdata,* ?) p6 ~2 q7 e- I4 \, J4 o6 b0 `& U
                .release = led_dev_release,
& s3 K  @+ W! i, k' ^        }3 F9 y: n: @3 p
};
8 r' z/ _' H8 x0 R. \8 j1 d& l
/ Z' ^& `  W7 t  V, A0 @' i" zstatic int __init led_platform_init(void)
) F/ f# f. o- p4 O6 O& j8 o{7 F" o$ Z$ {+ ]/ N4 k& Z) \9 ]
        int ret;. h9 [3 f' P- A
#if 0# P+ X- x7 z" A9 Y5 o) I! f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" s7 k( N- J' @5 y( R$ A- `" n; M
        if (ret)
; v) R3 Z  W4 y; Y: Z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 r# Q% z; i0 c  p0 K                                "%d\n", ret);: h3 X. j$ \3 q; Q. C7 p) J
#endif# \# X' x3 a0 P# x+ N; D
        ret = platform_device_register(&da850_evm_tl_leds_device);
7 F) W9 s$ A8 }  [3 |9 `& S        if (ret)6 c$ U1 g9 O/ }, s* V
                pr_warning("Could not register som GPIO expander LEDS");! r& q  ?7 t6 G8 ]
        else2 i( Y  X" \8 s( j: o* A
                printk(KERN_INFO "LED register sucessful!\n");8 w2 E8 R/ a1 }/ s+ t# r

- r$ g$ G7 B2 A6 \        return ret;
* w" j; ?- I" Q% \" y}
9 b- W; i$ {2 f" w* }
/ F; d$ \% a: w+ x4 f1 ~static void __exit led_platform_exit(void)
5 |* s2 r' B# i{
& U8 i! }0 E" p$ K- l        platform_device_unregister(&da850_evm_tl_leds_device);. j: M4 V2 m' Q" I) u
; R3 A1 i; V/ j
        printk(KERN_INFO "LED unregister!\n");0 N# T, ^0 v, e0 O! x/ }
}# r0 ]" Y+ |. U& V& }2 e
* ?4 J7 ]( X: b" a
module_init(led_platform_init);& F  X* y0 O$ x& c! ]) T7 s
module_exit(led_platform_exit);
( d1 C" ^, q$ v/ V0 g- a) Q7 }- r5 z  C  R
MODULE_DESCRIPTION("Led platform driver");
: |) J9 W& D0 `MODULE_AUTHOR("Tronlong");
- j* W+ x# r/ \' J1 `: A& OMODULE_LICENSE("GPL");
; `" X( H6 u; W$ L6 G9 E
; `$ L/ }4 B  f- w3 }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-2-8 09:08 , Processed in 0.037407 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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