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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( S+ ]$ F2 F% j+ u
#include <linux/init.h>
( j4 x. l) P% E1 t4 P5 q#include <linux/module.h>
5 L! x0 N& V- v) M8 U3 E4 L#include <linux/kernel.h># o: A$ F- @, W/ i! d: K1 o
#include <linux/types.h>. u* r, [( V/ m+ b  r
#include <linux/gpio.h>
' n4 S* L  i, ]: \#include <linux/leds.h>
, I7 }1 t, q. }, s#include <linux/platform_device.h>
' L- F+ V' G9 m8 P4 i0 M; r0 i* j  R* J, c
#include <asm/mach-types.h>9 L/ y( |, Q, L& H3 ?6 h
#include <asm/mach/arch.h>
3 c( F/ S7 ]* v6 @' L#include <mach/da8xx.h>  m& F- F/ E# L% i. l, k; M
#include <mach/mux.h>! P  T/ e% l' S, N

1 n" L. h% K% [4 v% n#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)( Z  F0 u) n  \7 t6 g1 @! R# M
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ F# S" t# f# B4 Y! {: j#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ J6 e+ h  i7 x1 }% g2 L
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
( G. @- \9 t; t. ]4 j$ ~' j& \% R% |: ]5 t$ b2 v& T: l) [
/* assign the tl som board LED-GPIOs*/% [9 c# O% Y0 O5 d) `( Q
static const short da850_evm_tl_user_led_pins[] = {. S* @3 G" ~2 x6 A# D: V
        /* These pins are definition at <mach/mux.h> file */9 T! K+ d8 |5 B9 O5 ]5 @
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' {' l2 t2 A' I* V3 Y8 J8 q
        -1
" t. g1 |. z9 X. s) v};
: F3 \, k. z4 N' _2 U0 Z* A: L& D1 N" K
static struct gpio_led da850_evm_tl_leds[] = {
7 ?  m: r, q$ ]9 }! b8 Y: z        {/ R- n' i4 v$ K* ?, k& t* ?6 `% R0 r
                .active_low = 0,! f  x; ]8 a: V: {
                .gpio = DA850_USER_LED0,: j7 v! X2 d3 }. {+ T6 W
                .name = "user_led0",. W1 S( K! [3 L9 E, i5 d5 I1 H
                .default_trigger = "default-on",
: q/ n, [2 o, [% z$ L  q        },
- k$ m! q1 A: A  H& ?        {
  S. S. z0 e2 j                .active_low = 0,
  K3 S# e2 @' C! @& C                .gpio = DA850_USER_LED1,
2 c- O% j4 q+ I. X2 Y/ W; a                .name = "user_led1",
  s5 N; E4 ~) E; P* z3 Z                .default_trigger = "default-on",
3 |  f$ j9 |3 M2 w9 W( C/ h2 _        },/ K& F; R1 I& F  O5 L
        {5 ]9 f, k3 \& H* C# F* f- j
                .active_low = 0,3 _) c& [! ~8 j  Z6 ?8 k
                .gpio = DA850_USER_LED2,
7 o- W) C4 b8 P9 b- F% Y                .name = "user_led2",/ w* `: M0 p3 W0 E: z) D, o
                .default_trigger = "default-on",- k# |5 S9 m" Q) J9 w) ~; @/ Q
        },' {8 G$ @6 L* A" t
        {- d( a$ D7 i! }- b0 m5 r
                .active_low = 0,
: n) X( x. a! j) S8 e                .gpio = DA850_USER_LED3,+ q8 \! l! _3 {1 ]* H/ z( O
                .name = "user_led3",
2 Q% r' X' F1 k0 {3 Y                .default_trigger = "default-on",
& [# l0 Q& g% C        },) R5 R8 P) v5 E( e
};
0 B5 g7 l# u, d/ ?) r8 O- w4 ~) b
, i2 M1 W: F4 L8 m; f* w2 nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 E0 j; T; v; [" [6 q        .leds = da850_evm_tl_leds,
3 t( l5 b2 u- ?6 h$ w& l" ]        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# `0 S/ V! N6 ^" E2 }) I
};7 M. u& r7 a; x" u) @0 Q5 N

# V( u" I, p, U- `2 }9 d3 pstatic void led_dev_release(struct device *dev)7 g7 |0 K7 H8 ~2 w; `$ L5 r+ F' ?
{$ z* O1 j# [# o+ f
};
6 e# R8 Z  y/ J% B- [; {! _. M; Z: t
static struct platform_device da850_evm_tl_leds_device = {
, Z% p8 l  o$ ~6 _' ?& C" d        .name                = "leds-gpio",( |, Z, D; R" |3 Y0 U7 }' m+ n5 A: j
        .id                = 1,1 U5 \& y$ F6 s0 A4 J" [7 H% y' G
        .dev = {7 K+ e3 n8 R4 A: Y& g& Z6 h' Q
                .platform_data = &da850_evm_tl_leds_pdata,
/ G+ c" C6 y) N1 \3 U                .release = led_dev_release,9 ~8 f; c) w, J2 ?: w2 y/ }9 O
        }4 C# V8 J5 T8 _( L+ Z! `" R* h  N2 x0 i
};
9 P. o  t$ M" G) K7 U$ _% O. r1 o. q7 r3 }; b! F! q
static int __init led_platform_init(void)( _0 G1 Q1 D* P. b% K
{
. R4 }% V: v' ~6 C3 h5 m) I4 B        int ret;
* W' E9 a$ m4 e# A#if 0+ }) a, A" T  q- ?$ J
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 N. y4 V6 p, s
        if (ret)
3 Z4 y. D" g1 e! i                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 q" j4 d8 C; E" ^6 S. c& ?
                                "%d\n", ret);0 X7 a; {; M6 V6 o: b
#endif% m8 Z# O+ _3 J$ }
        ret = platform_device_register(&da850_evm_tl_leds_device);; f( J: A1 s; k
        if (ret)* r( i/ F- H& G( A  X, v$ u
                pr_warning("Could not register som GPIO expander LEDS");
2 c+ w* X3 e- D0 w, ]        else
" J" S+ T* Z( B                printk(KERN_INFO "LED register sucessful!\n");
+ {6 ?9 P0 I: b! G: m+ |
+ w- V! q( i6 u7 E/ a( n5 @        return ret;) p& e6 u, {) V3 V4 z
}
' ^6 N9 P6 Q& A" ~/ _7 J4 y  u
8 R/ G/ j# _. nstatic void __exit led_platform_exit(void)
4 m" T, A6 P; c' H! d7 v{
2 M2 M  w1 p/ M        platform_device_unregister(&da850_evm_tl_leds_device);; S' U5 M! x: h' D9 L

4 Z8 i9 d7 |& j0 P        printk(KERN_INFO "LED unregister!\n");. D+ B7 W% p  x0 o& D% ~" T1 g
}
+ e$ w/ h* c6 M# t1 f. }" |! [5 g) M; \# D- Z- t
module_init(led_platform_init);. m. b& ]9 z! N  G, w
module_exit(led_platform_exit);% d1 y- o  I( Y4 k) l2 z; `3 p

8 E; o. b' M# `+ d1 c- d3 vMODULE_DESCRIPTION("Led platform driver");; z* d& s0 K/ T# j; \. S% G
MODULE_AUTHOR("Tronlong");3 P/ }  p( ^0 [' M$ k5 T
MODULE_LICENSE("GPL");
( J+ v5 W- h( y9 l0 ]( i% D9 V6 ]- J% g! W: x9 ~. A6 `# ^$ [; l
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-24 09:26 , Processed in 0.040408 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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