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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 T" U  R( V6 z7 q5 j% S
#include <linux/init.h>
# d- |% N5 D& s  Q) s#include <linux/module.h>
- @4 A7 ?& Z* [7 z- ?#include <linux/kernel.h>
6 J# Q& j: z" K, |2 E6 l, M/ M#include <linux/types.h>. K* O/ S) T5 ^
#include <linux/gpio.h>. M, c8 G; q5 K2 }  }4 Q( A
#include <linux/leds.h>
- u1 r$ g5 Y  K8 `#include <linux/platform_device.h>
5 d. ?' ~) q) s' ~, J/ e1 \4 C% ?- D/ {# f- c  `7 o8 o4 }
#include <asm/mach-types.h>
# S3 w6 h5 g% H: b6 U) k#include <asm/mach/arch.h>. p* p( t+ j, |. e6 s
#include <mach/da8xx.h>
" Z5 A5 |$ ~& i6 p4 V2 \: L! l' |7 r#include <mach/mux.h>* e! @; L$ b. x/ j" J
4 W% i' B; M: k  _; v$ U
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); r5 \; M# \* u. I+ C: r
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)+ N. @* s" u0 }, O  z* a
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& N, C4 a) c: g* A5 W
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 d2 f+ [; p) L" I: `; B" ^2 j. {

' X, j- g* M5 C+ C8 d' E/* assign the tl som board LED-GPIOs*/  B' a1 a; Q4 t! r+ }7 \) s1 s
static const short da850_evm_tl_user_led_pins[] = {2 l7 \; H: m) h4 g
        /* These pins are definition at <mach/mux.h> file */
4 ~- V5 Q$ y% e& }  J8 b        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 {% H9 v5 E1 Q1 X6 B, ]' w; n& K        -1: w. w6 r% {' ~4 a' `5 x! X3 R
};/ f; D& M0 q. i- i. J4 k! o1 N

) ~8 Z* d" R9 ~$ rstatic struct gpio_led da850_evm_tl_leds[] = {9 }, {8 V% O" S% C" H4 u
        {& f! L+ H6 O, ]/ i4 [" L
                .active_low = 0,: F/ s6 |5 W+ S2 E& z6 n; Z% ^
                .gpio = DA850_USER_LED0,
+ Y3 p4 @- x, g3 P                .name = "user_led0",  _/ p* N4 B) N& T# j+ ]
                .default_trigger = "default-on",
& o4 Y  c: f7 e" b( x  M        },/ T; ]; M9 @) `
        {' x4 P8 Q2 X1 w  ^/ Z
                .active_low = 0,
* A" P6 V" K1 J7 P# ~9 T3 L) w4 L                .gpio = DA850_USER_LED1,
- e) h) T, d* P; N1 Z                .name = "user_led1",
" H. R: @0 v' p: w: s$ o" w0 V                .default_trigger = "default-on",
! I. w& m% |: }* Z" p        },
9 C/ D3 `7 t7 V- J' E        {$ K: Z: v' ]. M1 S7 a
                .active_low = 0,
: A9 k- z2 K7 W! S0 H. \' A/ h9 `                .gpio = DA850_USER_LED2,* V! N" l8 }* }- U1 I. ]
                .name = "user_led2",  J# W( n, L$ d
                .default_trigger = "default-on",
# \+ a: L/ j& D0 m        },
# Y/ r9 R8 O6 T# o2 e9 l& {/ l        {
, [, a) X. B' f) i+ g1 b                .active_low = 0,
8 r* X# _: \- F& p! l, a                .gpio = DA850_USER_LED3,5 p4 ^9 q& Y* Y
                .name = "user_led3",
) I2 i- e* Q* B0 b, P( O2 q( f                .default_trigger = "default-on",
! N" C" @8 h& ^# Z' U7 a4 A. j* O        },, W: ?; H/ P+ a1 v
};1 M: S9 K! P2 Z

: H9 `, p, w) i6 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# m1 L* S* [! E/ v% \; E
        .leds = da850_evm_tl_leds,7 S6 m' H, w" ]8 C6 s* ]+ R
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' u# o) X" e8 I+ |+ L( I# x
};6 P  v+ X+ I$ N/ b, w& X8 h* {

& c! a6 @3 @8 r! I* e& hstatic void led_dev_release(struct device *dev)
3 G; c& \1 ]: }9 i* }5 _  F, _{
, Z! W8 ~0 r& b! Z( b};
& J/ W. F% O* Y9 Q  Q' B9 L& p6 t# `- j" E/ i) g
static struct platform_device da850_evm_tl_leds_device = {
8 x& k- ?% L0 \* U4 U: K" d        .name                = "leds-gpio",0 `4 X, U  c- [9 [# C, E
        .id                = 1,
) o+ V1 j4 r4 g) N* S        .dev = {
1 o9 a; l& [0 ^3 X+ c! v3 n  x# K5 E                .platform_data = &da850_evm_tl_leds_pdata,
) |) r+ K( `6 Y9 S" G                .release = led_dev_release,
! s; R% T( R2 j9 T5 g2 h        }
' b$ A; d/ _, B};
, w1 Q, J  i  n4 R7 J3 z
0 t* @$ r' a, d+ D3 W3 _static int __init led_platform_init(void)7 Z. R; R: z3 ]; t0 a; E
{2 l& j' V- K7 e" o6 L( D5 ~
        int ret;+ ]: K$ v4 U2 Q; U
#if 0
8 p1 C3 m$ _& \' f2 h9 }        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 S' @. o; _; J( t3 k: i
        if (ret)
+ F+ }2 l5 R+ p, t9 ~                pr_warning("da850_evm_tl_leds_init : User LED mux failed :": C: [6 d9 y8 S8 P7 B
                                "%d\n", ret);2 c4 A# g' ~; F
#endif
. D* Y3 h( ~# ?( X        ret = platform_device_register(&da850_evm_tl_leds_device);+ }8 b7 n( ^% n7 E* A
        if (ret)
* i$ a0 M  R- i$ d4 B# y                pr_warning("Could not register som GPIO expander LEDS");
( B# E* g9 Y" @        else
: }9 M/ y" \& r2 O, r" {: ], s, g- m                printk(KERN_INFO "LED register sucessful!\n");
" }' j8 a1 j5 ]" l/ h/ ?  I$ d% j3 _2 J% h+ ^6 z" {
        return ret;9 D$ i0 e# V3 O. U, E7 [( s9 A* L$ w
}
# R- A& L! R) G
% T+ V! e; I/ y8 I; {static void __exit led_platform_exit(void)
5 e/ y" O4 ^, D7 _) f{
; G" G7 O& o) m% I        platform_device_unregister(&da850_evm_tl_leds_device);
: X5 S) T, I% E8 F
5 f. H5 C2 y; H: l        printk(KERN_INFO "LED unregister!\n");
: n+ n) F* [7 q6 j: l- }: u}
' H- i# X* Q# l' ~3 r2 b0 i& y% n+ o$ w! @  F; r
module_init(led_platform_init);
6 a# h' A& k* A8 i; V! H3 fmodule_exit(led_platform_exit);: Q0 C( q+ z, U! v2 h% j8 g# {' b! V

6 M3 g0 w  p7 y2 L( i; fMODULE_DESCRIPTION("Led platform driver");5 T2 j: x+ m& V' L: R7 A0 v
MODULE_AUTHOR("Tronlong");3 t; Q8 n. z+ x; t$ I) S( u9 T
MODULE_LICENSE("GPL");- q- `* B0 s+ R$ i' P8 x

' Y1 ^, A/ O& k. f# Y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-25 07:06 , Processed in 0.039357 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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