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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- H* f( i5 Y' \1 a
#include <linux/init.h>" E1 H2 I* G. y- _4 f& }
#include <linux/module.h>
' g3 b, Z" _* ]1 O7 O#include <linux/kernel.h>
: k5 V% q9 V8 u) w' h. K" @#include <linux/types.h>
! \8 T: ^% l6 s8 P$ _% C#include <linux/gpio.h>
5 U& J& B. G. u# B( s; w#include <linux/leds.h>, Y5 F; i8 N& @$ E  n8 b: w& [
#include <linux/platform_device.h>
2 `6 B0 l1 z8 c
1 w- _. c  `3 a+ j/ v* R#include <asm/mach-types.h>' l4 N# O9 @4 X8 M$ u
#include <asm/mach/arch.h>
) k) r7 u0 w9 j% G#include <mach/da8xx.h>- p" O6 S$ \- r# }
#include <mach/mux.h>6 ]9 [/ N  H9 e2 u# D2 C
' z6 @7 s! W0 H) |) h/ t1 c
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 {) R# n4 H7 b# [7 b; `: B
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)- A! S2 P1 v5 Q+ D1 v3 b1 H- l
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 `2 B' K5 D! P4 ~% W
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 P+ t2 [/ i; N: c( K0 U( a4 `

/ B3 O- o2 p6 M# |0 F6 [/* assign the tl som board LED-GPIOs*/. I% d# O' _- \; ~: A- ?" m0 s5 r
static const short da850_evm_tl_user_led_pins[] = {6 r6 {  u6 X9 C& d, ?
        /* These pins are definition at <mach/mux.h> file */+ F5 \* [& ~) `  L' n
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. G7 e; V: `# E. T) M        -1( X  H7 V0 d: \& v
};! H# l! y' G/ d/ q& e# I
4 v* x- E% p4 C2 N+ E" [. }
static struct gpio_led da850_evm_tl_leds[] = {- d' q; y- J4 C! \0 O! z
        {
1 L# t- t, J8 n, i) H+ I: R2 N                .active_low = 0,
  h3 l8 j+ O" h( D* r                .gpio = DA850_USER_LED0,
4 ~& }& J( [- H' O: B5 ~# Q$ Z                .name = "user_led0",5 ^! W2 _* c/ p7 [* i
                .default_trigger = "default-on",, A/ e8 v, _, U5 P
        }," Y# D+ h; S% _0 a0 N
        {
+ p- e) S/ X% x! W# p                .active_low = 0," o5 W8 z  f! t  V# W
                .gpio = DA850_USER_LED1,$ ~; H* ~  H( ]7 y
                .name = "user_led1",
8 K5 N8 ?& V& Q, j7 a# @$ c7 _$ I# l                .default_trigger = "default-on",  U" `/ I  O) t
        },
% p5 w; f8 {7 k        {# ~& H" y; T" h' m
                .active_low = 0,& a& E4 R) E% k5 n, }2 P
                .gpio = DA850_USER_LED2,9 v, x; z% D: S, {; c* \
                .name = "user_led2",
0 h7 ~. _& A% g; D: p                .default_trigger = "default-on",% P. G+ x! l, @4 k# S& ~$ d& ]  l
        },
; m% e/ s2 @' D        {9 Q. r$ s  h( V" u
                .active_low = 0,) ]9 Q7 x2 S, T' D* l
                .gpio = DA850_USER_LED3,
3 f6 `4 w% q% D* `  t* o/ g                .name = "user_led3",& L: x( }, y2 u/ E9 v% H, ^
                .default_trigger = "default-on",# X* b1 ]& s, ^, R7 {
        },$ P4 f. R$ h8 P& |, L( O
};9 U7 J" J) I# c) I. t4 ~) |' `
# c, q3 C7 X; I* k) |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ f% C5 D' A& u        .leds = da850_evm_tl_leds,
) b% ~  s2 K- U- ~$ c        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ F' c/ [% M% D
};
' z( [0 L2 }5 V
: j+ e3 t- g* q" r% M0 mstatic void led_dev_release(struct device *dev)* m% F  Y; F. D- C- [' Z9 p
{
/ [/ S) K* j; }6 ^4 c};
) M  N& I/ Q, K0 e7 L; T* ^* t2 r
7 `* G! [9 k9 C0 u% `; X  S/ }% a  astatic struct platform_device da850_evm_tl_leds_device = {
, s! n* h* |4 t        .name                = "leds-gpio",
' C/ m4 \' l& R0 O        .id                = 1,
: a9 O) J6 m% e! ^2 l        .dev = {7 C, @9 T) h% o) j
                .platform_data = &da850_evm_tl_leds_pdata,
% D+ z$ @0 z- \# O# ], e" V" |: a                .release = led_dev_release,
& l  R* I! P& W/ A9 H) N        }9 \- \& W/ f4 P
};- z% j2 `. L. t; d+ g) f

: N5 `( Z; X7 w# Ustatic int __init led_platform_init(void). y. w* f2 [$ S+ Q" i( I
{
& Z8 a; _7 Q! J        int ret;% A0 R. c( R& B7 Y) H3 V
#if 0$ I4 z' l  k/ f0 @+ |* C3 a: M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' d( m" x/ T  z: s6 p# S        if (ret)/ h+ h5 }# Z+ l3 [: D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- m; T( d+ v; U1 U& f
                                "%d\n", ret);
8 s, f/ R/ w4 f. q+ W7 y* B0 F#endif
" J; c0 H' j: u' |0 n- `3 _) f        ret = platform_device_register(&da850_evm_tl_leds_device);- a7 I0 T( ]! U
        if (ret)5 t& ~2 a: k4 t2 j
                pr_warning("Could not register som GPIO expander LEDS");
8 ~! z8 }- V  i/ m1 {' W        else
; g6 g+ z; f/ M9 D/ B! R7 z. f, D                printk(KERN_INFO "LED register sucessful!\n");
# d- j6 C$ A- P
* ]) E( P- J5 J7 R% q2 W        return ret;& x* {6 N' k1 ?- w2 a# e
}9 h5 f5 n, s7 ?5 m9 l" `0 u
* e; L# e6 b7 b/ n' d; W6 P
static void __exit led_platform_exit(void)% u4 ]* m. }7 ~% N  c. g
{
" H0 t7 w$ W$ F  u# ?9 B& \        platform_device_unregister(&da850_evm_tl_leds_device);0 z! B3 @: G+ z6 w

& L( L" q9 U; [4 e% \  k        printk(KERN_INFO "LED unregister!\n");
# v& Z; ]& t8 `, i}
6 ?0 V' @: F( X- O$ C! B7 H% s( |6 d8 M& l$ s7 R
module_init(led_platform_init);; w& X( L, V& }8 v( m
module_exit(led_platform_exit);
% W6 O  f, \2 y9 Q4 B' H/ U/ f. A2 i- N5 R9 M0 k3 f
MODULE_DESCRIPTION("Led platform driver");
) F: Z4 P8 \' O' ?$ Z9 iMODULE_AUTHOR("Tronlong");
' c% @" ?6 z( ~MODULE_LICENSE("GPL");
5 |4 l" Y- ]/ F! @5 u3 r
' \/ y& d2 r2 ^$ ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-9-21 02:03 , Processed in 0.040289 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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