程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. s$ Q$ g% v. a' l- f#include <linux/init.h># O  ], Z* ?  t- P2 Z
#include <linux/module.h>7 z! O. V+ X* n$ m5 }
#include <linux/kernel.h>
1 k3 W( A6 O+ A" _! H" q#include <linux/types.h>
0 g) S: @4 I, L1 o! d% i5 D  @4 b#include <linux/gpio.h>
: W1 h, M4 m: H1 N- D( Y# `, N! e/ i; B4 i#include <linux/leds.h>
1 g) ^+ Z" s3 ?4 K, F#include <linux/platform_device.h>6 ]) `$ Y2 K) o" S( \7 C
( J" M7 U3 n% b$ F
#include <asm/mach-types.h>
% o; t+ n' e" v' J#include <asm/mach/arch.h>  L) c% g* H+ H- \* ?+ v
#include <mach/da8xx.h>8 I$ f; ^  W5 q. i" [4 W) c
#include <mach/mux.h>
4 J4 M$ k, R4 J7 U0 l. S
+ _) n, p" U, {#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; C7 Z6 }- g. @/ F. A3 s, R( X  S( D#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). [0 H  X' g5 I+ ~# D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) c. w, L4 p: P! h2 [( F: _2 s
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( K; x  J8 x. k
& i1 z7 S0 j, Q. t# H3 o
/* assign the tl som board LED-GPIOs*/4 u; j2 I' Y! T& j  K$ V: u
static const short da850_evm_tl_user_led_pins[] = {
- f+ N4 t1 ^' S' [        /* These pins are definition at <mach/mux.h> file */
( |. K. j6 n, {+ v1 @; \0 @        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 E: Z) D$ r. Q1 w        -11 o6 c- U! V! |- @+ x5 q: t
};
$ N3 w5 n: I/ i8 z) R
: g! M. M: ^4 _4 ]* ^% g) L' nstatic struct gpio_led da850_evm_tl_leds[] = {9 T, @+ T( Z) [. w# ]: o
        {
2 I/ X# u8 @7 P8 v/ ]7 D/ \, a                .active_low = 0,) }" Q/ z2 M- F; [! z. G) N
                .gpio = DA850_USER_LED0,) r! Y9 j! r/ U* Z5 u
                .name = "user_led0",+ s4 ~6 J3 B+ M. T$ V; Y% s) T
                .default_trigger = "default-on",
' q7 x2 Z8 Z$ v! m9 w8 N( y        },
+ Z6 P  A  V2 j: Y        {
1 ~7 z8 K0 M. o9 e6 M5 H6 h$ i                .active_low = 0,. F* f! h' V- H2 H
                .gpio = DA850_USER_LED1,
9 L, |" H  h) X9 r" c+ R+ x                .name = "user_led1"," @% b' T$ J7 R+ Y
                .default_trigger = "default-on",& n8 a# J1 a( P
        },
% f2 ~: ~, Z6 B5 |        {) b. @" A% `. g$ G8 Z1 [
                .active_low = 0,. `$ n/ z0 c0 {& Y+ u% k
                .gpio = DA850_USER_LED2,, `/ y$ X, T& O3 y1 @, [* ?; }1 |5 e
                .name = "user_led2",7 u4 |6 j) d5 L9 `3 L( _
                .default_trigger = "default-on",8 `4 X+ o' x& h' e' p* g; o' `
        },3 B( a2 ^" |4 ~6 `: m
        {6 E+ Q/ e6 W- u9 S/ ~8 ]# F
                .active_low = 0,
2 C, h& M  ?5 w$ u+ {                .gpio = DA850_USER_LED3,, R- }# R& P! Z. w
                .name = "user_led3",
/ o6 `/ I* k( f9 ?2 {4 T- w! [                .default_trigger = "default-on",
7 S1 T# E  g* \9 n" h! W) Z1 a        },
1 W9 X1 y* J) S; F5 [; X};
) j8 N' [: C8 Y& O( l2 U1 C( G0 D* q5 T( }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 c8 K! U; w; l* e        .leds = da850_evm_tl_leds,1 M6 D# E. c2 O1 `: f- ]+ w& S
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. w; t! ~$ {% ^( Z9 Q* O
};# b. e# ~0 Y7 |
& A5 q) b& K0 D
static void led_dev_release(struct device *dev)
5 }* p4 k- J1 U+ M7 c$ K" Z5 P{  N4 C- t! o* f1 K6 ?
};
. h) B, R& q/ S2 X' t* m' g: A( F* \* {: b5 b) t' S
static struct platform_device da850_evm_tl_leds_device = {
- d0 q7 O' a: w& H) z' Z        .name                = "leds-gpio",
+ M& {) H& e$ k2 r' t# X) s        .id                = 1,
) ?$ ?: B3 T+ n        .dev = {
+ R5 X3 w7 P. j3 n; j! D( B: _8 h                .platform_data = &da850_evm_tl_leds_pdata,8 N0 X7 C: }: ^  @, Z
                .release = led_dev_release,
$ ~  D  c' e. ?* ^' C0 z        }
- R8 m9 l- X( S) w$ F};3 S4 N$ M1 T. S4 e' H9 I  D. e

7 r1 V7 x+ y. ?static int __init led_platform_init(void); z+ \/ x; |8 l% X0 y+ g+ T7 ]
{/ i' |: M* W  Z6 R9 R: h& z3 L
        int ret;
: ~9 L0 v, c/ ?  P#if 0
/ z7 j8 Z. x  e        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! x" Z4 ]4 I+ @. X        if (ret). t3 U( v2 n, }# k$ A1 i
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ }; ?  o  p- g& J  X( x
                                "%d\n", ret);' f1 v9 j2 f; }
#endif
6 \' T. K1 Y8 P& V6 H( v        ret = platform_device_register(&da850_evm_tl_leds_device);8 _1 H1 y) Q( L& I& X; g
        if (ret)* D* Y0 e# k9 q- A$ E
                pr_warning("Could not register som GPIO expander LEDS");1 L: }& q. a1 i, b# a
        else
" ]' V7 M  R! G) Z9 n2 y                printk(KERN_INFO "LED register sucessful!\n");7 f$ I' c1 }5 B: @3 p  W- z! f' d
1 Y* j7 n) w9 Z$ x- u
        return ret;; v7 [9 e6 J4 k/ G+ G/ s
}& d7 s: M9 ?% f* b7 P
- u* ~* z# c0 o& k( C
static void __exit led_platform_exit(void), e  J" |+ Q& V4 I. D4 q
{1 F8 e6 H4 l2 j
        platform_device_unregister(&da850_evm_tl_leds_device);. x8 D+ ]8 z7 A3 E

5 p+ Z, b" I+ V% }* q( ?2 ~        printk(KERN_INFO "LED unregister!\n");) U: b& a2 d3 e* V) k( c
}
+ p+ n& Q: h7 L; Q" k+ m* Q1 r6 y& L- B# D0 k
module_init(led_platform_init);& x, y# k2 n/ b1 n4 S% l; c" o
module_exit(led_platform_exit);
5 J* k8 P9 H( g$ m, J! A! S  n6 P- D# `
MODULE_DESCRIPTION("Led platform driver");1 p6 h  u6 E2 N
MODULE_AUTHOR("Tronlong");
$ I) m% U) m7 L9 Y  y- LMODULE_LICENSE("GPL");! |9 [# l0 O$ g3 t( B
+ F& C, \$ ]: S; u  z6 `: |2 ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-12 00:57 , Processed in 0.037541 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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