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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 l! u$ @/ @" j- J$ g+ R* {, X% [#include <linux/init.h>
9 V6 u7 O% d& }: K' f% V. B& p) x#include <linux/module.h>+ c# W, F. z7 S/ @$ ]
#include <linux/kernel.h>! D3 J! d' M7 E( v, q- H  z
#include <linux/types.h>
2 L4 W6 I* a/ p0 q; S#include <linux/gpio.h>! v+ t  Z" E2 d
#include <linux/leds.h>9 L' K! M1 t0 G4 w3 U  S$ S3 L
#include <linux/platform_device.h>
( \6 w( Y- E! R
4 j6 {" w0 R2 g#include <asm/mach-types.h>
) ^. L6 w! e8 J( i5 |3 p! Y#include <asm/mach/arch.h>7 W  H) M/ g4 A! e
#include <mach/da8xx.h>
$ \  k7 e3 ]  m0 c#include <mach/mux.h>
7 B0 Z- h2 w0 A& d; |) k( `+ R* t: H$ {4 n- o
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ a& n4 ~6 L. V  g2 [' u#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- I, U! \* q! e#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  I# T% }  @" Z9 G1 @* j#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' ?3 T; [$ e, A; S. m, m
6 [2 F( F( \4 M* s7 n$ G
/* assign the tl som board LED-GPIOs*/$ q$ a# l* J/ R
static const short da850_evm_tl_user_led_pins[] = {$ X9 x1 k) q; b( _
        /* These pins are definition at <mach/mux.h> file */
" ?- ~" ]% ]& A% p        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' p) A3 u9 ~" s* ?" P5 h  H: Z
        -1! i" u8 c( V2 c9 b  M! D  E
};
1 D5 c# P, _3 r9 L9 O! b% e! x1 B, s  ^  x8 J5 k% P, C/ \0 ?2 L& U3 L
static struct gpio_led da850_evm_tl_leds[] = {$ T4 a' B% B1 @% b0 d
        {
9 L$ h9 k+ g7 V2 A                .active_low = 0,
* h- M$ x: ]" e3 X$ @: m) |+ u0 z                .gpio = DA850_USER_LED0,
" ]# A; Y0 w- f* b) n, l9 y                .name = "user_led0",) H0 @% p/ p7 k) i& x
                .default_trigger = "default-on",
# t2 r1 |, J, R        },: e6 y  L+ G' ?$ |1 C$ M7 J& P
        {) B/ h; t$ }6 z8 ^* ~1 m9 ~
                .active_low = 0,
& r$ g- d! D2 P0 O8 C) f: }1 ^' B                .gpio = DA850_USER_LED1,
% d4 _- u/ y  Q5 j  ]                .name = "user_led1",* P( U  A" D: C; r
                .default_trigger = "default-on",8 Y, s" j+ E8 U' B0 |! [* J* T# e
        },  W: D' @9 f) t. Z
        {
& R' ^9 v6 B* x  `! ^1 q! G4 x                .active_low = 0,
7 y2 M- @: B* v; m+ b! U1 l                .gpio = DA850_USER_LED2,
4 y3 k3 V: t0 e) D/ V) ~4 }                .name = "user_led2",- U0 l7 J# N' P. |0 R. a- Q3 ~
                .default_trigger = "default-on",
( n- v, g& F6 h7 U* Z, h- [        },7 m( P7 @: Q( B
        {
4 a( ?* d' M$ G' W1 `7 W. d9 L! H                .active_low = 0,
2 t- X+ h3 ^% r* C* J/ g                .gpio = DA850_USER_LED3,
, }" R( o7 _& D4 O/ l                .name = "user_led3",
' z% M8 Q% r# Y                .default_trigger = "default-on",
/ y; V. ^3 T) Z' ~# @3 J/ {        },$ e& w) e; f# k# O1 u9 \7 t/ J
};
- E0 c& R/ f& z6 |
1 L" ?$ m3 I) w/ vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: q) {9 T1 ^- `* h5 x/ i1 [        .leds = da850_evm_tl_leds,3 J, u8 b( y9 s9 B7 u: |
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. `3 q5 c1 o- W1 O  W6 ?};
& k- M$ q8 }4 J2 I3 Z, A% @) {& |" ~6 n5 m& ^" X% C& N, P, s
static void led_dev_release(struct device *dev)
* s* k+ j2 H3 R, t% w: b{
! a4 D. G" l; Y, x5 L};
$ J( j1 j8 \7 J9 E/ f
. M& R) V7 T2 g2 \& kstatic struct platform_device da850_evm_tl_leds_device = {
8 [) R$ Z: U7 i% K9 S        .name                = "leds-gpio",
# J. v6 g5 V/ d        .id                = 1,1 c* i" x- `( n" z, r6 {/ I
        .dev = {
3 w) t. b4 y- H* L  P                .platform_data = &da850_evm_tl_leds_pdata,
  H; ^4 n1 \: d% P+ q0 n( h                .release = led_dev_release,
( N. U* h8 p" f. J) [: J; o4 N: w        }
8 j, J  K5 Y' C# s7 r};
: X& \0 |; u: p
' X3 L$ ]3 x3 q. I$ Qstatic int __init led_platform_init(void)8 ?/ d1 @! R! l
{+ Q2 {# g' y: v# N. |8 d8 W- ~. q
        int ret;
+ l1 c- s0 g0 O% D9 a* R/ u#if 06 W' U5 o* c) Q0 w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 j/ s" G" B- X$ ]) J4 Y        if (ret)4 o& o! U. W3 Z& I6 W
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# d+ `2 L1 x2 J* a# [7 O                                "%d\n", ret);$ m: d+ A* ^# V3 Q, ?% h3 v
#endif
" {. [+ K" j: h6 i) J; v2 a        ret = platform_device_register(&da850_evm_tl_leds_device);+ i* c  e7 d: R) b
        if (ret)
! x3 [! _" V. ]! y9 x! b                pr_warning("Could not register som GPIO expander LEDS");
" e4 e0 K& b0 L/ Z7 }6 ~- V. t0 I        else
& j. ?( f7 Y6 p% D; P( [                printk(KERN_INFO "LED register sucessful!\n");
) h' ^" a4 O3 S+ G( p8 s7 b6 E  |* g# z! V( K" M9 ~1 O' B
        return ret;
: @0 b. c0 G1 B! X}8 R/ t$ e- C0 I1 q! Y

! `, ~6 P8 x5 V$ @  q7 bstatic void __exit led_platform_exit(void)0 E# }* d- \, S% W
{+ V3 k0 t2 I; e* r* f+ P6 n, N
        platform_device_unregister(&da850_evm_tl_leds_device);# W( F9 L' O/ I. ^; l4 E

! I" b" I+ i2 K* s6 W        printk(KERN_INFO "LED unregister!\n");
& t8 q0 m8 Z: v/ k1 G% d}7 I: \% F7 B+ H/ S7 b: v
4 n/ T  m5 g5 {3 D8 Y% }3 v
module_init(led_platform_init);
; {& O9 C- I% k7 ]module_exit(led_platform_exit);' O9 T7 D" h+ \. S9 M

: s0 q% M- P( B+ S* S# y# nMODULE_DESCRIPTION("Led platform driver");
! ~9 g" ]$ j9 C- m% _MODULE_AUTHOR("Tronlong");+ H  R% Z' h% e+ K( G& l$ m
MODULE_LICENSE("GPL");
" A3 }5 Y$ Y/ u2 e) H' Z- t0 ~/ p$ n  W, R6 |2 Y8 Q- U* U
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-25 07:14 , Processed in 0.037611 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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