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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ @( [; Q) G2 A  [/ I2 m1 W#include <linux/init.h>
# e. T' e6 ?, g" P3 e6 D#include <linux/module.h>
4 J$ m% N  i/ P1 |#include <linux/kernel.h>
2 h( L. t. m) V" k/ ?5 r" p9 o#include <linux/types.h>. Q3 J% l3 Q" b; Y# g1 y9 l
#include <linux/gpio.h>" T8 f% k" J) G/ i
#include <linux/leds.h>7 {1 C( t; b3 _6 i/ J
#include <linux/platform_device.h>
" b2 ^' E1 d! V1 k9 k9 b, Z
9 L: a2 A( |6 ?9 c1 g#include <asm/mach-types.h>
! Y/ G* ^/ f7 E#include <asm/mach/arch.h>  E6 x8 C& m3 M7 K* _" l# X
#include <mach/da8xx.h>% X. S3 x0 I  I6 i' j2 e) a
#include <mach/mux.h>5 i! G; |+ M0 _9 z& \6 K
5 L/ g) e2 `% S  b* a; P9 L) }
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 M* i( G  b7 r# L
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
+ D7 S! B/ E4 \) a4 N#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% W  K6 p" x1 o* K/ s# ^#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
) A8 |- ~' u6 l( E9 }+ K1 i! F. x4 [6 ?9 q: p
/* assign the tl som board LED-GPIOs*/
9 F7 |, z: D" g  zstatic const short da850_evm_tl_user_led_pins[] = {) p: R5 U: }$ ?6 u" U& Q
        /* These pins are definition at <mach/mux.h> file */
5 U2 V0 c  }# F0 ^) i+ p1 @  P5 ~        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 R# y3 o4 S8 s' V9 u- p0 f8 ^& b- }        -1; t- K- v  ]& r3 M0 r; |
};( i5 B/ V! V% f* x4 W+ h

* X( F" D# [3 o* u4 C" S8 bstatic struct gpio_led da850_evm_tl_leds[] = {
/ [- [! a+ V3 P$ v        {
. V0 Q! T+ g1 y  O) x                .active_low = 0,
: o: D- [5 Z, z4 i6 U/ k                .gpio = DA850_USER_LED0,
% y, n3 V  {. a' s4 e; c                .name = "user_led0",
1 l  s, c+ i% Q( P                .default_trigger = "default-on",& o' u! v0 K1 A$ a$ i" Q
        },
3 \4 _8 J' m6 @- ?1 c# P0 c        {# T$ q* a" l9 ^# g
                .active_low = 0,% j- L+ I8 X8 }6 c! D2 l
                .gpio = DA850_USER_LED1,/ C% b; `" \1 n6 g7 x9 J% U
                .name = "user_led1",
7 I0 p7 {8 A6 B  p                .default_trigger = "default-on",
& b9 F5 Y; r) Z( W9 f: u' n* f        },
6 Z9 G6 N. k  v7 o3 w/ x        {
" j8 K$ E/ J* L5 b, s+ s" k                .active_low = 0,5 B7 |, z$ m5 q/ s+ F: D
                .gpio = DA850_USER_LED2,+ s0 |- W4 v" u& d0 R/ t0 z, V
                .name = "user_led2",7 K) @. ~0 l5 a1 C1 @& e
                .default_trigger = "default-on",
% Z' h$ C4 j9 O2 F& N' C        },
& x( M! o9 V4 q        {
" F( C8 e: Q: n- Y' k                .active_low = 0,7 x3 Z/ O, j# D  a
                .gpio = DA850_USER_LED3,
" m7 |! i/ D* k                .name = "user_led3",
% b8 @6 k4 p& d1 D% ^4 c1 Z                .default_trigger = "default-on",1 ~6 j9 ]: {5 T8 l1 v) L9 }& u" j+ Y
        },* ?9 Q2 d7 U; _
};( b& ?8 H4 T* @- B  D" ^" c
; ^; F# b! w" Q, Y- M; R0 }/ H1 C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! x, v/ [5 v+ [7 J0 S        .leds = da850_evm_tl_leds,0 V6 O+ R" ~! i( Y% K6 e
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 v# C, @/ J4 I- X7 D0 m6 R
};
6 q4 V$ v3 ^7 Y" [  z  Z6 S; U1 C# u  z5 ~9 I
static void led_dev_release(struct device *dev)8 c0 p3 c+ z* w3 K) M: O
{$ @$ W% c8 i3 {, P0 p
};
- ~+ \9 ~1 l$ c1 j( [, ^' d
- F8 \) x1 l! c% ]static struct platform_device da850_evm_tl_leds_device = {
( f; G5 M* t5 |        .name                = "leds-gpio",
) N$ I+ d; s* B% x5 \- q        .id                = 1,
& @0 S' Y1 G6 ^3 k- i% G' ~        .dev = {
  n9 h8 G4 u8 S) s% G( ^! _% W                .platform_data = &da850_evm_tl_leds_pdata,* C& g. c- c& l( ^6 Q9 T) R
                .release = led_dev_release,2 w8 a7 [7 `+ g+ R8 G) o
        }5 f  q5 ?3 Y$ L+ D0 y8 p! N3 o
};
- P: N2 r; J+ @7 K$ S( c$ F3 d, ]4 S! `
static int __init led_platform_init(void)
9 L/ `1 D+ _# K{
! B6 O% B! R( ]: \+ R        int ret;
. g8 z2 X: a! r7 d#if 0
! t+ ?1 t3 i* Y( P( a- S: w        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 u$ x& C2 T% J/ @7 S# \9 u
        if (ret)) s, q* f0 q4 d. B, {2 S; }
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :". k) Q- Z& }( s8 d
                                "%d\n", ret);
7 i+ Z( T; f6 W) V  p4 p0 q#endif. U0 k$ O( B( S- W
        ret = platform_device_register(&da850_evm_tl_leds_device);
" o. H% s' ]; Q3 s- k        if (ret)! A% I' K) Z% \* r1 T/ K4 P
                pr_warning("Could not register som GPIO expander LEDS");
3 m" G4 U$ x* s" l, r        else; L; l9 o8 o% C% }
                printk(KERN_INFO "LED register sucessful!\n");
4 ^9 r6 l: b" Y, @& j
' B" r4 n6 O4 b, d7 d        return ret;
4 G. D' i1 x% x. ]8 ~}8 ?$ [1 f" O) I

" a# C  u! z/ D. ?, zstatic void __exit led_platform_exit(void)
( ^' ^& J7 C6 H+ e. M/ r. w) R{
& Q, @! ^- W' p! t7 p        platform_device_unregister(&da850_evm_tl_leds_device);; S( J5 Q3 X1 p' t; ^$ `
, G7 k& ]/ k4 V$ m
        printk(KERN_INFO "LED unregister!\n");
* B$ z, M8 q. @/ }( G8 ?}
; c9 j4 }+ Z' h: D( D# P! Y. N! m6 \2 y8 s" w1 u; `9 R
module_init(led_platform_init);
, d7 H7 q: U" t& U$ A4 P$ [, F$ e3 Amodule_exit(led_platform_exit);
5 x7 M. B# ~/ [2 s/ A; h
( e9 O; ~  i1 m; TMODULE_DESCRIPTION("Led platform driver");
7 [  ^4 f- ]7 ^0 d% z) @& MMODULE_AUTHOR("Tronlong");4 p6 r7 t/ W0 n7 T3 i9 b
MODULE_LICENSE("GPL");
8 S) _, J; R" W/ }
7 R: ~1 @) F+ S; x1 N2 T1 P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-23 23:07 , Processed in 0.038585 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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