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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。0 |6 W  w8 i( L" x8 R
#include <linux/init.h>- Y, J; c* ~- Z3 w
#include <linux/module.h>
& V9 M7 V  V6 H( s9 o#include <linux/kernel.h>
' N. H/ B/ p& h+ v, r6 t#include <linux/types.h>: [2 B. D* L! x6 Z6 _- L5 {* I
#include <linux/gpio.h>% l) U, Q. Z! G! r2 }# ?( V# l0 Q
#include <linux/leds.h>
+ q' m7 x/ \2 M8 [4 V8 E#include <linux/platform_device.h>
# ]' L- v, A: [# A2 ]; M  v
3 c% Z, t+ ]6 `. K( [7 T#include <asm/mach-types.h>" p$ c+ f0 D/ r) E
#include <asm/mach/arch.h>' q% ~3 I* c$ R1 e
#include <mach/da8xx.h>
, o/ v, p2 [! w: c; U3 \+ |#include <mach/mux.h>
6 j" a" ?/ ~- k) }' ~& t  [% c9 T+ M, u, z6 P1 H6 S
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. l0 o5 i8 v. A- {+ ]+ ?#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 G' u4 @" ]2 R, l9 c0 y#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)0 I" a4 S9 H! G$ Q) f5 Y  O5 }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 k/ e  }* e& @7 G+ H+ b4 D; B0 r" L
/* assign the tl som board LED-GPIOs*/
$ |7 ~( x) T- s% A; Qstatic const short da850_evm_tl_user_led_pins[] = {
9 t$ H7 f5 {) c- [1 c& R" q        /* These pins are definition at <mach/mux.h> file */
! q, H+ O7 f: n$ j; ]        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& ]: \% l, x; R$ v% P        -1( R0 }1 j6 e& Y; P# g/ P
};# u" Q. k% t$ E
0 e7 ~( v. R$ q' Q5 I/ u) p2 Y/ m% `
static struct gpio_led da850_evm_tl_leds[] = {$ C  X: X8 ~. l- |, Z4 W* v6 P
        {
9 V, D' y% f, @% x                .active_low = 0,+ X  x0 k/ \& r3 d3 W# P3 ?
                .gpio = DA850_USER_LED0,6 H: G) J4 @/ N7 T  O
                .name = "user_led0",
3 w1 ~* |* a- d, `4 W! J                .default_trigger = "default-on",
; s0 s2 b7 ^/ K  W8 j9 s# \        },- |) o3 Z: e# s2 }( i( v* t$ \! K
        {3 U! Z2 r1 |1 c# ?
                .active_low = 0,
$ a# ?. ]8 r, u  s                .gpio = DA850_USER_LED1,
8 v7 x8 B) C  \9 J                .name = "user_led1",9 h% A+ S; f/ y% b$ W
                .default_trigger = "default-on",/ A8 w6 a; l8 S! z3 u5 B
        },. j4 R8 O8 d1 H) d1 j; V0 {/ `
        {
! S3 K1 s9 i& [9 K                .active_low = 0,
, X0 z4 h- X1 U& F) L. q                .gpio = DA850_USER_LED2,) D$ @2 j9 K! ?
                .name = "user_led2",' P% r5 g# g$ p( H& E6 b
                .default_trigger = "default-on",2 j$ v7 ^6 D) }
        },
7 v" l/ ?4 |. }" b. U        {
. R# @. z" S+ c4 o                .active_low = 0,( k/ G2 l) z) ]6 a/ v% b
                .gpio = DA850_USER_LED3,% [4 V1 Z* d: T2 p" }. i
                .name = "user_led3"," L  B' B6 `: g8 D0 ~/ y
                .default_trigger = "default-on",$ ^' V9 Z7 J7 y: |; c; @$ e7 b
        },
  \4 T* f# T5 v& ?: E' y};
+ ~" ]. o3 R) [
6 U! h1 e4 \1 z+ q3 K; istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 S/ h  G# x4 G( [/ ~        .leds = da850_evm_tl_leds,9 D$ r  z% p! W" E" K! T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 a/ ^$ F6 Z" _5 U};
9 i& B" L3 a: W1 m  t. d' u' G4 O; p1 s( w
static void led_dev_release(struct device *dev)+ E' u, f9 K9 B* w# M
{8 ]7 X' F' q$ k8 l+ W
};
9 J2 m+ `  ~0 a/ M, k! x# j8 H2 L0 f  n) s* i7 u1 s; {/ f
static struct platform_device da850_evm_tl_leds_device = {" S0 v# h  s1 A6 c# E1 E
        .name                = "leds-gpio",2 a: ]8 f& s. T
        .id                = 1,
1 m, X6 w- q) p( O& j& k3 c9 d        .dev = {8 M( P) Z" r$ y: O
                .platform_data = &da850_evm_tl_leds_pdata,
5 C1 d% A; P. N- r                .release = led_dev_release,- C5 j) _3 G6 Q. ~
        }0 q- m7 m1 f8 V8 p7 [
};
: c* \( b% v4 d$ n+ y" Y* u8 C% V. U% [2 a0 i
static int __init led_platform_init(void)& i; A9 I3 b1 A, |4 v% }
{
5 A* r# D+ Y8 g! i. s        int ret;# w$ w: ?6 X6 t2 X5 z  V& s' W
#if 0: b2 n7 y, w+ }; n1 S& m
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 i; z# D2 s: J3 w! G' {. _$ k        if (ret)
! b# ^4 i9 e! |) y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 ?# j6 g8 ~9 p* d                                "%d\n", ret);% L* t! M* t. v0 V1 m1 D6 _7 ^4 I
#endif
2 L( n  j& S" n; _4 k5 K# q1 T        ret = platform_device_register(&da850_evm_tl_leds_device);
; N2 A; x. e5 L/ }        if (ret)& i$ r0 [" l$ z( X! g7 J
                pr_warning("Could not register som GPIO expander LEDS");2 Z% x" |# e3 f
        else
. v. C( U, F2 j5 X( X0 r* M                printk(KERN_INFO "LED register sucessful!\n");
4 O5 L& D2 g& z4 ?2 H+ x( ?# L# s0 T* V  S& Y
        return ret;
, i1 X/ K% K( \: R3 B  R7 e) @% I}
7 {' i( t( z" |! T7 E; R
6 u8 P" R1 x& ]( Sstatic void __exit led_platform_exit(void)
! Y3 f4 V7 u3 g, G{
3 \+ }( s3 Y# e* Z2 e        platform_device_unregister(&da850_evm_tl_leds_device);
$ |) u) ~  t6 ?& c* \8 u
1 a" b/ _) w* \7 `9 e        printk(KERN_INFO "LED unregister!\n");8 D5 X+ X6 I  p& L. {
}
7 u) p: F* O5 I# g$ `! S
( Q# C3 V/ w' R8 r9 S* Zmodule_init(led_platform_init);
6 e6 `) t5 Z! q$ Omodule_exit(led_platform_exit);0 l* @* ~- w/ r
4 f  c& {9 L! }& o# s( b5 R; @0 A
MODULE_DESCRIPTION("Led platform driver");
, h. q( i+ M; S) V  X  oMODULE_AUTHOR("Tronlong");3 W1 m, F4 O7 K1 n1 R2 H2 `
MODULE_LICENSE("GPL");$ |; D/ P4 M* p3 \/ \
% B& e! F2 J4 g. ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-6 17:19 , Processed in 0.039407 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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