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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  o) O6 ]1 u6 p* l% K; n
#include <linux/init.h>
1 O% r+ L2 U+ M5 j#include <linux/module.h>
( |- d9 D6 p/ H3 B- _#include <linux/kernel.h>6 {; A- V( c, @
#include <linux/types.h>
2 O; y* x9 y+ v3 w* J: g; A#include <linux/gpio.h>3 K% ~$ `0 ~8 Z  M+ h9 Q
#include <linux/leds.h>  k5 k, }7 K* K7 D5 W! i
#include <linux/platform_device.h>
$ U0 `5 o) e  O% [$ V( W
7 `" r. |4 _( K7 q/ z& _#include <asm/mach-types.h>
; \# W" O) L2 ?6 \6 B; x#include <asm/mach/arch.h>. M. _$ x* r. \" w* |# H
#include <mach/da8xx.h>+ b  @) f: d6 ~5 Q# y
#include <mach/mux.h># _. T) G! B" |( w0 I/ G  ?

% H% h$ X5 c6 O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; b) i3 p5 |* |, j0 i' G#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)* d! z0 x6 w: U9 ~; O
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 ?" l% J$ E  f
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); \2 }& f9 W( L' D, M) O& `4 E
) `- [! a5 n# `
/* assign the tl som board LED-GPIOs*/
' f9 f4 O4 l1 J+ `static const short da850_evm_tl_user_led_pins[] = {
0 S9 o2 ~  |! K8 O0 j9 l3 A3 u  D8 }        /* These pins are definition at <mach/mux.h> file */
6 F" a( B+ K' s# X: r        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& w# L3 |* g$ F* y8 w1 U
        -1
  t% n, S$ R- `- \( ~: ^};
6 j/ @0 ?# j2 f  s4 a
0 Z2 f& ^8 [, V7 [, Qstatic struct gpio_led da850_evm_tl_leds[] = {8 P% k0 k& I, J  c4 y, B* i
        {& ~( R% o3 S7 l: c
                .active_low = 0,- U* X6 [# L: @" k# n
                .gpio = DA850_USER_LED0,
2 {2 w0 w8 W3 N- ~                .name = "user_led0",/ ~+ T9 g8 X7 j- ]) t2 h4 D
                .default_trigger = "default-on",: q& i3 i  D' |9 t' |* S% i8 S3 h
        },
2 E( s0 ?) \1 Z        {
* C1 q4 Q& v  q7 c# n$ j5 G                .active_low = 0,' J! f) C1 A6 f" @2 N# s0 t
                .gpio = DA850_USER_LED1,
* h9 w6 [/ \0 J3 }& ]: [2 v                .name = "user_led1",1 P$ Q8 c5 u2 S: A
                .default_trigger = "default-on",
# D! I5 |% s5 \8 I% Z        },; y- A4 T8 V3 H! h7 @1 t. b4 ?+ f
        {% w7 A! h2 g0 Y# N  P
                .active_low = 0,9 o4 b1 p" \! v" g% u8 y
                .gpio = DA850_USER_LED2,
* `7 ?8 P9 K7 q+ y                .name = "user_led2",
1 p4 J; }) J+ a8 F( F                .default_trigger = "default-on",- ]1 n0 ]2 L& A
        },5 _' J- G9 f5 ?$ x$ x; B
        {
) E% {- l# T, l) p3 J# |                .active_low = 0,
' h5 S) \6 m' L8 s1 b                .gpio = DA850_USER_LED3,7 i: ^  B% `5 |+ G
                .name = "user_led3",
. X9 A4 W7 X1 C3 K3 R                .default_trigger = "default-on"," w' o* ~8 c" T
        },
8 D, L( i, ^0 U# K+ N; s! H7 ^};$ Y$ T8 ?/ Q* i
) L/ b3 }; {% h: Z. u% F: D9 D% k+ E1 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( q, D8 u& Y4 ~4 E
        .leds = da850_evm_tl_leds,1 h% D$ w1 D) @# V6 Z+ c4 f
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 w8 W+ g& o8 b" v7 o" u8 R  u% \5 q
};
6 o- q2 V7 D3 c/ ~0 n; Q8 O* `6 m1 U. j) ^3 r( V0 C( W. a
static void led_dev_release(struct device *dev)
. e9 k0 }! Y" p( k) a9 Z- Y8 ?, V  a{
/ F2 e) z( }7 o2 p! F$ S};! U" s# J- b& s5 R" ?
0 V2 `7 n+ P( a( u4 p6 g
static struct platform_device da850_evm_tl_leds_device = {
! w3 Y9 Z! u4 K; Z6 V) f# T8 J$ P$ N        .name                = "leds-gpio",2 R5 c8 P: f* \4 x
        .id                = 1,& x3 T3 f0 ?3 b( b5 Q
        .dev = {2 b* V# J* ^+ x% R* R0 p4 W; s
                .platform_data = &da850_evm_tl_leds_pdata,
2 `8 v' J0 Z, I! K5 x                .release = led_dev_release,' f; \6 S& a4 a! @0 n
        }
