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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。0 v0 h: c0 M+ f2 i
#include <linux/init.h>" ^% r8 Y% f! R, J3 {4 a
#include <linux/module.h>
) C/ x% w8 ^+ ~* n3 p" g/ \#include <linux/kernel.h>2 M4 X; a. M5 d% t- {8 d/ A! k
#include <linux/types.h>. ?" c' B' e/ T
#include <linux/gpio.h>- ~7 F! m2 {8 M- ?
#include <linux/leds.h>: d- X& L1 a* G  `, R. {' H
#include <linux/platform_device.h>
1 r4 X/ ~& O! l. G7 r0 f+ J
% s4 C7 _9 J: O#include <asm/mach-types.h>
1 f7 `5 ^! u5 ^! C. a  F' O: h#include <asm/mach/arch.h>
6 Q. m5 v) O7 [9 R2 c#include <mach/da8xx.h>  t% m: d# p6 b  V* R; Y0 L
#include <mach/mux.h>
1 O) @& {  ~$ F5 u! X2 s" z( P
0 ]+ u" g% O8 F, t4 q6 \$ P$ o#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 |5 Q+ Z( ^( s, _! X3 K5 j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ @7 h1 j- M, p+ m" V#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): g! Y" G9 a/ Y7 O
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 t- _7 Z* Q2 C$ x& ?/ U/ k: K* g  h: `; U5 ?) o6 M, ?9 X% W
/* assign the tl som board LED-GPIOs*/* x* f! L; n% Y, h! g
static const short da850_evm_tl_user_led_pins[] = {
; K1 t/ v* S) r' `4 o        /* These pins are definition at <mach/mux.h> file */& o) s  U8 Z/ T: h3 l# b/ z! H
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  C3 z9 a# c8 I3 G- M9 o4 s        -1
6 E8 e. o; A2 p  j5 d};
) @  w" z7 L& K2 F$ t" o
1 E$ R* `# ^% x, ostatic struct gpio_led da850_evm_tl_leds[] = {
; ~8 r  \4 D! d1 y9 g. a6 D        {
: |$ N% \0 D, o; Q- S3 R                .active_low = 0,+ K& C0 A8 I; N7 U- Q6 s; @
                .gpio = DA850_USER_LED0,
. X. N3 Y: Y  G                .name = "user_led0",
# Q2 T+ h. f$ E% G/ y                .default_trigger = "default-on",
: k3 @2 _) b7 w  R        },' g7 X, `3 M7 A  [8 X
        {( I- m: Q, V0 W0 Y" }$ K- C
                .active_low = 0,* ^' `  N: X2 w' m  {
                .gpio = DA850_USER_LED1,9 b3 o% D3 A3 D& e, I' B; c5 u
                .name = "user_led1",
, y7 A! p6 `# ?0 U0 W( _2 ?# C                .default_trigger = "default-on",
) a. b5 {- t) q5 g; f& k/ a8 x        },. L6 B, H& N5 M6 l3 S  y" {. Q2 v
        {- n- a# ?( M$ v( V+ R! e3 s8 O
                .active_low = 0,
2 Z' ?: ?4 G; n* v' v' d9 [7 ~/ T                .gpio = DA850_USER_LED2,
4 x8 j/ `4 S' G6 Y                .name = "user_led2",
9 y+ g6 c: `1 S8 ?$ M                .default_trigger = "default-on",5 g1 p( y" r, s; G; n/ ?
        },
+ w1 m; D( w/ M  F6 L0 n$ k# w5 ~        {1 A; j( B. G  j$ g% x) w
                .active_low = 0,
' r- L6 c  l2 m- K) M, C                .gpio = DA850_USER_LED3,8 Q) C; P. Y6 G6 L% d
                .name = "user_led3",  G7 v/ T9 \: C9 g2 S. P
                .default_trigger = "default-on",, Z3 `0 o) @7 F& J7 `
        },6 v5 U! d) k  Z4 e: y+ Z) c
};
; q% ?+ U4 q' |0 W1 X4 s( ~* @, O$ g0 o# G( W4 H. t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) ^- a5 G+ l0 n8 |5 y. t1 T6 O        .leds = da850_evm_tl_leds," s3 ?9 v0 `; q/ U; o# Z1 a
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* V* q5 |" P' r$ p8 x/ K* S
};- n/ P0 S' d9 B1 b; U& {

' G3 e$ d1 D+ f8 N/ ostatic void led_dev_release(struct device *dev)
9 p; b- ?  j6 {2 f6 L{6 Q9 ]) ^4 L4 t8 ?0 a3 m
};
" v7 V. l+ k3 J% P7 y! [: o. P2 }4 {* X/ c
static struct platform_device da850_evm_tl_leds_device = {
7 F; K% \7 j$ i4 u4 s        .name                = "leds-gpio",. M: c$ x) D) e9 L
        .id                = 1,- c" g5 E# e$ {8 b4 d+ X5 W& z
        .dev = {
/ n- }+ ?6 K# P                .platform_data = &da850_evm_tl_leds_pdata,1 B9 P$ t. b0 x; Q, d' C( J
                .release = led_dev_release,
