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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。/ Z) ]9 v, g) l
#include <linux/init.h>
5 f3 C0 f8 t2 u#include <linux/module.h>7 y$ N9 |1 p2 d1 ~$ e# U
#include <linux/kernel.h>
" x% ]) |9 Y9 \9 i#include <linux/types.h>6 _, }. ]5 G. R9 Y+ o% q- Y4 }
#include <linux/gpio.h>7 y& G6 @5 t. R5 y5 G
#include <linux/leds.h>
! i) U: L% [7 o#include <linux/platform_device.h>& w- _3 F7 o' \& u" V
' |% m$ Z+ A- h# S' c
#include <asm/mach-types.h>' R& y2 t3 }  o7 n& @. Z  I
#include <asm/mach/arch.h>
  p7 L1 n5 i7 m) ?& L#include <mach/da8xx.h>/ S& A  F" y: D$ z' ]& h; L2 a
#include <mach/mux.h>) L; M' a% f4 o5 Z0 A5 U& z! \

) D5 f# K, X  k" V, c#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
1 X) \9 R; d/ T7 S% n3 x0 ~; [#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- w9 w4 c- V+ ]8 Z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" f4 D  a" r# h5 \#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ c7 d2 T) r+ Z" l% C* ?

6 {- }5 s' ]$ x9 ?9 K/* assign the tl som board LED-GPIOs*/! Y, M3 r3 N" m! [
static const short da850_evm_tl_user_led_pins[] = {
1 `& K0 D3 N1 g( _' B9 U3 a% J" d        /* These pins are definition at <mach/mux.h> file */1 u  W9 s2 @3 r, m4 |$ V' `+ {7 }
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 S8 c% t2 ?$ o3 @        -1
& P  @! |+ z$ S$ l; _};/ |' K! k+ D/ L! [3 E5 J  x; ]

4 }- Z+ r, f$ o3 q1 h; _* \4 W1 L' Qstatic struct gpio_led da850_evm_tl_leds[] = {" G' x9 u. b7 _* r4 Q) f5 a
        {
9 r) u0 ~6 v( ]! R* g5 @                .active_low = 0," z: d8 o1 v+ |/ ]
                .gpio = DA850_USER_LED0,& ?. \8 A/ s: H1 o
                .name = "user_led0",9 I2 m7 I% z% P- A, B' H( G8 o  r
                .default_trigger = "default-on",
  n" D& [- w* R( Y  r3 o* T# g        },- {. ]% W* x9 s. ^
        {; q9 I- r* [$ m- X
                .active_low = 0,5 j/ E# U0 w' x. w& j8 n
                .gpio = DA850_USER_LED1,; j$ y. M+ _0 @! b" y3 U. g
                .name = "user_led1",
/ U8 R  Z, U# V6 \6 K                .default_trigger = "default-on",% g( }% ^4 U0 N" b8 }0 \# G/ R, }/ S
        },
' T' K; A6 O2 F3 |) k- O        {
1 N. V' b. M5 L- a) x. p7 t& J                .active_low = 0,
& ?6 n. W4 o5 h1 v/ {! a                .gpio = DA850_USER_LED2,
) V  X5 `8 M6 J2 Z- W                .name = "user_led2",
- ^9 {' V9 P# o$ \+ r                .default_trigger = "default-on",! ~9 Y, T, ~" A4 V) u5 d$ t
        },- V: D- `0 B6 C* H8 ^
        {6 k; L( p. b$ ]% j4 F
                .active_low = 0,
- z# r5 ~# @8 n4 F9 i                .gpio = DA850_USER_LED3,
" J! W3 Y. Q5 b                .name = "user_led3",
8 ?( i4 R, i1 E3 d7 m2 r5 J  e4 Y                .default_trigger = "default-on",( B: K$ \$ S* g' E0 y6 ?0 i+ U1 @* [6 _
        },
) y: N+ v3 F  H0 q) z1 l6 k};$ w2 z, v8 H- h! r7 m- B; r+ F2 E

; I. i$ ]5 z2 f* b5 U( n3 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. {: E/ D' C  h+ \, Y4 z/ `
        .leds = da850_evm_tl_leds,+ k! S' v; d' g& S5 K$ P
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 p7 I' c9 j) B- u9 |) U! z
};) x+ C% |- G: u- t7 a: J

" O6 @/ g% s4 U/ ^6 fstatic void led_dev_release(struct device *dev)
. P9 f7 k- a; P1 M4 r{: [: A7 J) x: P  Z& E3 g7 J
};
8 c0 @/ n; x# @3 P1 }4 a) p& f- V2 n( U! ~
static struct platform_device da850_evm_tl_leds_device = {/ ]1 j5 E/ ^7 @* j
        .name                = "leds-gpio",
: Z. l& D! B8 l& h8 `" o        .id                = 1,3 x! l+ `, D+ m, M
        .dev = {0 _- _% F, O; H+ o! |4 c( m1 ^) q
                .platform_data = &da850_evm_tl_leds_pdata,% |' m& q7 B; V' ]
                .release = led_dev_release,4 T6 k, i# g, v5 z! a6 S8 L3 z7 F
        }$ ]: k% B0 {: t* F* T
};
- P' Y  T3 }" _: w% b! L$ N
" s& B  k8 }2 H4 istatic int __init led_platform_init(void)0 C& @5 o. K: J3 {4 |, g
{  `7 J4 y  b" O5 c! D7 C9 Z
        int ret;$ y0 Q  Q; |9 n8 ^7 R, F) k6 v
#if 0
, z8 V& M/ }# H7 Q' b        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: O; g. I2 ]; `, O/ j+ H        if (ret)
% n3 A/ z/ \; \: c: k# s                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; _$ s* S  `' h# C                                "%d\n", ret);
8 d) y- H3 G% w9 ^6 h: y8 k0 p#endif
0 t* L1 I, A5 `/ g        ret = platform_device_register(&da850_evm_tl_leds_device);
: ~! s9 ^) I. d1 d3 k' R" j        if (ret)! Q9 c# S7 r: \2 c; |7 s. d5 }' m
                pr_warning("Could not register som GPIO expander LEDS");
! L5 q% x1 _) I        else) \' p3 i- V8 f! U; y, A/ G
                printk(KERN_INFO "LED register sucessful!\n");
2 o  b% M4 Q9 Y, f% A; R& Y2 F
8 C8 H, {( s: _8 f        return ret;. w* k! j. J6 ~& Q
}
9 y5 s/ e, t' c+ C* H/ }" \4 ?% o
5 F& j1 F, A/ W0 Bstatic void __exit led_platform_exit(void)- J: w( g( ]# S. E8 z+ s
{
2 b5 q" h1 N1 i6 |        platform_device_unregister(&da850_evm_tl_leds_device);
2 X" h" y5 R( j8 o( e; o; @2 e" y1 q4 w! m  d
        printk(KERN_INFO "LED unregister!\n");( a" c  [- w4 K% G1 r! w
}
6 O/ \& S$ O6 y$ t
# m9 x  v: C4 B& f% W( s) p4 bmodule_init(led_platform_init);$ h! f! e: u+ v; k
module_exit(led_platform_exit);) N( {" e+ m' m' J. S: }

4 x2 B$ \: ~& k& O, qMODULE_DESCRIPTION("Led platform driver");
0 \! `" c1 Q* B; L. AMODULE_AUTHOR("Tronlong");, S( l, E$ j! v  q" S8 E4 ]. U
MODULE_LICENSE("GPL");
* t) H2 L) G& }6 J  k0 n- n
( O5 Y) T* L7 d! Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-4 00:26 , Processed in 0.040467 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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