程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% S& p2 A& v( O4 H8 O: F; v
#include <linux/init.h>% R, b/ g" e0 P7 u& s; W& |2 C- I
#include <linux/module.h>
; \( ~+ e: O" C4 ?5 n#include <linux/kernel.h>
5 [) w5 R% e" u2 P) _#include <linux/types.h>" e0 s* k4 j6 X. a' j' g
#include <linux/gpio.h>
  F8 \# F, \' @5 j! x6 y: P1 q#include <linux/leds.h>
* |( t( J* y5 I, K- X( k#include <linux/platform_device.h>
' n8 B6 R$ Q) V8 W5 O5 e# v1 @
1 a% }6 d' M( _4 X8 V/ E8 V) c' T& q#include <asm/mach-types.h>
' i' q2 u8 Y' s( c& O) K#include <asm/mach/arch.h>* F/ ^1 D' j# u1 e1 M$ |! ], N
#include <mach/da8xx.h>& I( i5 k0 j# o, M
#include <mach/mux.h>' J" _+ E: w/ a+ |* Q3 f; j

3 Q4 [; P( X+ I6 q9 `3 K" @9 g1 L#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 [' O' b, |3 U. n#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) P' q3 x3 u! R0 V#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 J# l: v+ X0 Z6 E' i6 x
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 K6 w; \0 e8 [1 k3 Z; B- x6 z
# h2 L% K8 y  i* E6 M, u2 e: k1 Z/* assign the tl som board LED-GPIOs*/
8 D8 B- U# {! q8 bstatic const short da850_evm_tl_user_led_pins[] = {2 J0 v9 s: \; Q" s6 t% d
        /* These pins are definition at <mach/mux.h> file */
3 v" |% t4 t# B* U; \; H        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" g) u- c9 u- j4 k1 y  `. c        -10 t% _6 q6 o! S8 o% C2 P1 @
};
, \* Z5 C- a8 c/ f) _5 [  r& h' I; `
static struct gpio_led da850_evm_tl_leds[] = {5 z% I2 V* J# ]  |6 ]" \: I5 T
        {+ p& [6 O- g* \: C# P9 g' K
                .active_low = 0,8 i/ ^8 w+ P4 D; l( G* n8 f( ~
                .gpio = DA850_USER_LED0,5 W4 I; f4 }6 `, h( U
                .name = "user_led0",' e" D! l' |4 ?  T
                .default_trigger = "default-on",  l  J9 e& E5 _
        },
7 m$ Q+ I# b' E/ q& W+ o( _        {
; Y' f% A4 i: {! o: P0 {& b' K                .active_low = 0,
: P) z  w% @7 w) x, c5 A                .gpio = DA850_USER_LED1,, a4 R- m6 m1 l% [4 [
                .name = "user_led1",
4 s! t( P0 V# t; C' M                .default_trigger = "default-on",$ Q# y: D/ E9 i( `/ g* c
        },% M/ x- V" G7 a" u: _
        {
6 C' \* _6 x) g: a  n" s( g                .active_low = 0,
& |5 o5 |0 C: P, N1 |4 N  y                .gpio = DA850_USER_LED2,
3 W9 f0 l7 a! Q. F( {! P. Q0 s' Y                .name = "user_led2",) Y& w& c8 z% V& v; s: k
                .default_trigger = "default-on",. G9 O' _% m" l) G# ~
        },
4 J% k' r& c: |- I        {8 ?, f! `) A. f0 h9 E+ f
                .active_low = 0,+ ?$ T: p) n0 Z, {, }- h0 B
                .gpio = DA850_USER_LED3,0 V) d( o6 Y3 j# k' Y! e1 V
                .name = "user_led3",
. z0 E' j* ~4 J% H  @                .default_trigger = "default-on",
* b# K& l( n! I5 C' i  c        },
; O# a( k1 \" C" a};
+ A* r3 x. I" ?) A0 l4 [! F, s( W6 n* R4 {( J# ]& n6 N) r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 F6 G) ?. s) h9 |. H" Q" _# |) i
        .leds = da850_evm_tl_leds,
. e3 A0 V! S; T" }+ m% M        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 g  E) {" ?/ ~' v% O2 Y};
! k, \7 o& ?4 ?* H4 P3 V8 U3 ]9 C3 F+ P* L. U
static void led_dev_release(struct device *dev)
* G0 R3 k- _% u  ]5 }6 a{% e: B/ ?# l; Z$ M$ j8 B5 {
};# g) k- H, X3 M% }  D+ }

" y6 X/ f! R- f% Z, b% q- L$ b5 astatic struct platform_device da850_evm_tl_leds_device = {
9 Z2 t: \/ b, F, ?        .name                = "leds-gpio",
' e+ e& p5 {3 t0 J& c  G! o        .id                = 1,
/ q& Q6 W! c& s" f* N- ~        .dev = {6 k6 p! H* K% x. Q! p
                .platform_data = &da850_evm_tl_leds_pdata,7 K: U8 r8 u0 I) g0 a, f
                .release = led_dev_release,- w' O5 d5 S# V; h- K
        }/ `7 A+ R! P' h/ C9 [' `
};- r/ ?( \6 a# K2 Y1 w1 {

$ e- w+ z' B, X! ~. Jstatic int __init led_platform_init(void)8 o6 w0 L/ O: x
{! p1 R( j' t  X8 U* @% Z
        int ret;
9 ]3 m' X$ S, W4 ~1 ^; C#if 0' _+ I% I0 c* b! R' R* o
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ n2 c: `1 y3 P% T2 L        if (ret)) l8 A' O7 \1 ~2 I# ]! k6 g6 R# Q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" j: M" ^  x4 g
                                "%d\n", ret);/ V" r/ ^. _4 `/ D1 A, j
#endif
3 |8 J# y3 k# o: ~: a        ret = platform_device_register(&da850_evm_tl_leds_device);" T0 G, g) I  t2 H' E+ W2 s
        if (ret)
. I7 H7 B% y* `% [7 x5 _                pr_warning("Could not register som GPIO expander LEDS");8 `' ~  \3 I  b4 f( ^
        else1 W( a+ s1 j' E
                printk(KERN_INFO "LED register sucessful!\n");
! p5 A. h* M# E
' p# M4 L9 x0 d: X$ Z. C        return ret;
6 K2 ?' A" d, N0 ?% {  s}8 I* L, A0 _( ^

# \- n5 i- B' I3 y0 V' Wstatic void __exit led_platform_exit(void)
( g( A$ G5 }. a& u$ _7 o{( @& E9 @2 t# J. n- e' t
        platform_device_unregister(&da850_evm_tl_leds_device);6 f, b/ O. {9 B1 }! r7 p, Q" C' M
3 |4 Y5 [' R/ x  K
        printk(KERN_INFO "LED unregister!\n");
0 I3 c) N! Z% G1 ^}
# W; S8 p+ y& v* e9 U& H
0 r+ K$ ^$ \& M7 Qmodule_init(led_platform_init);
1 o2 r, c+ s/ jmodule_exit(led_platform_exit);8 N8 p, k4 e! c1 ?1 m& A, l
+ F; S# S. I8 `+ m# p* R/ P3 W
MODULE_DESCRIPTION("Led platform driver");8 k4 l* l9 Q+ Z/ n: p( f
MODULE_AUTHOR("Tronlong");
: H& d, y1 b& |/ }2 lMODULE_LICENSE("GPL");: G; x' m' ~: h2 L4 U
  e4 ]9 ^" J$ q& z# e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-11 06:23 , Processed in 0.039088 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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