/ ~9 ~+ ~  j, p2 w1 j+ G3 K! g% g  |8 _        }
6 k0 f! e7 m# ^6 r+ Q0 J};
1 S" e, p( n9 ^. A8 C4 U3 L" I& y# [$ N" Y+ K  h) A3 ?+ J8 n8 e4 t0 {8 S- [
static int __init led_platform_init(void)
+ h! h* K- N0 B; T$ m6 y' o{
. k, T. b5 M) a* M, I* t9 r        int ret;
! T& O: h* ^$ Q, ~% \5 }7 O#if 0+ j0 n5 W2 h. z# k$ t
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 V. Y& Y8 u# W. m6 ?
        if (ret)
) I9 F& F/ {  A3 I; e' P                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- A+ Z( v6 s# ~                                "%d\n", ret);' ?9 ?: F; q3 O# \
#endif0 P+ I+ G  F1 ?1 d  J, Z1 H
        ret = platform_device_register(&da850_evm_tl_leds_device);
! g6 I* H* U" W# p9 h- ^        if (ret)  l; `2 P! }" C7 x
                pr_warning("Could not register som GPIO expander LEDS");" Z) }0 F1 `5 Y' [8 J$ _
        else0 i8 c2 ~' S7 P% K$ w
                printk(KERN_INFO "LED register sucessful!\n");
3 ?2 G5 J+ V2 }% g* O5 t
0 O/ M3 p- \# x4 w& V- [% a        return ret;; g0 Q0 e7 `8 x- \! n3 z
}3 P/ L7 A! O+ ]7 l+ y7 }; Z

$ U$ G+ R6 A. K3 O* s* hstatic void __exit led_platform_exit(void)
7 S) H& V! M1 [8 q! c3 c- [5 H" P{
/ ~% _8 j' j1 D        platform_device_unregister(&da850_evm_tl_leds_device);
8 G, F' |3 N9 [8 y  E  W' N- f$ \
2 ?8 W$ ~. G+ {, t. }, W        printk(KERN_INFO "LED unregister!\n");
8 @$ a6 ?# z( `1 r. A, t}
1 O$ Z, n% p4 @! L! z: U1 J, N! T7 e9 D9 q) n
module_init(led_platform_init);! i5 \& V: Q) ^5 b* _
module_exit(led_platform_exit);/ g" R. r. G4 B  t1 |. e3 e
( d/ K+ x/ B! L4 [
MODULE_DESCRIPTION("Led platform driver");
# g( @; {+ R1 X/ ^7 I" GMODULE_AUTHOR("Tronlong");
% L" M; E& v; S6 ]( g4 W& B4 mMODULE_LICENSE("GPL");! l2 x* z- o/ h- A4 D! V$ Z! Z* V
- x: @# K+ I7 D9 T
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-5 19:43 , Processed in 0.040645 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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