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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( H1 D8 c& i" N
#include <linux/init.h>
7 @1 J/ U9 H6 T# v8 ^- u#include <linux/module.h>/ j- P& u' v! m1 |1 i  }0 K
#include <linux/kernel.h>0 {1 A9 ?) u9 W# y! W7 J9 I: Y
#include <linux/types.h>$ [( r: C9 q+ c: ?3 v3 L- W( Z. t
#include <linux/gpio.h>
2 O: ~0 U' h0 @8 U" o#include <linux/leds.h>
2 @( {  q. T3 k3 L5 s* T#include <linux/platform_device.h>
5 f, E/ d9 Q- {3 F6 K. k5 |, Q% x- X: f# z
#include <asm/mach-types.h>
0 @0 k7 o: O$ D#include <asm/mach/arch.h>5 `8 q$ r" q+ k/ ?
#include <mach/da8xx.h>
3 i/ C; U; a* ?  J; J$ ?1 r#include <mach/mux.h>  w+ S6 F: b4 z" x4 y# C5 R5 R) n

5 s# W' D% T3 o7 Q" }4 t+ a  a" a& c#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 p) I$ t9 Y/ e: B" u#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 Y6 d2 d& |4 G6 ~' d' M3 _( H3 |9 t: ?
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& l; t' l+ ]: a# k* J  g! F
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ B) O0 t/ G+ u( \! e) m9 _( S7 l: l+ z& H/ G3 U% g% Q1 X
/* assign the tl som board LED-GPIOs*/- Y- K% Q( Z4 \" o! U
static const short da850_evm_tl_user_led_pins[] = {
# W/ X; C3 x* M: m        /* These pins are definition at <mach/mux.h> file */  Y3 S" T+ u. f) S
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, S# h  B- m# t2 E        -19 r; v+ b* F/ I, x% Z* W
};
, X( P# @3 U& Y! z
/ c; Z7 R4 Q0 o3 g: pstatic struct gpio_led da850_evm_tl_leds[] = {# M: X$ Q8 a/ m/ ^2 R9 E
        {
4 {; K9 Y$ C: Y9 Z4 v9 i                .active_low = 0,/ {- a7 [, o. C7 G' G; u8 z, u
                .gpio = DA850_USER_LED0,  w" o; J4 u3 u& w, p3 B% Y. t
                .name = "user_led0",+ L1 y  G( X5 N! R
                .default_trigger = "default-on",
- l% f2 t4 l2 t6 R' g; m! d6 K        },
( w8 Z( a( R8 r4 c+ L8 E        {
+ U+ l4 o  j5 U, I                .active_low = 0,
3 q  E: H- L, _; |) E) b                .gpio = DA850_USER_LED1,
) ?6 r" q/ _& G5 Y                .name = "user_led1"," D4 z0 m' [7 c) |$ U
                .default_trigger = "default-on",
7 Q$ v/ G* m1 q        },
  Y8 B/ I: l1 f4 e, z        {
( t% T$ ]% i9 g9 U; j( m                .active_low = 0,- _$ A- Y$ q, T& m/ _& S$ _1 |7 d
                .gpio = DA850_USER_LED2,
2 e2 ?' t* w' Q$ q- u  k5 N                .name = "user_led2",* d( b/ L& C3 j/ d
                .default_trigger = "default-on",
3 s2 @/ K; k6 s2 n        },
  Q0 J$ j5 T6 v/ M! u4 H# g        {
; H* @. I7 i' @$ ]+ W7 `+ {                .active_low = 0,
) a( g  w# h' ]( S                .gpio = DA850_USER_LED3,
# [; f. V; l9 R! v% a7 C6 E                .name = "user_led3",% ]& `, q+ R: t5 T! |0 G* M3 D# G
                .default_trigger = "default-on",- ^! \% Q, W: i1 H/ [9 ~. t
        },' G- I# g3 s8 [, c
};
' E& ?) c: \# B" ^- n& _& n9 u
& {$ Q1 D- O( @# n. t, G$ X8 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ T) F$ [- H6 a5 `$ u        .leds = da850_evm_tl_leds,7 B, y$ r( t* J; x, w
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! y8 M! }% S' F1 [( I3 [9 U0 k};7 u: \9 A, [4 G* q+ X
" |4 n3 O6 U3 u( X
static void led_dev_release(struct device *dev)
6 ]8 R0 m1 n2 ?$ v3 B! D' s% V{- k7 I( Q2 F$ p% \; X
};
$ [6 B/ {1 @  X+ U  X4 [2 {0 @  s/ q2 z" p6 k% f2 ~" c0 R
static struct platform_device da850_evm_tl_leds_device = {4 |3 }. i- \( l2 D8 l2 C& A
        .name                = "leds-gpio",
/ p) Y/ E" y' U: }- h4 c  ^' Y        .id                = 1,- w# e! K. L( V6 C0 _
        .dev = {$ Z9 \( s2 v6 J  P* E) \& @& a
                .platform_data = &da850_evm_tl_leds_pdata,0 b% |4 z% z0 Z' u1 M
                .release = led_dev_release,' b4 C6 S6 U4 D( O
        }
6 F1 h' |9 y4 s8 X( v};
) g) U+ V% E# N
. Q; H+ A# N( G  f; D: gstatic int __init led_platform_init(void)  `, @6 o: o# ^" X- ]# e
{
% {! u0 _2 _3 o* x8 `% `6 N: {        int ret;# S: n% i6 Y* A, H2 j8 f7 g% P
#if 0
2 P1 P' y8 c1 I8 O! ^& s        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; [/ v7 m' X! `) Z+ N6 b        if (ret)7 D) \; y6 i! J. E8 K: q% m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( |1 |+ O- w$ H; Y  A, f6 F
                                "%d\n", ret);- c% U5 V+ i! x# u4 G4 ~3 T1 d- u
#endif" J) `( \) U* o; M8 u
        ret = platform_device_register(&da850_evm_tl_leds_device);0 ^9 \9 Q0 j: _
        if (ret)
/ _2 ], X; z5 Y: Z4 A9 S8 @( J1 s                pr_warning("Could not register som GPIO expander LEDS");
. N( a2 E/ ~5 F; @        else
) E/ x5 H0 {) Y: p  O: u% Z1 z% C9 b$ ^                printk(KERN_INFO "LED register sucessful!\n");
2 e: j" F* C, c9 Q7 U9 s/ a4 U. e$ r
        return ret;4 `! C. P% f" r! j) {* r
}
7 S/ @: y2 P8 {: ^
- h; T* b* v, ^( ?# s7 H/ jstatic void __exit led_platform_exit(void)
) K/ F3 d1 g0 O: ?0 m8 c* d5 g{
8 }7 W2 Q5 d1 G5 j        platform_device_unregister(&da850_evm_tl_leds_device);3 V$ g" J9 K7 y, ^5 f: Z6 }' B

) D: i0 v2 Y/ i) b        printk(KERN_INFO "LED unregister!\n");
( T: I# j* [0 c  k) K. M}
9 t# Y) \5 Y8 o. c% Z0 h. \. A) ~# p, u
module_init(led_platform_init);( M4 I% |, ~* x& z, L% D% I0 u
module_exit(led_platform_exit);0 D/ u4 c; p. P2 G( l  |
7 F/ K+ g; w9 [, g) M7 A& E0 U
MODULE_DESCRIPTION("Led platform driver");
: y9 n  u! d4 SMODULE_AUTHOR("Tronlong");% u/ f4 h9 X; y( d' T' E- p
MODULE_LICENSE("GPL");" o: q0 c  u. `5 }0 G
5 {& K$ n- y" J* w8 e* u% L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-11 04:35 , Processed in 0.047436 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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