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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 N9 J) e' a) F: S  _0 ^! @) m#include <linux/init.h>
; b: d& Z2 i2 ~: v" L#include <linux/module.h>
  Z* d' {4 t5 M1 P% F" v) b#include <linux/kernel.h>8 ]: k9 {8 R" ^* `$ J4 w
#include <linux/types.h>) C$ _( F" s" |: ^# w$ n
#include <linux/gpio.h>9 E6 e5 q8 N- M/ f1 m, {
#include <linux/leds.h>
' G& [. P) A  K* O* e% ~#include <linux/platform_device.h>
, F" r0 d, |" ]2 w$ n2 L4 M6 B* j$ l0 c; ^2 _! c9 O
#include <asm/mach-types.h>/ s9 b' A7 o' r
#include <asm/mach/arch.h>8 w2 S, P, L5 i/ B9 ~
#include <mach/da8xx.h>
# \5 v+ |$ |) ^$ M; ~* t#include <mach/mux.h>
2 G" y4 s3 b) O' [* J' v. M/ o! j5 ^5 W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% c/ p( Y4 y( A. {7 ~
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); x3 R4 z/ W1 \& a2 v5 m! |- h/ F- }
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# s. L# i4 n- U' G- g9 X4 p#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# q7 O( g) D0 a; q/ l! F

% d" B2 z, W; w( _. }5 b# ]/ }/* assign the tl som board LED-GPIOs*/
4 v/ t2 E4 f+ B) i" Q/ |; E9 I' X$ pstatic const short da850_evm_tl_user_led_pins[] = {* S8 @- |8 o) E$ n; r% l. A
        /* These pins are definition at <mach/mux.h> file */1 b4 j/ y9 E1 f; ]
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) B7 t& U! @) ]
        -1
) Q2 W5 H+ K+ ?2 @' |+ U$ T- n};
" c8 h  r& @0 q8 t. ^3 R1 F
$ L5 U" K' p' ^2 U* bstatic struct gpio_led da850_evm_tl_leds[] = {& k: M- a7 i+ Y% W- [$ M
        {2 O4 R$ r7 V  d( J7 E0 T4 y
                .active_low = 0,! O5 r! Y5 \# i
                .gpio = DA850_USER_LED0,( Y# d$ V2 c! L2 A; s3 F  \
                .name = "user_led0",/ V8 n& t+ y8 s* W  M8 n0 G
                .default_trigger = "default-on",; D" P; V- c* ]3 _% p
        },7 y5 f3 s' G: ~& r8 f
        {
1 {9 m' b$ ^. Y( Y9 `0 |1 [% l                .active_low = 0,
/ ~, V2 C. r1 ~5 s                .gpio = DA850_USER_LED1,
5 O( {" b# x$ `$ ?* c' H                .name = "user_led1",
- h( z) I' m/ |  x8 K                .default_trigger = "default-on",- S- S  A4 A# i  A
        },% M2 a$ J2 ?5 N+ G
        {
; s8 H: I' d, @% J$ i( j                .active_low = 0,
% p, A" N! P1 ^( ]& ~/ s3 O                .gpio = DA850_USER_LED2,
+ e8 U0 h+ {( w' ~; i; b                .name = "user_led2",3 \) Y' F) c, `' E2 I% E
                .default_trigger = "default-on",, J& p9 O3 R- t) w2 f# w
        },$ n. v: y# }& U; X* x
        {
% f/ K# @4 f9 n( X$ l4 B: r                .active_low = 0,/ k- S$ @2 b2 @
                .gpio = DA850_USER_LED3,+ F8 Y/ W3 F. v" E) ?! q
                .name = "user_led3",& |; P9 \1 V* B( H
                .default_trigger = "default-on",9 e$ R8 Y8 D( b, ~; F$ u  ]
        },
  {% I' M, q5 }* R0 `' i};
* g5 G% ]# t) C# [* b+ g
, H) R+ G) p; W5 D- Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ N7 f( }/ a3 _' x6 @7 x
        .leds = da850_evm_tl_leds,
8 m) K5 \0 `, e- i; h        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; g' Q9 I2 g/ _- u9 e/ X7 f2 Y5 C
};( t; W+ e' _1 W& }  k" i
1 h/ \' e% T0 n0 x4 a' m- q5 a% ?, ?
static void led_dev_release(struct device *dev)
! f: R# g" H0 {+ z6 L{% v" \: ^" I6 K
};/ K9 A7 O% {0 p7 r; X, n6 L

/ h+ n* S6 `9 `* y* z4 Q* cstatic struct platform_device da850_evm_tl_leds_device = {3 M* Z7 V' l9 k8 v# _$ j
        .name                = "leds-gpio",
# O* @$ j( q0 o2 n/ M# d! ~        .id                = 1,* _& I. F5 D! Y( f* `' h& x
        .dev = {# f! Y7 C, e+ ^9 e% }
                .platform_data = &da850_evm_tl_leds_pdata,
5 G+ ]2 f6 d: ?) S# a; c                .release = led_dev_release,' c' I. w5 q( x- P7 i( u
        }6 N: l3 M* c9 b+ n0 ~: B% ?% \
};
4 J& R! u, u+ B7 x' u. P
2 v' q7 J. _0 @: N; bstatic int __init led_platform_init(void)
( Q( B: T* N! x. V# D; K, y% g{
6 v* T5 f* U8 B' {( h8 A        int ret;
9 s3 q' X$ t1 {# Z2 `. Q#if 0! p/ V0 Q& V0 F& V  n' T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ V- h9 I- H$ o1 E, Z# J
        if (ret)
* l3 s$ a7 z/ @, K: [, R8 [) A4 N$ h                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 _3 c% n8 _/ @8 G
                                "%d\n", ret);
; X. y+ b4 U8 n( S0 v  j. g! _- N, t9 m#endif
+ v6 _9 c4 ?9 y) ?3 G4 e+ {        ret = platform_device_register(&da850_evm_tl_leds_device);& V0 S. Z4 ]6 A/ ]. ?# E5 D
        if (ret)
: Y0 F2 u; W3 s                pr_warning("Could not register som GPIO expander LEDS");
* z  Q& b( t! B        else
* |8 n* _' o5 ?+ U5 {! l) `                printk(KERN_INFO "LED register sucessful!\n");
& ]# D: D' b! f# }+ H# R. Z" b9 G& L, c) T4 a% b& r! A
        return ret;
( _8 [. c0 }" R# d% H}  V" g$ U: r4 }! t/ V
' i5 @2 h, J6 E+ [3 J$ Q+ e6 b
static void __exit led_platform_exit(void)
  p2 O" K& w7 g- N1 e{$ Z0 |! c, t& t
        platform_device_unregister(&da850_evm_tl_leds_device);
$ j1 }/ u& l  r- F! i8 Q& J9 |9 E0 |! }3 r
        printk(KERN_INFO "LED unregister!\n");
; Z! S9 _" l3 I}' S  R$ m" a8 b2 j1 Y( M

5 \! \0 Q; r# i; U0 ]% c$ Cmodule_init(led_platform_init);0 z, C/ b& L: D0 {
module_exit(led_platform_exit);  _( x4 b  E7 R! Q, \6 I

! E  ~% {9 U  XMODULE_DESCRIPTION("Led platform driver");2 p) [' K  A8 m& h5 Y
MODULE_AUTHOR("Tronlong");
3 z- z( @; Q7 N6 I& y! R4 C& oMODULE_LICENSE("GPL");# n! o2 y/ _* _1 v2 f$ g- N2 C

8 I* T/ p# W4 D) {( A6 N
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-6 17:07 , Processed in 0.039229 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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