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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( {% W+ Z' `5 E/ Q9 e( q: V( K. n
#include <linux/init.h>
1 {, f: k; o/ Y2 ~. x1 _: h3 M1 K#include <linux/module.h>4 U1 z7 P. _8 }# ?& f: p
#include <linux/kernel.h>4 e1 `0 j9 ?7 W" W
#include <linux/types.h>0 ?( i4 S# T! P
#include <linux/gpio.h>
8 b9 ^; B: R7 F) v# x#include <linux/leds.h>, _  R; _, t" G6 Q0 l$ k. d
#include <linux/platform_device.h>1 S- G. l( e0 K8 C. L
% X' g7 f( S( l" `
#include <asm/mach-types.h>
# O8 [3 s8 \& g4 t#include <asm/mach/arch.h>. c. r6 I6 Y1 x. [# u/ a
#include <mach/da8xx.h>) O/ k3 z/ ~6 V7 k
#include <mach/mux.h>, B$ m  t( d# }" T* c" F* D

% {( z* g2 N( H2 L# _+ ]: X#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* O/ S3 u  ?) m5 Q+ ]& j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 ]6 k1 [; X4 i#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- N1 g5 ]* A/ s8 a
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
( [- R1 O- g, ?* s6 @/ `
5 m0 K: F! L% K$ \8 H% p/* assign the tl som board LED-GPIOs*/  G$ ~9 E, u& U% y3 [) _
static const short da850_evm_tl_user_led_pins[] = {
' V. C/ ~: m$ J$ e        /* These pins are definition at <mach/mux.h> file */5 m' ?3 o# N% ]6 a8 ~
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- v- U5 U4 F; [7 [* A6 D" A8 }
        -1; a& M  M% t% y$ G
};
" ?6 Q  e' M( H; i" d1 K# ?, t9 C; W
static struct gpio_led da850_evm_tl_leds[] = {
3 i. _$ O2 a  u3 M6 t; `- C        {- f6 v0 ~; ^) L2 Q. G3 h
                .active_low = 0,6 h- o& j" S  A: l& y  Y: h
                .gpio = DA850_USER_LED0,. F6 }* |1 E# d# f  a0 x
                .name = "user_led0",4 Q8 u$ [% h9 G7 W& b9 h. U
                .default_trigger = "default-on",
& W& l5 o+ n; B- q( @$ \% |: C        },
: k& }" k! O1 F6 m' ~  U! X2 Y2 W7 ?1 `        {
( k3 Z# `" D' B                .active_low = 0,
9 [8 ]2 q: |: z0 D+ y                .gpio = DA850_USER_LED1," F3 `3 L: A0 b
                .name = "user_led1",
1 Y) x/ p- R, d1 Y( m- h* j* n" [  D0 a                .default_trigger = "default-on",
# u8 A( t  T+ t0 c, ~' M        },; H) f0 J8 \; A$ R, }
        {
: K% H# k+ y/ C, T- Z! l- x                .active_low = 0,
: c( y9 a. N, X& u9 S- y+ `                .gpio = DA850_USER_LED2,5 u  o, o$ c; s5 J2 Z% A: a6 F
                .name = "user_led2",* _& J4 |- V+ d+ G; Z
                .default_trigger = "default-on",
( ?- N% ]0 u2 s3 C( \' m2 ]        },. p- G* e# ?7 Q0 {
        {
% [& J6 L, s% ]% U* ?/ e9 _9 N3 N                .active_low = 0,
& x+ e+ d* Q1 A+ M4 g& C4 p: c' Y                .gpio = DA850_USER_LED3,0 i  j5 Q6 y* ^9 i) o$ F- b4 N
                .name = "user_led3",1 o; s& P7 k! V( l$ n* y
                .default_trigger = "default-on",: F) f: u5 y! F0 S* ^# z- K
        }," K, D& F, o4 Y6 G# \& i8 N
};& A- i! u6 F! e9 _* l

7 Y, r* S$ X9 E4 A' ~0 G& ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 G4 s3 |; r" l& ~% P! n5 U& y$ g
        .leds = da850_evm_tl_leds,8 R* M2 E- z+ F
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 K' P$ }) f' z- G3 s};+ g5 t% O% }# q) w/ d, Z

1 X# Q7 G+ T  Wstatic void led_dev_release(struct device *dev)2 `0 L7 Z1 W- c4 R6 z( y
{
4 j9 W5 x6 d- c1 |" C4 B/ R9 D};; V7 K) T2 T2 S( t3 F# e  H
2 S& c) |& u/ u" S
static struct platform_device da850_evm_tl_leds_device = {
, e& Y: A! j" M' q1 _7 a* G) a        .name                = "leds-gpio",
* G1 u' ~( f! M8 b% F9 Y: C        .id                = 1,+ F8 f& T3 u: _  K6 _  M- x6 V# |
        .dev = {
% J' \* v2 c0 S6 e* P- M# E( j& H                .platform_data = &da850_evm_tl_leds_pdata,
2 I2 {9 a$ _# N6 h4 b% o2 w: S+ D0 w                .release = led_dev_release,% U; `* O' v) z5 @9 K" j
        }
# z' O# j$ ~4 G% N5 U6 R};
9 A& i  @1 @2 K/ S+ j- y) O& P2 t% x' h- H7 i: L3 b
static int __init led_platform_init(void)
- Y( ^7 P) [% D# L+ m" E{' E( }$ P/ H$ M
        int ret;
% J: A& Y5 ?8 q" W3 X3 L#if 07 k: }# s" `8 @
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, p/ l- ?" m& r' V# s
        if (ret)& f7 U8 y6 S8 a6 K5 s8 t- R
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", E. |! P$ @% P6 n% T0 u% S3 [
                                "%d\n", ret);
: E# s. H4 O1 q3 t4 k#endif
( j* \$ _- |1 f. z: A        ret = platform_device_register(&da850_evm_tl_leds_device);" X' ]& t+ {; I! q6 n# [' m
        if (ret)
9 h3 k0 x5 c+ E1 z7 s. u  y. k                pr_warning("Could not register som GPIO expander LEDS");4 u9 X: ^( @( B! q' N# @$ t
        else' D8 U% @# G" t  B; u7 H/ R. V  C4 ^
                printk(KERN_INFO "LED register sucessful!\n");5 _$ M% v1 I8 q; l
0 s3 T' F# o5 B) w, C8 ~2 @- j; A
        return ret;: P6 ]4 N8 j# t1 }4 b7 m
}5 M( T9 g4 @. x1 R3 N: B
0 V: L1 I  V# M
static void __exit led_platform_exit(void)
  [9 E9 c: y) I5 m3 I' _( j! l{
9 k0 [& m) g6 E        platform_device_unregister(&da850_evm_tl_leds_device);/ E9 z+ f# L1 C9 Y

0 J' v- P3 A5 Y$ H# Z        printk(KERN_INFO "LED unregister!\n");/ s1 v. _) w  e
}& O4 X! B( `% T5 }% m0 a
- a8 _% y3 ?2 z- r( }: Z
module_init(led_platform_init);
- y; P8 p% l: z. \$ |4 {module_exit(led_platform_exit);
2 H! I. @) V! s' C7 }" E1 w) P" M. ~
MODULE_DESCRIPTION("Led platform driver");  r, b% Z/ k2 u: Q# j1 y  C/ _
MODULE_AUTHOR("Tronlong");9 ?( U( J" [$ }" ]4 U+ z9 k. d2 q
MODULE_LICENSE("GPL");2 p  B9 ~/ u( d6 L2 Y$ C
& c1 W  _; E7 H/ M# d+ L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-31 07:27 , Processed in 0.037673 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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