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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- X% n0 S0 E0 M' c# L8 a1 B1 }
#include <linux/init.h>
# F* m7 K; \/ Z#include <linux/module.h>0 |5 V& }) S5 z+ s! s8 A
#include <linux/kernel.h>+ W5 s# `$ r( Z, C* k
#include <linux/types.h>
, ^& P2 |6 j( z7 e#include <linux/gpio.h>
- \' f7 Z, h3 D! U" Y% j( ^6 k  C8 i#include <linux/leds.h>
9 h, A; C; `- j/ i#include <linux/platform_device.h>5 d! {7 Z  F8 T% Y

% }! ]: \9 M/ y: x4 K7 r9 _" I#include <asm/mach-types.h>
  O7 y1 Z! e% j5 D+ P% {, f: _#include <asm/mach/arch.h>7 G# c4 H0 x- t+ [; `" N
#include <mach/da8xx.h>6 q7 A* J: ]8 s8 f
#include <mach/mux.h>, c5 p- Y! \! q$ q6 a1 a) b

; j3 W& }/ S9 K9 A9 S$ D- H#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- P0 I: B1 Z! n
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
+ A- G. n5 Q2 {/ H#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ i. `- {& q- W1 B
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 p% p* D2 Y/ A4 B2 h

/ d8 v1 z: S) R, D. _/* assign the tl som board LED-GPIOs*/! b, M/ J! I4 p; i# j& E
static const short da850_evm_tl_user_led_pins[] = {
) H5 x  s, k! P4 N' R; n5 B        /* These pins are definition at <mach/mux.h> file */8 E$ ]% c) {/ x2 Y8 d9 x
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 H. [0 L" v7 Z
        -1% L# P! m: a, B7 E% b6 R
};
/ x" T1 ^/ y2 U/ G$ F& D: s1 Q& b5 y4 ?9 Z; [- v0 S# V7 O
static struct gpio_led da850_evm_tl_leds[] = {6 C: [/ _0 T! x( q: N
        {+ e* f3 `. f. g, X1 C/ I' _
                .active_low = 0,9 z: i8 P$ q4 l: q
                .gpio = DA850_USER_LED0,
- V( o' G4 X1 e, {2 E2 @                .name = "user_led0",
6 x8 K- h* k' B" d# @, c                .default_trigger = "default-on",
2 W7 M- [5 r) Y. O5 s        },0 ~. U* X" T$ d  a
        {
9 i! u" D  P6 Q+ G9 R                .active_low = 0," X0 h; \% I1 [& E; R2 m
                .gpio = DA850_USER_LED1,
$ v: {8 A# M: \                .name = "user_led1",. F' N! B5 }- p: g/ a" }+ D5 a
                .default_trigger = "default-on",) b) G' [% K; T/ w5 ^4 X
        },1 T! a: T1 }& z
        {
2 u: _6 ]( c( h7 [! u                .active_low = 0,, t1 h4 G5 T1 m8 [
                .gpio = DA850_USER_LED2,
$ b9 h- M) h$ _7 n                .name = "user_led2",
( z3 A, W0 W/ H. w! J, _3 M* D                .default_trigger = "default-on",' l' v5 d7 I* _2 U( O7 i
        },
8 s. x* A3 C! x        {6 n% [2 X' f2 z+ R( L
                .active_low = 0,
( |3 i$ h3 D: ^1 B, y                .gpio = DA850_USER_LED3,
' o1 e6 ^$ S1 m4 S8 H9 ]4 w                .name = "user_led3"," I( l. y' ?& [
                .default_trigger = "default-on",
: b8 |3 G' E. z        },0 \, ]8 N) y) L0 {. U
};
! ~* U# E* S8 [% N; H, b7 b$ d; m, G. n& K, h6 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 v5 J  y9 e1 L$ w# v4 n8 |* N( N& w        .leds = da850_evm_tl_leds,
: I% V5 G' b2 A, v: X8 n4 J" c        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ G4 o$ i5 |- b& Z9 B) [+ y
};' T5 n7 x' ?' _* P+ }) \; z
" H: |" ]# v9 q
static void led_dev_release(struct device *dev)" `! l# c/ W/ W" P: |
{
# Z& T& B5 v6 h1 A! o, \};6 L  ^3 i. `/ O; A4 D

, y. i+ \$ n! d' j+ t* gstatic struct platform_device da850_evm_tl_leds_device = {
8 B+ P  F! ?5 b9 k7 b/ V3 [7 e        .name                = "leds-gpio",5 g  h3 n% x/ x: V% ~
        .id                = 1,2 V) h/ `7 c5 k& K
        .dev = {
1 z) E5 V, `' }* F                .platform_data = &da850_evm_tl_leds_pdata,
$ ?( n6 ^4 m$ Z6 f. K* |                .release = led_dev_release,/ I! `/ l" E3 I$ F; X0 j
        }% N5 a* G# K8 z; g% R3 m- L
};$ j9 `6 T- E& p+ u( h6 w3 H: a' }
+ c' [( q! u/ {
static int __init led_platform_init(void)% _! S6 V1 N& p% o/ _$ J9 L0 O
{( z; f' V& W. x, B
        int ret;
/ W! I+ m; b4 q2 G5 Z5 }#if 0( e1 S1 k" Y& E4 X' b* `! _) ~0 A
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 y& ]: ?# U3 l# t! V5 ]* t$ w/ H% Q        if (ret)" V; F; _( u+ U4 Y5 P
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# G: `- i( f$ W+ \                                "%d\n", ret);* `# K3 Y. d) i2 Y
#endif
) k4 J& a! B* H% w8 Q        ret = platform_device_register(&da850_evm_tl_leds_device);$ u( ]2 m# @9 U/ B0 y9 T( T3 p
        if (ret); z* t; r! J$ l0 X1 m
                pr_warning("Could not register som GPIO expander LEDS");
9 m0 f3 F0 _, p' h0 d3 h        else
+ T7 |1 X4 ?$ {" i                printk(KERN_INFO "LED register sucessful!\n");
* _* i/ L. g* J$ D6 q/ ^7 E, w- k
        return ret;
% c9 B6 ?8 n7 Z}- _" `- j& t  D5 T) f' z* R1 u8 o: x) r
0 M# e  Q- n# c
static void __exit led_platform_exit(void)
2 f7 ?& k. u- }  L6 }; i, I: t{
) I" W" c2 C. m# _$ e) }" Z. A  Z3 E        platform_device_unregister(&da850_evm_tl_leds_device);
* @# i/ ^; Z" ^' @9 [
6 r' q; G. t5 N- j        printk(KERN_INFO "LED unregister!\n");
" [9 E3 E$ [) J- R& l}* \2 W/ I0 P: {2 S& g3 d" Q
3 c4 n1 J" f# h- W" ^( G
module_init(led_platform_init);
4 _2 Q" I5 L; P' rmodule_exit(led_platform_exit);
: ^: m. f0 U- w% m4 k# G4 B5 u
* K2 E; i2 M5 W: K- J$ p  ?' qMODULE_DESCRIPTION("Led platform driver");
0 y& H& l1 [" X& x( r  e. C5 Y9 UMODULE_AUTHOR("Tronlong");! S5 E4 ^" i+ n7 X
MODULE_LICENSE("GPL");6 D+ T2 o" @* s+ W8 ~6 c; f+ z

3 t6 Q2 O7 O! T, a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-6 08:10 , Processed in 0.042406 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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