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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 ?9 ^+ i+ h' b7 t" Y#include <linux/init.h>
* R. E* [9 l0 z$ T) W$ ^) g#include <linux/module.h>
% A( [, k& F% J7 _5 W#include <linux/kernel.h>
; r$ m- h* `5 s* S#include <linux/types.h>
' O- |  w$ o7 c3 O* x; R#include <linux/gpio.h>% Q% a( b6 p6 ?8 T! c& u
#include <linux/leds.h>. J! x0 Q. E; B: B+ u0 u
#include <linux/platform_device.h>
/ M; J/ w' H# i  O- L4 T  Q' R' @( D7 L& z% D& @6 t9 ~" z
#include <asm/mach-types.h>
7 ?' u, W; A, P& Q/ n#include <asm/mach/arch.h>2 @. e7 p0 _! ]9 k9 V
#include <mach/da8xx.h>
9 W6 r3 @. f+ V2 {3 V- E) o#include <mach/mux.h>
  X4 z/ a, w9 U* J
7 B0 |# k$ ?# s* W: ]) j#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* M- R. {6 e# y" |% a# o9 k#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 ?! x5 P! l- w#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 C$ R& J/ ^3 Y6 Q) R, b#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  o  O5 W3 q; J3 h
4 S, P$ K/ ~8 V/ C! p. [/* assign the tl som board LED-GPIOs*/
8 c8 `5 [: d5 k; Y( Pstatic const short da850_evm_tl_user_led_pins[] = {9 g1 p' [" o: F5 k
        /* These pins are definition at <mach/mux.h> file */8 |* v0 O0 N' G: g) c
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ U( S( k' L0 v" f# n        -1
" x  X3 J! v8 \& w+ ~};
0 ?( d; [3 e8 o  i. J- E: A8 f0 X6 G) g* F* u! _
static struct gpio_led da850_evm_tl_leds[] = {8 n, J, B  m9 P; b5 Q0 \
        {* G) @+ J$ k1 t  ^2 k2 p. a
                .active_low = 0,
+ ~  _$ s5 ~5 J2 U+ P" F  L                .gpio = DA850_USER_LED0,+ |4 r+ ?7 [* z5 G. k/ B) _
                .name = "user_led0",6 {. J9 P6 h: S# d: N$ F, ~% ~  U" A
                .default_trigger = "default-on",
# h: a; {/ o8 X) |        },, T) J6 C: |5 `3 T0 \% a3 L: f
        {* r% s9 M% c7 z& |' m+ ^: z! I# x
                .active_low = 0,* L& u1 z) @7 l0 u
                .gpio = DA850_USER_LED1,
0 H9 u2 ^) Y6 e" B& D                .name = "user_led1",0 e0 U! b! w. z/ w- O
                .default_trigger = "default-on",
) X! ~1 s& v4 S        },
( W2 U, `7 O* C3 R" h        {& C) g/ ~. i- T! x  l
                .active_low = 0,3 H0 Q4 I3 Z6 {! a) i" H/ E
                .gpio = DA850_USER_LED2,
& }: h1 Z, m/ @/ C: M- g                .name = "user_led2",
2 }( E! l4 z# z- {                .default_trigger = "default-on",
# o+ y/ G8 B2 Q, Z        },
5 O3 ]) ?: e# N$ `' L. a        {
& V' B# O7 N7 x5 H( ~0 s                .active_low = 0,
( e+ t: T" r; U                .gpio = DA850_USER_LED3,' A( }# I( G- R5 V4 ~( K) H
                .name = "user_led3",' o5 b5 K/ Y5 S1 B4 O
                .default_trigger = "default-on",9 [- k; j7 H- W" t5 |& l7 o- Q& Z
        },4 s8 x; {/ h/ }$ I7 m
};5 ?' G; o8 d! `7 [5 k' x6 U$ X+ O' T5 w
8 ]0 h# e  f/ ?5 l6 T4 p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; u1 l. p3 S5 |        .leds = da850_evm_tl_leds,3 l+ L8 C  x5 U! A
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
  P6 a8 Z: \8 n) v1 {};/ V4 X; R* D9 O  a) m+ t
6 n* S/ u) b: f5 ]. R& I# Q9 q
static void led_dev_release(struct device *dev)
/ c1 L: a( _& l3 `& f{
! M! ~- j9 d" Z+ Y};! Y7 c% s8 S# N7 J
) ?- s# R" a) r& V9 @
static struct platform_device da850_evm_tl_leds_device = {2 L. e8 M" e- }: l+ ^- [
        .name                = "leds-gpio",
, f. Z- n# ^4 K! W( ]" C        .id                = 1,
! o6 j6 O) \+ A/ O7 G0 d" J        .dev = {) \: D- Y. q0 |
                .platform_data = &da850_evm_tl_leds_pdata,
; S* S- H" q9 S- t! a* Q4 g" D, P                .release = led_dev_release,
3 v7 R$ T$ c- m& Y9 A0 ^* \" K        }0 F% \* o3 a! X+ p1 D0 C2 W
};9 W( T0 \- |4 h0 ~; q; o

4 m2 i2 r5 t6 O' Q8 K* B( D/ [static int __init led_platform_init(void)( G, q6 Z* L9 s! F7 b7 A0 K4 H
{
+ m# Q1 `% N% S& D        int ret;
) D+ x( l. V% L4 r- ^#if 0
* u- |) d7 {5 G3 S4 G; _% Y. q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. O0 B# o- c+ R1 a9 K
        if (ret)
1 G6 E- i3 r9 b/ R9 r2 {                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  ~4 _# T$ E# V' N) Q! Y2 C
                                "%d\n", ret);3 I+ u8 E% s1 Y& i1 T2 h( T
#endif
' H; h! P/ K# }) _9 f3 r' s$ g        ret = platform_device_register(&da850_evm_tl_leds_device);. \3 W" c9 z6 z0 D
        if (ret)
- g. S+ @7 x6 I( R. Y: m7 [                pr_warning("Could not register som GPIO expander LEDS");/ z% o$ W" e- Y
        else' ~* z$ h! p! K; C: v+ a9 X
                printk(KERN_INFO "LED register sucessful!\n");
) P1 A. K8 U  D7 W$ x  H; |- X' J7 @, }8 q# T' Q, I
        return ret;
4 L* Z4 X& M4 T; w}( p1 W) m. k" p6 d) a  |
9 W- w: w) Y, U4 P& h
static void __exit led_platform_exit(void)% b0 ]1 w8 c# h8 t- k
{
- r5 y( U7 o% _9 ^* T* ^5 k! ~        platform_device_unregister(&da850_evm_tl_leds_device);
; Z1 S  X+ s/ |. B2 J4 ~! m' N. o; P- z" f, x
        printk(KERN_INFO "LED unregister!\n");
, p6 v8 `$ H3 ?# o8 `9 L; D9 ~9 c( q}$ x8 ^5 N3 ]3 L
4 ~# {9 D9 Y9 ~0 }& D
module_init(led_platform_init);
* G3 o6 ^; I1 z$ X- p9 G7 `0 @module_exit(led_platform_exit);0 k0 a" l; D+ N. L+ F# X& _% y

5 b: q" O0 ~% S/ jMODULE_DESCRIPTION("Led platform driver");
* _  r  F5 r9 o% O4 a. BMODULE_AUTHOR("Tronlong");
0 c6 v9 f! f( `; _( C$ V0 QMODULE_LICENSE("GPL");. U4 Y. ]( {! f3 a, E

0 E- u& l  v- K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-22 04:41 , Processed in 0.043628 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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