: L# r5 t( `! I8 z  n( a1 I( z};
2 o: s  P0 ^2 ^! @  L
7 l# L) ?2 o& Qstatic int __init led_platform_init(void); ~) p& ^$ k, D0 U$ C( b+ \
{
2 Z. S5 B) S9 s3 h: T        int ret;; U2 x8 X: B4 B9 T* \+ ^- S/ D% ]+ M- S. V
#if 0$ V2 ]2 O0 m5 T0 w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 R' w! Z' a. g7 t! C6 d( S; z        if (ret)+ W  G+ E4 p& D7 b3 e# n
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% M$ w9 L( D. U1 C2 m
                                "%d\n", ret);
+ y/ i; d7 ~4 x' S#endif9 A0 Y& r( I. F9 W3 f
        ret = platform_device_register(&da850_evm_tl_leds_device);  z& t. P# e0 O6 `& K/ r
        if (ret). m4 I" i$ g) T% b3 p( D1 E- _. q
                pr_warning("Could not register som GPIO expander LEDS");
% P$ ^4 c- Z% a( B; ?- Q0 r        else
- ?  ]$ P/ D) d$ a0 Y$ N# ~) h6 X9 R                printk(KERN_INFO "LED register sucessful!\n");6 H8 j+ e% p8 u6 n0 n& G
# Y  ~/ P. P  ?2 W+ ]
        return ret;
- u! l* S9 g7 h+ |}4 r3 i% B" I# S! V* ^
# N* r4 I0 C; y8 R, \6 X
static void __exit led_platform_exit(void)
' G( p9 e9 }8 G: _" l: j# {{4 W; |& m6 h1 w7 \7 d/ |
        platform_device_unregister(&da850_evm_tl_leds_device);" {6 f! X6 `% T% @/ H4 d

% k! @) t* I1 v: [! f/ i        printk(KERN_INFO "LED unregister!\n");
  v1 p0 I: p4 ?0 _0 C4 I/ n7 k}
  m; H6 U1 B$ V4 c! A" G4 f1 a, Y/ [2 p9 d! |9 X" F( f: v8 c
module_init(led_platform_init);7 n2 r3 k8 W3 }/ v% Y
module_exit(led_platform_exit);
! {( R: A6 K7 I5 v0 ^* \' l, Z- q* H& |1 B# p
MODULE_DESCRIPTION("Led platform driver");! X! x' n! y. {; O( f
MODULE_AUTHOR("Tronlong");0 S# U+ |( S. \2 `4 G3 }) E+ `$ u
MODULE_LICENSE("GPL");
, u# L& Y7 X: P$ o, m8 _7 l1 D1 k4 o: l$ _8 }0 t7 t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-23 07:38 , Processed in 0.039724 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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