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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
/ h0 ]$ X" |/ d8 ~. O. A- D#include <linux/init.h>
) r' ?; U) ]: Q7 s#include <linux/module.h>0 ~% J6 A; g% U" ^( J: ?% o8 e
#include <linux/kernel.h>) m% B; E9 y) i# _) z. v3 S  p5 `- ^/ l
#include <linux/types.h>3 `/ H$ e4 m; P
#include <linux/gpio.h>
, n6 C6 T! u! T) ^  d" S. S1 ~#include <linux/leds.h>( f: a# Y: u$ D) c, ^2 B# @* u
#include <linux/platform_device.h>. G! Z) s5 r0 O
( z, K5 S+ P+ `1 O# F- [3 C
#include <asm/mach-types.h>
9 H) S, k1 p7 Z3 y; `#include <asm/mach/arch.h>
, P7 e8 p& n( A3 |: w. l3 I% ?: _, Q#include <mach/da8xx.h>7 j* c- @+ |! [* g0 s" I
#include <mach/mux.h>
& [4 x/ i, w3 V+ |; p0 P
7 }' Y. R! i% w: R& f. D( `#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% n1 U( M* r# Q2 l/ N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); s/ ]" e  H/ I- C3 k$ v: Z7 Z( a! b
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
& B+ I6 D4 ^: k; Y) U#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
( y0 o- r( x# u/ r* T4 ]# [' y" `' L2 o( m8 E: a
/* assign the tl som board LED-GPIOs*/
) A6 |8 z; a1 C5 J1 n3 G3 z7 ~1 `static const short da850_evm_tl_user_led_pins[] = {) ]+ n( ^: G% G( q- ]
        /* These pins are definition at <mach/mux.h> file */# \- W! q4 P7 h6 v5 v
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 `7 }" f, m1 _0 a
        -1
' ~! {, s. X$ i6 P};& S: A2 i  F# r0 H; B1 Y

8 ]2 V" a  ]0 s$ o8 Z% y. `static struct gpio_led da850_evm_tl_leds[] = {
. T2 S9 U8 g+ W: p$ U- F" t/ b        {
' A! X7 o) s2 V( k0 o                .active_low = 0,; E# _* q9 K! J) J4 `
                .gpio = DA850_USER_LED0,
1 h' v2 Y# Q+ F0 @7 b7 ~2 A                .name = "user_led0",3 u6 g; Q' m; D$ U) i# p* [& k$ E) R
                .default_trigger = "default-on",3 X) d; q" {- n+ B8 S
        },
; A+ e& U( d" u9 D  N. d# @        {
+ g8 b* o4 S) t4 Z6 E/ B                .active_low = 0,* Z( \% }5 ?& ?4 N$ [8 j8 z; h
                .gpio = DA850_USER_LED1,
. p  O* {5 ~1 i                .name = "user_led1",
: U9 w' [( e5 S. K: w+ E) `1 [                .default_trigger = "default-on",
' B% B2 z! M2 ]! d# e' Y  @        },
. b: q* ^$ z4 f; p+ V* v        {$ Y2 X: @' B2 I% y( ~3 W, C: y
                .active_low = 0,
! F1 g; s+ x5 T( |& q( A1 {& ]0 @                .gpio = DA850_USER_LED2,% E7 u4 S* _  @7 X
                .name = "user_led2",
. }, j+ B  r$ r; r                .default_trigger = "default-on",4 ]. h6 p6 p( Q$ t
        },
7 K* C" r/ K' N% R. N! W; ?        {
6 Y$ n' G, x9 i  a                .active_low = 0,
. T8 @. R" t* y0 g! K" Z$ R                .gpio = DA850_USER_LED3,
, _' m- Q1 d( n& r                .name = "user_led3",
. n! j  c# h' a/ I- W$ Y                .default_trigger = "default-on",
  A/ O9 f! p+ A0 Q* ^1 ^: m        },
$ ]3 o' j0 f% D/ s};
/ a. P# r  d- s5 K5 G' t$ Q
* P2 s0 U7 w5 s5 e% K0 b4 Q2 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 R" S: [4 s# L6 |8 D5 R  K: @        .leds = da850_evm_tl_leds,
1 V( L* c" h, g: u# ]7 T. O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 |6 \1 n2 A. H! o
};* W$ r& h- G& S6 u. ^" |

