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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 p: J: z5 X. b3 f  c  K#include <linux/init.h>
7 V0 `% r: ?6 g#include <linux/module.h>) \$ {: S8 K) Z/ @
#include <linux/kernel.h>% P( s+ Q! M. q# E8 m+ Y- {; y/ e' ~- o
#include <linux/types.h>: _1 S" C8 e! ~1 Z, J! n6 ~
#include <linux/gpio.h>
. G% w2 z2 \( k1 h% q#include <linux/leds.h>
2 }* k) z- b6 T0 ~4 F. K& M#include <linux/platform_device.h>/ D/ A7 H$ Z# g, U% N
9 G2 a$ [2 f2 }: n/ E
#include <asm/mach-types.h>: t# \- m. q$ `3 ]
#include <asm/mach/arch.h>
3 j* Z& w+ M0 Z1 p) J6 L( {#include <mach/da8xx.h>
% b& U3 s$ G+ r2 t3 [- B5 K; K#include <mach/mux.h>
/ e7 i- N" s0 v4 H* ~% \4 H5 i+ q+ u* x2 B, E* c$ \2 b/ W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, X4 f" ^5 P" v  j3 f' Y* E#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 ^9 ?) P3 e2 p* f1 @8 f8 b#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' D$ Y8 o4 a5 x9 r#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). G4 N  l3 o! O

; G% b7 ?8 O8 k5 S$ w- y/* assign the tl som board LED-GPIOs*/
# w' C, [) ?# x4 X: ^: C, Z: p( a. dstatic const short da850_evm_tl_user_led_pins[] = {5 v5 X# [$ l* q& s. ?+ G
        /* These pins are definition at <mach/mux.h> file */  W" F% J3 M1 m1 G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- s8 c; k& b. \9 J* o( v        -1
# w2 y( \# z% ]" Q4 Y% p};; m; V, L. W' U2 ?! R4 w. o( ~

1 C* `3 L& }6 K( M" f" |static struct gpio_led da850_evm_tl_leds[] = {1 |6 u( V( f& h& m
        {
3 L% ^& ~2 q) `) y0 \4 G                .active_low = 0,* X3 ^6 D, A# i3 U4 O9 p
                .gpio = DA850_USER_LED0,, v/ e4 @7 L: q5 P" U
                .name = "user_led0",5 [4 {( E( H( j) e0 F, F* ?6 z
                .default_trigger = "default-on",8 O- G0 o/ Z, b. E0 a. ]
        },* E1 N6 i% L, k& S" N4 H. a
        {
0 f+ H' A  y+ m. C* m" j" ]+ C( |                .active_low = 0,
; W% b5 C  M3 t, W' f/ c                .gpio = DA850_USER_LED1," Y# v7 `! O$ ?) f+ W
                .name = "user_led1",
, S& T' o, V4 t+ T; M" s                .default_trigger = "default-on",
: r8 U- t2 J& N8 `6 _3 B; k        },% M* [: F7 Y; N, O# [. Y  l4 l
        {% H) S6 f  [+ W' R1 ~& F
                .active_low = 0,
: ]2 ~5 h4 }) n                .gpio = DA850_USER_LED2,) ?4 D2 S( b3 p
                .name = "user_led2",' G* ^  z3 d9 [. o& j' {
                .default_trigger = "default-on",
) h5 N  [2 S& w6 C) ?        },( q5 C" q' a; \9 g9 @
        {2 ~' Y/ W# Y; R5 V5 R3 t( K
                .active_low = 0,
: L, H) n! B+ j$ H  V& q- h                .gpio = DA850_USER_LED3,1 n/ I, w6 ]( P. U% Z2 p& a
                .name = "user_led3",4 ]7 J' ]% T+ g" B5 K
                .default_trigger = "default-on",
7 \( O) O2 R7 S2 Z% q        },
9 ^  V$ N' ~" i  s! X0 e; m};
' `8 \2 G% K$ l7 s) G) p4 W* e4 |- ?/ E1 P9 H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 r5 q. e; G2 J$ [; e8 H6 @: v        .leds = da850_evm_tl_leds,
, @: n0 d' ?( F) s6 a$ B) f# @+ q* e        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 ^$ d9 A( K& c
};& U5 X& Z* N% Y- t, E

* u8 F& H+ w+ s" vstatic void led_dev_release(struct device *dev)
% \7 s  l1 J' P, G2 j9 b6 w{
) U5 N) g2 [+ E  N+ \};
+ b  Y8 X) v; p$ i1 ^/ z; U* r3 r2 X. h, ]& A+ ~0 g& k
static struct platform_device da850_evm_tl_leds_device = {
1 C$ t  H. P, {" R; e) J7 L4 [        .name                = "leds-gpio",3 b0 T" v5 N% P
        .id                = 1,& y9 y7 U& ^, R7 t) F+ o
        .dev = {
& T7 ~% @/ {  J                .platform_data = &da850_evm_tl_leds_pdata,. F$ a' j: Y1 w- v( D
                .release = led_dev_release,
' _$ r8 S' J+ N. ?9 A9 }1 Y) ^9 ^        }& ?* @7 Z$ \4 n- |* [+ d% X! ]9 G
};
' U6 r# g+ G1 Y$ i8 p3 E# O+ q1 a6 |& B1 c9 k1 j5 b! E0 p
static int __init led_platform_init(void): g- i  `! K) T0 ~2 Y
{
* {/ k, V: z- X. l  a& H% U        int ret;
6 H( }, f2 W8 c( R+ `7 i% h3 @#if 0! O, ]# R' I3 R7 T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 x. x0 C+ @* C
        if (ret)
' V: P& h, r* S& q+ a7 F                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: _& [! p( t3 i- X$ }( l% B/ `                                "%d\n", ret);' [+ c! E8 K: b# z) k
#endif
, h6 D$ G' r4 e8 t) u8 p* C        ret = platform_device_register(&da850_evm_tl_leds_device);( W( `( s5 c/ u9 L6 c
        if (ret)3 J" T% b. w1 b6 X
                pr_warning("Could not register som GPIO expander LEDS");
2 P% b! c* J' ^: }$ Z# q        else( v+ ~) @& z) u
                printk(KERN_INFO "LED register sucessful!\n");. C; p3 ^3 g& U& }2 U+ a

+ j9 N& Y" [6 I- |2 ^        return ret;
7 e9 a8 U+ v! r0 x  \  E* I}& K" q" ^! J' d; \8 M5 C
' A  D7 A& D! _7 Z
static void __exit led_platform_exit(void)% x4 m- ^! O: [, @
{8 |* S/ I/ C1 I9 ?# J9 ]
        platform_device_unregister(&da850_evm_tl_leds_device);
+ K' w# Y& T) m0 v1 Q* }$ L7 y
& I* y% T: k6 C. p( ^        printk(KERN_INFO "LED unregister!\n");( }: A  x- [; f
}# a' i# u( U, A3 Q; j6 p

/ K$ S6 P! f: x6 J+ Omodule_init(led_platform_init);
3 \; a  B: O' s1 a' U. Ymodule_exit(led_platform_exit);
; O: h4 n3 [) p: T* V* P
) [' x. M' p8 @* FMODULE_DESCRIPTION("Led platform driver");$ o7 k5 h- X" I3 `- K
MODULE_AUTHOR("Tronlong");
: t3 Z3 i9 ~+ m- HMODULE_LICENSE("GPL");& u4 u# e7 M- G

0 i$ r3 C  Q& M2 v- W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-27 14:50 , Processed in 0.040180 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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