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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 U' @' u! U8 {6 s' ^#include <linux/init.h>3 k1 [1 {- l- I  j, `* R" s
#include <linux/module.h>
9 ~' N0 w& }1 _& |7 B( V7 \2 B' g7 a#include <linux/kernel.h>( F. @& c3 s" k6 l+ w$ ]
#include <linux/types.h>
' }$ F, v: b1 N3 j#include <linux/gpio.h>3 r& t5 ^7 P- }; q! W$ ]. L# u5 w, f2 y
#include <linux/leds.h>
! \2 c% ?6 _8 I) _2 _2 O& y. ~#include <linux/platform_device.h>
1 T, `; ?4 a, u8 b0 Y/ e# ~
4 w2 p* M  I4 W  @+ W: k8 \7 P, e& n" B#include <asm/mach-types.h>$ ?" D) A3 Y; y  t6 ?
#include <asm/mach/arch.h>' U: J& u0 c( L* C9 q0 |
#include <mach/da8xx.h>6 ]% }: T4 |$ h
#include <mach/mux.h>
  F2 D; m, t8 H6 p. s! \; J( U9 C2 s3 T  N4 v% Y, p: E  v
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ f* V% C6 y' U% x* _3 z2 V#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 y& J* q  O  E4 X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); T! k! K2 k3 k6 y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 E# c( V3 L2 M6 n. H3 N1 H$ u
* D' c# }/ O0 k( Y1 t8 S0 T4 F
/* assign the tl som board LED-GPIOs*/
# [9 O2 u0 D( @) p" ^3 M: n' wstatic const short da850_evm_tl_user_led_pins[] = {7 R& y1 o3 h' U  Z1 U8 v/ n$ A" x
        /* These pins are definition at <mach/mux.h> file */
; I2 [- }3 e9 M" P2 `; F        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# n7 \3 N" ?9 v9 F6 m: _        -12 \1 _/ `3 i. Y; w
};6 M6 V$ i% f9 p' W4 H5 v9 F8 k7 I4 t9 {

