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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。" }. v5 F' O& r$ Z
#include <linux/init.h>
, X; r+ t! F! |#include <linux/module.h>4 O' c) H" w# Z6 @# K% m% n
#include <linux/kernel.h>
  K: W0 g+ F( v6 ^- L( n#include <linux/types.h>
6 C# n; ~! b+ d& D- C) E: }/ w#include <linux/gpio.h>0 H. J3 a9 ]. Y; ^
#include <linux/leds.h>0 c4 i% A5 w* Q. N
#include <linux/platform_device.h>% ]- s! M1 r5 R$ p  d

$ \6 p/ I9 H0 o6 k! w1 _# @/ q#include <asm/mach-types.h>
% ?5 @& m9 Y) p7 k#include <asm/mach/arch.h>
; _9 a4 a7 t) T! z2 A5 |7 c#include <mach/da8xx.h>
. i7 W) S0 G, W0 D% Q9 n; {! E#include <mach/mux.h>
: y) x/ _4 C. Q/ A: U6 G/ u' |
" W4 T& X2 ]1 d! F0 _) @#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  w" G* s8 \  I. X9 m2 m#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). B3 C2 A7 E2 O3 }
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 Z7 Z6 Z- E. J, h. W; o; B$ X
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 s( s# x% u; @" {7 s

  ]' g- i0 A. H! W; ]% S  t. B/* assign the tl som board LED-GPIOs*/
8 x& \! r5 ?5 xstatic const short da850_evm_tl_user_led_pins[] = {
& o; x4 w& [4 g3 x& T: y        /* These pins are definition at <mach/mux.h> file */
. u( W  Y2 F( v, O: @        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# U4 j7 T" }0 ]. I0 \# Z
        -1
* r1 x9 o! d% q/ Z) P! \5 M% k};* Y4 t" ~& i2 }3 u
. J+ z" v2 Q$ ^) ~; Y) T
static struct gpio_led da850_evm_tl_leds[] = {& F3 T# O8 D: g  _
        {
& d- S7 r7 e( _( ?" L0 }- o' P                .active_low = 0,
% Y& f) s% D' U8 _. A4 ~                .gpio = DA850_USER_LED0,
/ W" d, ]0 ~7 r! Q1 A+ g1 |                .name = "user_led0",
* y. T( r! b- ~/ l                .default_trigger = "default-on",$ g& \+ E1 Q& x" s5 A
        },- O. g6 ^4 j* w% \* M: v& D: e# X! ]
        {& B# |7 q& d; e" r3 U6 }8 R9 n. l
                .active_low = 0,5 ~5 Q% e+ i3 Q/ e8 i8 b! r
                .gpio = DA850_USER_LED1,3 \$ H6 G. A+ \3 `4 k7 E- o% M
                .name = "user_led1",
* N1 T. W; v6 j" _                .default_trigger = "default-on",
* x7 N: z, f0 C# c9 m6 U        },
' Y- z) b+ Y$ c. g/ I+ A) n: u        {2 F7 g% Y" ]5 g7 L; a( I7 j6 f/ t! c
                .active_low = 0,2 T8 b7 m% O; Q
                .gpio = DA850_USER_LED2,- [6 s/ O: F" V4 [, n, i' L
                .name = "user_led2",* c) @' |# [) q, `  U
                .default_trigger = "default-on",8 o; |/ f7 f: o* u' U( b
        },
8 a, t+ C7 D, s# T' }9 p2 }5 R% d6 t1 h        {6 T  C2 k: o- [7 v0 L
                .active_low = 0,6 ~4 O5 t; s* T5 E4 L; C7 h
                .gpio = DA850_USER_LED3," B2 @# X9 K1 ]- I' D' C- k
                .name = "user_led3",
3 C" o- g& I0 ?. x7 j) {, U                .default_trigger = "default-on"," B9 {' q. y. N; P+ N" W2 c+ R# _: j
        },
2 E) b' |0 [! l0 x3 b, _* b8 @};1 B1 ~" a4 }2 ]& L; Z1 g6 b

* z6 Y& ^8 P7 c3 y- Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' ]& M7 T. u& H% t: L        .leds = da850_evm_tl_leds,: }6 J* i' |+ o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 q, w% C' @7 \: c
};
" v/ s" N: U& V3 X1 S) q9 i7 D& |2 b: V
static void led_dev_release(struct device *dev)$ ~9 V  q3 K' R; E" R
{
3 ?  A+ I5 e  R};; [( r# N$ Z* t
! m9 X2 |1 g5 ~% e. U
static struct platform_device da850_evm_tl_leds_device = {, H" B, l8 Q9 }6 C' X* M! e
        .name                = "leds-gpio",& A  ^8 H2 Z. F$ p5 c% [
        .id                = 1,
: A4 Y! t" |9 ~# w2 Q. i        .dev = {* H8 w$ _. E. b- _1 r+ @
                .platform_data = &da850_evm_tl_leds_pdata,
' l. W1 }$ j& R9 b8 b6 P                .release = led_dev_release,
! z4 B7 b3 y1 @        }5 {% J+ G8 u! k: B% c9 R" c" B9 i
};5 M$ W, }8 o0 O- x) M
/ u* {* I! {7 P0 U5 k
static int __init led_platform_init(void)
1 d: u* a: S8 j4 |: H" V* I{+ a0 L/ v! F: d8 ?. L
        int ret;
0 k" f; G7 i7 C  z1 y( F#if 0
+ ^# O' K4 I% ~4 Z9 h. U9 w        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' v' y5 r' M6 `% E8 |3 Y        if (ret)% o1 P4 B* R, `$ f' O' t) v$ N/ z9 m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 e) r0 \( \% i; p; S7 i& l  Y6 U
                                "%d\n", ret);0 h. |1 g& u- W5 Q4 t
#endif
3 H+ Q! i0 r% [1 B        ret = platform_device_register(&da850_evm_tl_leds_device);- \( g; p: P$ f* f
        if (ret)$ E' o. v- ~( U5 l% @( V
                pr_warning("Could not register som GPIO expander LEDS");
: h5 r8 `. w; O6 U$ _/ K8 ~        else
- ?$ D. |. J( T                printk(KERN_INFO "LED register sucessful!\n");/ }! M6 B# r! S3 h0 k8 S

1 F/ {6 m1 I2 W3 ]) q        return ret;
; O( C2 W4 U* P1 ~& l' E}
: {& t. Q( c( G& f2 k/ ]& H) A
6 h9 m1 _4 v. S( g- v$ ostatic void __exit led_platform_exit(void)
' }5 }4 [0 r6 ^& W5 R& c4 n{
/ c; b. `2 D/ o5 c        platform_device_unregister(&da850_evm_tl_leds_device);+ M: o5 [& C. V0 I
& J% q# r0 a4 V7 Q1 Z" k& C6 [
        printk(KERN_INFO "LED unregister!\n");# a$ h- ~% V- {6 \* E( L
}
% a  t8 y- m( j# [* Y% W# q- V  g! |2 T' n
module_init(led_platform_init);
( R- g0 r+ T4 W$ Umodule_exit(led_platform_exit);2 X: Z. P' R7 f# ^! A  N, R, R# n4 i
" ^* g9 p+ O+ _0 h+ t
MODULE_DESCRIPTION("Led platform driver");
- @' [0 B3 j1 p: C/ W( d/ O9 BMODULE_AUTHOR("Tronlong");; A  r: n, z3 B: g. }
MODULE_LICENSE("GPL");
, x* e2 m# o* B2 J" ]% F4 t2 I" Q8 |& i* p9 v  z: n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-21 07:35 , Processed in 0.038863 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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