. X  |& g1 c+ k' d% K! ostatic void led_dev_release(struct device *dev)
; m: U" \1 q2 _4 Z$ k1 ]& v{6 C- p5 l8 D. P2 t2 r  V7 v: `1 {
};
2 e  W4 I. h6 y, Y  h8 H4 |6 n' g  [3 M# ^/ @+ t: a
static struct platform_device da850_evm_tl_leds_device = {
0 f" V" \2 B( \7 o) \$ |, a        .name                = "leds-gpio",1 ^+ ~# E$ A  N" p
        .id                = 1,
0 w9 C6 v4 j! X2 ]2 i8 o        .dev = {
4 t, t8 R! D0 `* A) I! t& a                .platform_data = &da850_evm_tl_leds_pdata,
2 M4 B1 W' u# @0 _$ z+ x                .release = led_dev_release,0 B/ }# G8 Z! c9 ^* y! e, y
        }
5 G: K3 K3 D! _$ P# }) f};* ?3 s* b$ D, v: A3 K- o

8 X* N4 Q9 O( ]  t/ ~( Lstatic int __init led_platform_init(void)5 A- E1 K, z( b
{
& A& u2 w$ G! B        int ret;
6 {; a4 _. J! x2 X( B  V& Q* X#if 00 F8 P. N& x' H3 S/ h* G: I# O; p( @: Y. i
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ _1 J7 m* i3 u: V        if (ret)
  d/ S  f/ }% ~5 T6 n. s7 I  m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 e4 I' @$ C" {6 d8 u' j
                                "%d\n", ret);- @. ]9 f. B2 Y' a+ D
#endif
5 j6 Z- i# Q% S        ret = platform_device_register(&da850_evm_tl_leds_device);3 P5 ?3 V2 x, T2 C0 d  w
        if (ret)
- [+ p" f; d2 V, h8 x                pr_warning("Could not register som GPIO expander LEDS");
9 F7 J3 n, d. |9 z/ C        else
% j3 }8 k8 x4 M; d# F+ I                printk(KERN_INFO "LED register sucessful!\n");. L; j7 P  b. _1 m2 d

) m. [5 g, P5 \7 f  m        return ret;
' O) {4 Y# h$ |}6 h! y: _8 @7 O7 p. X
6 P" b1 a9 O9 Z
static void __exit led_platform_exit(void)/ f6 F% U4 ]3 O. _3 @$ }9 |
{# G, b7 @0 X, y/ i8 k. F7 b1 r/ L, l
        platform_device_unregister(&da850_evm_tl_leds_device);' W) ?2 J9 x. [' y, s
' [. H7 X4 l" p  }
        printk(KERN_INFO "LED unregister!\n");7 R; r, d: n' Z
}2 v6 d% S; o% w
/ Y' Z6 s1 L; G9 I/ Y# Y
module_init(led_platform_init);* ^. z8 \9 ?3 g) ^' ~+ W, |$ E3 f/ G
module_exit(led_platform_exit);4 v4 N, }. y; e

" G$ M: \2 Y# z8 QMODULE_DESCRIPTION("Led platform driver");6 W" K, s3 x7 v4 Y! H" s2 x0 f
MODULE_AUTHOR("Tronlong");
$ K4 z+ c7 p( J, G1 }& f- y) |MODULE_LICENSE("GPL");
' J. B7 k! |/ l) y/ Q5 K, q6 c% g- m: s8 H* r8 j/ _2 F
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-3 02:22 , Processed in 0.037921 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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