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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 a0 G! K& r; B3 ~; ?- \  Y#include <linux/init.h>
  p. F- {' L8 |. n#include <linux/module.h>
- f6 r" A7 S4 u8 ]  S' C6 s; y: S1 D7 ~7 e#include <linux/kernel.h>( u4 Y5 c7 S2 u7 L4 `
#include <linux/types.h>
3 X7 \, L8 g! [" Y  v$ v1 v  b$ h# T#include <linux/gpio.h>
& m/ T' M0 F& A#include <linux/leds.h>
0 H2 k/ L5 C' \# H+ m+ Z* M#include <linux/platform_device.h>
* ~: e  u" U! u( O% r4 a
9 X' o2 ~% \* |6 i8 r) H# z#include <asm/mach-types.h>
% A7 A1 I! V' E#include <asm/mach/arch.h>- b5 j0 E! [' C/ ~& g
#include <mach/da8xx.h>
' N  f9 N. ?( d#include <mach/mux.h>/ W5 v7 l. t% R) c! m& p

2 J1 x+ f0 h; N/ k* K' R#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! K- `6 J' Z7 t) Q; T
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
8 f5 O' Y) }, J#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: r: P! m3 ]1 e- g- C' }#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. l  k2 I+ @, g$ q# a7 f
; C. C# C7 U1 t0 [6 k( i/* assign the tl som board LED-GPIOs*/* h; g* Q( U4 ~
static const short da850_evm_tl_user_led_pins[] = {: E" r1 i. n# Q) W7 a' m$ `
        /* These pins are definition at <mach/mux.h> file */: K. V7 m5 i9 u) x& ~8 ]  x# t  U$ X
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. I8 r# A- ~. X* Z" d        -1
+ \: h* p! ~& T};# b0 E3 ~4 [, h- k9 u2 B

" I; Y; o$ |9 W3 S4 a; e7 V9 t' g. ^1 ~static struct gpio_led da850_evm_tl_leds[] = {3 ?7 @! o) {8 q$ q/ b% z$ J
        {
3 k5 p0 w' W/ ], ~/ I1 C                .active_low = 0,% Q5 r0 Q( J2 Z& J( y* p0 i
                .gpio = DA850_USER_LED0,
' l0 T8 l' f! U7 J$ q                .name = "user_led0",% y0 G# n3 U- p: i" Q8 y
                .default_trigger = "default-on",& }2 {2 m4 B5 N% t2 f0 X
        },
- \3 m2 l0 e' ^) \/ `9 w        {
( ~' p  {4 |' L4 \" H$ o1 p: I                .active_low = 0,
7 r! g) e, a  Q9 z9 C& O                .gpio = DA850_USER_LED1,
: G7 e6 X' T' R, K: [" Z# z                .name = "user_led1",
" j+ a/ [! A5 y2 h- M                .default_trigger = "default-on",# P2 h! _0 O! Q/ B# Z7 s
        },$ m& S# H. l2 b' Y# k4 B6 f5 @
        {/ \0 ?& I. F/ l/ g  C. L( t
                .active_low = 0,/ m+ l( O1 w4 A' h
                .gpio = DA850_USER_LED2,0 k, J. G0 W( Q* n/ Y
                .name = "user_led2",( n, s% Y7 i! X; C! J" R; r/ P
                .default_trigger = "default-on",
2 W# v8 X% c. m( U. {        },/ Y# F- ?/ o) V  a0 Q
        {
. M. U- Z& Q5 J& y                .active_low = 0,# c* r& q2 c. [. F! k( |
                .gpio = DA850_USER_LED3,6 _/ C0 r  \7 _
                .name = "user_led3",/ ~) L! c. m+ O( A, C% r
                .default_trigger = "default-on",1 L: W/ ?0 O$ P2 w! |+ c
        },* c$ M" j$ z7 Z8 Q  H
};, D4 G; m6 _9 v

' ~1 l" v) T1 S: D7 x! i( u: ~7 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- a3 N: Q2 B$ a7 H        .leds = da850_evm_tl_leds,
. ?, a8 f2 {" u        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 m$ M( q' s$ V/ Q- h
};+ U' o. E/ T+ B4 x) R
$ C0 a, y# `! R# n% n/ |. N
static void led_dev_release(struct device *dev)3 I- J) {% r1 R+ E" _! ]
{  i( x: Z( W1 P: c9 V
};
4 f( r1 j3 ^3 ~1 e* O
% I, g- ^8 i( Gstatic struct platform_device da850_evm_tl_leds_device = {( l; x4 t; D& h, @$ E% o- V
        .name                = "leds-gpio",
+ n3 C+ A  v6 Q# O% ]        .id                = 1,* }/ I+ l' i4 v9 C8 M
        .dev = {- }; Z' |0 p4 |: ~
                .platform_data = &da850_evm_tl_leds_pdata,4 _/ q5 k3 [" E1 b4 {
                .release = led_dev_release,3 r5 f2 P: _/ B
        }9 `/ b* |6 t0 b0 P: d' d
};
4 z  p. P- i. I( f' x; ^7 \, G' \4 c; D' o& B& @- Z: Y
static int __init led_platform_init(void)8 v# E* F' t9 `5 {: [8 y  j  a/ |7 w
{
3 U- L! ~$ I6 I7 h! {. M9 ?& k        int ret;- p- G5 K+ L2 ~- `& X
#if 0
! ?& ~0 t- R! J7 A; V! X0 Z: ~        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 R. E! C8 m' _        if (ret)* x: G3 t( k# N* q6 ^; R% [( }
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( u8 J8 e5 n$ n* j& f
                                "%d\n", ret);; l" }& T, R! c
#endif3 ^' r) P! s' y3 k  R7 o1 l
        ret = platform_device_register(&da850_evm_tl_leds_device);& V- x) U  D, {% Q" c7 b
        if (ret)
& t! U2 x( S0 v) x2 k0 r                pr_warning("Could not register som GPIO expander LEDS");3 y' g  z3 d* A# p
        else
: U: n/ P. p5 ?1 {7 k( N                printk(KERN_INFO "LED register sucessful!\n");
- t  N# R# b4 f/ o8 C7 T$ U5 l/ A! m, `- C% Y
        return ret;, O. ?/ M' b; [* A8 D2 c( y
}. }3 L; Q, s. ~
" v. `9 e$ x: m6 w6 ~7 R
static void __exit led_platform_exit(void)
& ^- E7 c* d; P4 K$ u& h4 d7 M{
# A% ?4 @) I. r' C5 U, N        platform_device_unregister(&da850_evm_tl_leds_device);5 T. d9 H8 d* d2 c9 w; I

, [2 Z6 e. ?7 f. r5 w2 @        printk(KERN_INFO "LED unregister!\n");
0 [" W/ V* {- u}
8 a2 N* ~3 t' s2 g! u7 K3 f
$ _* b8 ?" W6 `8 `9 W* o3 Bmodule_init(led_platform_init);3 b3 K1 u- p: Y0 R) c8 v
module_exit(led_platform_exit);
# _2 W, u$ s" p) @$ m* |7 N1 Q0 l1 `! G
MODULE_DESCRIPTION("Led platform driver");0 M7 ?! q2 L6 _$ s% l1 P' P- I
MODULE_AUTHOR("Tronlong");9 O" \' G) k' N6 U* Q9 _0 T
MODULE_LICENSE("GPL");$ X) e( v) t# n) X! a8 k

: @0 `. x2 }8 v) {8 @& V
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-23 10:05 , Processed in 0.037518 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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