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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
' j  |2 s/ R0 g. u#include <linux/init.h>( L: N" E* @! A1 d6 N* a" ~
#include <linux/module.h>
8 o2 L/ J: y; d) f#include <linux/kernel.h>" w0 i$ E8 c# ^/ J" A, ]
#include <linux/types.h>
; C8 B4 ?& n! {) m#include <linux/gpio.h>$ a, S, _0 y/ B9 H3 U8 i3 h
#include <linux/leds.h>
' P7 w7 N7 k0 {( X: c" \0 K5 R0 m2 Y#include <linux/platform_device.h>9 A  t7 z; Q* z/ n
% V4 E$ W% m8 X) a5 t% x2 S1 S
#include <asm/mach-types.h>; G; z5 N4 P' a0 c- i! `
#include <asm/mach/arch.h>6 M; z/ R7 I# R, C
#include <mach/da8xx.h>( o' Y0 G0 m9 k) q
#include <mach/mux.h>1 e: ?3 m& K; B' m4 b  V1 q
5 o7 J7 P2 R* s8 G; d
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: S$ u6 F- X' ?1 o( Z7 j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 A4 \; U- ?! l( p9 ]+ N( e/ w
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# G: ?7 b3 O6 _* V#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); i+ t0 `, B2 J1 \

" Q8 Y  m$ x' R" u4 q% z2 a! ?7 W/* assign the tl som board LED-GPIOs*/
7 [' J( E# P) \6 R5 X4 e; e& rstatic const short da850_evm_tl_user_led_pins[] = {( v8 }2 v) H+ ?  u: K
        /* These pins are definition at <mach/mux.h> file */
, A3 R1 E) ~, d2 o# K0 X8 F8 D/ P: ]        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* @4 H% G* y) R        -1( d8 C) M" N0 s% H4 K( o2 S% y- ?( `
};
9 B! [3 ]7 r; g7 Q' B* s6 h! j2 Z1 ]. P" P& V* G" D4 w
static struct gpio_led da850_evm_tl_leds[] = {: @, P- j" Q# ]! P  D- B
        {6 o/ @3 F9 O5 }& X
                .active_low = 0,
. m3 q+ [0 |- X0 c; d                .gpio = DA850_USER_LED0,
; v$ E: b8 A- ^6 _& X% R0 M. U                .name = "user_led0",3 P( N, u/ I" m
                .default_trigger = "default-on",
' A+ w) O$ d' ]$ ^' y' Q        },
+ \; Z3 _% r9 x; C# B: f# m        {/ p( m+ S( m: v4 |
                .active_low = 0,- O, }1 z$ P3 I: V6 D1 p8 }6 ~% |
                .gpio = DA850_USER_LED1,
