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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。0 k6 J4 K( F% @+ G  e7 F9 p  r
#include <linux/init.h>
( L; @4 f# W. @3 \8 v#include <linux/module.h>& ^5 q6 k9 b( `: Y5 v
#include <linux/kernel.h>3 @3 B5 ]4 [! [0 R4 ], S" W; m: ?
#include <linux/types.h>2 A# X6 u% U" p1 W5 z  [; L
#include <linux/gpio.h>
0 p2 s" h8 p& r. }" |2 @' M#include <linux/leds.h>
5 E8 O( l* a6 I#include <linux/platform_device.h>7 M5 B% I+ c( |7 X) Z" a
, }# Z6 u8 P/ @1 d9 h
#include <asm/mach-types.h>
8 ?  J1 R8 j) T# ]1 m#include <asm/mach/arch.h>
2 V. M' Y, r: u9 h9 b3 n#include <mach/da8xx.h>
& y; ~* u9 X* }5 @* Q; Q' k0 P#include <mach/mux.h>
7 b2 Z# V: L" b9 r* s1 I' c3 ]: p. v3 p9 {6 w6 @! n
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ X1 g! f) }& Q5 x1 Q) X#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
8 q6 P3 {4 t% y6 `- H$ q6 f7 x#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): ^' ]! r) s* ]) F: }) J% r
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ @2 z" i+ W7 p5 V$ J% s! Y
- Q$ z6 k, m# w' s4 J: J7 Y/* assign the tl som board LED-GPIOs*/6 Y3 f# A* ~/ X- P
static const short da850_evm_tl_user_led_pins[] = {' ]( @- X$ z5 T& j2 J& h
        /* These pins are definition at <mach/mux.h> file */
: T9 ?  O+ ^4 q& V2 {- e+ `        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 K  f; _- j' s3 q: ?        -1
) t5 P+ w6 o1 r! c- n# L};
4 k2 D: A2 Q  E- Y! V1 [& O: q( q) \, h# d0 y0 h- J
static struct gpio_led da850_evm_tl_leds[] = {
5 i. P$ ]  V, l1 r) P7 p        {" ~) C0 x9 c9 @3 G1 F+ ]& X1 W
                .active_low = 0,
) [( ~, i3 R, I$ _6 }5 t                .gpio = DA850_USER_LED0,% z6 ]! E% C( r' P6 \9 Y
                .name = "user_led0",
2 c  Q) x# R" Z( u  h, c0 I* y                .default_trigger = "default-on",& J8 N9 v$ I3 v; r
        },
; S5 A, L1 e/ u! W2 V5 k8 N        {, V6 X! G: G5 j( z1 A
                .active_low = 0,
: _; N5 G6 }  s/ Z                .gpio = DA850_USER_LED1,
6 }: R+ `: A8 [9 k8 b                .name = "user_led1",
6 g* c4 Z- }$ l& L- a# U                .default_trigger = "default-on",
& H$ Q9 s9 \0 [% l+ ?+ ]& z        },/ M  p9 w; d" ~% |* P+ ]
        {3 I0 n4 G: ?) p: Z6 I
                .active_low = 0,
$ `$ N$ R  R1 H8 l# |& G2 h                .gpio = DA850_USER_LED2,* k8 m5 j. }& |1 |
                .name = "user_led2",3 ^- i7 a. j7 W2 X+ w( p) G
                .default_trigger = "default-on",
