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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) W4 s, Z0 c, |1 L) _- \) Z#include <linux/init.h>
. }/ H, d5 g& `7 o. i#include <linux/module.h>
% ]# b0 v- n6 ^+ x: ^+ Z7 n#include <linux/kernel.h>$ N3 B% S. }2 {$ l- }
#include <linux/types.h>
3 G+ k+ L) Q; W1 h#include <linux/gpio.h>* E7 Y/ N: ~% n; F9 z# `. U
#include <linux/leds.h>; C* z6 J& q6 t% I9 ^
#include <linux/platform_device.h>
8 c; R2 u* b4 {6 y/ W" A& Y, X5 y0 ]6 \+ F
#include <asm/mach-types.h>; f+ [3 o- U" R* U
#include <asm/mach/arch.h>
6 N) K/ B9 J5 v6 d#include <mach/da8xx.h>/ g1 k3 ]! A' i
#include <mach/mux.h>. \( i8 ^! r% [! j6 n, P# Y. E1 o
; F  f; S' v' X  D( S9 q
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 s& b% H4 z) g
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
+ q* L7 H2 I4 c8 M. ~' M+ e/ }#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 r( n( s, b: a& R& Y#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 y" J/ J& c6 U- Y* J, x  a* o

' E/ ~3 H4 [6 p0 _! {% F1 U/* assign the tl som board LED-GPIOs*/
3 m8 P- O/ I# D9 t4 tstatic const short da850_evm_tl_user_led_pins[] = {# _- K0 `! A0 I  C8 O
        /* These pins are definition at <mach/mux.h> file */& t3 m& {( d/ ^7 m. P1 P9 S/ f$ {
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. \, |; e: K# [" M        -1
# ]1 B2 e5 W' o/ \' t' f9 B; i};
2 L! J' j5 V1 c4 C) U
& q; Y8 \# P  [# k3 j% {9 c2 @static struct gpio_led da850_evm_tl_leds[] = {
6 B& i' t9 U0 R( c1 s* G        {
3 H9 P! e( d9 A' o                .active_low = 0,( w9 |0 y- {  S' I# s& u2 A3 |8 ?
                .gpio = DA850_USER_LED0,
5 \  \3 t6 b! \# }                .name = "user_led0",
' Y. \7 ]" e! [# M4 J                .default_trigger = "default-on",. Z+ M: m5 L2 {* d2 T
        },
" J0 X2 O7 Z4 I* N        {! R7 _! N3 b6 e+ m2 A
                .active_low = 0,0 j: I+ Y# f/ D/ u! d+ F
                .gpio = DA850_USER_LED1,8 |" T& v) K7 P6 o5 I$ A
                .name = "user_led1",
: z, J' a1 j" r' O2 B7 T( ?: b" P                .default_trigger = "default-on",
8 Z" O* U. K# T9 S" R5 J4 {" F' S        },
; V- p6 f& R$ h' u" B        {: V+ T+ M% c5 |, P
                .active_low = 0,1 k. e: n" L: w- E3 G1 S1 q
                .gpio = DA850_USER_LED2,
- T8 x  B0 T- }0 c4 I                .name = "user_led2",
( r% i3 O  l1 c' A! j( k                .default_trigger = "default-on",3 ~, b7 f3 {; b- I
        },/ X9 Z  U1 a/ r* D% D
        {4 M. f& ?9 L7 N# Z
                .active_low = 0,1 d1 b/ O- Y, o; n  F0 Q* G- f7 p4 X
                .gpio = DA850_USER_LED3,- G% v: j' m2 n$ m( V; g
                .name = "user_led3",# j7 s! s2 W( K1 l6 n9 Y7 K
                .default_trigger = "default-on",+ u' Y' ?* i' s: e/ m
        },
( o2 U8 g6 A, T. _* Y/ S! p: Z2 q% Q( @};
8 v3 G! \0 t2 Y. t
  B+ g( D& j. W1 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 c, q  V6 r! D) V7 M5 k        .leds = da850_evm_tl_leds,, s( m0 l! s$ ~$ g+ I2 Q0 P2 S1 E
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% k( q+ M, B  i' n' {
};
( |% Q: s4 }5 f
% [& E8 K5 x2 y, d/ Ustatic void led_dev_release(struct device *dev)" S  b& N# C* j
{9 Y: o8 W" ]: ^" u* {* x
};
, v; n7 K' `+ }' y) t
9 \3 Z6 O: Q" Ostatic struct platform_device da850_evm_tl_leds_device = {
+ j7 T/ n) b/ g; ]( o$ L        .name                = "leds-gpio",$ d% e$ y: N; t4 [8 u9 e
        .id                = 1,5 D. b* m8 |; h( s2 ~
        .dev = {
- X4 V" s6 b2 w' r3 ~8 u. }# H                .platform_data = &da850_evm_tl_leds_pdata,
$ L0 S! j! W. }, q                .release = led_dev_release,
+ ]" A6 w9 x: g        }
1 k0 H" S0 y' K( ?};" [# b& w8 ^$ D! d

5 W4 s4 D1 c0 ystatic int __init led_platform_init(void)
6 C5 T6 r: y" [. `{1 r% k% |7 V) I" K3 r
        int ret;- k0 G- a/ [  x" b( I
#if 0
. b7 {# o6 Y( g8 u6 W8 U. d$ @& n        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 |7 r3 ^* z: C6 X- T  Q$ i+ \        if (ret)
- w$ s% D2 j, A2 w" w5 q                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' c& g3 i; G3 @6 o                                "%d\n", ret);& _, y/ Q; f& t/ e" L5 L- y) j4 l
#endif' y& X  w" j( s7 I$ g
        ret = platform_device_register(&da850_evm_tl_leds_device);
1 [5 K; \( g  W0 P! u# j1 j        if (ret)0 g0 Z- R& }6 o9 Z& Q- c! |
                pr_warning("Could not register som GPIO expander LEDS");
) r1 |) j! ~0 F1 I7 ?        else5 S8 L, [: a; m( e9 k- Q
                printk(KERN_INFO "LED register sucessful!\n");7 s% u- Q  V6 p( Q$ X0 _

+ e  B  s  ]. z$ ]& U6 T        return ret;2 y& m) A) ]# Y* u- N3 i
}! r' d/ M; p, i3 w, N# q1 V/ w
( v3 F  E; c$ t1 d
static void __exit led_platform_exit(void)
1 G3 w# r7 ]- t; a# b3 d{
0 e5 p( E1 c" u3 ^2 E9 z        platform_device_unregister(&da850_evm_tl_leds_device);; }9 A2 k) j2 C7 I! r; `

8 S; r3 A5 R1 L& R! I% n0 u& b" D        printk(KERN_INFO "LED unregister!\n");0 x! u3 E. T0 a( Q( s
}# x! o& s) m$ Z+ e8 l

7 l# Y( i0 D) \! z$ ^: s' Q% vmodule_init(led_platform_init);
4 i. ]) @( C/ ^) R, W7 v% y9 ~module_exit(led_platform_exit);
" t5 N- d( q: Y/ U9 C, O, ~* A; A$ R" I' L% l
MODULE_DESCRIPTION("Led platform driver");
/ i, J6 Y3 X* O& x1 r3 ?9 y3 S0 iMODULE_AUTHOR("Tronlong");4 i6 y8 `* Y1 c) ?
MODULE_LICENSE("GPL");
4 t# N" S, |$ c- D  Y* H
7 d4 s  L* K6 u- ?& W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-29 05:41 , Processed in 0.037607 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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