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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' u# V7 U) b; z$ q  j) T% h, r7 ^
#include <linux/init.h>
. Q4 S/ ~! ?7 Q# r, w) z: q#include <linux/module.h>+ n" J1 Y: G3 z5 @3 y9 V8 ?
#include <linux/kernel.h>, U6 G' H+ ]; K" K# e3 P% o
#include <linux/types.h>
: G8 |, _; F( ]4 i9 v#include <linux/gpio.h>. P% c( o  N) M% q
#include <linux/leds.h>; b! _, D% n$ }( R1 N2 s1 X- K) }, A1 X
#include <linux/platform_device.h>
: d3 j+ {$ p4 Z8 F  p8 ?( q: g, U3 [
4 k- \; }) N4 D6 n/ S6 d#include <asm/mach-types.h>" b3 @. ^6 ]4 _7 |8 [# }# w
#include <asm/mach/arch.h>
, e# n0 |1 ~& V/ r#include <mach/da8xx.h>
7 I( h  G  f! [/ D+ ]  _, h" e#include <mach/mux.h>
" G+ n! E& F9 Q, T0 J3 c8 F$ R, n! f* A
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
% T" ~3 n9 \7 {: q! K4 ^% N1 `! A! @#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
/ i5 H- w2 j8 _; Y, e% Q* B" n& Q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: [6 [) H2 g8 H# |#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)* R4 W1 r' F5 X7 h
+ o) d$ s0 I0 i2 \1 r
/* assign the tl som board LED-GPIOs*/: J5 E: }7 {% X
static const short da850_evm_tl_user_led_pins[] = {
+ Z4 |, I/ i' Z7 D- G8 @& @- y        /* These pins are definition at <mach/mux.h> file */' ]2 s, m* {2 o: A0 M3 [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! h$ i% ^+ N0 Y- `) m, K. h        -1
$ J& J9 c" B# G7 y/ E4 q};4 l* k1 [% L4 ?$ f6 Q

: q7 L9 V5 S1 O3 Mstatic struct gpio_led da850_evm_tl_leds[] = {$ K. t8 M9 i9 P+ @- m0 I
        {+ X9 X# i# |4 @
                .active_low = 0,
# B# |; s  L5 ]- W+ D                .gpio = DA850_USER_LED0,
( s6 f6 Q% i8 f) c/ v4 ?                .name = "user_led0",
, K. l5 M/ a$ O2 C2 W                .default_trigger = "default-on",0 v$ s9 v- F  X* K# n4 _8 D
        },& R5 Z, v$ Z! ~7 o
        {
' M4 {! O8 n* W( o* O+ X5 A! m                .active_low = 0,
) w( _6 }" X9 l# {                .gpio = DA850_USER_LED1,& B% ]+ i: G- I7 U0 g2 p  Z' {5 ?
                .name = "user_led1",: \1 G  T( _6 a( e" v2 c/ t/ o
                .default_trigger = "default-on",
0 m9 \$ \9 \$ b" P5 C) Y) k3 B        },
$ e/ j, ~$ P3 |( ?: N        {& e# |- C* f- t1 w/ B) k5 f) }
                .active_low = 0,3 |5 V+ Y7 f/ B' F+ N) ?# ^
                .gpio = DA850_USER_LED2,/ V2 I( M- q% C5 U5 y! x. [
                .name = "user_led2",) M1 }6 ^" I( \
                .default_trigger = "default-on",
6 r- r. L' k/ i& n: y        },# l# r- Q' S5 y$ X9 b3 V2 m
        {
) T) g! a4 k+ g* m                .active_low = 0,9 ~4 P0 y5 G5 \3 |4 V3 C3 m7 k* e
                .gpio = DA850_USER_LED3,9 i0 n( z% F6 B- H* t
                .name = "user_led3",, ^/ ^' g3 o, n5 O, k4 \/ c
                .default_trigger = "default-on",
5 a7 V, \' i# F2 t        },
# Y8 Q. i' V1 @8 ~9 v};
3 L0 z; f- N7 q3 j# p" B& [
# K6 \$ V8 W; e8 _0 P  M: C% ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' Q+ E* q* X! O# `. N$ p. s! K        .leds = da850_evm_tl_leds,
1 [8 Z" q8 N9 t  ^4 T, c% o9 s0 V        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 N  ~; e( A! G  p8 l) z};4 k# O6 G) f& L9 a, w; _8 q# ?6 m

7 t1 v6 V  Q/ R# ^3 @static void led_dev_release(struct device *dev)
+ ]% q0 ~- l& K: z{5 f! W6 O8 W$ j4 t' z+ A- z
};
4 s4 `( j3 {. W# I5 g7 a  ~* i
7 q* B/ @7 m) X. Z9 `  Qstatic struct platform_device da850_evm_tl_leds_device = {( b1 X8 v; ~6 E4 X) V5 R3 t
        .name                = "leds-gpio",
2 |$ q. s, Y4 l" `5 ]        .id                = 1,
' r& _% M, U% V, {, m6 l/ Q        .dev = {" q" b8 F/ @+ T) o5 O! I1 V
                .platform_data = &da850_evm_tl_leds_pdata,
$ G3 S6 [- N# k                .release = led_dev_release,
4 R; F: t6 ?3 P: V  J; B        }
' }# W6 A, i  @# h  D4 s};8 [+ `7 K- a7 C( v6 ^5 R; o+ C+ u
% G4 F0 O7 o) L: Z
static int __init led_platform_init(void)
, f; I7 }3 E" c/ `: L{
% s# v' P& r  E; w" Q        int ret;
" x* J) Y, P# B6 J( @#if 0
# v" u( c: n: R        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' ~2 E( R& I, z        if (ret)/ R2 q9 n# L( x& D, R
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- j7 F0 ~0 q% B0 u, b8 j  G: @4 ^
                                "%d\n", ret);. S* G& K% ~& F* A5 |
#endif; E" c* n: [, e7 x- h0 K: @+ `
        ret = platform_device_register(&da850_evm_tl_leds_device);
1 t9 v5 l9 g" c$ T# M- Z        if (ret)* K0 ~. z9 H2 [4 a$ l$ u+ z
                pr_warning("Could not register som GPIO expander LEDS");
) w# A, j1 Q; L  b( j; T9 B$ F, r) b        else
% P/ I6 G8 l% {9 m, V                printk(KERN_INFO "LED register sucessful!\n");# U* I$ c% I) ]1 {& [7 ]
# g4 Z1 M6 @8 ?5 U! ~
        return ret;
4 j! `0 d2 y; x% W) R}
  |" ]7 P; I7 d0 Z
5 E2 v) O5 r9 D5 L$ nstatic void __exit led_platform_exit(void)
9 n+ t% A  o7 M4 m- y$ s5 S{: E5 e. `0 N& C( n/ N& ]
        platform_device_unregister(&da850_evm_tl_leds_device);' b* i4 h% O3 Z0 l1 q3 ~% F4 L

, n; s, L/ r( w6 d- r5 J9 k, q        printk(KERN_INFO "LED unregister!\n");
. v% p2 k; S5 h}. v2 N, P9 r8 c+ p# p0 `* z$ h4 l) `

5 @( q7 |7 }* Q5 i, ^4 b* [! Xmodule_init(led_platform_init);% h4 r3 u4 E6 ^% o  H1 a% u+ o
module_exit(led_platform_exit);0 w( Y$ T) A$ n  e
/ R0 U2 M) ?* E7 N/ N" x
MODULE_DESCRIPTION("Led platform driver");: N2 T: a7 ?5 Q# y6 @% Y
MODULE_AUTHOR("Tronlong");
2 ]6 t* P6 O9 {0 _MODULE_LICENSE("GPL");& s( L1 s9 S- u- q& S. P' W# r

9 |8 s7 J5 M. P) Y9 }" |$ D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-4 16:05 , Processed in 0.058288 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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