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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。3 t2 H2 v. @. w2 d. S3 D; {: y
#include <linux/init.h>' Q7 d3 y+ Z) E
#include <linux/module.h>
$ s' H  Y' a4 a3 s" Q#include <linux/kernel.h>, }+ {* h8 B4 w! m) V
#include <linux/types.h>. N# V5 C. l# s4 c' D
#include <linux/gpio.h>( P. Q* e/ |; V0 E% e5 k: E
#include <linux/leds.h>$ @% z2 D( C# ?4 N& a5 b/ r
#include <linux/platform_device.h>
* b: Z# V2 Z0 y: O, h
3 I2 ]/ D( E& F! [4 G: [9 q#include <asm/mach-types.h>2 ]; x2 k% a, Z3 M/ \
#include <asm/mach/arch.h>, O; R; j+ g9 l2 u
#include <mach/da8xx.h>
7 p6 S9 H, a) z! L#include <mach/mux.h>$ }" Z9 k6 T- Q% M4 Z. b+ B9 I" {- d

' C& W' S6 P: A6 }! t& D; {+ i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
4 y3 q) f0 k$ Q3 l9 U5 {0 j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 s! o+ u# R7 f5 l
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): Z* s, |( u# Y  ^( U
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& O  ?7 Z/ D5 X
' @( O: Z: E- h# \! g+ h# O
/* assign the tl som board LED-GPIOs*/% O: _4 s( ^- [1 z6 W0 i  N: U2 U
static const short da850_evm_tl_user_led_pins[] = {9 d4 f! {+ ]4 p* ]/ Z* n2 H* ]
        /* These pins are definition at <mach/mux.h> file */
5 L2 M6 `, I% R6 j6 f        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 \4 B9 l+ D/ m/ O/ V
        -1
( |* r+ x# V( I/ [+ z) S% e+ N};
" d  L' g& r. O& O
6 p- e1 |/ ~$ D, Mstatic struct gpio_led da850_evm_tl_leds[] = {  f9 I) U9 X8 r7 m7 q8 {7 @8 I
        {- E- o: n: |3 F4 g$ v
                .active_low = 0,
0 e3 W" p! `- l                .gpio = DA850_USER_LED0,
( d# y% k* G. a5 d0 s5 ~                .name = "user_led0",: s/ D/ L; L' g
                .default_trigger = "default-on",
( t  S1 m+ ]- M& e% E4 p        },6 I  P0 I1 T' g: q' V7 j: R6 Y  u
        {
( P7 b1 s& M2 f! I* G9 m# G" }* \                .active_low = 0,
  `% z$ L) a( y7 {2 {7 j  m7 t                .gpio = DA850_USER_LED1,) f& R/ j2 G$ b; }7 W/ C
                .name = "user_led1",. n0 y3 j8 {" q/ _: j
                .default_trigger = "default-on",
% T0 }* X# b" @        },1 Y, Q! i6 N: v9 Y# p: B
        {3 d, i+ ~* x% b6 ~- f! E, E
                .active_low = 0,
- K, M* s* a! m/ V: Q9 v) C                .gpio = DA850_USER_LED2,
5 y1 X  o: V8 F5 O8 _                .name = "user_led2",1 H* u  }) e$ i" s  Z% I
                .default_trigger = "default-on",
- `1 s: z7 O$ T9 o- f7 e6 n( z% T: R8 }        },0 N9 i; I$ A% D* c
        {
6 B7 A* ?9 h: S. ]) R) J                .active_low = 0,
- h2 c" F# ^' e. }! d# J% Q                .gpio = DA850_USER_LED3,
  T& `( w1 O9 b' j) `. ~                .name = "user_led3",: C. E: d  d% d  X
                .default_trigger = "default-on",  R0 f5 L1 A  ]" [0 j
        },
