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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; Q& [& g/ a  K1 \6 V! _3 b5 L
#include <linux/init.h>
0 f  S9 {2 b# k% S! ^# s# c/ K#include <linux/module.h>
: z) r$ k  @' J, r#include <linux/kernel.h>
- }; `9 ]' {& V6 u, i! c# \#include <linux/types.h>
; O. u9 P7 ~, y. ^! ?- c8 z8 Q#include <linux/gpio.h>
9 J1 ~7 j! W; g: _#include <linux/leds.h>
4 N3 }1 W9 ]) I! ~6 z% l. y! k7 h8 `#include <linux/platform_device.h>) b7 m3 b0 Y+ Y# Q' N/ A- t. t8 r; x

" ^! Q8 m4 N  e* Y( o$ s#include <asm/mach-types.h>
6 X" R3 C8 ~. C  l: c0 v2 v#include <asm/mach/arch.h>! t7 ?7 @* \- a. H# N( `
#include <mach/da8xx.h>
& l0 Z& i# D  E9 ~+ Y( t/ L#include <mach/mux.h>! Y( w) |. |' \& z

6 M8 @2 K2 A7 i! C9 }) V#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 t$ v3 I7 x6 \* N/ u! p
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ E$ \5 X7 Y$ g1 B7 H$ A1 b
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 E' R, G* @6 U* w( L7 g$ j
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), B( z9 \+ f/ r0 Q, r
- E" D! `  D( t+ L0 V
/* assign the tl som board LED-GPIOs*/
" ^) O  Y9 o' ~! m/ V4 R" c! ^static const short da850_evm_tl_user_led_pins[] = {
3 E# c6 Y4 _# ^7 I        /* These pins are definition at <mach/mux.h> file */1 H  U: k  x& l
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 s5 {: @8 s+ \% I* G; W  u+ Y        -1  J5 z$ v& j+ G( a
};( s+ D/ ]' r; U
( ]; w5 ]2 |5 G! w# w6 {0 L
static struct gpio_led da850_evm_tl_leds[] = {! u: W) P5 s' |- \# }
        {
' S1 q, t* s& {                .active_low = 0,7 B, M1 V/ [5 c1 G$ y
                .gpio = DA850_USER_LED0,3 \  |1 z: x! c, x+ P: @
                .name = "user_led0",
5 Q2 x  J6 q# d& M                .default_trigger = "default-on",
* q' j7 O4 V& h, k5 |        },5 G2 p, q$ B( l7 _6 [' |
        {5 v4 {/ H4 \3 q! l) k
                .active_low = 0,9 Q& _* t& M+ V5 q5 i3 y
                .gpio = DA850_USER_LED1,
% Q/ H. a- B$ Q# ~$ ]# t$ W                .name = "user_led1",
4 s. ~* e& j5 f$ m5 h                .default_trigger = "default-on",4 g; b: T3 {% ~2 i
        },7 O+ \% v! \- a
        {
2 ^6 |6 t& A' U7 E+ k                .active_low = 0,4 `+ b6 c  ~$ u/ [0 w
                .gpio = DA850_USER_LED2,6 k7 \4 I3 z4 L# l
                .name = "user_led2",
) L% K. s# u% q6 F0 ?5 T% y                .default_trigger = "default-on",8 J% |9 c$ c; P9 E
        },
5 `" c. H- d4 b        {
3 R! E. G2 W0 e( o6 O& O" i9 K                .active_low = 0,9 |$ }9 c# J- T* g$ Z
                .gpio = DA850_USER_LED3,
; |" T4 ]6 w8 c4 s) o0 J9 s                .name = "user_led3",
. ^  S, q8 N; |+ @  m$ z2 T                .default_trigger = "default-on",: L- L" h) @% c" X) }
        },
& |( p( W  U4 ?6 z5 c};
6 c( m) h$ h0 D+ W, Q. n& `$ f$ `. }! {4 b' Q$ A. \; E% i, _+ d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. H" G- p3 i9 P( d  y# v        .leds = da850_evm_tl_leds,5 b  J9 U3 X  I. Z4 P" b$ E
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% w. t, \" }7 u7 d6 R' u7 S
};
1 V* `! p0 X( e( Y9 x
9 g# n9 J% I9 Hstatic void led_dev_release(struct device *dev)
; _1 x) O/ w: J{/ g, l+ N/ U$ r: z
};
1 G8 }3 v- e  U/ Y
: t( s0 z5 Y; r( n" t& \% jstatic struct platform_device da850_evm_tl_leds_device = {
  q; r" U' O5 {) `% ^' \0 S        .name                = "leds-gpio",
4 H- \5 p( R6 d        .id                = 1,
  _! H0 S; L+ _' V        .dev = {) d  d4 o+ A5 n5 b" ?
                .platform_data = &da850_evm_tl_leds_pdata,( w; Z$ R" z7 a0 s* W6 {
                .release = led_dev_release,
  F$ f* f' E3 j/ s7 W8 Y        }% H: v6 \7 O: w4 B8 r- y/ N6 l
};8 e+ ~( u# Z" F9 ~  K

0 V/ i# r# i/ ^  Y4 \2 v- istatic int __init led_platform_init(void)* H" o: y& N! M( R
{
, e5 p' b7 T9 W4 e/ u) F& I        int ret;
$ U; R5 t5 f, q6 U( B#if 0
% w' H/ @7 M! o! q+ R1 M* |        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* R" R- h8 j+ \$ k/ N" n1 z$ }, O' M
        if (ret)- J; V2 B+ b8 G
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 l& Z6 I2 z8 m% m
                                "%d\n", ret);; ]  f3 b! E& q6 K, K- S& c, v
#endif0 ]) h8 h" i1 }7 D" |* @8 L
        ret = platform_device_register(&da850_evm_tl_leds_device);% t0 @+ q6 `9 }/ z) J- R
        if (ret)4 Q# `8 U8 T0 w  V, Z6 M# t: ^
                pr_warning("Could not register som GPIO expander LEDS");) M7 K- c) X; x# L! a$ N$ B3 E
        else
1 x. o0 {$ l& s& K* m                printk(KERN_INFO "LED register sucessful!\n");! m" y& q% K% F: S/ J
6 U9 e, g/ e3 k% W+ n: g
        return ret;5 F$ k; ~- l/ `  g
}9 }3 A$ z; M6 ^$ t

0 A( Z8 W% k# _" A% e/ ~static void __exit led_platform_exit(void)
9 r* y- ~! v3 x0 a& j% e  B{
* o5 Z2 B0 |' A        platform_device_unregister(&da850_evm_tl_leds_device);) H6 G9 E0 S5 v% ]' I' Q: Y

4 \, ]/ L: Y  N  o( s) M' ]  n        printk(KERN_INFO "LED unregister!\n");! X' _6 t5 B3 b3 z0 ~2 g
}% y3 P" W6 a% w

! X7 O9 a8 j. v% J1 Q! q$ {" e; E: z! Bmodule_init(led_platform_init);
: m% G( @( D1 D( u7 a% a: cmodule_exit(led_platform_exit);
3 a* v5 k6 r  m
9 _; g$ C9 j4 z4 l6 B0 S3 ]9 `/ CMODULE_DESCRIPTION("Led platform driver");2 D3 V3 f7 J7 [5 G! T
MODULE_AUTHOR("Tronlong");
6 O7 e0 P7 x3 ]. }MODULE_LICENSE("GPL");! |+ ?: c" m5 b! r

( U2 F- h3 x3 g. H$ D0 T& f
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-20 06:38 , Processed in 0.037674 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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