1 g4 t+ a) D5 P- k8 R                .name = "user_led1",
: [- k7 v6 \% R  z. a# y& n                .default_trigger = "default-on",
9 ]0 {. p' q# v        }," O2 ]8 y+ `; L1 Z
        {
2 |% Q( }, Q% L- r! x                .active_low = 0,
- Z! l& q" N3 g7 E+ x/ C4 ^% n' l                .gpio = DA850_USER_LED2,! w  ^! t/ k4 o0 Q# @  O! q
                .name = "user_led2",
/ b" V* p" w+ V  s3 A6 b8 o                .default_trigger = "default-on",! l7 Z8 y, N3 t8 N0 S( o; T# h* n
        },# A6 F- O7 J$ l. q( ~6 V& a- ?
        {
( c, e0 w" f0 z( z; c, L! m/ o5 X- z1 k                .active_low = 0,
$ w4 s1 r7 s) }* p) t- a- H                .gpio = DA850_USER_LED3,
3 E0 D  g7 @' Q7 r# M                .name = "user_led3",+ B, `: I' A0 l* I% y, R
                .default_trigger = "default-on",9 e. |) A$ w/ g  E
        },& ?( R9 Y! M* T+ J# F
};6 u! \. G  `" n' O3 K

" Y9 S$ L& U1 N4 ]6 G. R+ X9 Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! o7 _" \( L2 ^
        .leds = da850_evm_tl_leds,
- a/ s. M. a- l' a- C! w+ x        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  W' P& F$ V( ]. _
};
6 L( j) d" f; z% @! J- y/ x  P! a$ i) g; B" v/ ^& u0 g3 d/ k
static void led_dev_release(struct device *dev)1 |) d' C9 d6 d/ [  @/ M7 w
{3 L) \0 C* m" W
};
* ]$ b7 S% Y9 \  @
* _8 e  y, w0 ]+ W$ U5 U! Z" {+ ystatic struct platform_device da850_evm_tl_leds_device = {
9 f% T: i$ e/ L& D( L) M        .name                = "leds-gpio",
) z1 y4 j+ V* @7 I- J; v        .id                = 1,3 T6 _" c7 E, r
        .dev = {
' Y* `( A4 R; ~+ E7 h                .platform_data = &da850_evm_tl_leds_pdata,
7 l/ W' r8 S$ v                .release = led_dev_release,
5 C7 G/ g- i) H1 j5 y, ^( k        }
/ G2 ^! E. N  z1 ]( z};* R' o3 w+ V+ Q3 @8 y/ A8 {" n
. p- x$ x- V9 Y. B& J
static int __init led_platform_init(void)0 s( m# k, L, a: |4 p5 F8 X. s
{# |7 J  H# R+ x* `% N( w) \2 S
        int ret;8 A$ V- G# Z4 g6 g3 T, b1 q9 m0 U
#if 00 Y5 }5 i0 ~' f7 J1 u5 [& R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 h9 V* C! K. [4 S3 L  u2 l: q' K( ~
        if (ret)# d4 e2 l( j8 F3 U1 H: B
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ D9 D0 z1 K3 a                                "%d\n", ret);
1 v4 z  h3 v# u, g#endif" o( u/ E! Q1 [. P  E0 H
        ret = platform_device_register(&da850_evm_tl_leds_device);
/ A" f) G! g" }7 W: O- K( [$ n+ M% N        if (ret)! S4 j* N+ C) w, k4 ~) l: p( X. J1 b
                pr_warning("Could not register som GPIO expander LEDS");0 o3 g7 {8 u0 R2 D4 M7 Y
        else
0 a$ d9 Z9 ]5 d                printk(KERN_INFO "LED register sucessful!\n");
$ v- G  x* p# G, J" u- G; y7 D3 ?
  C& L- x/ _/ p6 y3 X1 R, c4 g4 Y        return ret;8 e; P" n9 n. N, `- l7 y  o) f
}
$ K8 h+ G: I' W+ z# w  a. ~) e# _7 u! w9 @2 b
static void __exit led_platform_exit(void)- W, o( ~! p( W. b3 w7 Y
{
- `, V$ X' [" U1 }. Z9 o        platform_device_unregister(&da850_evm_tl_leds_device);
6 F! I  D. F* L3 T9 y( b
) k1 w0 i" s; \        printk(KERN_INFO "LED unregister!\n");
  v) O! R" w" x0 \' B' W}
! W2 r2 V4 Y2 K- T- }! e5 A1 C+ x. s. Z9 Q0 S+ d
module_init(led_platform_init);
) U9 c6 V" E  \1 ^6 pmodule_exit(led_platform_exit);+ ?8 k& d! i* ]0 t! A* K

" A  z2 `, p; @, IMODULE_DESCRIPTION("Led platform driver");. l9 ~& |& B' B' o
MODULE_AUTHOR("Tronlong");) d- f" _& {5 l9 e) y+ \) A% T
MODULE_LICENSE("GPL");, K* I0 L% k( _: d2 t
+ _; [7 [2 Q  A7 F$ o
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 20:35 , Processed in 0.040305 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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