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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 Y; S# s7 m8 K5 P0 y#include <linux/init.h># r6 r1 h; m+ i: ]
#include <linux/module.h>' h) r! R( Z# R# t8 _- P& e$ n
#include <linux/kernel.h>' U% G! z5 ]1 N$ l8 u$ j/ R3 T9 ?
#include <linux/types.h>) h+ ~' t) @" U" V5 {
#include <linux/gpio.h>  b/ c5 _8 H2 r7 z! h& l
#include <linux/leds.h>
" ?/ K* n* S, K" c% q#include <linux/platform_device.h>
+ B7 E7 ^  o: O6 w$ Q3 X  D, B
4 q) _. N! O9 D1 I2 M% ^#include <asm/mach-types.h>
5 t  N7 d7 {& E9 y3 P9 \/ z# q#include <asm/mach/arch.h>5 z7 E: Z( N4 g2 \
#include <mach/da8xx.h>
) ?  w4 w. D- y9 Y( K2 i) H#include <mach/mux.h>3 C  I- }2 `' J, U; }( g
6 T. }% Y1 ]( Y3 |: c
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 D6 o- J, n3 F# _6 b#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 e/ f7 C4 E) _6 l#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" M- {. p$ ^4 u#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) X  f/ t8 J7 W- Q% F. o: `! \

) S3 \( H1 G. c/* assign the tl som board LED-GPIOs*/) A4 l# V% _  J$ Y* Y, w
static const short da850_evm_tl_user_led_pins[] = {4 w8 h7 q5 q& a2 R
        /* These pins are definition at <mach/mux.h> file */
3 @) }% `. N. @  @5 F# O        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% w! o! a6 O, p        -11 {/ j! s' a8 B% D
};- W) g/ R% w) w5 Z

, b  R7 m( v5 _$ Sstatic struct gpio_led da850_evm_tl_leds[] = {: i9 M9 q! a% A/ c+ X! d6 G
        {
* m5 A* Q  z4 K, i3 w+ ~                .active_low = 0,
/ M  z* W0 S3 W9 ?" F7 s                .gpio = DA850_USER_LED0,
3 L" Z9 U% ?( i/ x, Z, H+ R6 ^                .name = "user_led0",) p5 I( U# R/ i4 m
                .default_trigger = "default-on",
! |. D4 M  F) \2 v        },
( L1 N3 h; r7 H7 Y2 B        {0 f* V4 i! O+ x5 G
                .active_low = 0,
$ ?* b+ f8 F2 e+ N) g                .gpio = DA850_USER_LED1,4 e; ?/ t! i; V+ r7 Q
                .name = "user_led1",
3 n6 h' y& i: z8 q  g                .default_trigger = "default-on",/ N+ x* _, ~+ C) I
        },
5 w2 }- x, u/ d9 J& E* O* U1 _        {
2 d0 B7 [9 `; u! c  _( I) G/ B                .active_low = 0,
' s. u+ b+ L, O7 ]( q3 {                .gpio = DA850_USER_LED2,
5 r/ U; F: G' Y! L1 S, {                .name = "user_led2",
# G% h* Z0 s; O- r                .default_trigger = "default-on",  \0 J+ l$ @1 T( P
        },
7 y# g8 Q# k( k: t0 c0 H        {+ g& ~- K% D3 p  |8 t& t  @
                .active_low = 0,* s3 J, k% N. x# G. |
                .gpio = DA850_USER_LED3,1 i0 ^' ^: G; o6 B9 B( z  j) {
                .name = "user_led3",
" t2 V0 _1 B, j, k( F- p( Z                .default_trigger = "default-on",
9 [! ]% n& h; h! @; X        },* ?& k' W: M# a, p: [
};
% Y& ^* M& v, Y4 R7 J5 R- v- P( D- ~+ l% Y5 D8 y% g% v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& r+ g# H8 r3 j
        .leds = da850_evm_tl_leds,
& [- k9 P  K3 u" z+ ^$ M' Y4 E        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& l  z' z7 X) c; W
};
! S- B/ y0 k5 ~( b/ G
; L) i2 F3 }4 ~, B6 ostatic void led_dev_release(struct device *dev)
9 L" }. u$ t1 X' e. |9 Z{
* H7 a  U; L; @6 ~};
5 l3 @6 Z* y3 X" Z, c; O5 d0 _/ Q/ v+ g2 q' U
static struct platform_device da850_evm_tl_leds_device = {
) [7 A1 [- g6 g9 q        .name                = "leds-gpio",- \2 s1 a2 c. K  c4 ]4 `% B9 |: H
        .id                = 1,
# k5 w6 X, f: X8 g  E* w' I$ p        .dev = {
2 S9 o0 G: ?) F$ Z                .platform_data = &da850_evm_tl_leds_pdata,
1 F+ D5 N, j3 D4 x* A* G7 J                .release = led_dev_release,: z# {5 u( j. N6 `
        }
! W4 R, O1 `) ^' [+ b/ @% [; a};
! P3 F: H. s3 h1 s( k( p
  x3 ~0 a/ z; e0 H' }: Xstatic int __init led_platform_init(void)
% z$ J  m8 R8 E{/ @5 Y+ Q6 W8 i4 W; l2 B7 h
        int ret;* o" r5 C" \) y" M9 `: ~% `6 p
#if 0; W0 X4 n0 E0 r
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 f' F6 ?2 Z8 _# c6 h        if (ret)
3 Q. c3 |. q  R5 e2 n! H9 K0 K3 Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% _7 ^- ?  t, F3 h' u7 C/ m; Y
                                "%d\n", ret);0 E  l8 d# @+ H7 S. y
#endif
' S* y# u1 e6 \        ret = platform_device_register(&da850_evm_tl_leds_device);
* X  p. x& D, K7 i1 w+ B        if (ret)3 {1 }$ F# I& z4 R
                pr_warning("Could not register som GPIO expander LEDS");% Y2 x& h% `* \# {; `) t: W
        else
- N2 h7 |4 E- p  D4 ~( f3 W# @$ r/ U/ T                printk(KERN_INFO "LED register sucessful!\n");
0 v  a3 \' Y8 T+ s- W4 Z
8 X( x9 u$ H$ o: m2 k# J# b% S2 ~        return ret;
9 `4 h1 _# J3 I7 A9 l  ^}4 A! R$ ]4 }' P' @0 I% m
9 Z6 J& R( m9 I+ }
static void __exit led_platform_exit(void). M! A! L; X2 t' a( O2 ^
{& M7 z$ ~- W' S& P0 g" e
        platform_device_unregister(&da850_evm_tl_leds_device);
% E" Q6 X5 l/ W, a8 h- ]9 f( f* o$ V9 z' N! t2 u( ^
        printk(KERN_INFO "LED unregister!\n");! F0 f) m% Y9 M" @9 m$ ]
}1 D  M1 J# ?3 T1 `0 |6 x/ t9 c

" ]) u' s* D  C" V7 }module_init(led_platform_init);
) K3 n. |- S( {module_exit(led_platform_exit);
9 z- Y4 ^$ m& n, z" U
: @* G' E" o5 Q- H5 xMODULE_DESCRIPTION("Led platform driver");' V6 D. J+ Q4 J8 N
MODULE_AUTHOR("Tronlong");" ~, I  g% c  s4 D
MODULE_LICENSE("GPL");
+ Y% s. F; ~+ W* f5 r: u) h2 t1 v+ a- e% x8 g
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-20 04:50 , Processed in 0.044770 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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