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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  n4 ~, B  Q9 I. J) {#include <linux/init.h>
2 Q7 f+ H6 Z) b& A0 {7 g6 ]9 b) N#include <linux/module.h>
6 |' ~) z+ t) ]#include <linux/kernel.h>$ u+ U5 v/ Y1 F: }" g
#include <linux/types.h>8 Z7 g# \. W3 Q
#include <linux/gpio.h>6 _. L/ z, N# G! t& O7 y
#include <linux/leds.h>
, S' ?* X6 x  ~; k4 @#include <linux/platform_device.h>3 l4 g6 `4 |1 }4 S: E) t
  x1 y" Q0 i8 l, b) n! C: a( n
#include <asm/mach-types.h>
7 p% A8 h4 v8 R5 _& e#include <asm/mach/arch.h>7 ^0 B7 }7 s1 g9 j# J
#include <mach/da8xx.h>
$ a+ ]6 w9 t. a5 W#include <mach/mux.h>. c  E$ b& u# ~8 @  a& R
# U7 H" n3 d1 o" l  r' s
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 f, J5 D, y6 Y. f$ G% l
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)- N7 S! P0 W* v; s2 W: W
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% \7 t8 W1 G# I#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# G0 q$ y' ^1 _; I: Z% @# c: P# L# J: d
/* assign the tl som board LED-GPIOs*/
) ~8 ^. p, v- c9 {static const short da850_evm_tl_user_led_pins[] = {
! P+ {  C" w# t# M$ H& r        /* These pins are definition at <mach/mux.h> file */
) a% w. X3 T3 b& I+ Y/ i# @/ `        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* M: l7 L* X& \) E  U8 p
        -1
0 i1 n5 m- g% v" F4 L};) ~! d3 V7 l2 {# i0 L, _

' |7 f6 [6 ~% cstatic struct gpio_led da850_evm_tl_leds[] = {
3 G( ]) q; ^5 \4 v& I: n$ o0 x        {7 l& M" ]9 F4 l" ]$ [" T
                .active_low = 0,
2 h  |4 c5 H; N& ~3 m/ n* v* b1 a                .gpio = DA850_USER_LED0,+ d/ [3 d5 O/ D, V, e# x) x* R/ v
                .name = "user_led0",! ?, v( {8 i" [# j8 ^% q0 K
                .default_trigger = "default-on",8 E3 E9 W& m- O5 v/ [* X
        },
0 [6 R2 ~  H- G+ R6 i( U7 l        {
- P$ ?( d& H5 [8 g5 A# d' ^& j1 c                .active_low = 0,7 C) r/ ?" |9 q: c
                .gpio = DA850_USER_LED1,
5 H$ p! W# E. Q; L; l0 q                .name = "user_led1",
! r& c$ ~8 V2 }                .default_trigger = "default-on",% ?/ @5 P1 y& c
        },5 \5 C# @0 F4 K& o) X/ d
        {/ O% R3 I, O: O7 V& o# B
                .active_low = 0,
8 ^( R( Q) R8 q                .gpio = DA850_USER_LED2,; l% b1 S* U$ r2 ~
                .name = "user_led2",
7 W/ s% R0 t4 o                .default_trigger = "default-on",% B: N9 ^6 S8 @7 j
        },
; V! l# F* v! h! I; |+ {        {
8 Y# f$ M9 ?3 \9 ?: x                .active_low = 0,' R' g& K/ I: {( z9 [
                .gpio = DA850_USER_LED3,) m3 Y8 l& N3 |# u! W
                .name = "user_led3",7 \3 q& }9 I* Q
                .default_trigger = "default-on",
: w/ m% D" I; M/ ~% q* U        },
! e8 `( [- {5 |) X* B5 x+ c/ S, N};
1 d7 D5 \1 X) Z
$ a! o/ w  C% Z8 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) q" X6 S* i3 B0 c/ R0 ?$ b        .leds = da850_evm_tl_leds,
4 Q2 }' f4 W; y! u% L  }        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 v2 B" M1 |4 {  A8 O
};
# b4 Y* D- \/ Y) j- I* s
7 _2 |/ G" V/ `& G4 K0 J. Jstatic void led_dev_release(struct device *dev)4 B2 W' q6 N3 a4 J# d$ n
{2 B6 |! d: o" k2 ]) j  _
};+ j8 y* p) H2 F) f; s
& e/ Q2 |, N$ M" n$ p8 c
static struct platform_device da850_evm_tl_leds_device = {9 P; X4 t; h4 A9 r7 |
        .name                = "leds-gpio",& {7 T' q1 p( `5 J, J1 L
        .id                = 1,% ?4 }8 ?- ?: L5 l6 x" T
        .dev = {
( [* y, C" H) o$ e  e* a0 l, \                .platform_data = &da850_evm_tl_leds_pdata,
4 S) ~; t4 r: ~& P* ?, U  w' C                .release = led_dev_release,( _/ `+ [/ S3 A* N* U' W
        }
; G2 B# |& a4 d- F: h3 ^. E8 j6 i};( W: `, B7 @5 T2 t1 h* c+ n
# T7 Q0 B4 @) J
static int __init led_platform_init(void)
) T. N9 D" E) e{
7 ^+ B  f6 ]5 a$ i/ _8 J2 H        int ret;
- m' n1 S4 e4 `4 e: h, F3 \' {#if 0. f" w" l- ~5 h& J, @
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& j4 _9 ?' S+ Y! n3 f* i' L' p        if (ret)
& ]& {2 t3 a; B5 V                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 P& o6 J6 o8 @  {. e& u/ ?9 |
                                "%d\n", ret);3 t- o5 f+ k4 [4 O  M" |
#endif
4 d3 V+ t; M( E/ G        ret = platform_device_register(&da850_evm_tl_leds_device);
, D. ^" z6 E+ D, j# N" u        if (ret)+ K7 b! {$ a! `6 \+ I3 d& P
                pr_warning("Could not register som GPIO expander LEDS");" i4 g4 r& b" @
        else2 v* V* p) ?' T4 r/ D( S$ M
                printk(KERN_INFO "LED register sucessful!\n");
2 Y; ^9 |& ?% |+ `4 _7 s; V
% `+ J; _+ \; |7 o* P        return ret;
8 p! h5 Z, w! \}
# Z3 _" D: ^  x" ^; ~6 }* ?5 k! e$ d; R, V3 f6 D
static void __exit led_platform_exit(void)$ Z7 q6 Y1 O5 o% f/ X' M* h
{) C+ ~3 P+ b6 p& A) @7 q4 m
        platform_device_unregister(&da850_evm_tl_leds_device);
& a; L: }6 x; M, ~  Q2 E" o, E3 Z# Q( }0 E) U
        printk(KERN_INFO "LED unregister!\n");1 }. V9 Y" {& P, Q3 d% n! i( w% m" X
}
% R- A" X! Y6 d, P; O" ]# F2 A
+ x6 U1 O& R& F+ Omodule_init(led_platform_init);: f6 G' W0 ?- t/ j8 f2 Z% I
module_exit(led_platform_exit);
+ f- q5 ^8 ^' ?& [0 E$ m2 G  N: K* I2 |* X; {5 V  B0 Y
MODULE_DESCRIPTION("Led platform driver");* P# t6 C, e, o2 P
MODULE_AUTHOR("Tronlong");( K- V9 h; t' k$ o; A8 L# ^  J
MODULE_LICENSE("GPL");# b: d1 m) Q1 i
7 r, v! ?6 Q! y9 ]' r( ~( \
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-7 18:29 , Processed in 0.036142 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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