# {; a2 i+ c0 n* q* k: f        },5 V$ a8 c6 [7 ^
        {
! F# Q9 R* e4 `% M# ^! K, k                .active_low = 0,
( g( K0 C. o  B$ d: J9 G                .gpio = DA850_USER_LED3,0 o+ o4 s2 Q! Z
                .name = "user_led3",
# S  L" N! K$ S. Q8 E9 [: {                .default_trigger = "default-on",. |, w5 u/ V1 k2 _( F% P
        },
$ @# x; Y' V) u$ c& H};
  p* I, H. _5 Z/ @+ ^& Z$ K
0 R1 ?7 B: K% }2 _- \/ zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 @& _7 ^5 N% ?' k
        .leds = da850_evm_tl_leds,0 G$ S9 ?) \8 o  s+ U; Y7 K- I1 D
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; y4 {( N9 ^& p5 x0 @' ~; W
};
3 p& d! i1 Q3 t) u2 u, V( g0 \8 Y3 M- O5 L" E: z9 }
static void led_dev_release(struct device *dev)
4 o. m1 t  R& x! O# W{' ?7 A$ p2 Y4 p8 X; |4 b- H
};: y. a* K4 O9 `# R
7 ~7 D. J/ G$ Z+ v7 k& `) Y
static struct platform_device da850_evm_tl_leds_device = {
4 T7 a- J4 k$ f6 ^4 S+ r& Q        .name                = "leds-gpio",5 o$ R8 ?! z% B1 k
        .id                = 1,
6 ^: l, t% \" T2 K* X& l        .dev = {
$ C- y( C* }6 t( g$ Z                .platform_data = &da850_evm_tl_leds_pdata,- J+ |) _6 Y+ H! F0 O' X
                .release = led_dev_release," d$ \8 J, I& G5 A0 m; h
        }
6 I) k! t8 Z  n  S. f};
) s4 v! W! a" C5 q, A/ ]& T+ r5 l4 U
static int __init led_platform_init(void)
6 o# h) g/ ?4 f: `1 ]6 F' A" H{0 `- g$ F. u3 b3 p0 G* J
        int ret;7 g% [+ h0 j/ z6 n) E
#if 01 o$ N6 B7 d. x3 Q9 d9 I% k( I
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- q% \( O) n7 j6 ?$ Y
        if (ret)
% \3 b- a. B- b4 E) D( f; K                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# f+ t% S0 @  A( A2 n! X                                "%d\n", ret);: B; z4 X, x8 c
#endif* f* P, ]& d3 g( x9 ^% u" U
        ret = platform_device_register(&da850_evm_tl_leds_device);) P: m9 Y! o' u  l6 a
        if (ret)
, f( n7 s. L( f5 L, q: h* j                pr_warning("Could not register som GPIO expander LEDS");
& W# b% M: S7 b9 n6 i  Q- W        else1 r( u: d/ Q" P8 @8 i, u
                printk(KERN_INFO "LED register sucessful!\n");# g5 ?, f6 G# T

  s( s& Z; z$ w9 Z$ \, a( ^        return ret;
2 V* ~' p. S+ X/ r% M! _0 g; b}4 K. r  ]# K, n* M% W

' S3 u) {* m; J3 C+ ]; B$ pstatic void __exit led_platform_exit(void)
5 K8 b) j: b" x3 u0 i. d3 a{
4 O, [" ]0 N5 J( d        platform_device_unregister(&da850_evm_tl_leds_device);8 a+ a! L: p% w" b% M
& [% J- P9 m* T! \4 V( p$ M. R& F
        printk(KERN_INFO "LED unregister!\n");
" c$ \9 T7 x8 k) g0 a& N; c}- k$ B+ ~5 f" T7 V/ r  I

* ?7 I' n3 t( u9 T9 ymodule_init(led_platform_init);
! ?9 z* E$ z0 ~6 ]/ t/ Smodule_exit(led_platform_exit);0 R8 B  A1 F! a4 ^- F% h, ~; ]8 H
% p7 I2 i* v  {! ?) ~
MODULE_DESCRIPTION("Led platform driver");: F$ n' ^. p2 [
MODULE_AUTHOR("Tronlong");: ]& Z& z/ s* _1 D
MODULE_LICENSE("GPL");- t+ G* e+ e: E
. K: ^( S* H1 K9 h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-17 02:42 , Processed in 0.047597 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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