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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; N( V4 }2 }: g# q( X1 [. c
#include <linux/init.h>) Z/ h+ t; r7 e/ Y' [' N+ U
#include <linux/module.h>* S6 [# M, l& M2 b0 Q' a
#include <linux/kernel.h>
- ~9 I- \6 S: C#include <linux/types.h>
1 u1 f$ g7 Q7 J$ B. W#include <linux/gpio.h>, j; a, G0 S' b
#include <linux/leds.h>  H$ y% m+ P5 x9 n9 ]/ Y- S
#include <linux/platform_device.h>  ?% p# J- }" E( u

: ~6 n) a- T2 E) ]( F8 a#include <asm/mach-types.h>
/ C/ Q4 N5 r& o7 G' T#include <asm/mach/arch.h>
% H3 F! R( X8 T9 @& M#include <mach/da8xx.h>
6 }- e8 d$ D8 K9 J#include <mach/mux.h>
4 C6 X* m1 z( e% I) D+ l% H- s8 u7 B5 {/ D
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)9 C+ V) c6 Z, S4 @) Z
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 \1 y$ i/ l" ^1 z0 V2 {
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( O7 a3 V# d8 k8 D8 |0 Y' q) Z#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); k; t) a% h3 J' h& [% I9 n
4 t' m+ `3 Z" c# k" d
/* assign the tl som board LED-GPIOs*/
: a. U3 _: R1 E7 [  U3 R7 Cstatic const short da850_evm_tl_user_led_pins[] = {* Y2 l1 ?4 d" D; K8 z7 ]
        /* These pins are definition at <mach/mux.h> file */, Z3 r4 N0 X+ E) f# a, `0 t
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* l7 f6 x$ d, v$ U7 P- G- A+ r        -17 `  X; Y8 _( m- H, n
};
. F" w5 i( r/ Q0 G& M- [, R5 j9 N9 V" l) I& i) s+ @( N
static struct gpio_led da850_evm_tl_leds[] = {
6 h& F: M2 t; g2 F3 \        {. `9 z$ Y0 {7 \$ y# u
                .active_low = 0,
4 |: W* }; V9 b9 m7 B: r                .gpio = DA850_USER_LED0,0 l/ S$ z7 h" P: Y5 K
                .name = "user_led0",
7 _4 r+ ?8 U, U" B- k- J6 M% u1 k                .default_trigger = "default-on",, ^4 d* T- h0 O" z
        },
* T7 D! ^0 t. x/ W# o) A        {
$ y$ H7 }* ^; t                .active_low = 0,
- F& b. u2 \/ U$ o3 ?  f                .gpio = DA850_USER_LED1,
0 Z' p% s: T+ L- c/ C% ~3 U                .name = "user_led1",
$ l6 W1 F7 R: N                .default_trigger = "default-on",9 ~# r3 F! O* p* G- j
        },+ a" N0 ^# j4 ?7 Z  [2 `5 p- _
        {
9 o7 s: S5 P  k7 i+ R6 T                .active_low = 0,
/ W7 x% W: N( j                .gpio = DA850_USER_LED2,! K2 A" ]% X; b* [4 U, h
                .name = "user_led2",, G' j& u9 o# L# V0 M& _& T' k
                .default_trigger = "default-on",
. M- m3 r! l0 g* h& a        },
9 L1 C! F3 C& ^        {
) e5 }  b) O6 O: e$ \) ^9 z                .active_low = 0,
- s5 K/ Z3 q+ a) U                .gpio = DA850_USER_LED3,
$ r6 c8 O- u8 \1 Q* h" x                .name = "user_led3",
  ~% c; q. t; h4 m) d/ F                .default_trigger = "default-on",, u' w6 W3 D; C( k1 _: W3 l) N
        },3 L+ J& W: M1 `0 s- c! {( K; A
};
- R  T0 V0 Z1 I+ L, Q- D
, I. a6 q! p/ a! J1 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" ?0 @% N, z" L( x$ D% E        .leds = da850_evm_tl_leds,4 s% J2 D8 q) H' O
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" z% U6 w1 R: _, b9 f9 {" E4 ]};
  L& j  j. e2 i9 P3 I' y
* M" B. o2 Z# t6 a4 A# _3 U4 Fstatic void led_dev_release(struct device *dev)
, `) y- J' j5 H# i2 _{
6 z) V* ?* w/ y7 B};
/ @0 o4 g; V1 w. n0 e
: t& Q- x' l0 a' m# Wstatic struct platform_device da850_evm_tl_leds_device = {! @# ^7 c, t. S6 |
        .name                = "leds-gpio",
