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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
5 f+ g. |. n( R6 U; D) j+ Z" L#include <linux/init.h>$ p) b, T. K  U7 z2 d' j
#include <linux/module.h>
2 D& y  ^; o0 S- K#include <linux/kernel.h>
! p6 c- S# M9 V#include <linux/types.h>- {( v( }4 E# N
#include <linux/gpio.h>
) L; K+ [7 i9 J3 A8 m#include <linux/leds.h>* h4 u7 ]& x; G7 ^
#include <linux/platform_device.h>
0 T7 E, F& H3 ^4 E
3 \- j: I2 g2 G4 Y( Z- Q9 m#include <asm/mach-types.h>
6 W8 s3 k0 i* L7 N! G2 H! R) q9 E#include <asm/mach/arch.h>) C) |. N3 C7 z4 a
#include <mach/da8xx.h>
: i5 W+ F9 b8 k* {#include <mach/mux.h>
+ n4 f5 @7 f0 M. F" z& s7 d( ^- Q( ~1 X. K( C
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 w, A( ]  Y1 y+ X( E7 K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- N5 k9 d$ g3 z  N#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% u9 ]9 O! c, b. a8 Y4 [
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 q: ]# b: A' J0 B7 a. j
; L2 x9 g8 _% d0 [) |: m: x- m3 q
/* assign the tl som board LED-GPIOs*/$ }! y; A2 O2 f# h
static const short da850_evm_tl_user_led_pins[] = {
6 R, V' O5 K. N4 P$ d& u        /* These pins are definition at <mach/mux.h> file */
8 O* r& D# f4 y" p* r        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 L6 k( g4 y% j* i" T, ~- h# k3 V& J9 \        -1
7 a: O0 u) `) K. j( P  r};2 V+ A; I& p' s, K* H

7 d) B+ |$ b: v: w5 @+ G( Hstatic struct gpio_led da850_evm_tl_leds[] = {/ z# N5 i/ ~: y" ?0 T. g- J
        {
4 ^  v: |& B$ }$ a- Y# g                .active_low = 0,# ~0 e, [2 k: ^5 M7 s6 l
                .gpio = DA850_USER_LED0,+ C- b' Y3 S& U0 h8 n6 }
                .name = "user_led0",
! D- z6 |3 k9 Y7 P) x% y4 d                .default_trigger = "default-on",
$ {5 A" ]; W6 |- {- t        },
6 p- B" F. f* J$ J# J" }, [        {. ?/ _: `9 W* [7 P
                .active_low = 0,7 Y4 r3 T& G/ _8 ~0 H$ P
                .gpio = DA850_USER_LED1,
! O) k1 h1 P; y$ S                .name = "user_led1",* c, F5 b7 H) q
                .default_trigger = "default-on",( ?  q" _: W. _* ?
        },& R4 j* }. W+ |) o* c2 C1 ^
        {' g, m0 }& q# S8 _) V
                .active_low = 0,
& B& J: R3 a% Y                .gpio = DA850_USER_LED2,7 \9 t9 c, C* I# I' b1 g2 w! k1 q
                .name = "user_led2",  t& a, t$ m3 O' e0 ]
                .default_trigger = "default-on",
/ F, S4 s/ a, Q" Y$ s        },+ N) c1 X- g! z0 n& W* i! }; S
        {
% J5 ]9 _  h% C2 U                .active_low = 0,) q+ W4 h  K2 g- V% G, i4 d5 Y
                .gpio = DA850_USER_LED3,
5 t# c% ^' n7 b! c, B                .name = "user_led3",9 J. r4 F. \) y! v: }7 l5 J
                .default_trigger = "default-on",
+ S8 q. p# H# C2 `        },+ e' V; @4 k: a
};* R- l& x0 E: y2 I* Y# {, o

% n& b2 w9 h. U& H4 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ }# b9 W$ q9 Z9 D- C$ M9 r' c        .leds = da850_evm_tl_leds,: G- Z9 T4 H* Z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. G+ h/ _3 j* e
};6 F( s7 n, Y# [" f6 Z! o+ \, d

6 t+ W2 m  p& {. K- Estatic void led_dev_release(struct device *dev); l, ?& s, M1 O0 T9 l
{
: \8 r7 Z1 k4 @8 M3 H};3 h% [! W4 o: o4 h* x/ }; s
: S. b+ R# n  Y8 ]2 A! g9 r+ g
static struct platform_device da850_evm_tl_leds_device = {* ~* A- I+ a8 \* H! D
        .name                = "leds-gpio",
, b0 s1 t6 E2 D        .id                = 1,7 b1 w+ A+ P+ {" {8 J* ^
        .dev = {8 o, U' X6 s- x8 A
                .platform_data = &da850_evm_tl_leds_pdata,& l  k2 z! U1 Z! o/ L9 `
                .release = led_dev_release,
# H% S# F0 t  H( [        }
2 n2 d8 l% a$ q! r9 }# k};2 _( n( @# b' X0 v$ l
& L2 F1 r- I, |7 G& W4 |
static int __init led_platform_init(void)
# Y0 a. u% Q2 ]6 s4 Z, F: {& M+ m/ W{
; z& h7 d) f7 r# c* a0 J, N7 b  Z8 x        int ret;
- x! @. ^+ w% x" X; \8 m  A8 t#if 0
, D$ P) s. Z, }4 x+ [        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 H0 P: u7 M6 O: c& u5 Q        if (ret)
  A0 H: o3 q! t$ e5 S: U" F, V                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" y, X2 s  p1 H
                                "%d\n", ret);4 I* ^* }7 L' S% c4 a  u
#endif& T& J3 M- i+ Y* R# R2 w$ p
        ret = platform_device_register(&da850_evm_tl_leds_device);
% d7 D/ s+ Z% @+ d3 g" D        if (ret)' w. B2 f1 {8 H% w
                pr_warning("Could not register som GPIO expander LEDS");
. B9 z8 o( y! L6 W8 z( |, F        else- a9 O# w, ]$ R4 u% @5 f: F
                printk(KERN_INFO "LED register sucessful!\n");. M7 T% F5 n# Z; X$ B

: ^/ }$ Z' a: U- l        return ret;
, B: d+ [- N, ^/ f}
- U1 g3 I+ [' Z/ z( h% Z0 _# P# R- y0 h6 }4 n
static void __exit led_platform_exit(void)
* J! j, ~; E! A+ i  s: B{3 S) x2 f3 G- ~
        platform_device_unregister(&da850_evm_tl_leds_device);1 y6 K  G, N- v

' N  n; l7 y; o) u        printk(KERN_INFO "LED unregister!\n");1 B5 Z9 Y- K( z- r* u
}5 T0 M4 M% }4 J

! z: ^4 d% R: \, A. M1 ^$ n/ Wmodule_init(led_platform_init);7 t$ h8 {+ m; a- t
module_exit(led_platform_exit);
: o) j+ {9 G3 f$ Y6 |( w9 s! I$ H$ _/ V- s5 U* [' E' D' J$ [) w! B& ]
MODULE_DESCRIPTION("Led platform driver");# I/ r' z. z0 T8 C
MODULE_AUTHOR("Tronlong");
8 F' R+ |$ b& D' a# c# R' B# w2 O6 JMODULE_LICENSE("GPL");
2 ~, ]- K- C2 L7 ]
( k0 B1 X. k* O# G$ D, j
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-6 02:28 , Processed in 0.041021 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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