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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
0 S8 C% e* d5 i- E4 d  q: b. c! {#include <linux/init.h>8 ]1 \7 u! W( k: I! b& m
#include <linux/module.h>
3 S( C' y8 o# p, n2 w; ?#include <linux/kernel.h>. q1 `: _; t1 L8 i/ R, I& _$ \0 K
#include <linux/types.h>
% e& q( z! Z$ [7 f# j' O1 N#include <linux/gpio.h>
) I- h) v: P" ~#include <linux/leds.h># ]8 t5 _* B3 B7 H0 a1 @
#include <linux/platform_device.h>- k4 d, f- u0 Y. U

9 n" w7 V0 K. p- s! ?#include <asm/mach-types.h>  Z+ O6 j/ @* s( L( l
#include <asm/mach/arch.h>
  [& l7 c# V- W4 G" g6 M& w+ \#include <mach/da8xx.h>
# K- A6 ^' m* V1 J+ \* b#include <mach/mux.h>
* S6 l8 f2 J' u+ }4 X5 H. f# Q# T0 Q( k- z) A
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- L3 X3 @( a8 {# Z* c
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  L( @8 O9 g8 S' V' x% d* t
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
$ K. a- C: m% [4 }$ K  j) D# A5 q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& A( m$ _/ U: ]4 }
: _% u% T- Y$ X$ d/* assign the tl som board LED-GPIOs*/
' C  x7 l6 ^( @% Ystatic const short da850_evm_tl_user_led_pins[] = {9 q7 U5 \  Y9 h4 o8 c1 C' v
        /* These pins are definition at <mach/mux.h> file */4 ]5 t' |" {; r! l" |* d4 z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 z2 }" b" e- [1 T2 `1 @1 n        -1
3 p5 z, x0 B8 y};: u$ R$ ~7 |% I6 _! R9 D

% K7 d8 g6 K3 Q. ^% p% o- Tstatic struct gpio_led da850_evm_tl_leds[] = {
% ^; c- h& Y! p        {  M! B7 b/ b: v( u& U
                .active_low = 0,; s; K  E  x6 N$ [0 P6 g
                .gpio = DA850_USER_LED0,
1 {. T8 l# ?, s- F- ?7 C                .name = "user_led0",% Q: [0 `% q* N* ?5 \# U- R
                .default_trigger = "default-on",
$ a$ M$ J5 }* A2 }        },6 ^0 _" x: N# u3 ?
        {6 o. h: U" d* r: S" h
                .active_low = 0,( N7 h: e% ?: E. }
                .gpio = DA850_USER_LED1,
/ V: Z; l# Y( }/ c0 r% H                .name = "user_led1",& O6 J7 }/ i- s$ x0 L
                .default_trigger = "default-on",. }5 H. B8 w  \, M  i
        },; F4 c9 l# r% O/ Y8 C4 V
        {# H% ]. E! o% U! i: s4 _, F
                .active_low = 0,
9 r: @0 z4 i4 H; [6 ^                .gpio = DA850_USER_LED2,
- d, d# a6 g% M+ d$ @                .name = "user_led2",1 X( j8 M8 E+ }, ?% M" Z5 f  Z" S
                .default_trigger = "default-on",
  W, u$ w9 r/ u- j( j        },
  T1 J  g; j- O5 U! Q9 I; t* ^7 ?) [5 ^* o        {1 }& ^1 \' a, G& ~8 L. f
                .active_low = 0,
" s" v; N# [; t3 j2 F! i# n                .gpio = DA850_USER_LED3,
# ]2 {$ X. p- C0 R8 c0 Y% T2 {; x                .name = "user_led3",5 }( N* V6 L# A' ~* L& B
                .default_trigger = "default-on",
, o4 q0 r9 [6 S  Q9 u8 }+ q" d        },0 m/ l0 d1 S* b4 `
};
8 s$ h  y  S( k7 k3 N! [2 y
) O2 Q" {$ o6 J+ Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ w6 ]; b$ n8 l; T        .leds = da850_evm_tl_leds,5 a. L' V. z6 b/ ^* ~. r
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 s+ x; ~! Q+ f* K1 ^1 v
};/ c( a& w. m1 Z7 K6 N+ Z4 G0 r* z3 B
  H; v/ X$ t+ }" D- f( R' \  j
static void led_dev_release(struct device *dev)6 p( x! G' u$ z8 j
{
7 Q. h# K- O' R};
( u+ H' n8 x& m* y( }( N' I: G. s6 ?# c8 H7 m/ ~9 i
static struct platform_device da850_evm_tl_leds_device = {8 T, S, q$ K9 z. P5 g4 e
        .name                = "leds-gpio",
! @0 E4 |( o, r: h4 D3 M( f5 Z        .id                = 1,6 Y' p! H# N9 W& d, c
        .dev = {1 t) F5 `+ j) }
                .platform_data = &da850_evm_tl_leds_pdata,
9 a# u, V% X0 ?+ u" Q                .release = led_dev_release,$ i8 A7 y' R7 ^  r$ S( F
        }4 z& b7 d, d& H: T. {
};8 `" F9 z& [" @

3 d. i: b( W' _' G- J  F- V/ tstatic int __init led_platform_init(void)
9 a2 U4 x! K- k: L* Q{
/ F( a" X( o+ l: n: I5 r8 r3 W& [        int ret;
3 e- g( O3 P: u+ U+ P6 q#if 06 s: D% b* ^+ y  }( s" R9 T3 g
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ V! \7 n5 _; e' m; @
        if (ret)0 M3 R& E8 c& R8 b7 v0 T2 x
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: R+ ~0 F- G: t3 M8 ~                                "%d\n", ret);
# M% o5 D& A' l#endif
2 E9 m0 b' l! o        ret = platform_device_register(&da850_evm_tl_leds_device);
/ L9 N# E. _" {; F4 [7 @        if (ret)
" f! T* q- `9 L6 d2 t                pr_warning("Could not register som GPIO expander LEDS");
, A, v& M) J8 g7 _! q" l        else
7 f; H* Q2 C* v# b! S3 x6 T- D8 D                printk(KERN_INFO "LED register sucessful!\n");0 E3 _$ y" P! e( N& d( ?  x

! y8 h! r0 `8 K7 X* u* J# {+ W        return ret;- K1 r) M" [4 Y- U6 a3 [! t
}
$ w. K5 d/ }7 P! c; ]" t
* ]% p7 G9 Z# Z/ q8 l0 g' U6 ostatic void __exit led_platform_exit(void)* e# @6 W: ^1 j+ {
{, ^2 g/ `1 s# ^( c9 W4 O1 Q! p
        platform_device_unregister(&da850_evm_tl_leds_device);
# d* _6 o  I& N1 A% Z3 j- d! d* J
, Q1 e) g& m% P% ^6 ^6 g  ?        printk(KERN_INFO "LED unregister!\n");; D. o, ]5 |" x/ |
}
( q4 p3 D: E, b3 U/ h
- t' S5 {$ T" qmodule_init(led_platform_init);
, J- b0 B9 n1 M" l5 tmodule_exit(led_platform_exit);
' i" |5 X9 k+ z! `3 i- I: K3 K" i+ e! S2 q; i; X" e
MODULE_DESCRIPTION("Led platform driver");
% @: u( Q8 h* ]" a+ L6 V' F# Z  UMODULE_AUTHOR("Tronlong");
# r: x4 G1 _4 c- |MODULE_LICENSE("GPL");! S3 X* c2 V3 E
* _  X0 _$ p1 [8 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-12 15:58 , Processed in 0.038163 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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