4 U$ S, ?- h3 S8 ]+ j9 R8 n        .id                = 1,
  }3 p9 R% h( Z0 _( d' W        .dev = {
& b2 q& m0 p4 q9 S3 E* @% {                .platform_data = &da850_evm_tl_leds_pdata,
/ q. E- b6 O+ H3 d0 j                .release = led_dev_release,
$ ?# k& \1 Y$ z+ p' W8 b+ k        }* ]$ k; m1 ?! K- ~$ m
};
4 t; `& f4 s' J+ y
# x6 G5 ~4 p1 L& {) f/ s1 N, L' x6 zstatic int __init led_platform_init(void)
  V3 C7 H6 c4 D, }7 }& x{8 z* r( ?$ `, x. y+ ]0 m
        int ret;; y1 G4 r' A; |* C  r: M( L
#if 0
% Y$ ^0 O' c" k/ ?4 s- @0 F1 V' o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 \# Y9 S% g0 J8 l2 u( ]0 N        if (ret)- z1 c, \3 L  T! K& U: U* Y. w2 o
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 @6 ]0 g5 i' `" u  Y  B
                                "%d\n", ret);
  I- l$ z  x5 y& x#endif
5 s7 A9 c% H2 E* ]        ret = platform_device_register(&da850_evm_tl_leds_device);
# G; _; s7 l' ~) N2 U% O. O9 V( b        if (ret)
6 L7 a% R! X/ w- {- D7 q: y4 J1 R                pr_warning("Could not register som GPIO expander LEDS");
) h3 i/ T/ a4 s0 C        else
2 @  ~- q9 i* O+ w$ Q                printk(KERN_INFO "LED register sucessful!\n");
: ]8 k( d' o8 r, T4 X
4 m3 D8 {1 K# V+ ]$ [        return ret;
$ m4 s6 _' k1 m2 e9 ]+ Y}% y0 N7 k* Z0 o4 M: W
" b* S$ ^+ o, D, L
static void __exit led_platform_exit(void)! I2 h' J" M# W6 F- G  z% }
{
, v8 P* F3 P- n6 x( I" v9 C        platform_device_unregister(&da850_evm_tl_leds_device);3 Q5 I" }* N" ]+ |: a

' Q( x! G) T- |4 ~5 a1 ~: g; Z        printk(KERN_INFO "LED unregister!\n");( P3 \$ N8 t" H) e5 i
}
+ t& d4 [; V# C9 |/ X: q; z
' a' z  k/ U/ c0 w1 ]6 F; K0 `& Ymodule_init(led_platform_init);% r, F: p1 ?7 y1 \& M
module_exit(led_platform_exit);9 A2 m; r2 w' s5 p: f
3 [. X& ~" q' p9 c+ y& w, u
MODULE_DESCRIPTION("Led platform driver");
; {* K) @% g, hMODULE_AUTHOR("Tronlong");
  D6 V5 Q$ o7 w: L' c# p+ LMODULE_LICENSE("GPL");& S4 b9 L7 A* w+ ?) x1 c

+ L. z1 i5 Y, D* r3 k* x9 h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-21 14:16 , Processed in 0.049665 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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