程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  Z8 \7 W. J3 q) u- M/ o. H! b4 h#include <linux/init.h>" Q, _* H0 L" k, T
#include <linux/module.h>
- J) @. l7 C5 P7 U( W#include <linux/kernel.h>) `, y. L# C; N$ Y- R; Z6 x
#include <linux/types.h>
1 s" _% Z2 T9 o* x#include <linux/gpio.h>
# k" W( l! {* ]; z4 \#include <linux/leds.h>
! w& |; {$ l% w' @#include <linux/platform_device.h>
6 \, S1 A2 |% A2 E: M/ U5 V4 w4 _
5 H4 j8 v8 y3 `. s#include <asm/mach-types.h>( V3 w( _9 z% q" Z5 z, X
#include <asm/mach/arch.h>
7 `1 O: K$ I. z6 }#include <mach/da8xx.h>) h9 g/ n, x  y2 }4 _/ m" M
#include <mach/mux.h>
6 {& r3 J) b1 m$ S5 Q5 {6 n; R' B. M& R* N% m! s4 [! J
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)0 A9 s: V( c/ b  y/ g9 `
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 g& o: ^8 Z+ x" `#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 u! z3 S0 M. O& E* m
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 `% |2 U8 L+ x1 i+ I

. @  M  m0 Q" `+ H! G' G. L/* assign the tl som board LED-GPIOs*/
  ^/ Y8 J5 l" T# X- a, c1 hstatic const short da850_evm_tl_user_led_pins[] = {: I& m0 I( a- o& t7 ~
        /* These pins are definition at <mach/mux.h> file */. S8 O  l# f4 N4 t
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; M; H4 S) p4 T
        -1: R, I; F9 z2 M7 D, n$ }2 ?
};6 N+ C# ~# a  z. o% x; B+ @. j

4 x7 b7 U( }# r0 s$ x5 ^static struct gpio_led da850_evm_tl_leds[] = {
: _- i* _/ I* e8 ]( R" \        {
8 B5 M$ u1 N* Y4 O4 X                .active_low = 0,
9 x; t! h, ~& Y% x                .gpio = DA850_USER_LED0,
9 n$ z4 e  Y9 k/ `/ e# C                .name = "user_led0",
8 S" ?* I! F) U/ y                .default_trigger = "default-on",
+ r9 B' n3 B- p( r/ Z; l        },
! u  ^1 E# F- [. o        {
, x7 e' U0 q/ ]2 I% u* |                .active_low = 0,; t( `6 w) b: N7 d4 K
                .gpio = DA850_USER_LED1,
& O) H6 Z- ?$ a0 H& k# ^9 G                .name = "user_led1",
! j- w3 B# u2 d( U                .default_trigger = "default-on",: `  j4 X( W6 d
        },& D8 E9 \- e- _( i2 U* s! h
        {
6 Q2 R% J6 G+ K  y4 P                .active_low = 0,0 ^6 q% h6 G& m" Q
                .gpio = DA850_USER_LED2,- f+ p# p: A" I  T
                .name = "user_led2",  g0 q6 Z( J; b; l8 ]
                .default_trigger = "default-on",8 H. m" E* B0 E5 G' u
        },/ y5 c6 G# s! j  n1 j
        {1 Y( c6 ~& C+ n" o% P: s
                .active_low = 0,' }9 L, Q8 A% L. F; E
                .gpio = DA850_USER_LED3,  X9 G* V+ }3 ~8 [' f+ H
                .name = "user_led3",; P, ]! u* v% p+ {' m' F6 s2 i0 c
                .default_trigger = "default-on",; J. `, x8 I- ?7 g8 d
        },$ |; E$ i/ L2 V9 u+ Q0 l& {
};( B+ X# {2 D$ D- Z, ?
/ }- b! J, N' V) h5 n& A4 ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# e; C2 K3 C& _( }, E& m8 Z        .leds = da850_evm_tl_leds,) Y" j& s- t' z8 [, Y4 S1 L5 `; A
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 W( c: E9 |) s" H! j
};
( `7 q/ N+ K, C: z/ k5 Y8 A0 y3 A" t8 Q. a( E& D8 y/ m* b% z
static void led_dev_release(struct device *dev)9 Q2 K. G6 k- |
{
5 R5 N$ T: m/ W4 B- V- z};
- h" A8 f/ u2 x0 z' }
) F; t% y- N% r- o7 Q; ^, A# Fstatic struct platform_device da850_evm_tl_leds_device = {
! U, Q4 H7 u! a7 O5 T* ]8 l        .name                = "leds-gpio",8 a. B8 Q0 N: \$ n
        .id                = 1,. D' u# C. {' i3 p- x. r" f" a9 j$ T
        .dev = {
9 B: {: C% r7 d8 b7 {$ ~& t& [                .platform_data = &da850_evm_tl_leds_pdata,; a: A- r8 l. w. {, H
                .release = led_dev_release,
3 D+ }& o8 i. n  |$ `        }
! w  g" f* n; S; a: |; z# w};1 u, X4 `" H. z- D% j

) k8 I4 X6 V" Pstatic int __init led_platform_init(void)
- X- I! c  p5 u1 @: w{
* Y% d& A9 t. L: S5 c        int ret;
% S$ R; {' w7 d0 ?! x" O0 F) S#if 05 q' D2 |& u6 l# D5 F
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 u/ s/ o/ I7 I. l! D! `2 [        if (ret)
1 ~7 c2 c  L; N6 ~4 L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; k3 ]& ]" B/ y! c& N
                                "%d\n", ret);
! }0 D7 K& `7 c#endif
1 d8 z  b- L, G; z& y+ U- m        ret = platform_device_register(&da850_evm_tl_leds_device);. x* Y0 |2 c! ^& Q
        if (ret)
( }# f3 ~$ ^+ n8 M                pr_warning("Could not register som GPIO expander LEDS");
, w! y: [3 }# @; _, Y, T        else
" _! X( k2 T$ j3 r                printk(KERN_INFO "LED register sucessful!\n");
* ?- ~3 b, B$ G
% ~0 \5 Y; q. `# Q% {        return ret;2 ?) Z1 d) w  I7 ^- d2 k0 g
}
& j* ^" t; c! q: G8 N" t  d# F3 S1 e; E, a0 R% U% B, l
static void __exit led_platform_exit(void)% _+ J3 k) Z; |9 g' u
{! ?; E0 [4 D# ]9 L0 u; y
        platform_device_unregister(&da850_evm_tl_leds_device);
' k8 o8 x' {* {$ \
) \' x7 i4 L/ T& D( K, m+ t        printk(KERN_INFO "LED unregister!\n");1 I+ d# N% y( w3 j
}
$ h2 ^! e* I8 z1 |, t) U3 }, @7 T
module_init(led_platform_init);& p. `! y* t& q" g8 l
module_exit(led_platform_exit);8 q4 J+ \8 l# R2 }, X- w  R# v; _; P

+ @3 R* g0 y. W$ H( g# t9 xMODULE_DESCRIPTION("Led platform driver");
$ v1 D; G& I& s; }5 [; ]MODULE_AUTHOR("Tronlong");
1 B& \. I: v4 W3 ?MODULE_LICENSE("GPL");
5 d! D4 j% F1 {! L* b% C# Y' G2 z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-5 08:41 , Processed in 0.045449 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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