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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 b, i9 `. r* B' O#include <linux/init.h>
$ s( W8 [( @! A5 r* ]#include <linux/module.h>4 R, v1 `  x/ R# q5 m
#include <linux/kernel.h>
0 n( w$ l( [: @#include <linux/types.h>0 C: ]* n+ `. A- l, y
#include <linux/gpio.h>
% q( d" `9 a0 s9 W8 k( Z6 o5 \#include <linux/leds.h>
" ?* c! P( L. c. G8 E8 d#include <linux/platform_device.h>
6 v' g4 ^' {5 o, J$ G4 Q3 I( Q7 M/ e& w$ ?) U% E: c
#include <asm/mach-types.h>: g3 H0 u; {4 @7 M' f+ k- z3 I
#include <asm/mach/arch.h>5 j9 f  U5 w$ Y9 V0 J
#include <mach/da8xx.h>
: N4 G- m  b# D* ?#include <mach/mux.h># v( y. e4 H( A% U- b

5 d; G1 Y( Y2 D  A#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 m8 @. I: g7 `#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)) k  G" O/ X8 k* F& t% U
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 s7 U9 k* G+ s; v
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ f- R2 O. R( A( d9 f1 k. F6 p7 o) _

/ L' j1 \( a7 C2 ?1 z5 c/* assign the tl som board LED-GPIOs*/
! T2 g, K% z- ^* J0 Z8 ostatic const short da850_evm_tl_user_led_pins[] = {
+ U  O$ a3 `1 ?        /* These pins are definition at <mach/mux.h> file */
- a. B3 T. e6 w$ {5 ?        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& |( H& h1 U5 v6 V. c: R        -1
$ c: [# G' f, ?; u};9 Q4 W& @. f+ |

( r. x+ g4 R8 C0 {" G5 Istatic struct gpio_led da850_evm_tl_leds[] = {: d1 ~( [. k9 V
        {3 E! f( g1 O9 S0 e! N( V+ L1 L
                .active_low = 0,
6 z6 A" Z2 r  I                .gpio = DA850_USER_LED0,' B8 j" w& x9 P4 m% L' S% |
                .name = "user_led0",# a9 F% A) B0 `6 V8 f: K: T
                .default_trigger = "default-on",. j; t' C5 c, e, b. \  w6 G
        },) d5 o; F; G% L0 k
        {8 i0 B2 k* N! ~/ v/ ~
                .active_low = 0,
' \; \" E/ C; [* {  ?  |& S6 f                .gpio = DA850_USER_LED1,
; t, s( \- x6 i7 }: `9 `                .name = "user_led1"," D0 `; W3 ?0 c( B2 r
                .default_trigger = "default-on",3 K* e5 |# l6 a* P' Z
        },0 Q7 M7 S' n* U
        {
' a/ i" p6 p3 Q- M                .active_low = 0,7 A' ^; I5 K7 S$ e+ `  U
                .gpio = DA850_USER_LED2,, y2 _6 X2 s8 o3 Z, |# e& s2 n
                .name = "user_led2",
) n7 t- I: S! b! |1 L6 I                .default_trigger = "default-on",
; m$ l' P: x5 a3 X) r/ |4 C8 t        },: b9 B' v8 S; ]1 u$ r( \  w4 g
        {
/ L# C' N+ `& D4 I0 g                .active_low = 0,
2 s* q7 e1 N- n! H! I3 }9 e                .gpio = DA850_USER_LED3,9 o4 {9 k% P; y- E
                .name = "user_led3",# q7 {( q6 M6 j, Q( W: H# u/ N) L
                .default_trigger = "default-on",
; I# ~6 D. x3 K        },
3 A7 e1 F! y+ T( V};9 u$ I8 q5 f: ^# e/ o
+ F' B' ]/ @1 x) n; G3 O7 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: F, o, L8 l& y
        .leds = da850_evm_tl_leds,7 Z  T6 e5 r; R$ u/ d7 J$ N
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 g' X2 b6 N" M
};
3 z7 a0 s# o: e2 ~
' q% Q9 Q" x& w' L3 T9 ^& Pstatic void led_dev_release(struct device *dev)
6 U" N$ \% a0 M* s  K) o{
6 ?8 L' |  U6 E};1 i, }( U) h7 T$ m) Y

- Z; q0 K% x! _4 P( Gstatic struct platform_device da850_evm_tl_leds_device = {
$ t0 B. t. ~/ j- H" n& V/ o        .name                = "leds-gpio",9 M1 x4 b) K# e$ p& Z0 y! @
        .id                = 1,/ L; M2 g2 F2 Y0 s
        .dev = {! \1 d/ P! j. \4 G' p
                .platform_data = &da850_evm_tl_leds_pdata,: E2 o2 V0 @: m' w7 D$ t
                .release = led_dev_release,/ b) E0 h; u! d
        }5 u# G. p% o" W% f2 [  ?
};
: m, V2 G% w/ l
( g3 G: a/ _& k( ~0 F$ ^static int __init led_platform_init(void)5 @( \" A; q8 Y; a! }/ {+ Q( |
{
6 E/ ?  I) H7 p' X        int ret;1 ]: G# G0 N+ F8 a+ i6 _8 i: r
#if 0  C# A7 B1 x8 R5 @8 N' I
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 X6 A: [# b% m5 A" o) F% z1 \4 y/ t        if (ret)
0 r: l* U8 {3 ^' X                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 \1 ~$ G1 V& \; p1 s, h2 s+ b                                "%d\n", ret);+ }" W6 B6 O9 q' ~1 P( r& B& _
#endif
8 {* Q, r0 T3 p& m        ret = platform_device_register(&da850_evm_tl_leds_device);" Q2 O% N- Z! a% \* j; K) k: l
        if (ret)! f6 J/ j* I5 h0 J1 r0 B
                pr_warning("Could not register som GPIO expander LEDS");
! \( j; J+ U( h        else
. y& x# g$ J2 H# S  Y                printk(KERN_INFO "LED register sucessful!\n");6 h; Z+ b% z; r7 E2 I

2 m8 q6 A9 z: h        return ret;- J$ b% a" b' @3 I6 _/ a
}. K; J; ^0 M$ n' M
" q9 w" C( F, O- m- n3 @5 v1 |* L
static void __exit led_platform_exit(void)5 m0 {8 q% q3 ^$ R9 o
{
4 ^, v' K- v3 z* p; W; P$ i        platform_device_unregister(&da850_evm_tl_leds_device);
" m. S7 A- e4 m6 ?. G! L; q1 D& U, C, `+ {2 L3 r( H( Q' V, P
        printk(KERN_INFO "LED unregister!\n");
- H- F" C. j& n; B2 Z}
/ O8 J8 _! y9 M5 w7 {( m8 J
2 P# Z9 k5 ~/ c% p) W' ^- d0 Fmodule_init(led_platform_init);  I; h+ C7 _& e6 _/ I% z
module_exit(led_platform_exit);
2 k8 b! {$ |  L3 K- [/ r8 H8 K+ \6 G0 c3 z, ?. i" T, g
MODULE_DESCRIPTION("Led platform driver");
: h- M8 P; b$ C; @' L- s: CMODULE_AUTHOR("Tronlong");
* y) O8 }7 z/ V, u( g/ R' @: eMODULE_LICENSE("GPL");
- M/ q, P3 x7 ]$ D' j6 X0 E2 [7 T4 u4 C! V3 ?% ]( c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-26 21:09 , Processed in 0.126627 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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