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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' b  t0 I, R+ v4 a  ~
#include <linux/init.h>
7 j) E. u( d/ m% [#include <linux/module.h>+ z. `! ]) a+ N- Z( b8 h
#include <linux/kernel.h>" ]4 P& r+ e; p! o: u. Z! y
#include <linux/types.h>
5 K1 W( i# ]; {5 Z#include <linux/gpio.h>: f& Z+ G5 O0 S; D6 M1 A
#include <linux/leds.h>
: `9 _1 \% @! H# W& M" n#include <linux/platform_device.h>9 R9 q2 J! L7 M/ I6 {
! }9 s- J, U1 q; [+ v2 a9 @
#include <asm/mach-types.h>5 X; D' l+ B( d: Z; n3 c9 X
#include <asm/mach/arch.h>  n/ o2 o; q+ v: S- T8 W! K( F7 x
#include <mach/da8xx.h>
1 p: @- ~- o/ P2 Z#include <mach/mux.h># s7 i7 E1 a7 F" z4 @' G* N
2 U0 U5 ?7 O4 T4 p7 q/ {
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ e) v/ e. `6 j6 }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 U% ~3 F+ B& ~$ T) N1 P
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
9 E: Q/ e% A! [0 t6 I3 q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
% l" H# ~8 {, h2 a5 R+ @) G% }) X9 Y; q
/* assign the tl som board LED-GPIOs*/
  M; k& ]* M. ^& f& z0 J- sstatic const short da850_evm_tl_user_led_pins[] = {
6 s, o9 N3 {  }5 T        /* These pins are definition at <mach/mux.h> file */4 E7 U; ]- {2 `9 w' M
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; z% A2 A0 R, E4 t  K& H
        -13 C) {; ], j# K% q7 d2 V) i
};% Y% d  N) S% i% m
3 H; b# B. M- |1 V( I9 v+ x
static struct gpio_led da850_evm_tl_leds[] = {
5 F8 [3 R4 z3 ^1 h$ M% S        {' ]- j6 u/ T! k- b
                .active_low = 0,  J0 ]; l; L, U* x7 _
                .gpio = DA850_USER_LED0,
" }& k0 T4 q  P0 y                .name = "user_led0",
8 G+ {  X) u: [- d                .default_trigger = "default-on",
) c$ C& ]0 G% n        },
2 r7 n9 I( b: u2 p& z7 v        {! X. C* i4 y8 @5 m
                .active_low = 0,
" Q3 J: \, |  g' a/ w                .gpio = DA850_USER_LED1,
$ Y6 W; y) R* `* n                .name = "user_led1",
$ H% u4 }, B7 c3 i2 R                .default_trigger = "default-on",8 H: d) I/ C$ b) m0 `
        },
0 h0 A% }3 M8 M: I        {
+ P! J+ m0 ~3 c# P. S9 ?                .active_low = 0,
5 }9 I, v( M, G4 X                .gpio = DA850_USER_LED2,$ {  u0 r$ w9 h
                .name = "user_led2",+ y, Q& [! {9 E. T, `
                .default_trigger = "default-on",9 x4 r0 _0 v  o! e/ \0 G. _' Q
        },, R& x: C4 X( h! t# `4 P! V
        {% B  m' o+ h% ?) K+ g
                .active_low = 0,
; n0 v! x  o' H                .gpio = DA850_USER_LED3,5 ^; E% W2 f; D, e% Z- P3 F
                .name = "user_led3",% }$ l- H* c: P! u% O) b
                .default_trigger = "default-on",8 k0 P" G& l& p
        },
0 x- U; i5 {+ s+ Q};
8 p3 M* N+ J) l& v0 ]( X! p' T7 }1 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ m9 I$ f% P- [  d& G5 I
        .leds = da850_evm_tl_leds,  C. F6 K& V% z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- `% d( k) S, f: m4 i};6 d, w" s0 e: @3 P. n- t  V
0 p  K2 f# P! I) ]/ Z: X8 h0 ^( ]
static void led_dev_release(struct device *dev)
  S* @" b  N* s3 X. @9 A! Q  b0 \{( Z. ?. E* c" j, M
};
) x1 T  Q- j- ]8 ?7 ]+ ]- [( n% ?/ h
1 j* ^& J/ `* h3 A7 Qstatic struct platform_device da850_evm_tl_leds_device = {) V- g( ^) t; q& R9 H( X) r& h5 v
        .name                = "leds-gpio",7 G, x1 U9 n" R2 l4 _" n
        .id                = 1,+ G) d7 n- v: D
        .dev = {
; A: s" P. n, J+ g  I1 A1 `) A                .platform_data = &da850_evm_tl_leds_pdata,+ _3 f$ d& M5 r4 ]
                .release = led_dev_release,
. o" g8 ?9 }# b8 W& O        }0 e9 f& ~. s2 V# U' T8 H* L9 |
};
1 C4 G" s6 q% T8 B7 p4 k/ q
) M! U- M7 P! d5 y( _' |. p8 a; estatic int __init led_platform_init(void)
3 @; u: \/ U# Y0 E# R/ ?{
' V0 Y; i- v! t8 S        int ret;0 U7 O7 G7 y, t) r( X. K
#if 06 z& ~1 {1 K3 q. ]. V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" k  F/ }( G" k* w4 S1 F9 C        if (ret)
$ M: y  b4 N5 @; w5 ]4 ?- O/ I9 z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' i- L5 j6 y: U' Z                                "%d\n", ret);
, ~$ O) r& Q% V0 U#endif# z; ]3 X1 }3 i. q. n+ _
        ret = platform_device_register(&da850_evm_tl_leds_device);0 @: V& n3 G7 n: C; b$ w
        if (ret)8 Z' }* t4 ]5 n8 w
                pr_warning("Could not register som GPIO expander LEDS");
- k2 d2 F7 p0 G5 }. G! g/ t, V        else
8 P/ S, H5 Y( N0 j5 o% C0 @                printk(KERN_INFO "LED register sucessful!\n");3 [# i9 q& D1 s, W
( @* J% J1 _% t. i8 h3 q' a
        return ret;
: z9 Q  Z% `( M  w- u}2 p% m% S8 r7 Z$ w
7 I$ u- ?7 e$ C! x
static void __exit led_platform_exit(void)
3 q3 M$ |: H6 k5 a" s# `( b{1 i6 O* H; d; L6 k9 [
        platform_device_unregister(&da850_evm_tl_leds_device);9 u. k- u, W9 z  y( R* @

1 z* g- r/ [, m1 A        printk(KERN_INFO "LED unregister!\n");
6 p  N+ s* Y' ^# g& i}+ H! a0 u* L5 O. O, C8 `

) S5 J* x* }6 E9 }7 D. @& Xmodule_init(led_platform_init);" x1 A+ z0 Y+ ?' c
module_exit(led_platform_exit);1 \9 J' ^' U2 x% k
- X# T1 U. m+ y9 L2 K+ b, O
MODULE_DESCRIPTION("Led platform driver");- P0 u% k5 ^! E6 o$ m9 V
MODULE_AUTHOR("Tronlong");
3 p+ t( }/ z  U( V- l: M! o9 kMODULE_LICENSE("GPL");( k" V! R' ~% W% O6 X% t; v" O
# \& y( x1 c' q( V1 M: u6 C
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-14 22:58 , Processed in 0.041224 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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