* q1 `% \2 k* jstatic struct gpio_led da850_evm_tl_leds[] = {
0 n* _0 \5 B! x8 K+ t# M9 a* |+ _        {
8 w- y+ J5 O5 |# R                .active_low = 0,
" w' x8 a: ]! k                .gpio = DA850_USER_LED0,
5 {, L' z/ N: ^, ]7 H* @                .name = "user_led0",
. u/ |# g- J7 v$ Q9 g6 ?4 D                .default_trigger = "default-on",/ q4 W, G( n' A* v  }! `
        },* W8 l7 C9 \$ ^- z7 F
        {- {: u+ `  g! k4 b
                .active_low = 0,
+ u( u3 T2 Z" y                .gpio = DA850_USER_LED1,: f1 V0 S" D' j, V' d3 [
                .name = "user_led1",
/ E3 S9 s+ ~8 m; Q; j                .default_trigger = "default-on",
5 c6 i0 U6 z* w* ~# @, a7 ^        },
5 `6 }- C. h6 p* j, ~0 ?1 c8 h) N1 k2 K        {4 r! w. i$ s, I4 E2 S
                .active_low = 0,
9 Y( W/ I" B4 M; y) x9 y2 `                .gpio = DA850_USER_LED2,* S' p& d0 L* ]) H# O
                .name = "user_led2",0 O/ w+ A0 j, V) B9 w: Y2 z. g
                .default_trigger = "default-on",
: A0 |4 B! D, U0 h' n: d        },- _& K. f" P% m
        {/ P3 Z0 I2 D" g' R
                .active_low = 0,
7 p* b( I: O9 S& h. U) H  b                .gpio = DA850_USER_LED3,
# t1 ?+ |5 P+ Q. b8 E2 f9 ^& Y                .name = "user_led3",
" d. |4 F; |+ S+ n; `& ]0 s6 k& L                .default_trigger = "default-on",- f* y# I& C- ?, R
        },/ [; r5 @! g1 _' C+ T9 n$ ^
};
1 ?0 `; o; R8 z- f+ j7 Y, D  l, e, I" w6 {# r3 k1 k' j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ D+ r" W* g" v- W6 ~3 O- d        .leds = da850_evm_tl_leds,
" ]' {8 E0 Q; u5 R  q  Z% Y. P1 L        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& F3 C" ]  @- V' e2 G7 [};
6 e5 H6 G( F$ P. m2 y; @6 N3 g2 r" j2 Z, o  W1 D
static void led_dev_release(struct device *dev)' z+ [8 ^3 |3 t, J) O
{
% Y: V5 X2 x, w; G3 K" z5 p};
3 m" s8 D# R8 s  ]9 Y7 _6 d/ A: @8 ]; y( A4 S) ?* \1 ?' n, i
static struct platform_device da850_evm_tl_leds_device = {
/ X1 I# L" W+ ^1 k+ n, m        .name                = "leds-gpio",
  G% k9 l' x2 j0 o' F) [        .id                = 1,
4 x& K, ^$ ?) m, |5 u% o7 s4 M        .dev = {; C+ Q) O9 j7 A
                .platform_data = &da850_evm_tl_leds_pdata,
6 p0 W2 a: ^& J3 a8 Y                .release = led_dev_release,) R  O5 y4 R1 @! Q
        }
" z* ^' r  [4 u  d; Z};
0 }% Y9 j$ U# ]1 c/ _) h" ^4 k
; p+ d( g6 v5 _, c) M. Xstatic int __init led_platform_init(void)
% r" N) _7 q( x& O. `4 \' V- T{  u, q+ P  ?# G% ^* ~4 O
        int ret;  K7 N- |/ Z6 z+ R- n" X! R# o# [
#if 0* M, @' l% v+ e8 D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 j! F$ M0 P" r0 ~8 G
        if (ret)
3 @- Z) w$ O0 l' x2 `                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- q  h9 }/ \& n4 H" Y                                "%d\n", ret);' @1 r4 h( c" t$ ]7 D
#endif
. S# i6 E" |# ^        ret = platform_device_register(&da850_evm_tl_leds_device);0 N0 r' n3 x; Q+ z9 R$ f5 h* Q
        if (ret)- z/ I/ Z3 t* y" y% x1 g+ ]
                pr_warning("Could not register som GPIO expander LEDS");, d5 O& H5 I7 w* P6 j% r0 f
        else
; W4 c. [5 [5 b0 C* M; v  p& w                printk(KERN_INFO "LED register sucessful!\n");9 Q. f. ~0 l; C* M2 G7 l

9 |3 H) P1 A- Q$ B7 g1 W& J        return ret;" @% W5 b% |0 o. ~0 y. U- k$ A
}! d- ~- I# P3 I. D3 Y8 c
/ N3 w: u# ]9 s. R) N% l! Q6 T2 b
static void __exit led_platform_exit(void)
: o5 T. W9 z: o( I3 y6 i{2 q5 i: h3 b1 ]# k7 D
        platform_device_unregister(&da850_evm_tl_leds_device);4 F: }4 R2 q% \# E1 @+ W# o

; v5 k$ v0 I1 w3 t3 }: |. x. D        printk(KERN_INFO "LED unregister!\n");
' |, c$ l) R. X8 w# Z}& @! |; t$ ~" O6 h  T0 ?

5 J9 P8 Z* {* K2 Q* U& C) \module_init(led_platform_init);
/ p: ~1 c  ?/ {6 q3 R2 @module_exit(led_platform_exit);
. t9 K" R! q) |. {6 R2 p# w! z+ x1 r/ K% C7 F+ e- G+ {( H
MODULE_DESCRIPTION("Led platform driver");0 e. y3 e' E5 T9 j/ ?2 Y
MODULE_AUTHOR("Tronlong");. X0 ?8 B. z# |2 X+ g, f8 a, I
MODULE_LICENSE("GPL");
. v- l& k+ K6 a/ |3 F/ Y9 h: h- f1 _2 a! |! ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-30 16:46 , Processed in 0.038211 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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