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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% g- Z/ c0 f' g7 X
#include <linux/init.h>
3 j$ C7 s0 M9 k# I! V* }#include <linux/module.h>
" ?1 F! I5 j5 E2 c& N#include <linux/kernel.h>
( F5 l3 I3 C2 v, G9 t9 m1 V8 g#include <linux/types.h>9 g) w$ B! h5 R( {
#include <linux/gpio.h>! C4 U$ O+ w- |3 a' }4 a& M  b
#include <linux/leds.h>
- Y  x) c3 h, l4 X# D8 z( V! }1 a#include <linux/platform_device.h>5 ]  w0 |4 B. e& x; E+ _9 X0 a
7 d: @& b7 _/ |- Z. h" `; ]
#include <asm/mach-types.h>2 @- u, S" W5 w" t6 t4 p
#include <asm/mach/arch.h>  e3 Q8 {9 Y+ R# w7 ?$ b) M
#include <mach/da8xx.h>$ i6 o, T; ^7 x5 D
#include <mach/mux.h>
% A- _# B/ T$ ~6 S7 x
  H* c1 ?. B# X0 M  z9 x8 z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
& B7 O6 }9 D+ y1 O#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)+ w2 t4 q/ v$ \
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% K$ P; Z- u3 A- l& a! _6 l#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
4 r1 P( P% V7 c# w) F
/ D. }1 g& |1 V4 x# j) O- v1 t2 A+ `; q/* assign the tl som board LED-GPIOs*/
  \1 e; V" A6 y! Ystatic const short da850_evm_tl_user_led_pins[] = {
6 J" f# q1 N1 B. l- W+ m% |        /* These pins are definition at <mach/mux.h> file */6 `# L5 M3 F) j: i$ z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 @& t0 Y/ r9 ?        -1+ E  B; p1 F9 ~
};
$ b4 z0 x. D; |/ \. o  Z  K2 h& I8 c) H9 Q3 V
static struct gpio_led da850_evm_tl_leds[] = {
! c8 Q' T/ T  s. Z* ^. ]/ a3 o        {
: `$ [# y$ Y0 y                .active_low = 0,2 u2 h3 R2 F6 q  l7 y" h
                .gpio = DA850_USER_LED0,
; P, f( ^; T. C1 @) x, f/ `                .name = "user_led0",3 Z/ L1 V8 u' J" w, `
                .default_trigger = "default-on",
& e( X: E8 I" j' K" M5 @& Z" X        },* A$ _8 S9 V* N
        {. ~& U3 m" Q5 ?" ^% E! W0 J6 E
                .active_low = 0,
) L# d0 S+ F* R7 b6 R7 P7 Q! O                .gpio = DA850_USER_LED1,3 p, u/ }. E7 i
                .name = "user_led1",) l$ O! h5 R& i2 w
                .default_trigger = "default-on",  f$ d* w. [; v4 M. ~
        },/ ?( R8 a: e  Y+ C
        {0 B4 c0 f8 M: b, c3 a, a; c5 H
                .active_low = 0,
4 r) M8 O# X5 U                .gpio = DA850_USER_LED2,6 E; W/ @0 Y0 s
                .name = "user_led2",
$ j/ m2 @; }6 q* \7 L9 Y                .default_trigger = "default-on",
0 P* N8 _7 f. v2 [        },
+ i! ~4 ^1 f5 Q4 Y' @6 P3 g        {# ]- ?* D# q, s
                .active_low = 0,
+ L$ O8 q8 o, \% k! H- ~1 `0 t/ v: g                .gpio = DA850_USER_LED3,& g/ z0 l( G' A4 T: D
                .name = "user_led3",
* S$ w/ T" r. @$ {6 P2 }- o                .default_trigger = "default-on",
' ]5 J, Y( a2 U        },
; R" S% e# D' N4 T7 d/ ?% T5 s0 w; \};8 G! x) a: P/ G& ~( I# }1 j

* j: u3 P* ]) C' ^, `* tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 t0 e. h5 z/ Q" @* C/ Z8 q        .leds = da850_evm_tl_leds,
. ]6 P3 A) S5 W& y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- g) f2 C* B' ^  F4 ]6 P
};
2 h  q% S: P' _! U5 x" `
9 |# R0 j8 m! F2 S* d6 \static void led_dev_release(struct device *dev)
2 L9 Z% k/ W5 [8 ~( a' h{
$ E$ i  I0 F2 @" Y% S* E; S/ L6 J};
8 A$ t) j9 `) I$ J  x) m1 D- o% C9 i5 ]& j& V( O, [. S
static struct platform_device da850_evm_tl_leds_device = {
3 E6 a; y  ]* [' K! R        .name                = "leds-gpio",/ L6 N, o+ W& K" A% r2 A4 j6 G7 P* y0 i
        .id                = 1,
) ?3 R8 r4 m! x6 D1 G# {+ g. z        .dev = {6 G. o! j0 Y5 Y& f
                .platform_data = &da850_evm_tl_leds_pdata,
+ y& P: e. W* V& p' J: m: |. v                .release = led_dev_release,; H$ q4 @/ D/ L/ q9 @# {& ?1 K! T
        }  `8 f$ b$ v& i3 q& p
};
( t: N& g4 O- o/ e* _+ `
+ W+ J9 Q" J  i, Nstatic int __init led_platform_init(void): K, B) p- V1 u2 y$ f4 k1 ]! p
{
0 S4 \9 h5 x( u, B        int ret;
% L& y. ~6 K1 K#if 0
1 M& t9 H( o0 a        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" j7 R  P, t  a, H" F: Q3 T  _        if (ret)
* |' H" W$ \& R                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( k" x' f9 O( A4 q- b                                "%d\n", ret);
5 }' V- `* k! ~7 X#endif
5 L+ P1 ~6 p9 s& @* ]/ e        ret = platform_device_register(&da850_evm_tl_leds_device);9 H8 i1 G) C6 w- f# {$ S3 k# _
        if (ret)
# G* ]4 S& c9 J0 f! q: Z& c2 [; C* e                pr_warning("Could not register som GPIO expander LEDS");5 Y) i0 ~7 l% j4 f
        else, H1 p$ }  s0 h8 w
                printk(KERN_INFO "LED register sucessful!\n");
0 ~* d  w! _4 U5 k
. k, O* E( B; e6 h) O! Z        return ret;
- M) ?* w, K  b3 g# f) B4 \}3 t$ d% }# S9 D8 T) A6 s

9 C7 }1 k: q( ~static void __exit led_platform_exit(void)5 Z- ^) j: |6 z! n( R
{$ [' a+ ]; X! P" N: U
        platform_device_unregister(&da850_evm_tl_leds_device);
% V" h7 }; M6 K2 Y' u+ _
4 D1 V1 Z& l. @5 ^' _  M& I: t. ~        printk(KERN_INFO "LED unregister!\n");
9 [+ R, P0 L7 Q3 ]9 E) V}6 M) p. c* _  T5 f
6 Q( P3 u1 X' ]- V
module_init(led_platform_init);# @' o5 L7 @$ w, D4 H& i
module_exit(led_platform_exit);
6 |3 P: y  t. a" K$ Z. n7 d: E% W" x$ m* y5 q8 x
MODULE_DESCRIPTION("Led platform driver");, U: Q8 v$ \, j( ?
MODULE_AUTHOR("Tronlong");& z" y) k- S$ v" }
MODULE_LICENSE("GPL");/ d, q# ]! n4 I9 y. X& Z

" J1 `8 o/ Y( R7 \! u$ J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-7-26 15:18 , Processed in 0.063041 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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