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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  y+ \: e: p6 r5 N
#include <linux/init.h>. _7 }. b8 J. {3 D
#include <linux/module.h>
6 K3 Z/ }6 j# e) u6 b0 A+ w& t+ r; {#include <linux/kernel.h>% D5 A3 h+ d0 h
#include <linux/types.h>& F( Y  A1 `- |$ C0 B* o6 E. `0 _
#include <linux/gpio.h>' l( ?5 c% A& _
#include <linux/leds.h>
8 a) a7 v" `; S% }7 `, p6 q0 m#include <linux/platform_device.h>
/ o4 Z  Q6 t: ~2 v: s( |% Z
, y; s' Q6 T  D& T8 p$ u# ~#include <asm/mach-types.h>
( L: X2 `3 Q( X) a8 O) e#include <asm/mach/arch.h>
6 |1 @' q, J0 h6 z, I) N0 k+ v#include <mach/da8xx.h>
( d( L! ~1 u  m$ w#include <mach/mux.h>
: O1 m2 |' v3 x& y* o3 Q& C: z0 G" |- U
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ D) L3 P3 j+ A  E4 T( @" U& W
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 n3 m2 e2 O# i! K' W$ U3 H#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" Y9 d4 Q7 \$ A5 ^#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 N0 ]: a. D2 `9 c% y8 d0 ?$ z+ F7 }

' d+ i3 q9 T0 O3 G$ E! P) N/* assign the tl som board LED-GPIOs*/4 }2 H( {' O+ L) V( Y
static const short da850_evm_tl_user_led_pins[] = {. T+ s3 f: |' S- K2 ?
        /* These pins are definition at <mach/mux.h> file */$ _# b- {! {$ A1 X8 C  ]8 }: q
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ q& ]/ T' G; T, z+ K" t4 O
        -1  c1 p# r6 |: W, l
};
& t1 a2 c1 U  R6 ^; c
& t. }) X( D( l( `# |% Mstatic struct gpio_led da850_evm_tl_leds[] = {
8 q, Y/ I3 V% u6 e( c4 N        {
; J( b( m1 L( L2 ~7 O                .active_low = 0,
  ?' f1 F, f9 ?6 c5 l. E                .gpio = DA850_USER_LED0,
' ^) q+ w' ~9 q- ^. X7 l. S                .name = "user_led0",8 n1 B% v( D" i( N5 x
                .default_trigger = "default-on",) v( ]/ v% E9 p  i3 @' t
        },# \$ G/ C% w# G9 d0 t# n
        {6 I- M) T) }$ {, @
                .active_low = 0,
0 O' i! A7 g. _: u                .gpio = DA850_USER_LED1,
: t2 y, d, C( m                .name = "user_led1",
" |6 o0 P7 k( h7 {! f( A                .default_trigger = "default-on",6 t  V' Z* d$ ~# b1 O5 n
        },5 e. n. {3 J7 @% z# F3 J+ U
        {
8 _; j% [% `! a* ~                .active_low = 0,
7 v! H+ }2 [( u6 E- g" e                .gpio = DA850_USER_LED2,
) I$ E; `5 [7 G0 D                .name = "user_led2",0 V: r8 {# ^- f. I% A% K2 N6 C- c& |
                .default_trigger = "default-on",8 l, O' V, G" a8 c! L
        },
3 i! }. }  E# Q2 x) D        {
! l) M$ N/ u6 T9 ]                .active_low = 0,
% r4 U  z; e8 L  h                .gpio = DA850_USER_LED3,
) Q$ }6 |" Y, S" v                .name = "user_led3",
+ {8 S. j6 m: _* R+ r                .default_trigger = "default-on",
1 v( v$ E% ~' M+ u- p- v4 f        },
: J  q/ p% U1 U% ?+ L$ g};7 J$ Q' a- e6 F* h

4 J2 n/ x4 Q. [% |( m' Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( n$ W! L8 I9 }8 z6 _% @' k        .leds = da850_evm_tl_leds,
" |  V# U& n$ q9 |1 S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 y$ J- b8 J: }; K9 S};
9 V* G0 I5 A7 f6 ^* Z! S9 t! H; M
7 F! J8 f) R0 o: n! E9 k8 m: t! G$ cstatic void led_dev_release(struct device *dev)
* w* A3 ?: w( s" Q0 Z2 y+ @{
& p/ N) p) q+ @' p};
1 \3 D$ ~* V1 a( H$ X( A3 R9 [4 Z- J* s* ~
static struct platform_device da850_evm_tl_leds_device = {
: O) K- u* t" p        .name                = "leds-gpio",
! }# s+ i& q* R( t        .id                = 1,6 |. k8 e3 G, P# H+ c0 L, X4 L
        .dev = {
* g" {$ r& L" G' C! T7 y- Z0 p                .platform_data = &da850_evm_tl_leds_pdata,
0 E' ^8 i4 [; F* `  e) s- u                .release = led_dev_release,! ?# H( X4 z7 t. C: ?- s" T
        }# m2 H: W% G+ B
};
) I" R9 X# m, h( x5 C0 y% f" C6 R! M2 x. n0 ]4 U$ p
static int __init led_platform_init(void)7 M4 `7 j; p& f. z" G; i
{  Z$ E! |/ @& B4 y4 n# e( u
        int ret;# ?' g, p' D' \) Z! \( C  I* t0 I* J
#if 08 B6 F1 _5 [+ N" c+ ?& ~9 f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# b3 O; G6 @6 }- i0 A1 O* o; l
        if (ret)
# H# t( X- g% N( A0 r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& o0 |$ V! g8 p3 V
                                "%d\n", ret);
: o3 O& x+ v7 z, J8 _#endif
1 Q  y& l  c2 Y, ]! l5 J        ret = platform_device_register(&da850_evm_tl_leds_device);
0 B: d) k: A6 H0 E, ]        if (ret)
9 H5 [5 U8 n$ f, ~5 }) U# w                pr_warning("Could not register som GPIO expander LEDS");2 d) W1 h6 L* j( V* h, m
        else2 Y: p3 ]; y4 g2 ^: Y
                printk(KERN_INFO "LED register sucessful!\n");
3 r  _) R8 j& E( K* \6 @3 T; L0 c; ]. w
        return ret;
/ n* e  G8 y; C}
8 A' w; h/ L* B7 w& A) j9 d4 _8 \$ W  \' I2 l% K4 w2 \
static void __exit led_platform_exit(void)
2 w6 i: L2 l, I' M. x* l; B1 N* a{
% S2 f5 q# E, g" X        platform_device_unregister(&da850_evm_tl_leds_device);
& b0 N! j- P7 p% F2 V* p! C7 N! S
        printk(KERN_INFO "LED unregister!\n");. e8 u' j1 j9 F! q
}
0 l; O, {0 N' H/ Q) p( c  j( E; e/ g6 A+ M, {1 B8 Q, ~6 m
module_init(led_platform_init);  \3 ~0 h: Q/ r
module_exit(led_platform_exit);0 c9 F  `1 f' x$ N

4 [: g% a% Y. z4 \! S: i# s" xMODULE_DESCRIPTION("Led platform driver");/ u6 H% I+ C* {( _# D9 m. m
MODULE_AUTHOR("Tronlong");( X1 Z# d/ H! X9 v0 \
MODULE_LICENSE("GPL");% F. n: b& t% y- l3 ]5 w' V

1 |7 s$ o4 _. k0 G* C; s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-21 05:58 , Processed in 0.039696 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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