0 [* z% F( p0 D$ \& u* y6 U3 U};
& a# O3 W9 f" N6 P( ?0 g
, ]3 O  U" n% \5 J" d$ p% bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; j* o7 M6 ?& ~, @- U, ^' ]        .leds = da850_evm_tl_leds,$ ]6 v% G* M6 ?; o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: C; o. M4 {8 q& y
};$ c9 |* d% K; s) ]( k

9 Y3 V) x9 A9 O4 x/ ~static void led_dev_release(struct device *dev)! z2 @4 e' i4 r0 B
{
+ V  \, i: m% M9 h: X4 `};
9 S! X" {2 [% C5 @$ q; y) ~
+ [  k3 ]. ~3 ?4 N  n4 A; @static struct platform_device da850_evm_tl_leds_device = {1 ]* D% m6 s' w% Z# Z
        .name                = "leds-gpio",/ O* d# s. z8 x( w  e
        .id                = 1," D$ _6 P% ~  I" y# h
        .dev = {
! r4 {" ?" d9 z; i7 m, q                .platform_data = &da850_evm_tl_leds_pdata,
/ o% w3 ?& \) x7 Z( w) ~$ K                .release = led_dev_release,
/ [4 [2 F1 c8 p) V& X) g        }
* e% {% z1 A& A& \9 j& ^' B! ?};
& {* M5 d9 `& ]$ X4 n5 l; t5 f# d1 t3 A7 y2 Y" R
static int __init led_platform_init(void)
# j- ?) e' c# E% i+ g& t{
; W4 y. {. s7 J1 T0 r        int ret;
3 F5 A% n9 K8 @4 I#if 00 |4 I9 B. u8 t/ |
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 d% O0 N9 ?! h( K+ D) J) {6 Z. Z
        if (ret)9 f5 A5 B3 }$ i4 I' c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 d: l$ ^( z8 n+ u# I, L  z
                                "%d\n", ret);9 a0 c2 _8 r  O' a. K
#endif, P- E" ^; _" E  [; b
        ret = platform_device_register(&da850_evm_tl_leds_device);
* w7 V% a! {0 ^8 O! ^        if (ret)* y& k7 b& w8 x; ^
                pr_warning("Could not register som GPIO expander LEDS");' k1 L0 }, ^& t; {1 C
        else' m) Y! Q! V5 m8 r" G* u5 h2 }6 o
                printk(KERN_INFO "LED register sucessful!\n");9 r0 t5 R( n# T/ Z; H( ?. V3 Q( o
+ T  E8 x3 |+ w+ g, b5 `
        return ret;
$ |: d4 c, {* y. n0 p- j}
( `, S0 R* R4 A" j5 q* f3 c* W0 r
/ I: n: q+ t7 ]+ R. ~2 j0 jstatic void __exit led_platform_exit(void)
0 n* E" n0 K/ y6 v{1 L+ m8 V- _" m" e6 A. ~. y
        platform_device_unregister(&da850_evm_tl_leds_device);% D! d2 M0 N8 G; W1 S4 Y
+ w: X0 T* e: P/ _4 w1 r- P# O- S
        printk(KERN_INFO "LED unregister!\n");
1 m# K% c7 X- C$ i! Q}
) ]- K, {9 }/ h
4 z7 U6 i* s0 v' z6 R9 e. @- Zmodule_init(led_platform_init);
" K9 @4 |. i/ Q8 N3 L. ?; rmodule_exit(led_platform_exit);
: P/ n2 ~' U3 s, m* j* Y8 S# `* C: P/ K; _0 Z0 f- T
MODULE_DESCRIPTION("Led platform driver");. b, B3 A8 z( S- t" T7 a7 w
MODULE_AUTHOR("Tronlong");
8 `7 g6 d& y- s2 U5 W7 I3 TMODULE_LICENSE("GPL");! }$ [$ M6 ^3 a
" K# _' s  J) i# k# r1 {0 s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-31 09:20 , Processed in 0.052604 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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