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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: h5 N( O# f& L, K( v#include <linux/init.h>) C7 K! T1 Q+ x& }
#include <linux/module.h>, r5 Z+ B- T9 l+ F
#include <linux/kernel.h>) [& B# m+ q" z
#include <linux/types.h>( y# d1 `$ i. `* x
#include <linux/gpio.h>/ ^1 i# u. z" O5 J  q4 c  f+ \
#include <linux/leds.h>
: P3 F6 j+ o' w; p3 R0 O. t+ K#include <linux/platform_device.h>& G9 B3 [& m  B/ T4 }- ~7 ~# R
1 t; y  R5 S$ U. y$ I
#include <asm/mach-types.h>& x9 z% x% j; a/ O3 U5 [9 e2 [9 l" e
#include <asm/mach/arch.h>
1 e" ~) x$ t9 F5 e#include <mach/da8xx.h>
+ L" }3 j$ {" i% c4 C0 I#include <mach/mux.h>" W0 s0 U2 l8 X9 @' ^

; i1 q6 P: b8 w/ {9 C/ p* Q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), S* H+ d4 G+ `/ j
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; b3 Q) T: w2 N4 O) S: k#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 S: g3 g* ]) _$ B& ~
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 e+ f( y3 M- V5 j  w) E: D
- o% ]4 b# `3 ^
/* assign the tl som board LED-GPIOs*/6 j+ q1 z# G. U
static const short da850_evm_tl_user_led_pins[] = {/ T% r3 S# ]' f& ]( J9 i. n  L
        /* These pins are definition at <mach/mux.h> file */. d1 r+ R4 v* p3 R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 o0 \) c! n, i' Q        -1! q, x  M) @. P# r' o! V
};
7 A4 S! B" E* Q2 o# D8 r# ^. ~; }* n" Z% f+ O8 w
static struct gpio_led da850_evm_tl_leds[] = {# O! R5 U) }8 G- S- i$ W: s4 ]! y
        {
# B5 o7 `7 D; Z' F& R1 P                .active_low = 0,
! R- _- w$ F3 B2 I) X8 d                .gpio = DA850_USER_LED0,
  e% x% ]8 A# b                .name = "user_led0",# d) E  x5 s, z
                .default_trigger = "default-on"," h1 B  A0 _6 b1 E  t' A. a4 V
        },4 e) U0 A+ j( l4 W7 G1 n% E
        {5 M0 a6 u' `8 w; f. n7 z" z+ s1 a
                .active_low = 0,; i& y4 ?5 b. [
                .gpio = DA850_USER_LED1,
/ U6 `/ m! `' L9 j% f/ M                .name = "user_led1",4 n8 ~2 R8 P* |
                .default_trigger = "default-on",8 `0 }6 b" M! u2 v6 q7 P
        },
) M, k  H/ n0 z        {* x! J, h8 G6 J) X; m- d
                .active_low = 0,
0 o7 |6 h( c' g                .gpio = DA850_USER_LED2,
8 T( l- A) ]3 j1 e7 V                .name = "user_led2",
6 M/ T3 _: |8 P5 ?( K/ x6 w                .default_trigger = "default-on",
+ R1 N2 H; X1 |        },
& T1 `$ J/ h4 a8 j; K' s        {
! Z) D" i; E& c1 s$ `                .active_low = 0,
  S! w8 b0 q5 Z! j& C. f5 ~                .gpio = DA850_USER_LED3,
+ A+ ~" _4 s) j' ^                .name = "user_led3",
4 Z" ^* q  j! s* A. J. |2 g                .default_trigger = "default-on",3 t/ E4 n3 J/ W2 E
        },2 }" d" J% I" P/ N2 P& V
};
- v/ H8 F) C3 _2 H  f- y
# y" H4 G! A( s  K5 I  V' Z$ f/ B# o6 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ ?2 X/ H, k/ ]& ~1 f        .leds = da850_evm_tl_leds,. j. L6 Q" E) y3 U; @
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% J0 U" u$ b8 |+ l* M8 w7 B};+ u$ D; a$ Y3 P8 I; B  @
" y4 W# F* |# B! O& A4 C
static void led_dev_release(struct device *dev)
1 w( z1 A" G' @{
! E* b: \' `# W6 _3 t* g* s};
6 S& V: ]2 @9 r3 w8 N0 A, @; q3 I5 V% Z
static struct platform_device da850_evm_tl_leds_device = {9 v- B% y3 ~1 O6 t  R3 E- A) ]
        .name                = "leds-gpio",0 |7 u/ P: b; v" U7 X1 @7 ], g
        .id                = 1,
/ }9 {- L4 T' ^% \3 x6 _        .dev = {
5 f: w; Z( `6 P0 m                .platform_data = &da850_evm_tl_leds_pdata,) F# h+ e1 E, y( [! [  x2 E
                .release = led_dev_release,3 N$ Y+ ?4 E) J& q7 n( O& R
        }9 y9 w6 S1 c* ~5 @
};
  X' m' n1 d- m7 Y; n: Z( a( L& K$ ]( U$ r4 e
static int __init led_platform_init(void)- |* @) ~% L: j: I
{
$ `& H9 Q- b" _9 E3 S        int ret;
% d5 }3 t) d$ B2 B0 f7 |- e4 L" Y#if 0: F, b% o! }5 t* D" ~
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 y. K% I$ m  K! X
        if (ret)
# M9 l( K6 M5 @' X                pr_warning("da850_evm_tl_leds_init : User LED mux failed :". p; \9 R/ N& r6 w( E8 t9 f
                                "%d\n", ret);
6 q4 ?  U) ]1 [) F#endif
$ b, m9 a. T7 F2 {        ret = platform_device_register(&da850_evm_tl_leds_device);% ?& c( C! s7 p/ G& z$ `
        if (ret)
2 E; o6 l6 E- k2 \$ G- ]5 K                pr_warning("Could not register som GPIO expander LEDS");7 L6 O5 \$ G; q* v
        else: U% f: {& D2 }9 w2 E
                printk(KERN_INFO "LED register sucessful!\n");
2 F* [9 O7 ^6 ]( b
% p- o: r8 x8 O/ Y- g$ q        return ret;$ x# E1 {1 s  E( |  M( n
}
" T9 u" Y2 g7 L
+ @$ n6 x, ]+ i# e# P3 m7 astatic void __exit led_platform_exit(void)0 H. f/ z+ M, F( B" \
{
; T' W4 p1 s8 G- p& a4 w& V! a6 O  R        platform_device_unregister(&da850_evm_tl_leds_device);3 d5 Q9 @6 }; a
6 R' m1 t4 ]( K: Y
        printk(KERN_INFO "LED unregister!\n");
* x3 |' O3 j3 m0 A}3 y0 g  T) D% m( b

' M: Z7 T  y7 c6 S. i4 _; {8 Umodule_init(led_platform_init);
" F) R( y/ K3 m0 t) dmodule_exit(led_platform_exit);3 R( Q( ^( b9 q& G+ S5 L; d2 i# K0 j

8 P: e. Y6 S  Z' BMODULE_DESCRIPTION("Led platform driver");; P/ o2 G  u. L$ C( T1 Y, C
MODULE_AUTHOR("Tronlong");
3 {; a2 A' e3 _* qMODULE_LICENSE("GPL");" Y/ w' w, q! M
% S; C9 z/ w: \. u; ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-14 00:29 , Processed in 0.039430 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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