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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ v# b" I! u: F#include <linux/init.h>
$ V0 ]( g. n& s# a# q8 a% K' y#include <linux/module.h>5 |1 k/ |" o, X/ b& ^
#include <linux/kernel.h>
, U% e2 J9 g- m/ G' n#include <linux/types.h>* A9 F9 s1 p7 |% i7 v
#include <linux/gpio.h>: M9 T8 h; U+ |: p
#include <linux/leds.h>, L/ C" K/ U" K
#include <linux/platform_device.h>. }( s2 ]7 R  |

! C# }7 ~- B- O# z5 C#include <asm/mach-types.h>
$ q2 o- O5 `8 e7 L5 i#include <asm/mach/arch.h>
& l( r* i* _) y#include <mach/da8xx.h>
8 ~1 g# `1 j  [" O) S0 f1 m#include <mach/mux.h>! a! b+ e6 s: F8 \* I  _! a

2 k* P( l! O( g5 A8 |7 I#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 G+ R9 [  b! g* D/ y! }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) t# X. d4 a- B7 ~#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. m: h, d( s! Y. c) t  J9 F& ^#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 E0 g$ t7 L% k/ R# o( p- k

/ S  R* `$ X' L3 ]- b- {: A5 G1 I/* assign the tl som board LED-GPIOs*/; t# \; J, w& }% l( N& B2 U
static const short da850_evm_tl_user_led_pins[] = {
: A+ ]; p8 w- h0 O        /* These pins are definition at <mach/mux.h> file */2 G2 x* a( c5 ^3 A; o4 ]: `. O
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 ^% e" O  ^# V6 E5 F        -1
. p$ D* y* C6 Q+ H& b2 W& k- [};. k6 c3 o& H! _5 g. S: L
  M) K! B0 H. _4 N4 {
static struct gpio_led da850_evm_tl_leds[] = {
7 ^4 c& j3 K0 A7 ?& c$ V. j        {/ f5 L0 N3 f4 j4 R
                .active_low = 0,
& j% C6 K" D! H% z9 C                .gpio = DA850_USER_LED0,
# _: F3 A7 s5 D$ b$ G                .name = "user_led0",
$ l& H" x0 b! |# g                .default_trigger = "default-on",3 n/ |2 ^3 k6 @- }
        },) {8 b) L% c8 W) Z8 W
        {
9 H: K# J% }# z5 F: ^, t                .active_low = 0,& i$ \: ~/ W- `1 c6 m
                .gpio = DA850_USER_LED1,
* R4 B, E9 h* l  V4 ^3 _                .name = "user_led1",
) d+ g- u) B0 b                .default_trigger = "default-on",1 y, P' c/ c8 @$ u9 S* P
        },
# v& i+ A- l) _! t0 s. U        {2 @9 `5 D, K- |
                .active_low = 0,
, j7 g3 H9 [2 A# u1 z) c5 @                .gpio = DA850_USER_LED2,
% l) }' c2 x, u" F* A. [                .name = "user_led2",
7 c4 L/ x5 M' w0 i                .default_trigger = "default-on",, x) S: z+ Z% h# C) g
        },4 l1 [" }  ]9 @0 L+ b
        {$ b) C+ O$ {) ?$ {* u' b
                .active_low = 0,4 V- D' r" ]7 U7 c3 Y$ g" c* q+ b  K
                .gpio = DA850_USER_LED3,
4 F# S9 K0 ?( H/ u8 g) @$ i5 j                .name = "user_led3",# Y6 _" j* y5 ~, {4 s* r: _8 S
                .default_trigger = "default-on",
2 o. s+ h& i2 G        },% G( E8 B2 ^5 h" B; r
};* S) y8 R5 e6 ^8 S- G

' s" G: _0 u1 O: [  ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 X' C" n; C% c
        .leds = da850_evm_tl_leds,7 r# G7 c& x; X) Q" g
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 I+ x3 C7 c( \) T
};# \. q5 U- \) p, p) d! R; o3 ~

& V! m2 m  \& i$ I2 B- a& ^static void led_dev_release(struct device *dev)
9 [" r  k% \9 Y6 d) n{" `/ n* \! B9 }
};( G- ]/ l8 F4 `$ J, \! d) l' \. c

( l6 [' Z9 N( Kstatic struct platform_device da850_evm_tl_leds_device = {
5 q; i4 g" ?$ c8 H- T        .name                = "leds-gpio",1 A3 ^4 S6 _; Y* C
        .id                = 1,
- J% q5 j1 [6 d! `* ?  H        .dev = {
2 C- K2 T' T6 ]& _                .platform_data = &da850_evm_tl_leds_pdata,
0 ?- ^7 S; \2 W% X. V9 b: r                .release = led_dev_release,
0 I" w' M  A" Z& Z5 \        }
8 Q  W2 V# H& X& i};( c2 a; q7 u/ ^5 d; }: e
2 Z  X* Y6 E. I' p# `
static int __init led_platform_init(void)
0 a3 |9 C6 r3 V+ ~! G  i{
/ y+ Y& x- W* F/ x7 U        int ret;
/ Z1 G; G; T: S: N* L#if 0
. a! G  y. W7 J9 @        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ [% ^1 N! g9 I2 J( W/ K/ S, n7 M  S9 [        if (ret)8 b, t  u8 l2 ^8 p- j! z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 E0 D( Z( x0 f
                                "%d\n", ret);# U( r3 V$ i! R* p/ @9 z! _
#endif
6 I* e9 k' b1 a1 q. S7 k        ret = platform_device_register(&da850_evm_tl_leds_device);
6 W. M/ B5 L1 o& P/ n9 q        if (ret)" x1 O3 D3 a% ?* C! X5 E
                pr_warning("Could not register som GPIO expander LEDS");
" [, V2 V/ l9 S' K" r        else
' j) {7 d0 d' c! L0 A/ T2 x* A                printk(KERN_INFO "LED register sucessful!\n");
. E' b, g& h; u+ I- `% W
9 o! |$ n& X: k; _  F        return ret;
8 j2 H/ C  k- i% c  ~# v}  z9 z6 Y" ]7 M/ ~' z) ?, J, _( D2 l
+ A$ ~1 s5 N9 L! ?6 k4 R: R+ H/ |
static void __exit led_platform_exit(void)
8 W8 _' c: c# u' |9 B{* t. S6 z1 P9 I
        platform_device_unregister(&da850_evm_tl_leds_device);
4 f0 a- g$ Q- {: F8 q2 g5 d4 k9 T0 r. Y0 b, l$ p4 k
        printk(KERN_INFO "LED unregister!\n");
! n& U+ G$ \3 {' u2 s9 K}! g5 {  r# I' W( N: C/ x+ y

/ T" ]6 r4 E% ]# O" X: Fmodule_init(led_platform_init);2 M$ q3 M2 y3 h4 U! j
module_exit(led_platform_exit);
  ^1 [: z8 ^9 E1 {, E! e
. ~# p. `9 q9 F; \$ vMODULE_DESCRIPTION("Led platform driver");4 D) P( L( R& ~/ D& q
MODULE_AUTHOR("Tronlong");2 H+ H$ I% b1 S" J- o' ~0 L
MODULE_LICENSE("GPL");/ h2 |5 N/ X& T+ `: w: \% T

; I1 Z! X/ ]4 f' |7 {" c: j7 T/ X
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-11 13:27 , Processed in 0.037487 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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