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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" Q  |" x% i# H. u; a5 Z. D8 i+ r, o#include <linux/init.h>
. E& R! L4 P( P7 a1 X#include <linux/module.h>$ P0 G' I* C. K) F' v2 {
#include <linux/kernel.h>
+ t2 Q& L" h7 q4 ]: O#include <linux/types.h>
6 t6 ^1 w- e$ S: H. k: M2 Q#include <linux/gpio.h>
0 ?& Y/ {$ N% |& f( j#include <linux/leds.h>6 m2 c5 J9 x. `1 c+ t4 w4 D
#include <linux/platform_device.h>
, [2 j% W, z; m! \* G. |8 K7 _  i' _5 @$ z3 T6 ]
#include <asm/mach-types.h>8 }2 t# p7 D: R3 Y1 |
#include <asm/mach/arch.h>
0 Z! A9 c) O' i7 D3 V3 X* ^& a2 J( ]#include <mach/da8xx.h>
8 m* V& z# ~+ u0 w6 ?# z#include <mach/mux.h>
9 U8 E* [0 v6 y; m; P; I
; x4 H5 ]. w: ~#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ a3 M# i' o9 O! I- w#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 u; T- S2 E; a& v4 r3 e1 W- A#define DA850_USER_LED2        GPIO_TO_PIN(0, 1), O$ V+ H8 E# ~/ R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 V* A" r) ~- o4 b+ c0 i2 ^+ r
8 }& w. J+ O( b& E3 P; N5 i* f/* assign the tl som board LED-GPIOs*/* k2 a: n2 ]$ E( |
static const short da850_evm_tl_user_led_pins[] = {
* P( r1 n& h4 o8 a% |        /* These pins are definition at <mach/mux.h> file */! L( W# I: U  F3 x, {, {
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& x. H) r4 P3 C# X3 X
        -13 r& c  s/ h' y% i& S; O& w
};. \" F* F/ @3 y+ w3 G' d% n- ?9 K
3 A* m' r- w% r. d$ `: P+ h' V
static struct gpio_led da850_evm_tl_leds[] = {' y# l8 Y4 O* P, b
        {# J# E9 S, K4 i6 n$ Z% ~+ z
                .active_low = 0,
; y6 I. P1 _, Z1 E) p8 ?                .gpio = DA850_USER_LED0,
3 z7 g; D9 a: Q/ r1 t- O4 \- C% X& s                .name = "user_led0",7 [; R9 O& S: l0 e* k: Y
                .default_trigger = "default-on",
1 p) a: T' R- h4 ~# q) M2 r; {' T        },
: R4 {; d6 j3 w8 E; l/ @4 r        {  q9 F; k& w4 Z8 z" V
                .active_low = 0,
/ g* e' r1 p; j3 e                .gpio = DA850_USER_LED1,# a) X$ M) m& u3 h* E
                .name = "user_led1",. s* k0 N7 P4 Q$ R
                .default_trigger = "default-on",
* O) _; X) n9 t+ z/ G2 Y. K        },
$ e7 {/ L; G6 c$ I( m8 O        {4 D0 i( t( H6 k0 d. b; A
                .active_low = 0,
& @. _* Y6 z; n; I                .gpio = DA850_USER_LED2,
# O  y$ ^: `  V: R: C1 Z                .name = "user_led2",9 F8 T! V5 h4 M9 o" ~
                .default_trigger = "default-on",
; f9 d- G$ ]% q5 z: l        },
% ]! r, L: [2 p( j  }' b6 X        {
) ^2 S% X8 S) a1 y( }7 ^                .active_low = 0,
5 e$ ?% q2 ~# N6 b                .gpio = DA850_USER_LED3,* q: b& m9 g3 u
                .name = "user_led3",
: y# M6 k. U0 B: Z" @8 Z6 d/ ?                .default_trigger = "default-on",$ s* ?$ [; z' d- K! f9 O
        },
( @+ v, F( j6 W};
5 @6 c* M8 K9 D. ~. U5 D& |$ E; I8 k: E) d3 ~! _7 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: M9 K. E( ^$ Q5 L$ g
        .leds = da850_evm_tl_leds,
, n( y! A) f' e$ N- f$ T/ C9 n, O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 l7 @; x+ z2 B};
% \, ]# a+ g# Z4 j* p' u! T4 P1 l7 d8 `) |# h
static void led_dev_release(struct device *dev)
+ ^( e% M0 \1 H{0 D8 S3 ]5 L. A3 b
};
4 l3 t* S$ r. X8 ]9 N; i
, P* ]: u$ V$ H2 L9 @# G0 Istatic struct platform_device da850_evm_tl_leds_device = {
& U, i% ~4 ^5 ?! i        .name                = "leds-gpio",
5 ?1 _8 h  f5 G" j/ }        .id                = 1,
  m1 D2 ~6 g: z" E        .dev = {. ^( l7 M4 s+ i: @/ k9 h- v" A
                .platform_data = &da850_evm_tl_leds_pdata,$ W1 v9 D7 Q; P
                .release = led_dev_release,9 U6 R4 N7 V4 ?7 D5 y3 `5 a. e( j
        }
  q; q1 I( n4 ]* m6 T6 |- M};  N. H# R" o  t; N# G+ z( G/ n" _

7 X1 M! C& q% R4 M" e7 m! y" n" Mstatic int __init led_platform_init(void)2 ?4 F# ?/ p0 R
{) _9 _& H& [, U7 h3 J) v
        int ret;) t: @* i6 i. f
#if 0
0 ]1 a$ x% u( v3 T* Z/ p4 U5 X+ q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 @" P- J! {' \  X
        if (ret)
/ ~$ g: [, o3 }2 y) h5 g                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. t2 J! H: o$ ]6 Y  g                                "%d\n", ret);) P3 Y3 r/ C* o$ m
#endif/ ?: b$ g, J, C& `
        ret = platform_device_register(&da850_evm_tl_leds_device);
& X: O9 w0 B: ^; p0 v        if (ret)
4 s" \5 C# F, `9 ?( M& [                pr_warning("Could not register som GPIO expander LEDS");
' q3 I& `5 I* _        else
- h8 B6 \2 }" g' S: D# q                printk(KERN_INFO "LED register sucessful!\n");
7 L# A" d' X! w. X7 s
( D# j6 P  t6 u        return ret;
4 V( L1 F" J3 w: H( b! j$ L+ p}, j, z' i, S# m2 Y
: D: s4 G, `" v8 O2 ]! A
static void __exit led_platform_exit(void): W+ N% }6 ]2 G( X
{
/ q; H4 x( r4 b6 x" G7 ]' c/ u        platform_device_unregister(&da850_evm_tl_leds_device);
! Z5 c& X; C  `5 T; R' j0 R% ~
' G, d1 l7 P* e/ w' ]3 v* k/ b        printk(KERN_INFO "LED unregister!\n");
: m+ o6 E6 }$ b2 P0 s9 b}
9 Y2 [/ G( b9 a( W
5 t8 m8 Q. Z0 ]7 z0 kmodule_init(led_platform_init);
' o1 h7 s* V' G8 i. M. o' Nmodule_exit(led_platform_exit);
: f/ o6 D6 _3 l5 H% s' P) g
  g( C: F: @( ?% g$ o: `7 ~( IMODULE_DESCRIPTION("Led platform driver");/ A$ j6 n/ I! M6 \6 t1 |* w
MODULE_AUTHOR("Tronlong");
/ y/ f) g% x7 p3 [- wMODULE_LICENSE("GPL");4 M( P( Q# F$ v( j$ m, L& l8 l7 g0 v

! ~# Z2 f* A' C$ w
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-16 01:16 , Processed in 0.041356 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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