程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
+ d; X1 U. i7 J1 ^#include <linux/init.h>
  X9 N" S4 E0 D+ C# \$ m4 q3 O3 H#include <linux/module.h>
  R6 T# M* S: _( e6 q$ W#include <linux/kernel.h>
6 }3 y( f2 J3 S#include <linux/types.h>& O, j- q& c' E
#include <linux/gpio.h>7 h$ y- P. {8 U+ ~
#include <linux/leds.h>& L. q. Q) }3 ^! _2 B& H: `
#include <linux/platform_device.h>! t, h2 X2 L: _+ G( R
  D- a+ y5 H; g' s9 J* R0 Z3 S
#include <asm/mach-types.h>
" x' |0 }  P% c( a) H) E#include <asm/mach/arch.h>
# D3 ]; t, `1 r8 {( H9 _, ?#include <mach/da8xx.h>( s! _2 N( V! y+ t8 R7 [
#include <mach/mux.h>& y8 b) w$ `5 i& L. N; v+ M. I

6 ]% S# Z6 {  G5 d* ]#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)4 I& w9 l( Z* g7 G" I8 b: ~% V
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 k$ [0 r7 W7 ^8 H* j#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): ?( k' o" f# D- @" E2 s9 {
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ q; V( W/ ~, T# e6 ~9 T/ i" o) t' T) j# g+ R* w
/* assign the tl som board LED-GPIOs*/
8 x# e0 [# P( e- n$ W. D& L# gstatic const short da850_evm_tl_user_led_pins[] = {2 h0 J) U" P/ f# t$ {7 n& y
        /* These pins are definition at <mach/mux.h> file */4 P/ J* Q3 w2 B1 t: f) z: w
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% @7 J0 b% R* W
        -1' L. n0 v/ w% R0 i4 N5 u" Z4 q$ N
};
, w# F# G. R6 O, ?+ ^# Q0 Z% w' J1 e5 k' c" D  W5 y% P
static struct gpio_led da850_evm_tl_leds[] = {
* C3 V7 z" X  }7 w        {0 u- O1 h  a  Y# T/ N
                .active_low = 0,* H0 e/ _/ Z" A
                .gpio = DA850_USER_LED0,: ?% l. S8 b' \& @  G% r
                .name = "user_led0",6 X* O% S3 C! C6 t( ]5 g7 F  o
                .default_trigger = "default-on",8 H5 x6 p& k9 f- c9 f, e% d
        },# w& P4 l3 |& r+ E) ]; C
        {& z6 V/ Z9 f3 Q+ n" i8 K: D
                .active_low = 0," a- `, M- Y2 _4 s5 j8 A
                .gpio = DA850_USER_LED1,* f' j( Y: b, i9 l) ]
                .name = "user_led1",
& E6 D: C# z- v! j                .default_trigger = "default-on",! R. \* x3 l, P3 q
        },
2 J4 C; X5 B) d        {% f2 X9 z& S9 T, l/ c
                .active_low = 0,
' q7 Q) N1 Z) h: z                .gpio = DA850_USER_LED2,
0 ~" e& c# d' K% o# `2 B                .name = "user_led2",
  A& {, y( E9 x3 ?* j6 |                .default_trigger = "default-on",) d% d( n* o! a
        },3 m! F% p9 ^' j+ T- m3 W# N
        {
9 X- C5 {9 [  s. N% S                .active_low = 0,, d2 r7 }. }4 }7 U8 e$ ]6 S+ J
                .gpio = DA850_USER_LED3,
! R6 Q5 }. B0 s9 n2 e" h                .name = "user_led3",
# @. W/ S+ [/ ~; j; t  c                .default_trigger = "default-on",$ Y6 p. y/ }' j" X. _( O
        },
& p: n8 R) s) X/ N# k, |' K};
% o: p8 `: A$ s8 [0 e/ S+ J2 y* k  t0 J4 C/ \! H  S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ S+ i! e+ A3 `6 i' w, M' N1 |        .leds = da850_evm_tl_leds,4 k' O+ P7 _) ^* R2 {
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ D2 J9 W  {" R0 ]
};/ Y9 l- A+ ]: H% S( ]

2 Y9 Z4 z4 a; _7 Wstatic void led_dev_release(struct device *dev)
1 M8 \! z3 _* l" b* Q{
; d# u2 V2 D. i) a};+ }( o3 H4 \- _% ]7 c  Y. v4 n
) s3 r3 ]' @% d7 L5 W. x
static struct platform_device da850_evm_tl_leds_device = {
/ Z5 U7 s- F# a. B2 F$ Y0 K/ ^" E        .name                = "leds-gpio",# J' z7 T" V! f6 |4 e9 F
        .id                = 1,& S) _: T- f6 f
        .dev = {+ E2 E1 C6 ?/ |! S' x
                .platform_data = &da850_evm_tl_leds_pdata,
" W+ T# y; U" v6 o                .release = led_dev_release,5 [; L# k; V0 X1 [, \
        }& r9 z9 x0 @9 {3 V3 D' q
};
* ~+ _! O( B/ L7 c% G8 J: B* M6 L, _, {1 c; d8 w' Q7 n0 m
static int __init led_platform_init(void)# y2 z6 V7 s6 E$ J# J# A
{
" R; D8 n2 G. s3 [- p  n        int ret;2 ?9 o. ]2 Q' _6 S; Q1 K1 b9 u
#if 0
2 `- i0 l. E2 q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# x7 d; r. C1 n4 m
        if (ret): b3 J( ^/ e+ L' P# p4 G) s* z  G
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") B4 u+ c% A3 G5 y0 ~
                                "%d\n", ret);# s/ F3 V$ |  I: L4 \, K
#endif
( x9 E5 |8 c7 n% P; F, j& g        ret = platform_device_register(&da850_evm_tl_leds_device);# l' J$ H" U; \: B- l" i  A1 z
        if (ret)6 Y/ ?6 f6 h0 w& g7 E# n6 H
                pr_warning("Could not register som GPIO expander LEDS");
7 j, s; X: N+ u5 _( J  `0 B$ r        else
4 Z! E# R5 i+ @1 S                printk(KERN_INFO "LED register sucessful!\n");' V8 f! O5 ?6 j) l* N0 ~
6 k* M  Z/ ^7 M
        return ret;
+ P4 V# T  v  m" N5 Y( Y  S( p  |1 V}- I' B3 |$ C* p
  X3 g+ y" H$ E1 h
static void __exit led_platform_exit(void)3 ]9 {9 ^! T7 u! o% R  [
{: U: _; _2 B" A# v% ?
        platform_device_unregister(&da850_evm_tl_leds_device);
0 f8 N; q" w1 j' ?5 w% [, t; k9 n6 o
        printk(KERN_INFO "LED unregister!\n");
" R6 L& W' c8 L, W) L}
. d0 g' w: F5 f# B& e) U4 d4 d4 d, ~9 s  f3 f$ b8 ?6 s
module_init(led_platform_init);# ], h2 x7 e! x5 n% n2 R7 S# S
module_exit(led_platform_exit);
, M# o3 ^3 @' Q% t! S& _# h3 g6 M5 E0 f: _6 R; n
MODULE_DESCRIPTION("Led platform driver");
3 f/ c7 }: C. Y6 }# _MODULE_AUTHOR("Tronlong");3 n' Z# V8 a7 W# Z' _- a  ]* r  ^: f
MODULE_LICENSE("GPL");/ `) k2 r6 e: D: @* F" ~4 \7 @
' E& `' \& Q$ F+ O2 J% s1 @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-1-14 16:38 , Processed in 0.039173 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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