程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 n4 s  X+ l$ r0 f#include <linux/init.h>9 ]" |0 O0 v9 j* e2 S5 \' C
#include <linux/module.h>+ k- e9 P, g7 f' P# q$ b
#include <linux/kernel.h>$ M# f5 S7 s, m  r2 y
#include <linux/types.h>
3 f% m3 P- o- R! ]4 f, \& [& G#include <linux/gpio.h>! u: A% U# d* B
#include <linux/leds.h>. j1 C7 \, ]2 i" Z, `
#include <linux/platform_device.h>
, a4 ^- n+ _! _; q4 n0 x5 l0 s! S" u* y( m" s) v' Z
#include <asm/mach-types.h>3 b* x7 `5 x& E7 ~
#include <asm/mach/arch.h>
5 s$ R# r  _# ~6 c* z! x0 J#include <mach/da8xx.h>* C& \: M, q+ K2 q
#include <mach/mux.h>
5 O- S0 G4 ~9 W. z9 W" N+ Z- S6 I0 {2 G. H/ x
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
# \! d2 n# }( x#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)" z  o" I0 v- ]) }
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( n1 P: q' ^* F9 o, L" t#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& z: y3 j. ~' a+ n6 d9 q8 I

* w- M5 r, i: `* v" W9 G/* assign the tl som board LED-GPIOs*/6 c8 b& m/ b& H( m# a7 @4 w
static const short da850_evm_tl_user_led_pins[] = {( ?* s1 g3 N5 u/ Y1 x: L  o5 B. i
        /* These pins are definition at <mach/mux.h> file */1 x6 j7 @5 y7 f1 h% `/ p
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 _2 w( h% w) c- D" `6 t' }8 r
        -1
+ ~6 g: m* Z7 z  m' V1 ^4 F' Q};+ c7 B1 A) }' Y0 C- i
' s6 l6 w( V" p7 B+ j6 I
static struct gpio_led da850_evm_tl_leds[] = {
! P: b: r/ E, P! U; E3 P6 j        {
2 x6 h& T( O) y' N+ E2 h                .active_low = 0,+ k' G* I, M; t! m/ J* }# w
                .gpio = DA850_USER_LED0,
& P4 j9 N; h* j! r                .name = "user_led0",  d+ M( r- R6 G9 E1 w
                .default_trigger = "default-on",
$ X' w+ }. S8 `. n0 m: _0 f$ I2 s        },
1 h/ R+ W! c" P        {
; y& {0 j; R# s                .active_low = 0,1 E/ Y2 g3 L( u& X: _
                .gpio = DA850_USER_LED1,
( j4 ^" q5 a8 D$ {2 S                .name = "user_led1",4 Q% p3 j) v- Y' P
                .default_trigger = "default-on",
) V; {, C3 ?' {4 ~" A" N        },- R( u1 Y+ l) N8 O: K- J1 }: a
        {8 V( p5 m6 I4 I( _* z4 F; c4 ?
                .active_low = 0,
0 i! v4 s& s' U# T3 W" P- f3 l) a                .gpio = DA850_USER_LED2,
% H' M9 l, e% I( U) D+ g5 |                .name = "user_led2",  o8 Q% b  u1 W2 Z% w3 ^
                .default_trigger = "default-on",. d* H: t5 ]7 L: x
        },
, K9 |  K- o. ^* q. B! ]        {2 Y  y, a$ W8 [, c) p8 O
                .active_low = 0,
. R9 F0 [2 @9 ]" p+ E                .gpio = DA850_USER_LED3,
5 r- |4 r. `; r5 F( H                .name = "user_led3",
' A2 }3 K' o2 t, X                .default_trigger = "default-on",* l) u7 j, c1 O3 F+ [
        },
) Z$ R4 m& h7 g8 Q* C' b, d% B' \};
8 f+ W4 W# X$ ?5 m' S( n+ ~; }( @1 f
1 A# ^3 s, g- N6 F# Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( `2 B; v+ }* L& @) x: |        .leds = da850_evm_tl_leds,
/ Z' _3 H4 C+ Q0 y! c. c% @* G        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 k) b3 a3 q3 y7 x' I# |8 z2 ~};8 J7 T7 N& \" B5 f. v& t

; N7 m% R: Y1 fstatic void led_dev_release(struct device *dev)
7 `/ T5 @. c$ M; l{! x6 r1 R( m9 O# K
};
( N, \2 u# V2 {' [! g+ @( g. E
# A: l# ?) \! [- R$ Q/ |static struct platform_device da850_evm_tl_leds_device = {7 t- x3 Q) p7 [. B
        .name                = "leds-gpio",8 g3 b: P; Y  {1 E
        .id                = 1,
* g/ y2 \4 |' x( r; q        .dev = {1 C( ?  o7 l; s0 {6 G) e9 r
                .platform_data = &da850_evm_tl_leds_pdata,
. j& U" c9 \4 W( [: i                .release = led_dev_release,) Z& ^- @' j$ H0 H. p' C* W
        }
( e+ n. e0 O# G. F};& e# B8 ]0 ?# w$ p+ |, }

, P4 ^, w' _# ~3 O4 ~static int __init led_platform_init(void): O$ X2 p6 q) ?
{8 S: Q( K" T5 i, N% y+ w( L" N  ^
        int ret;
9 Z- J8 G0 x1 G( S* S' q#if 0
* C- x7 _, Q& W; j        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. n' Q* S% x' `
        if (ret)
+ {6 o* b& j" r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! E: y) L  x% E9 M7 _                                "%d\n", ret);7 ^( N2 h7 d2 t
#endif
- q- x% Y7 n! U        ret = platform_device_register(&da850_evm_tl_leds_device);
* P7 t0 k/ \) Q8 f3 b        if (ret)
0 ?* _/ u! G; y# j5 b% o" L                pr_warning("Could not register som GPIO expander LEDS");) D2 x' n' x( D5 N8 g% A
        else
- t# y7 o! A+ ^' H! `8 V" ~                printk(KERN_INFO "LED register sucessful!\n");" c/ V+ x( f; _3 W' Z4 J
% \' W7 n4 W8 @% Z9 |- y& z
        return ret;* P  f6 x+ G& x5 \! h7 C  G
}$ O8 y' ^9 s# K& d: d0 R6 |' s4 `

% H: ], ]1 }" X& a# h7 S, s) `static void __exit led_platform_exit(void)
+ [- |0 F) U, `% V! {' V{
( N- ]- C( x; x$ E& h        platform_device_unregister(&da850_evm_tl_leds_device);
' w& I: v( k: O( P) L3 I# R' ^( v- F6 M! q. L2 U2 B  i
        printk(KERN_INFO "LED unregister!\n");' _& }0 t6 h+ u) a
}: |, y" n) g3 Z6 d. A
# }/ ~1 G1 d& z1 Q: b) b
module_init(led_platform_init);" F3 x) n. o) l
module_exit(led_platform_exit);
0 T& Q/ X8 S& Y1 R. u  D1 L: z. ]+ ^5 e, U2 w  `- u* I
MODULE_DESCRIPTION("Led platform driver");" a1 f0 n# M& m% n  u
MODULE_AUTHOR("Tronlong");
/ S. D6 c5 Y7 ?1 ]& M' s; ]- A" ZMODULE_LICENSE("GPL");
3 G9 Y. p& L$ x- A& `" |8 `
6 A4 G* ^! |  z2 p. V7 ^/ Y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-14 17:59 , Processed in 0.036978 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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